From ad91850b9b666801910c4be8d5d237238f07d382 Mon Sep 17 00:00:00 2001 From: PartyDonut Date: Sun, 27 Jul 2025 19:36:10 +0200 Subject: [PATCH] fix: Custom tabs not opening default browser --- lib/screens/shared/media/external_urls.dart | 38 ++++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/lib/screens/shared/media/external_urls.dart b/lib/screens/shared/media/external_urls.dart index e0d2ff0..f74e534 100644 --- a/lib/screens/shared/media/external_urls.dart +++ b/lib/screens/shared/media/external_urls.dart @@ -54,21 +54,41 @@ Future launchUrl(BuildContext context, String link) async { } } else { try { + final mediaQuery = MediaQuery.of(context); + final theme = Theme.of(context); await customtab.launchUrl( Uri.parse(link), - customTabsOptions: customtab.CustomTabsOptions( - colorSchemes: customtab.CustomTabsColorSchemes.defaults( - toolbarColor: Theme.of(context).primaryColor, + customTabsOptions: customtab.CustomTabsOptions.partial( + configuration: customtab.PartialCustomTabsConfiguration.adaptiveSheet( + initialHeight: mediaQuery.size.height * 0.7, + initialWidth: mediaQuery.size.width * 0.4, + activitySideSheetMaximizationEnabled: true, + activitySideSheetDecorationType: customtab.CustomTabsActivitySideSheetDecorationType.shadow, + activitySideSheetRoundedCornersPosition: customtab.CustomTabsActivitySideSheetRoundedCornersPosition.top, + cornerRadius: 16, + ), + colorSchemes: customtab.CustomTabsColorSchemes.defaults( + toolbarColor: Theme.of(context).colorScheme.primary, + navigationBarColor: Theme.of(context).colorScheme.primary, ), - urlBarHidingEnabled: true, shareState: customtab.CustomTabsShareState.browserDefault, showTitle: true, + browser: const customtab.CustomTabsBrowserConfiguration( + prefersDefaultBrowser: true, + ), ), - safariVCOptions: customtab.SafariViewControllerOptions( - preferredBarTintColor: Theme.of(context).primaryColor, - preferredControlTintColor: Colors.white, - barCollapsingEnabled: true, - entersReaderIfAvailable: false, + safariVCOptions: customtab.SafariViewControllerOptions.pageSheet( + configuration: const customtab.SheetPresentationControllerConfiguration( + detents: { + customtab.SheetPresentationControllerDetent.large, + customtab.SheetPresentationControllerDetent.medium, + }, + prefersScrollingExpandsWhenScrolledToEdge: true, + prefersGrabberVisible: true, + prefersEdgeAttachedInCompactHeight: true, + ), + preferredBarTintColor: theme.colorScheme.surface, + preferredControlTintColor: theme.colorScheme.onSurface, dismissButtonStyle: customtab.SafariViewControllerDismissButtonStyle.close, ), );