bookmarks feature initial
This commit is contained in:
@@ -79,6 +79,26 @@ part of 'routes.dart';
|
||||
),
|
||||
],
|
||||
),
|
||||
TypedGoRoute<BookmarkListRoute>(
|
||||
name: 'BookmarkListRoute',
|
||||
path: 'bookmarks/:entryGuid',
|
||||
),
|
||||
TypedGoRoute<BookmarkFolderAddRoute>(
|
||||
name: 'BookmarkFolderAddRoute',
|
||||
path: 'createFolder',
|
||||
),
|
||||
TypedGoRoute<BookmarkFolderEditRoute>(
|
||||
name: 'BookmarkFolderEditRoute',
|
||||
path: 'editFolder',
|
||||
),
|
||||
TypedGoRoute<BookmarkEntryAddRoute>(
|
||||
name: 'BookmarkEntryAddRoute',
|
||||
path: 'createEntry',
|
||||
),
|
||||
TypedGoRoute<BookmarkEntryEditRoute>(
|
||||
name: 'BookmarkEntryEditRoute',
|
||||
path: 'editEntry',
|
||||
),
|
||||
],
|
||||
)
|
||||
class BrowserRoute extends GoRouteData with $BrowserRoute {
|
||||
@@ -282,3 +302,71 @@ class EditProfileRoute extends GoRouteData with $EditProfileRoute {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BookmarkListRoute extends GoRouteData with $BookmarkListRoute {
|
||||
final String entryGuid;
|
||||
|
||||
const BookmarkListRoute({required this.entryGuid});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return BookmarkListScreen(entryGuid: entryGuid);
|
||||
}
|
||||
}
|
||||
|
||||
class BookmarkFolderAddRoute extends GoRouteData with $BookmarkFolderAddRoute {
|
||||
final String? parentGuid;
|
||||
|
||||
const BookmarkFolderAddRoute({required this.parentGuid});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return BookmarkFolderEditScreen(parentGuid: parentGuid, folder: null);
|
||||
}
|
||||
}
|
||||
|
||||
class BookmarkFolderEditRoute extends GoRouteData
|
||||
with $BookmarkFolderEditRoute {
|
||||
final String folder;
|
||||
|
||||
const BookmarkFolderEditRoute({required this.folder});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return BookmarkFolderEditScreen(
|
||||
folder: BookmarkFolder.fromJson(
|
||||
jsonDecode(folder) as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BookmarkEntryAddRoute extends GoRouteData with $BookmarkEntryAddRoute {
|
||||
final String bookmarkInfo;
|
||||
|
||||
const BookmarkEntryAddRoute({required this.bookmarkInfo});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return BookmarkEntryEditScreen(
|
||||
initialInfo: BookmarkInfo.decode(jsonDecode(bookmarkInfo) as Object),
|
||||
exisitingEntry: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BookmarkEntryEditRoute extends GoRouteData with $BookmarkEntryEditRoute {
|
||||
final String bookmarkEntry;
|
||||
|
||||
const BookmarkEntryEditRoute({required this.bookmarkEntry});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return BookmarkEntryEditScreen(
|
||||
initialInfo: null,
|
||||
exisitingEntry: BookmarkEntry.fromJson(
|
||||
jsonDecode(bookmarkEntry) as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:nullability/nullability.dart';
|
||||
import 'package:weblibre/core/routing/widgets/dialog_page.dart';
|
||||
@@ -32,6 +33,10 @@ import 'package:weblibre/features/bangs/presentation/screens/edit.dart';
|
||||
import 'package:weblibre/features/bangs/presentation/screens/menu.dart';
|
||||
import 'package:weblibre/features/bangs/presentation/screens/search.dart';
|
||||
import 'package:weblibre/features/bangs/presentation/screens/user.dart';
|
||||
import 'package:weblibre/features/geckoview/features/bookmarks/domain/entities/bookmark_item.dart';
|
||||
import 'package:weblibre/features/geckoview/features/bookmarks/presentation/screens/bookmark_entry_edit.dart';
|
||||
import 'package:weblibre/features/geckoview/features/bookmarks/presentation/screens/bookmark_folder_edit.dart';
|
||||
import 'package:weblibre/features/geckoview/features/bookmarks/presentation/screens/bookmark_list.dart';
|
||||
import 'package:weblibre/features/geckoview/features/browser/presentation/dialogs/open_shared_content.dart';
|
||||
import 'package:weblibre/features/geckoview/features/browser/presentation/dialogs/tab_tree.dart';
|
||||
import 'package:weblibre/features/geckoview/features/browser/presentation/screens/browser.dart';
|
||||
|
||||
@@ -464,6 +464,31 @@ RouteBase get $browserRoute => GoRouteData.$route(
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'bookmarks/:entryGuid',
|
||||
name: 'BookmarkListRoute',
|
||||
factory: $BookmarkListRoute._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'createFolder',
|
||||
name: 'BookmarkFolderAddRoute',
|
||||
factory: $BookmarkFolderAddRoute._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'editFolder',
|
||||
name: 'BookmarkFolderEditRoute',
|
||||
factory: $BookmarkFolderEditRoute._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'createEntry',
|
||||
name: 'BookmarkEntryAddRoute',
|
||||
factory: $BookmarkEntryAddRoute._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'editEntry',
|
||||
name: 'BookmarkEntryEditRoute',
|
||||
factory: $BookmarkEntryEditRoute._fromState,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -876,6 +901,143 @@ mixin $CreateProfileRoute on GoRouteData {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin $BookmarkListRoute on GoRouteData {
|
||||
static BookmarkListRoute _fromState(GoRouterState state) =>
|
||||
BookmarkListRoute(entryGuid: state.pathParameters['entryGuid']!);
|
||||
|
||||
BookmarkListRoute get _self => this as BookmarkListRoute;
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location(
|
||||
'/browser/bookmarks/${Uri.encodeComponent(_self.entryGuid)}',
|
||||
);
|
||||
|
||||
@override
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
@override
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
@override
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
@override
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin $BookmarkFolderAddRoute on GoRouteData {
|
||||
static BookmarkFolderAddRoute _fromState(GoRouterState state) =>
|
||||
BookmarkFolderAddRoute(
|
||||
parentGuid: state.uri.queryParameters['parent-guid'],
|
||||
);
|
||||
|
||||
BookmarkFolderAddRoute get _self => this as BookmarkFolderAddRoute;
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location(
|
||||
'/browser/createFolder',
|
||||
queryParams: {
|
||||
if (_self.parentGuid != null) 'parent-guid': _self.parentGuid,
|
||||
},
|
||||
);
|
||||
|
||||
@override
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
@override
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
@override
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
@override
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin $BookmarkFolderEditRoute on GoRouteData {
|
||||
static BookmarkFolderEditRoute _fromState(GoRouterState state) =>
|
||||
BookmarkFolderEditRoute(folder: state.uri.queryParameters['folder']!);
|
||||
|
||||
BookmarkFolderEditRoute get _self => this as BookmarkFolderEditRoute;
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location(
|
||||
'/browser/editFolder',
|
||||
queryParams: {'folder': _self.folder},
|
||||
);
|
||||
|
||||
@override
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
@override
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
@override
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
@override
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin $BookmarkEntryAddRoute on GoRouteData {
|
||||
static BookmarkEntryAddRoute _fromState(GoRouterState state) =>
|
||||
BookmarkEntryAddRoute(
|
||||
bookmarkInfo: state.uri.queryParameters['bookmark-info']!,
|
||||
);
|
||||
|
||||
BookmarkEntryAddRoute get _self => this as BookmarkEntryAddRoute;
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location(
|
||||
'/browser/createEntry',
|
||||
queryParams: {'bookmark-info': _self.bookmarkInfo},
|
||||
);
|
||||
|
||||
@override
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
@override
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
@override
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
@override
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin $BookmarkEntryEditRoute on GoRouteData {
|
||||
static BookmarkEntryEditRoute _fromState(GoRouterState state) =>
|
||||
BookmarkEntryEditRoute(
|
||||
bookmarkEntry: state.uri.queryParameters['bookmark-entry']!,
|
||||
);
|
||||
|
||||
BookmarkEntryEditRoute get _self => this as BookmarkEntryEditRoute;
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location(
|
||||
'/browser/editEntry',
|
||||
queryParams: {'bookmark-entry': _self.bookmarkEntry},
|
||||
);
|
||||
|
||||
@override
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
@override
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
@override
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
@override
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
T? _$convertMapValue<T>(
|
||||
String key,
|
||||
Map<String, String> map,
|
||||
|
||||
Reference in New Issue
Block a user