implement user bangs
This commit is contained in:
@@ -19,27 +19,55 @@
|
||||
*/
|
||||
part of 'routes.dart';
|
||||
|
||||
@TypedGoRoute<BangCategoriesRoute>(
|
||||
@TypedGoRoute<BangMenuRoute>(
|
||||
name: 'BangRoute',
|
||||
path: '/bangs',
|
||||
routes: [
|
||||
TypedGoRoute<UserBangsRoute>(
|
||||
name: 'UserBangsRoute',
|
||||
path: 'user',
|
||||
routes: [
|
||||
TypedGoRoute<NewUserBangRoute>(name: 'NewUserBangRoute', path: 'new'),
|
||||
TypedGoRoute<EditUserBangRoute>(
|
||||
name: 'EditUserBangRoute',
|
||||
path: 'edit',
|
||||
),
|
||||
],
|
||||
),
|
||||
TypedGoRoute<BangSearchRoute>(
|
||||
name: 'BangSearchRoute',
|
||||
path: 'search/:searchText',
|
||||
),
|
||||
TypedGoRoute<BangCategoryRoute>(
|
||||
name: 'BangCategoryRoute',
|
||||
path: 'category/:category',
|
||||
TypedGoRoute<BangCategoriesRoute>(
|
||||
name: 'BangCategoriesRoute',
|
||||
path: 'categories',
|
||||
routes: [
|
||||
TypedGoRoute<BangSubCategoryRoute>(
|
||||
name: 'BangSubCategoryRoute',
|
||||
path: ':subCategory',
|
||||
TypedGoRoute<BangCategoryRoute>(
|
||||
name: 'BangCategoryRoute',
|
||||
path: 'category/:category',
|
||||
routes: [
|
||||
TypedGoRoute<BangSubCategoryRoute>(
|
||||
name: 'BangSubCategoryRoute',
|
||||
path: ':subCategory',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
class BangMenuRoute extends GoRouteData with $BangMenuRoute {
|
||||
const BangMenuRoute();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return const BangMenuScreen();
|
||||
}
|
||||
}
|
||||
|
||||
class BangCategoriesRoute extends GoRouteData with $BangCategoriesRoute {
|
||||
const BangCategoriesRoute();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return const BangCategoriesScreen();
|
||||
@@ -53,7 +81,7 @@ class BangCategoryRoute extends GoRouteData with $BangCategoryRoute {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return BangListScreen(category: category);
|
||||
return BangCategoryScreen(category: category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +96,7 @@ class BangSubCategoryRoute extends GoRouteData with $BangSubCategoryRoute {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return BangListScreen(category: category, subCategory: subCategory);
|
||||
return BangCategoryScreen(category: category, subCategory: subCategory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,3 +117,36 @@ class BangSearchRoute extends GoRouteData with $BangSearchRoute {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UserBangsRoute extends GoRouteData with $UserBangsRoute {
|
||||
const UserBangsRoute();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return const UserBangs();
|
||||
}
|
||||
}
|
||||
|
||||
class NewUserBangRoute extends GoRouteData with $NewUserBangRoute {
|
||||
const NewUserBangRoute();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return const EditBangScreen(initialBang: null);
|
||||
}
|
||||
}
|
||||
|
||||
class EditUserBangRoute extends GoRouteData with $EditUserBangRoute {
|
||||
final String initialBang;
|
||||
|
||||
const EditUserBangRoute({required this.initialBang});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return EditBangScreen(
|
||||
initialBang: Bang.fromJson(
|
||||
jsonDecode(initialBang) as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,13 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:nullability/nullability.dart';
|
||||
import 'package:weblibre/core/routing/widgets/dialog_page.dart';
|
||||
import 'package:weblibre/features/about/presentation/screens/about.dart';
|
||||
import 'package:weblibre/features/bangs/data/models/bang.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/category.dart';
|
||||
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/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';
|
||||
|
||||
@@ -11,7 +11,7 @@ List<RouteBase> get $appRoutes => [
|
||||
$onboardingRoute,
|
||||
$settingsRoute,
|
||||
$browserRoute,
|
||||
$bangCategoriesRoute,
|
||||
$bangMenuRoute,
|
||||
$feedListRoute,
|
||||
];
|
||||
|
||||
@@ -791,34 +791,57 @@ extension<T extends Enum> on Map<T, String> {
|
||||
entries.where((element) => element.value == value).firstOrNull?.key;
|
||||
}
|
||||
|
||||
RouteBase get $bangCategoriesRoute => GoRouteData.$route(
|
||||
RouteBase get $bangMenuRoute => GoRouteData.$route(
|
||||
path: '/bangs',
|
||||
name: 'BangRoute',
|
||||
factory: $BangCategoriesRoute._fromState,
|
||||
factory: $BangMenuRoute._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: 'user',
|
||||
name: 'UserBangsRoute',
|
||||
factory: $UserBangsRoute._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: 'new',
|
||||
name: 'NewUserBangRoute',
|
||||
factory: $NewUserBangRoute._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'edit',
|
||||
name: 'EditUserBangRoute',
|
||||
factory: $EditUserBangRoute._fromState,
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'search/:searchText',
|
||||
name: 'BangSearchRoute',
|
||||
factory: $BangSearchRoute._fromState,
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'category/:category',
|
||||
name: 'BangCategoryRoute',
|
||||
factory: $BangCategoryRoute._fromState,
|
||||
path: 'categories',
|
||||
name: 'BangCategoriesRoute',
|
||||
factory: $BangCategoriesRoute._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: ':subCategory',
|
||||
name: 'BangSubCategoryRoute',
|
||||
factory: $BangSubCategoryRoute._fromState,
|
||||
path: 'category/:category',
|
||||
name: 'BangCategoryRoute',
|
||||
factory: $BangCategoryRoute._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: ':subCategory',
|
||||
name: 'BangSubCategoryRoute',
|
||||
factory: $BangSubCategoryRoute._fromState,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
mixin $BangCategoriesRoute on GoRouteData {
|
||||
static BangCategoriesRoute _fromState(GoRouterState state) =>
|
||||
BangCategoriesRoute();
|
||||
mixin $BangMenuRoute on GoRouteData {
|
||||
static BangMenuRoute _fromState(GoRouterState state) => const BangMenuRoute();
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location('/bangs');
|
||||
@@ -837,6 +860,75 @@ mixin $BangCategoriesRoute on GoRouteData {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin $UserBangsRoute on GoRouteData {
|
||||
static UserBangsRoute _fromState(GoRouterState state) =>
|
||||
const UserBangsRoute();
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location('/bangs/user');
|
||||
|
||||
@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 $NewUserBangRoute on GoRouteData {
|
||||
static NewUserBangRoute _fromState(GoRouterState state) =>
|
||||
const NewUserBangRoute();
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location('/bangs/user/new');
|
||||
|
||||
@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 $EditUserBangRoute on GoRouteData {
|
||||
static EditUserBangRoute _fromState(GoRouterState state) => EditUserBangRoute(
|
||||
initialBang: state.uri.queryParameters['initial-bang']!,
|
||||
);
|
||||
|
||||
EditUserBangRoute get _self => this as EditUserBangRoute;
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location(
|
||||
'/bangs/user/edit',
|
||||
queryParams: {'initial-bang': _self.initialBang},
|
||||
);
|
||||
|
||||
@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 $BangSearchRoute on GoRouteData {
|
||||
static BangSearchRoute _fromState(GoRouterState state) => BangSearchRoute(
|
||||
searchText:
|
||||
@@ -864,6 +956,27 @@ mixin $BangSearchRoute on GoRouteData {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
mixin $BangCategoriesRoute on GoRouteData {
|
||||
static BangCategoriesRoute _fromState(GoRouterState state) =>
|
||||
const BangCategoriesRoute();
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location('/bangs/categories');
|
||||
|
||||
@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 $BangCategoryRoute on GoRouteData {
|
||||
static BangCategoryRoute _fromState(GoRouterState state) =>
|
||||
BangCategoryRoute(category: state.pathParameters['category']!);
|
||||
@@ -872,7 +985,7 @@ mixin $BangCategoryRoute on GoRouteData {
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location(
|
||||
'/bangs/category/${Uri.encodeComponent(_self.category)}',
|
||||
'/bangs/categories/category/${Uri.encodeComponent(_self.category)}',
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -900,7 +1013,7 @@ mixin $BangSubCategoryRoute on GoRouteData {
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location(
|
||||
'/bangs/category/${Uri.encodeComponent(_self.category)}/${Uri.encodeComponent(_self.subCategory)}',
|
||||
'/bangs/categories/category/${Uri.encodeComponent(_self.category)}/${Uri.encodeComponent(_self.subCategory)}',
|
||||
);
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user