diff --git a/flutter_custom_tabs/README.md b/flutter_custom_tabs/README.md index 5dd51f3..1cae946 100644 --- a/flutter_custom_tabs/README.md +++ b/flutter_custom_tabs/README.md @@ -146,8 +146,8 @@ void _launchUrl(BuildContext context) async { | Option | Android (`CustomTabsOptions`) | iOS (`SafariViewControllerOptions`) | `LaunchOptions` | | --- | :---: | :---: | :---: | -| Change background color of app/bottom bar | ✅ | ✅ | ✅ | -| Change color of controls on app/bottom bar | -
(Automatically adjusted by Custom Tabs) | ✅ | ✅ | +| Change background color of app/bottom bar | ✅ | ✅
(Ignored on iOS 26+) | ✅
(Ignored on iOS 26+) | +| Change color of controls on app/bottom bar | -
(Automatically adjusted by Custom Tabs) | ✅
(Ignored on iOS 26+) | ✅
(Ignored on iOS 26+) | | Change background color of system navigation bar | ✅ | - | ✅ | | Change color of system navigation divider | ✅ | - | ✅ | | Hide(Collapse) the app bar by scrolling | ✅ | ✅ | ✅ | @@ -169,6 +169,17 @@ Support status in `flutter_custom_tabs`: - ✅: Supported. - `-`: Option not provided by Custom Tabs implementation. +### Liquid Glass and iOS 26+ Appearance Changes + +Starting with iOS 26, Apple introduced the "Liquid Glass" background effects that are applied to system bars and controls. According to Apple's documentation, "Tinting the bars interferes with background effects that the system provides." + +As a result, the following properties in `SafariViewControllerOptions` are **ignored** on iOS 26 and later: + +- `preferredBarTintColor` +- `preferredControlTintColor` + +For more details, see [here](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller). + ## Advanced Usage ### Deep Linking diff --git a/flutter_custom_tabs/lib/src/lite/launch_options.dart b/flutter_custom_tabs/lib/src/lite/launch_options.dart index e7f93e9..9374aa0 100644 --- a/flutter_custom_tabs/lib/src/lite/launch_options.dart +++ b/flutter_custom_tabs/lib/src/lite/launch_options.dart @@ -12,11 +12,15 @@ class LaunchOptions { }); /// The background color of the app bar and bottom bar. + /// + /// **Note:** On iOS 26 and later, due to the introduction of Liquid Glass, this property is ignored even if specified. final Color? barColor; /// The color to tint the control buttons on the app bar and bottom bar. /// /// - Availability: **Only for iOS** + /// + /// **Note:** On iOS 26 and later, due to the introduction of Liquid Glass, this property is ignored even if specified. final Color? onBarColor; /// The color configuration of the system navigation bar. diff --git a/flutter_custom_tabs_ios/example/ios/RunnerTests/MockLauncher.swift b/flutter_custom_tabs_ios/example/ios/RunnerTests/MockLauncher.swift index f2a823c..1b9ff5b 100644 --- a/flutter_custom_tabs_ios/example/ios/RunnerTests/MockLauncher.swift +++ b/flutter_custom_tabs_ios/example/ios/RunnerTests/MockLauncher.swift @@ -1,5 +1,6 @@ // swiftlint:disable legacy_objc_type import Foundation +import UIKit @testable import flutter_custom_tabs_ios class MockLauncher: Launcher { diff --git a/flutter_custom_tabs_ios/example/ios/RunnerTests/SFSafariViewController+FactoryTest.swift b/flutter_custom_tabs_ios/example/ios/RunnerTests/SFSafariViewController+FactoryTest.swift index 9291d07..bb939a2 100644 --- a/flutter_custom_tabs_ios/example/ios/RunnerTests/SFSafariViewController+FactoryTest.swift +++ b/flutter_custom_tabs_ios/example/ios/RunnerTests/SFSafariViewController+FactoryTest.swift @@ -16,7 +16,11 @@ final class SFSafariViewControllerFactoryTest: XCTestCase { // Validation of default values for non-null values. XCTAssertTrue(actual.configuration.barCollapsingEnabled) XCTAssertFalse(actual.configuration.entersReaderIfAvailable) - XCTAssertEqual(actual.dismissButtonStyle, .done) + if #available(iOS 26, *) { + XCTAssertEqual(actual.dismissButtonStyle, .close) + } else { + XCTAssertEqual(actual.dismissButtonStyle, .done) + } XCTAssertEqual(actual.modalPresentationStyle, .fullScreen) XCTAssertNil(actual.preferredBarTintColor) @@ -48,18 +52,26 @@ final class SFSafariViewControllerFactoryTest: XCTestCase { actual.configuration.barCollapsingEnabled, srcOptions.barCollapsingEnabled ) + XCTAssertEqual( actual.configuration.entersReaderIfAvailable, srcOptions.entersReaderIfAvailable ) - XCTAssertEqual( - actual.preferredBarTintColor, - UIColor(red: 0, green: 0, blue: 0, alpha: 1) - ) - XCTAssertEqual( - actual.preferredControlTintColor, - UIColor(red: 0, green: 0, blue: 1 / 255, alpha: 1) - ) + + if #available(iOS 26, *) { + XCTAssertNil(actual.preferredBarTintColor) + XCTAssertNil(actual.preferredControlTintColor) + } else { + XCTAssertEqual( + actual.preferredBarTintColor, + UIColor(red: 0, green: 0, blue: 0, alpha: 1) + ) + XCTAssertEqual( + actual.preferredControlTintColor, + UIColor(red: 0, green: 0, blue: 1 / 255, alpha: 1) + ) + } + XCTAssertEqual( actual.dismissButtonStyle, DismissButtonStyle(rawValue: Int(srcOptions.dismissButtonStyle!)) diff --git a/flutter_custom_tabs_ios/ios/flutter_custom_tabs_ios/Sources/flutter_custom_tabs_ios/SFSafariViewController+Factory.swift b/flutter_custom_tabs_ios/ios/flutter_custom_tabs_ios/Sources/flutter_custom_tabs_ios/SFSafariViewController+Factory.swift index 25c0f20..7f58582 100644 --- a/flutter_custom_tabs_ios/ios/flutter_custom_tabs_ios/Sources/flutter_custom_tabs_ios/SFSafariViewController+Factory.swift +++ b/flutter_custom_tabs_ios/ios/flutter_custom_tabs_ios/Sources/flutter_custom_tabs_ios/SFSafariViewController+Factory.swift @@ -20,11 +20,16 @@ extension SFSafariViewController { configuration: configuration ) - if let barTintColorHex = options.preferredBarTintColor { - viewController.preferredBarTintColor = UIColor(barTintColorHex) - } - if let controlTintColorHex = options.preferredControlTintColor { - viewController.preferredControlTintColor = UIColor(controlTintColorHex) + if #available(iOS 26, *) { + // On iOS 26 and later, `preferredBarTintColor` and + // `preferredControlTintColor` are deprecated — do not set them. + } else { + if let barTintColorHex = options.preferredBarTintColor { + viewController.preferredBarTintColor = UIColor(barTintColorHex) + } + if let controlTintColorHex = options.preferredControlTintColor { + viewController.preferredControlTintColor = UIColor(controlTintColorHex) + } } if let dismissButtonStyleRawValue = options.dismissButtonStyle, diff --git a/flutter_custom_tabs_ios/lib/src/types/safari_view_controller_options.dart b/flutter_custom_tabs_ios/lib/src/types/safari_view_controller_options.dart index 92afc83..92fdcdf 100644 --- a/flutter_custom_tabs_ios/lib/src/types/safari_view_controller_options.dart +++ b/flutter_custom_tabs_ios/lib/src/types/safari_view_controller_options.dart @@ -41,9 +41,19 @@ class SafariViewControllerOptions implements PlatformOptions { ); /// The color to tint the background of the navigation bar and the toolbar. + /// + /// **Note:** On iOS 26 and later, due to the introduction of Liquid Glass, this property is ignored even if specified. + /// + /// See also: + /// - [SFSafariViewController.preferredBarTintColor](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/preferredbartintcolor) final Color? preferredBarTintColor; /// The color to tint the control buttons on the navigation bar and the toolbar. + /// + /// **Note:** On iOS 26 and later, due to the introduction of Liquid Glass, this property is ignored even if specified. + /// + /// See also: + /// - [SFSafariViewController.preferredControlTintColor](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/preferredcontroltintcolor) final Color? preferredControlTintColor; /// A Boolean value that enables the url bar to hide as the user scrolls down the page.