From 20be7cc8b7109b724c03628ccf6d06ff984ca40c Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:54:36 -0700 Subject: [PATCH] Sync system notification settings; filter out Abacus notifications (#258) * WIP * WIP * Settings * Lint * Clean up * Clean up * WIP * WIP * Update app settings when system settings change * Revert * Clean up --- .../dydxNotificationPrimerViewPresenter.swift | 3 +++ ...dydxNotificationsSettingsViewBuilder.swift | 13 ++++++++- .../dydxTradeStatusViewBuilder.swift | 2 +- .../dydxStateManager/AbacusStateManager.swift | 3 +++ .../_v4/Banner/SwiftMessages+Banner.swift | 2 +- .../Primers/dydxNotificationPrimerView.swift | 7 +++++ .../_Localizer/dydxAbacusDataLocalizer.swift | 27 ++++++++++++------- 7 files changed, 44 insertions(+), 13 deletions(-) diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Primers/dydxNotificationPrimerViewPresenter.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Primers/dydxNotificationPrimerViewPresenter.swift index 8100e3caa..1a38053ba 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Primers/dydxNotificationPrimerViewPresenter.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Primers/dydxNotificationPrimerViewPresenter.swift @@ -46,5 +46,8 @@ private class dydxNotificationPrimerViewPresenter: HostedViewPresenter Void)? + @Published public var cancelAction: (() -> Void)? public init() { } @@ -38,6 +39,12 @@ public class dydxNotificationPrimerViewModel: PlatformViewModel { self?.ctaAction?() } .createView(parentStyle: style) + + let cancelText = Text(DataLocalizer.localize(path: "APP.GENERAL.CANCEL", params: nil)) + PlatformButtonViewModel(content: cancelText.wrappedViewModel, state: .secondary) { [weak self] in + self?.cancelAction?() + } + .createView(parentStyle: style) } .padding([.leading, .trailing]) .padding(.top, 40) diff --git a/dydxV4/dydxV4/_Localizer/dydxAbacusDataLocalizer.swift b/dydxV4/dydxV4/_Localizer/dydxAbacusDataLocalizer.swift index ac34b3c21..affda1634 100644 --- a/dydxV4/dydxV4/_Localizer/dydxAbacusDataLocalizer.swift +++ b/dydxV4/dydxV4/_Localizer/dydxAbacusDataLocalizer.swift @@ -36,7 +36,10 @@ public class dydxAbacusDataLocalizer: DataLocalizerProtocol, AbacusLocalizerProt let language = keyValueStore?.value(forKey: _languageTag) as? String UIImplementations.reset(language: language) if let language = language { - setLanguage(language: language) { _ in + setLanguage(language: language) { success in + if !success { + Console.shared.log("dydxAbacusDataLocalizer setLanguage failed") + } } } } @@ -49,21 +52,25 @@ public class dydxAbacusDataLocalizer: DataLocalizerProtocol, AbacusLocalizerProt public func setLanguage(language: String, callback: @escaping (KotlinBoolean, ParsingError?) -> Void) { if let code = language.components(separatedBy: "-").first { - (UIImplementations.shared?.localizer as? DynamicLocalizer)?.setLanguage(language: code, callback: { [weak self] successful, error in - self?.language = (UIImplementations.shared?.localizer as? DynamicLocalizer)?.language - if successful.boolValue { - if let self = self { - self.keyValueStore?.setValue(code, forKey: self._languageTag) + let localizer = UIImplementations.shared?.localizer as? DynamicLocalizer + if let localizer = localizer { + localizer.setLanguage(language: code, callback: { [weak self] successful, error in + self?.language = localizer.language + if successful.boolValue { + if let self = self { + self.keyValueStore?.setValue(code, forKey: self._languageTag) + } } - } - callback(successful, error) - }) + callback(successful, error) + }) + } else { + callback(false, nil) + } } else { callback(false, nil) } } - private func json(params: [String: String]?) -> String? { if let params = params { if let data = try? JSONSerialization.data(withJSONObject: params, options: .prettyPrinted) {