refactor tab menu
This commit is contained in:
@@ -23,7 +23,6 @@ part of 'routes.dart';
|
||||
name: BrowserRoute.name,
|
||||
path: '/',
|
||||
routes: [
|
||||
TypedGoRoute<WebPageRoute>(name: 'WebPageRoute', path: 'page/:url'),
|
||||
TypedGoRoute<SearchRoute>(
|
||||
name: 'SearchRoute',
|
||||
path: 'search/:tabType/:searchText',
|
||||
@@ -66,20 +65,6 @@ class BrowserRoute extends GoRouteData with _$BrowserRoute {
|
||||
}
|
||||
}
|
||||
|
||||
class WebPageRoute extends GoRouteData with _$WebPageRoute {
|
||||
final String url;
|
||||
final WebPageInfo? $extra;
|
||||
|
||||
const WebPageRoute({required this.url, required this.$extra});
|
||||
|
||||
@override
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
return DialogPage(
|
||||
builder: (_) => WebPageDialog(url: Uri.parse(url), precachedInfo: $extra),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum TabType { regular, private, child }
|
||||
|
||||
class SearchRoute extends GoRouteData with _$SearchRoute {
|
||||
|
||||
@@ -22,13 +22,11 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:weblibre/core/routing/widgets/dialog_page.dart';
|
||||
import 'package:weblibre/data/models/web_page_info.dart';
|
||||
import 'package:weblibre/features/about/presentation/screens/about.dart';
|
||||
import 'package:weblibre/features/bangs/presentation/screens/categories.dart';
|
||||
import 'package:weblibre/features/bangs/presentation/screens/list.dart';
|
||||
import 'package:weblibre/features/bangs/presentation/screens/search.dart';
|
||||
import 'package:weblibre/features/geckoview/features/browser/presentation/dialogs/tab_tree.dart';
|
||||
import 'package:weblibre/features/geckoview/features/browser/presentation/dialogs/web_page_dialog.dart';
|
||||
import 'package:weblibre/features/geckoview/features/browser/presentation/screens/browser.dart';
|
||||
import 'package:weblibre/features/geckoview/features/contextmenu/extensions/hit_result.dart';
|
||||
import 'package:weblibre/features/geckoview/features/contextmenu/presentation/context_menu_dialog.dart';
|
||||
|
||||
@@ -283,12 +283,6 @@ RouteBase get $browserRoute => GoRouteData.$route(
|
||||
|
||||
factory: _$BrowserRoute._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: 'page/:url',
|
||||
name: 'WebPageRoute',
|
||||
|
||||
factory: _$WebPageRoute._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'search/:tabType/:searchText',
|
||||
name: 'SearchRoute',
|
||||
@@ -362,34 +356,6 @@ mixin _$BrowserRoute on GoRouteData {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin _$WebPageRoute on GoRouteData {
|
||||
static WebPageRoute _fromState(GoRouterState state) => WebPageRoute(
|
||||
url: state.pathParameters['url']!,
|
||||
$extra: state.extra as WebPageInfo?,
|
||||
);
|
||||
|
||||
WebPageRoute get _self => this as WebPageRoute;
|
||||
|
||||
@override
|
||||
String get location =>
|
||||
GoRouteData.$location('/page/${Uri.encodeComponent(_self.url)}');
|
||||
|
||||
@override
|
||||
void go(BuildContext context) => context.go(location, extra: _self.$extra);
|
||||
|
||||
@override
|
||||
Future<T?> push<T>(BuildContext context) =>
|
||||
context.push<T>(location, extra: _self.$extra);
|
||||
|
||||
@override
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location, extra: _self.$extra);
|
||||
|
||||
@override
|
||||
void replace(BuildContext context) =>
|
||||
context.replace(location, extra: _self.$extra);
|
||||
}
|
||||
|
||||
mixin _$SearchRoute on GoRouteData {
|
||||
static SearchRoute _fromState(GoRouterState state) => SearchRoute(
|
||||
tabType: _$TabTypeEnumMap._$fromName(state.pathParameters['tabType']!)!,
|
||||
|
||||
Reference in New Issue
Block a user