use query parameter

This commit is contained in:
Fabian Freund
2025-10-27 05:04:43 +01:00
parent 73572c03ca
commit faa4d9126b
3 changed files with 24 additions and 13 deletions
+7 -3
View File
@@ -181,13 +181,17 @@ class TabTreeRoute extends GoRouteData with $TabTreeRoute {
} }
class OpenSharedContentRoute extends GoRouteData with $OpenSharedContentRoute { class OpenSharedContentRoute extends GoRouteData with $OpenSharedContentRoute {
final Uri $extra; final String sharedUrl;
const OpenSharedContentRoute(this.$extra); const OpenSharedContentRoute({this.sharedUrl = 'about:blank'});
@override @override
Page<void> buildPage(BuildContext context, GoRouterState state) { Page<void> buildPage(BuildContext context, GoRouterState state) {
return DialogPage(builder: (_) => OpenSharedContent(sharedUrl: $extra)); return DialogPage(
builder: (_) => OpenSharedContent(
sharedUrl: Uri.tryParse(sharedUrl) ?? Uri.parse('about:blank'),
),
);
} }
} }
+13 -8
View File
@@ -710,27 +710,32 @@ mixin $TabTreeRoute on GoRouteData {
mixin $OpenSharedContentRoute on GoRouteData { mixin $OpenSharedContentRoute on GoRouteData {
static OpenSharedContentRoute _fromState(GoRouterState state) => static OpenSharedContentRoute _fromState(GoRouterState state) =>
OpenSharedContentRoute(state.extra as Uri); OpenSharedContentRoute(
sharedUrl: state.uri.queryParameters['shared-url'] ?? 'about:blank',
);
OpenSharedContentRoute get _self => this as OpenSharedContentRoute; OpenSharedContentRoute get _self => this as OpenSharedContentRoute;
@override @override
String get location => GoRouteData.$location('/open_content'); String get location => GoRouteData.$location(
'/open_content',
queryParams: {
if (_self.sharedUrl != 'about:blank') 'shared-url': _self.sharedUrl,
},
);
@override @override
void go(BuildContext context) => context.go(location, extra: _self.$extra); void go(BuildContext context) => context.go(location);
@override @override
Future<T?> push<T>(BuildContext context) => Future<T?> push<T>(BuildContext context) => context.push<T>(location);
context.push<T>(location, extra: _self.$extra);
@override @override
void pushReplacement(BuildContext context) => void pushReplacement(BuildContext context) =>
context.pushReplacement(location, extra: _self.$extra); context.pushReplacement(location);
@override @override
void replace(BuildContext context) => void replace(BuildContext context) => context.replace(location);
context.replace(location, extra: _self.$extra);
} }
T? _$convertMapValue<T>( T? _$convertMapValue<T>(
@@ -192,8 +192,10 @@ class _BrowserViewState extends ConsumerState<BrowserView>
case TabIntentOpenSetting.ask: case TabIntentOpenSetting.ask:
switch (sharedContent) { switch (sharedContent) {
case SharedUrl(): case SharedUrl():
final route = OpenSharedContentRoute(sharedContent.url); final route = OpenSharedContentRoute(
await router.push(route.location, extra: route.$extra); sharedUrl: sharedContent.url.toString(),
);
await router.push(route.location);
case SharedText(): case SharedText():
final route = SearchRoute( final route = SearchRoute(
tabType: tabType: