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 {
final Uri $extra;
final String sharedUrl;
const OpenSharedContentRoute(this.$extra);
const OpenSharedContentRoute({this.sharedUrl = 'about:blank'});
@override
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 {
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;
@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
void go(BuildContext context) => context.go(location, extra: _self.$extra);
void go(BuildContext context) => context.go(location);
@override
Future<T?> push<T>(BuildContext context) =>
context.push<T>(location, extra: _self.$extra);
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
@override
void pushReplacement(BuildContext context) =>
context.pushReplacement(location, extra: _self.$extra);
context.pushReplacement(location);
@override
void replace(BuildContext context) =>
context.replace(location, extra: _self.$extra);
void replace(BuildContext context) => context.replace(location);
}
T? _$convertMapValue<T>(
@@ -192,8 +192,10 @@ class _BrowserViewState extends ConsumerState<BrowserView>
case TabIntentOpenSetting.ask:
switch (sharedContent) {
case SharedUrl():
final route = OpenSharedContentRoute(sharedContent.url);
await router.push(route.location, extra: route.$extra);
final route = OpenSharedContentRoute(
sharedUrl: sharedContent.url.toString(),
);
await router.push(route.location);
case SharedText():
final route = SearchRoute(
tabType: