Skip to content

Commit

Permalink
fix(GiniBankSDK): fix buttons tint color in documentpicker when uibar…
Browse files Browse the repository at this point in the history
…buttonitem appearance tint color is globally overwriden

PP-733
  • Loading branch information
igor-gini committed Dec 13, 2024
1 parent c073810 commit c3f0bb4
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,26 @@ public final class DocumentPickerCoordinator: NSObject {
/// A UIDocumentPickerViewController that sets navigation bar buttons' tint color to a correct one, instead of using the accent color specified by app
private class GiniDocumentPickerViewController: UIDocumentPickerViewController {
var initialTintColor: UIColor? = navBarInstance.tintColor
var initialButtonTintColor: UIColor? = barButtonInstance.tintColor

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
Self.navBarInstance.tintColor = .GiniCapture.accent1
Self.barButtonInstance.tintColor = .GiniCapture.accent1
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
// make sure to revert the tint color, otherwise it will affect document pickers/browsers from the host app
Self.navBarInstance.tintColor = initialTintColor
Self.navBarInstance.tintColor = initialTintColor ?? UINavigationBar.appearance().tintColor
Self.barButtonInstance.tintColor = initialButtonTintColor ?? UIBarButtonItem.appearance().tintColor
}
static var navBarInstance: UINavigationBar {
UINavigationBar.appearance(whenContainedInInstancesOf: [UIDocumentBrowserViewController.self])
}

static var barButtonInstance: UIBarButtonItem {
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UIDocumentBrowserViewController.self])
}
}

fileprivate extension DocumentPickerCoordinator {
Expand Down

0 comments on commit c3f0bb4

Please sign in to comment.