use query parameter
This commit is contained in:
@@ -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'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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>(
|
||||
|
||||
+4
-2
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user