Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions flutter_custom_tabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | -<br>(Automatically adjusted by Custom Tabs) | ✅ | ✅ |
| Change background color of app/bottom bar | ✅ | ✅<br>(Ignored on iOS 26+) | ✅<br>(Ignored on iOS 26+) |
| Change color of controls on app/bottom bar | -<br>(Automatically adjusted by Custom Tabs) | ✅<br>(Ignored on iOS 26+) | ✅<br>(Ignored on iOS 26+) |
| Change background color of system navigation bar | ✅ | - | ✅ |
| Change color of system navigation divider | ✅ | - | ✅ |
| Hide(Collapse) the app bar by scrolling | ✅ | ✅ | ✅ |
Expand All @@ -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`
Comment thread
droibit marked this conversation as resolved.

For more details, see [here](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller).

## Advanced Usage

### Deep Linking
Expand Down
4 changes: 4 additions & 0 deletions flutter_custom_tabs/lib/src/lite/launch_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// swiftlint:disable legacy_objc_type
import Foundation
import UIKit
@testable import flutter_custom_tabs_ios

class MockLauncher: Launcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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!))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down