From 6d0530bc3d58942251ab084f6a3b0eeca361db09 Mon Sep 17 00:00:00 2001 From: Felix Schwarz Date: Mon, 10 Oct 2022 15:38:16 +0200 Subject: [PATCH] - SDK update: fix duplicate/"ghost" activities visual issue - ClientActivityViewController: fix Xcode 14 warnings - PopupButtonController: add themeing support - NSObject+ThemeApplication: add proper support for UISearchTextField, fixing #118 text color issue --- ios-sdk | 2 +- .../Client/ClientActivityViewController.swift | 6 +++++- .../User Interface/PopupButtonController.swift | 8 +++++++- .../Theme/NSObject+ThemeApplication.swift | 15 ++++++++++++++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ios-sdk b/ios-sdk index 3ff7a454e..3e687e4c9 160000 --- a/ios-sdk +++ b/ios-sdk @@ -1 +1 @@ -Subproject commit 3ff7a454ea7f8eb64eb628e070dff828698599ae +Subproject commit 3e687e4c9da83627b1387f8df81dc9eeb86f69c8 diff --git a/ownCloud/Client/ClientActivityViewController.swift b/ownCloud/Client/ClientActivityViewController.swift index ea699b4b9..42267969e 100644 --- a/ownCloud/Client/ClientActivityViewController.swift +++ b/ownCloud/Client/ClientActivityViewController.swift @@ -75,12 +75,16 @@ class ClientActivityViewController: UITableViewController, Themeable, MessageGro } } - deinit { + private func winddown() { Theme.shared.unregister(client: self) self.shouldPauseDisplaySleep = false self.core = nil } + deinit { + winddown() + } + @objc func handleActivityNotification(_ notification: Notification) { if let activitiyUpdates = notification.userInfo?[OCActivityManagerNotificationUserInfoUpdatesKey] as? [ [ String : Any ] ] { for activityUpdate in activitiyUpdates { diff --git a/ownCloudAppShared/Client/User Interface/PopupButtonController.swift b/ownCloudAppShared/Client/User Interface/PopupButtonController.swift index 83a2c8d12..c9587ee9a 100644 --- a/ownCloudAppShared/Client/User Interface/PopupButtonController.swift +++ b/ownCloudAppShared/Client/User Interface/PopupButtonController.swift @@ -38,7 +38,7 @@ open class PopupButtonChoice : NSObject { } } -open class PopupButtonController : NSObject { +open class PopupButtonController : NSObject, Themeable { typealias TitleCustomizer = (_ choice: PopupButtonChoice, _ isSelected: Bool) -> String typealias SelectionCustomizer = (_ choice: PopupButtonChoice, _ isSelected: Bool) -> Bool typealias ChoiceHandler = (_ choice: PopupButtonChoice, _ wasSelected: Bool) -> Void @@ -148,6 +148,8 @@ open class PopupButtonController : NSObject { ]) _updateTitleFromSelectedChoice() + + Theme.shared.register(client: self, applyImmediately: true) } private func _updateTitleFromSelectedChoice() { @@ -188,4 +190,8 @@ open class PopupButtonController : NSObject { button.sizeToFit() } } + + open func applyThemeCollection(theme: Theme, collection: ThemeCollection, event: ThemeEvent) { + button.applyThemeCollection(collection) + } } diff --git a/ownCloudAppShared/User Interface/Theme/NSObject+ThemeApplication.swift b/ownCloudAppShared/User Interface/Theme/NSObject+ThemeApplication.swift index b3adf4ec3..36b41b05d 100644 --- a/ownCloudAppShared/User Interface/Theme/NSObject+ThemeApplication.swift +++ b/ownCloudAppShared/User Interface/Theme/NSObject+ThemeApplication.swift @@ -247,7 +247,20 @@ public extension NSObject { } } - if let textField = self as? UITextField { + if let searchTextField = self as? UISearchTextField { + searchTextField.tintColor = collection.searchBarColors.tintColor + searchTextField.textColor = collection.searchBarColors.labelColor + searchTextField.overrideUserInterfaceStyle = collection.interfaceStyle.userInterfaceStyle + + if let glassIconView = searchTextField.leftView as? UIImageView { + glassIconView.image = glassIconView.image?.withRenderingMode(.alwaysTemplate) + glassIconView.tintColor = collection.searchBarColors.secondaryLabelColor + } + if let clearButton = searchTextField.value(forKey: "clearButton") as? UIButton { + clearButton.setImage(UIImage(systemName: "xmark.circle.fill"), for: .normal) + clearButton.tintColor = collection.searchBarColors.secondaryLabelColor + } + } else if let textField = self as? UITextField { textField.textColor = collection.tableRowColors.labelColor }