add tip for saving changes before exiting widget layout editor

This commit is contained in:
True Zhuanjia
2026-08-25 18:20:48 +08:00
parent 78f385d732
commit 0e8903d233
3 changed files with 120 additions and 6 deletions
+4 -5
View File
@@ -2637,7 +2637,6 @@
</state>
<connections>
<action selector="closeTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="sc6-Mq-rbQ"/>
<action selector="undoTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="d4b-0R-vJU"/>
</connections>
</button>
<button autoresizesSubviews="NO" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F7X-l4-cl3" userLabel="Undo">
@@ -3977,19 +3976,19 @@
<image name="tray.full.fill" catalog="system" width="128" height="88"/>
<image name="video.and.waveform" catalog="system" width="128" height="94"/>
<systemColor name="linkColor">
<color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemBrownColor">
<color red="0.63529411759999999" green="0.51764705879999995" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.67450980392156867" green="0.49803921568627452" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemGray3Color">
<color red="0.78039215689999997" green="0.78039215689999997" blue="0.80000000000000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.7803921568627451" green="0.7803921568627451" blue="0.80000000000000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemTealColor">
<color red="0.18823529410000001" green="0.69019607839999997" blue="0.78039215689999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.0" green="0.76470588235294112" blue="0.81568627450980391" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
+88 -1
View File
@@ -5978,6 +5978,35 @@
}
}
},
"Exit Directly" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Exit Directly"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "直接退出"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "直接退出"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "直接退出"
}
}
}
},
"Cannot select two touchpad controls at the same time" : {
"extractionState" : "manual",
"localizations" : {
@@ -16411,6 +16440,64 @@
}
}
},
"Save Changes" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Save Changes"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "保存修改"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "儲存修改"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "儲存修改"
}
}
}
},
"Save changes before closing?" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Save changes before closing?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "关闭前是否保存修改?"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "關閉前是否儲存修改?"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "關閉前是否儲存修改?"
}
}
}
},
"Saving over the 'Default' profile is not allowed" : {
"extractionState" : "manual",
"localizations" : {
@@ -20172,4 +20259,4 @@
}
},
"version" : "1.1"
}
}
@@ -208,6 +208,7 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
private var latestTouchLocation: CGPoint = .zero
private var vibrationGenerator = UIImpactFeedbackGenerator(style: .medium)
private var widgetSizeTransition: WidgetSizeTransition = .keepWidgetSize
private var hasSavedSinceLastWidgetReload = false
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
let dataMan = DataManager()
@@ -390,6 +391,7 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
}
self.loadWidgets(from: oscProfile)
self.hasSavedSinceLastWidgetReload = false
if !self.quickSwitchEnabled {
self.originalTrackPointEnabled = OnScreenWidgetView.trackPointEnabled
@@ -1158,6 +1160,31 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
}
@IBAction func closeTapped(_ sender: Any?) {
guard profilesManager.getSelectedProfile().name != "Default",
!hasSavedSinceLastWidgetReload else {
dismissLayoutEditor()
return
}
AlertControllerUtil.cancelButtonString = "Exit Directly".localized
AlertControllerUtil.showAlert(
in: self,
title: "Save Changes".localized,
message: "Save changes before closing?".localized,
withCancel: true,
buttonTitle: "Save".localized,
countdown: 0,
completion: { [weak self] in
guard let self else { return }
if !AlertControllerUtil.actionCancelled {
self.saveTapped(nil)
}
self.dismissLayoutEditor()
}
)
}
private func dismissLayoutEditor() {
clearSickInput()
dismiss(animated: true) {
OnScreenWidgetView.trackPointEnabled = self.originalTrackPointEnabled
@@ -1573,6 +1600,7 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
clearSickInput()
OSCProfilesManager.setLayoutViewBounds(view.bounds)
let success = profilesManager.updateSelectedProfile(layoutOSC.oscButtonLayerPool)
hasSavedSinceLastWidgetReload = success
guard sender != nil else { return }
let message = success
? LocalizationHelper.localizedString(forKey: "profileSaveTip")