fix: Custom tabs not opening default browser (#419)

This commit is contained in:
PartyDonut 2025-07-27 20:15:27 +02:00 committed by GitHub
commit df28964749
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -54,21 +54,41 @@ Future<void> launchUrl(BuildContext context, String link) async {
} }
} else { } else {
try { try {
final mediaQuery = MediaQuery.of(context);
final theme = Theme.of(context);
await customtab.launchUrl( await customtab.launchUrl(
Uri.parse(link), Uri.parse(link),
customTabsOptions: customtab.CustomTabsOptions( customTabsOptions: customtab.CustomTabsOptions.partial(
colorSchemes: customtab.CustomTabsColorSchemes.defaults( configuration: customtab.PartialCustomTabsConfiguration.adaptiveSheet(
toolbarColor: Theme.of(context).primaryColor, 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, shareState: customtab.CustomTabsShareState.browserDefault,
showTitle: true, showTitle: true,
browser: const customtab.CustomTabsBrowserConfiguration(
prefersDefaultBrowser: true,
),
), ),
safariVCOptions: customtab.SafariViewControllerOptions( safariVCOptions: customtab.SafariViewControllerOptions.pageSheet(
preferredBarTintColor: Theme.of(context).primaryColor, configuration: const customtab.SheetPresentationControllerConfiguration(
preferredControlTintColor: Colors.white, detents: {
barCollapsingEnabled: true, customtab.SheetPresentationControllerDetent.large,
entersReaderIfAvailable: false, customtab.SheetPresentationControllerDetent.medium,
},
prefersScrollingExpandsWhenScrolledToEdge: true,
prefersGrabberVisible: true,
prefersEdgeAttachedInCompactHeight: true,
),
preferredBarTintColor: theme.colorScheme.surface,
preferredControlTintColor: theme.colorScheme.onSurface,
dismissButtonStyle: customtab.SafariViewControllerDismissButtonStyle.close, dismissButtonStyle: customtab.SafariViewControllerDismissButtonStyle.close,
), ),
); );