From 43cb5775c4a1501cff2134d2814faf9a267a5882 Mon Sep 17 00:00:00 2001 From: Ivan Vedernikov Date: Fri, 9 Jan 2026 00:30:17 +0500 Subject: [PATCH] fix(ios): apply uiMode theme setting to checkout view controller The uiMode property in CustomerTheme was being decoded but never applied to the payment view controller. This caused the checkout UI to always follow the system appearance instead of respecting the Flutter theme configuration. This fix: - Stores the uiMode value from theme arguments - Applies overrideUserInterfaceStyle to the payment view controller - Supports 'light', 'dark', or auto (system default) modes --- .../CheckoutPlatformView.swift | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift b/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift index b4e4ede..17bce41 100644 --- a/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift +++ b/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift @@ -23,6 +23,7 @@ public class CheckoutPlatformView: NSObject, FlutterPlatformView { private let _view: CheckoutContainerView private weak var paymentViewController: UIViewController? private var checkout: Checkout? + private var uiMode: String? private func deinitCheckout() { guard let pvc = paymentViewController, @@ -126,6 +127,10 @@ public class CheckoutPlatformView: NSObject, FlutterPlatformView { @MainActor func createNativeView(arguments: CheckoutArguments) { debugPrint("createNativeView") + + // Store uiMode from theme for applying to view controller + self.uiMode = arguments.theme?.uiMode + let theme = getCheckoutTheme( arguments.theme, showPaymentDetails: arguments.showPaymentDetails) let formsOfPayment = @@ -183,8 +188,11 @@ public class CheckoutPlatformView: NSObject, FlutterPlatformView { func tryAttachController() { guard let pvc = self.paymentViewController else { return } - + if let parentVC = UIApplication.shared.delegate?.window??.rootViewController as? FlutterViewController { + // Apply uiMode to override system appearance if specified + applyUserInterfaceStyle(to: pvc) + parentVC.addChild(pvc) _view.addCheckoutView(pvc.view) pvc.didMove(toParent: parentVC) @@ -196,6 +204,23 @@ public class CheckoutPlatformView: NSObject, FlutterPlatformView { } } } + + private func applyUserInterfaceStyle(to viewController: UIViewController) { + guard let mode = uiMode?.lowercased() else { return } + + let style: UIUserInterfaceStyle + switch mode { + case "light": + style = .light + case "dark": + style = .dark + default: + return // Don't override if not specified or "auto" + } + + viewController.overrideUserInterfaceStyle = style + viewController.view.overrideUserInterfaceStyle = style + } private func getApiTransactionDetails(_ transactionDetails: String) throws -> TransactionDetailsResponse?