diff --git a/packages/url_launcher/url_launcher_platform_interface/CHANGELOG.md b/packages/url_launcher/url_launcher_platform_interface/CHANGELOG.md index 117f01765755..af7096206be4 100644 --- a/packages/url_launcher/url_launcher_platform_interface/CHANGELOG.md +++ b/packages/url_launcher/url_launcher_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.3.0 +* Adds `InAppBrowserConfiguration` parameter to `LaunchOptions`, to configure in-app browser views, such as Android Custom Tabs or `SFSafariViewController`. +* Adds `showTitle` parameter to `InAppBrowserConfiguration` in order to control web-page title visibility. + ## 2.2.1 * Updates minimum supported SDK version to Flutter 3.10/Dart 3.0. diff --git a/packages/url_launcher/url_launcher_platform_interface/lib/src/types.dart b/packages/url_launcher/url_launcher_platform_interface/lib/src/types.dart index 610df29f7091..9e3b3ad1a3e5 100644 --- a/packages/url_launcher/url_launcher_platform_interface/lib/src/types.dart +++ b/packages/url_launcher/url_launcher_platform_interface/lib/src/types.dart @@ -50,6 +50,18 @@ class InAppWebViewConfiguration { final Map headers; } +/// Additional configuration options for [PreferredLaunchMode.inAppBrowserView]. +@immutable +class InAppBrowserConfiguration { + /// Creates a new InAppBrowserConfiguration with given settings. + const InAppBrowserConfiguration({this.showTitle = false}); + + /// Whether or not to show the webpage title. + /// + /// May not be supported on all platforms. + final bool showTitle; +} + /// Options for [launchUrl]. @immutable class LaunchOptions { @@ -57,6 +69,7 @@ class LaunchOptions { const LaunchOptions({ this.mode = PreferredLaunchMode.platformDefault, this.webViewConfiguration = const InAppWebViewConfiguration(), + this.browserConfiguration = const InAppBrowserConfiguration(), this.webOnlyWindowName, }); @@ -66,6 +79,9 @@ class LaunchOptions { /// Configuration for the web view in [PreferredLaunchMode.inAppWebView] mode. final InAppWebViewConfiguration webViewConfiguration; + /// Configuration for the browser view in [PreferredLaunchMode.inAppBrowserView] mode. + final InAppBrowserConfiguration browserConfiguration; + /// A web-platform-specific option to set the link target. /// /// Default behaviour when unset should be to open the url in a new tab. diff --git a/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml b/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml index 2a63513f551f..3cf00e2193c9 100644 --- a/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml +++ b/packages/url_launcher/url_launcher_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/url_launcher/ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 2.2.1 +version: 2.3.0 environment: sdk: ">=3.0.0 <4.0.0" diff --git a/packages/url_launcher/url_launcher_platform_interface/test/in_app_browser_configuration_test.dart b/packages/url_launcher/url_launcher_platform_interface/test/in_app_browser_configuration_test.dart new file mode 100644 index 000000000000..33c7fcdab737 --- /dev/null +++ b/packages/url_launcher/url_launcher_platform_interface/test/in_app_browser_configuration_test.dart @@ -0,0 +1,16 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; + +void main() { + test('InAppBrowserConfiguration defaults to showTitle false', () { + expect(const InAppBrowserConfiguration().showTitle, false); + }); + + test('InAppBrowserConfiguration showTitle can be set to true', () { + expect(const InAppBrowserConfiguration(showTitle: true).showTitle, true); + }); +} diff --git a/packages/url_launcher/url_launcher_platform_interface/test/launch_options_test.dart b/packages/url_launcher/url_launcher_platform_interface/test/launch_options_test.dart new file mode 100644 index 000000000000..9f559e88dcb4 --- /dev/null +++ b/packages/url_launcher/url_launcher_platform_interface/test/launch_options_test.dart @@ -0,0 +1,28 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; + +void main() { + test('LaunchOptions have default InAppBrowserConfiguration when not passed', + () { + expect( + const LaunchOptions().browserConfiguration, + const InAppBrowserConfiguration(), + ); + }); + + test('passing non-default InAppBrowserConfiguration to LaunchOptions works', + () { + const InAppBrowserConfiguration browserConfiguration = + InAppBrowserConfiguration(showTitle: true); + + const LaunchOptions launchOptions = LaunchOptions( + browserConfiguration: browserConfiguration, + ); + + expect(launchOptions.browserConfiguration, browserConfiguration); + }); +}