From c3f0bb45e88d5adb55d0f320332e44ac503e0876 Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 13 Dec 2024 10:09:52 +0100 Subject: [PATCH] fix(GiniBankSDK): fix buttons tint color in documentpicker when uibarbuttonitem appearance tint color is globally overwriden PP-733 --- .../Document picker/DocumentPickerCoordinator.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Screens/Document picker/DocumentPickerCoordinator.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Screens/Document picker/DocumentPickerCoordinator.swift index f0ca0663b..b198731a0 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Screens/Document picker/DocumentPickerCoordinator.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Screens/Document picker/DocumentPickerCoordinator.swift @@ -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 {