diff --git a/flutter_custom_tabs/example/lib/main.dart b/flutter_custom_tabs/example/lib/main.dart index 4b3698a4..d95c56b0 100644 --- a/flutter_custom_tabs/example/lib/main.dart +++ b/flutter_custom_tabs/example/lib/main.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:io'; import 'package:flutter/material.dart'; - import 'package:flutter_custom_tabs/flutter_custom_tabs.dart'; import 'package:flutter_custom_tabs/flutter_custom_tabs_lite.dart' as lite; @@ -74,7 +73,7 @@ class MyApp extends StatelessWidget { } } -Future _launchURLInDefaultBrowserOnAndroid(BuildContext context) async { +Future _launchUrl(BuildContext context) async { final theme = Theme.of(context); try { await launchUrl( @@ -84,19 +83,24 @@ Future _launchURLInDefaultBrowserOnAndroid(BuildContext context) async { toolbarColor: theme.colorScheme.surface, navigationBarColor: theme.colorScheme.background, ), + shareState: CustomTabsShareState.on, urlBarHidingEnabled: true, showTitle: true, - browser: const CustomTabsBrowserConfiguration( - prefersDefaultBrowser: true, - ), + ), + safariVCOptions: SafariViewControllerOptions( + preferredBarTintColor: theme.colorScheme.surface, + preferredControlTintColor: theme.colorScheme.onSurface, + barCollapsingEnabled: true, + entersReaderIfAvailable: false, ), ); } catch (e) { + // An exception is thrown if browser app is not installed on Android device. debugPrint(e.toString()); } } -Future _launchUrl(BuildContext context) async { +Future _launchURLInDefaultBrowserOnAndroid(BuildContext context) async { final theme = Theme.of(context); try { await launchUrl( @@ -106,19 +110,14 @@ Future _launchUrl(BuildContext context) async { toolbarColor: theme.colorScheme.surface, navigationBarColor: theme.colorScheme.background, ), - shareState: CustomTabsShareState.on, urlBarHidingEnabled: true, showTitle: true, - ), - safariVCOptions: SafariViewControllerOptions( - preferredBarTintColor: theme.colorScheme.surface, - preferredControlTintColor: theme.colorScheme.onSurface, - barCollapsingEnabled: true, - entersReaderIfAvailable: false, + browser: const CustomTabsBrowserConfiguration( + prefersDefaultBrowser: true, + ), ), ); } catch (e) { - // An exception is thrown if browser app is not installed on Android device. debugPrint(e.toString()); } } diff --git a/flutter_custom_tabs/lib/flutter_custom_tabs_lite.dart b/flutter_custom_tabs/lib/flutter_custom_tabs_lite.dart index f466f684..27ff2003 100644 --- a/flutter_custom_tabs/lib/flutter_custom_tabs_lite.dart +++ b/flutter_custom_tabs/lib/flutter_custom_tabs_lite.dart @@ -1,2 +1,2 @@ -export 'src/launch_options.dart'; +export 'src/types/launch_options.dart'; export 'src/launcher_lite.dart'; diff --git a/flutter_custom_tabs/lib/src/launcher_lite.dart b/flutter_custom_tabs/lib/src/launcher_lite.dart index 77e8a912..498bb102 100644 --- a/flutter_custom_tabs/lib/src/launcher_lite.dart +++ b/flutter_custom_tabs/lib/src/launcher_lite.dart @@ -4,7 +4,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_custom_tabs_platform_interface/flutter_custom_tabs_platform_interface.dart'; import 'package:meta/meta.dart'; -import 'launch_options.dart'; +import 'types/launch_options.dart'; /// Passes [url] with options to the underlying platform for launching a custom tab. /// diff --git a/flutter_custom_tabs/lib/src/launch_options.dart b/flutter_custom_tabs/lib/src/types/launch_options.dart similarity index 94% rename from flutter_custom_tabs/lib/src/launch_options.dart rename to flutter_custom_tabs/lib/src/types/launch_options.dart index 962cbfaa..7f5b2988 100644 --- a/flutter_custom_tabs/lib/src/launch_options.dart +++ b/flutter_custom_tabs/lib/src/types/launch_options.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; -import 'package:flutter_custom_tabs_platform_interface/flutter_custom_tabs_platform_interface.dart'; +import 'package:flutter_custom_tabs_android/flutter_custom_tabs_android.dart'; +import 'package:flutter_custom_tabs_ios/flutter_custom_tabs_ios.dart'; import 'package:meta/meta.dart'; /// The Configuration for providing minimal options for mobile platforms when launching Custom Tabs by specifying a URL. diff --git a/flutter_custom_tabs/test/src/launcher_lite_test.dart b/flutter_custom_tabs/test/launcher_lite_test.dart similarity index 91% rename from flutter_custom_tabs/test/src/launcher_lite_test.dart rename to flutter_custom_tabs/test/launcher_lite_test.dart index f8696fda..b8773896 100644 --- a/flutter_custom_tabs/test/src/launcher_lite_test.dart +++ b/flutter_custom_tabs/test/launcher_lite_test.dart @@ -1,10 +1,9 @@ import 'package:flutter/services.dart'; -import 'package:flutter_custom_tabs/src/launch_options.dart'; -import 'package:flutter_custom_tabs/src/launcher_lite.dart'; +import 'package:flutter_custom_tabs/flutter_custom_tabs_lite.dart'; import 'package:flutter_custom_tabs_platform_interface/flutter_custom_tabs_platform_interface.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../mocks/mock_custom_tabs_platform.dart'; +import 'mocks/mock_custom_tabs_platform.dart'; void main() { final mock = MockCustomTabsPlatform(); diff --git a/flutter_custom_tabs/test/src/launcher_test.dart b/flutter_custom_tabs/test/launcher_test.dart similarity index 96% rename from flutter_custom_tabs/test/src/launcher_test.dart rename to flutter_custom_tabs/test/launcher_test.dart index 6c5f7849..359e711d 100644 --- a/flutter_custom_tabs/test/src/launcher_test.dart +++ b/flutter_custom_tabs/test/launcher_test.dart @@ -1,9 +1,9 @@ import 'package:flutter/services.dart'; -import 'package:flutter_custom_tabs/src/launcher.dart'; +import 'package:flutter_custom_tabs/flutter_custom_tabs.dart'; import 'package:flutter_custom_tabs_platform_interface/flutter_custom_tabs_platform_interface.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../mocks/mock_custom_tabs_platform.dart'; +import 'mocks/mock_custom_tabs_platform.dart'; void main() { final mock = MockCustomTabsPlatform(); diff --git a/flutter_custom_tabs/test/mocks/mock_custom_tabs_platform.dart b/flutter_custom_tabs/test/mocks/mock_custom_tabs_platform.dart index 39cc5173..a8d22a95 100644 --- a/flutter_custom_tabs/test/mocks/mock_custom_tabs_platform.dart +++ b/flutter_custom_tabs/test/mocks/mock_custom_tabs_platform.dart @@ -7,8 +7,8 @@ class MockCustomTabsPlatform extends Fake implements CustomTabsPlatform { String? url; bool? prefersDeepLink; - CustomTabsOptions? customTabsOptions; - SafariViewControllerOptions? safariVCOptions; + PlatformOptions? customTabsOptions; + PlatformOptions? safariVCOptions; bool launchUrlCalled = false; bool closeAllIfPossibleCalled = false; @@ -16,8 +16,8 @@ class MockCustomTabsPlatform extends Fake void setLaunchExpectations({ required String url, bool? prefersDeepLink, - CustomTabsOptions? customTabsOptions, - SafariViewControllerOptions? safariVCOptions, + PlatformOptions? customTabsOptions, + PlatformOptions? safariVCOptions, }) { this.url = url; this.prefersDeepLink = prefersDeepLink; @@ -29,8 +29,8 @@ class MockCustomTabsPlatform extends Fake Future launch( String? urlString, { bool? prefersDeepLink, - CustomTabsOptions? customTabsOptions, - SafariViewControllerOptions? safariVCOptions, + PlatformOptions? customTabsOptions, + PlatformOptions? safariVCOptions, }) async { expect(urlString, url); expect(prefersDeepLink, this.prefersDeepLink); diff --git a/flutter_custom_tabs/test/src/launch_options_test.dart b/flutter_custom_tabs/test/types/launch_options_test.dart similarity index 98% rename from flutter_custom_tabs/test/src/launch_options_test.dart rename to flutter_custom_tabs/test/types/launch_options_test.dart index 669fab9a..cccdec1b 100644 --- a/flutter_custom_tabs/test/src/launch_options_test.dart +++ b/flutter_custom_tabs/test/types/launch_options_test.dart @@ -1,6 +1,6 @@ import 'package:flutter/painting.dart'; -import 'package:flutter_custom_tabs/src/launch_options.dart'; -import 'package:flutter_custom_tabs_platform_interface/flutter_custom_tabs_platform_interface.dart'; +import 'package:flutter_custom_tabs/flutter_custom_tabs_lite.dart'; +import 'package:flutter_custom_tabs_ios/flutter_custom_tabs_ios.dart'; import 'package:flutter_test/flutter_test.dart'; void main() {