diff --git a/VoidLink/Base.lproj/iPad.storyboard b/VoidLink/Base.lproj/iPad.storyboard index d0b7a0f9..ebebbbf7 100644 --- a/VoidLink/Base.lproj/iPad.storyboard +++ b/VoidLink/Base.lproj/iPad.storyboard @@ -2637,7 +2637,6 @@ - @@ -3977,19 +3976,19 @@ - + - + - + - + diff --git a/VoidLink/Localization/Localizable.xcstrings b/VoidLink/Localization/Localizable.xcstrings index 374a8df9..e2d9ccf0 100644 --- a/VoidLink/Localization/Localizable.xcstrings +++ b/VoidLink/Localization/Localizable.xcstrings @@ -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" -} \ No newline at end of file +} diff --git a/VoidLink/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.swift b/VoidLink/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.swift index 17b0e608..cb3a5397 100644 --- a/VoidLink/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.swift +++ b/VoidLink/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.swift @@ -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")