update routes; small polishments
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:bang_navigator/core/routing/dialog_page.dart';
|
||||
import 'package:bang_navigator/features/about/presentation/screens/about.dart';
|
||||
import 'package:bang_navigator/features/bangs/presentation/screens/bang.dart';
|
||||
import 'package:bang_navigator/features/bangs/presentation/screens/categories.dart';
|
||||
import 'package:bang_navigator/features/bangs/presentation/screens/list.dart';
|
||||
import 'package:bang_navigator/features/bangs/presentation/screens/search.dart';
|
||||
import 'package:bang_navigator/features/chat_archive/presentation/screens/detail.dart';
|
||||
import 'package:bang_navigator/features/chat_archive/presentation/screens/list.dart';
|
||||
@@ -19,16 +20,26 @@ part 'routes.g.dart';
|
||||
name: 'AboutRoute',
|
||||
path: 'about',
|
||||
),
|
||||
TypedGoRoute<BangRoute>(
|
||||
TypedGoRoute<BangCategoriesRoute>(
|
||||
name: 'BangRoute',
|
||||
path: 'bangs',
|
||||
routes: [
|
||||
TypedGoRoute<BangSearchRoute>(
|
||||
name: 'BangSearchRoute',
|
||||
path: 'search',
|
||||
TypedGoRoute<BangCategoryRoute>(
|
||||
name: 'BangCategoryRoute',
|
||||
path: ':category',
|
||||
routes: [
|
||||
TypedGoRoute<BangSubCategoryRoute>(
|
||||
name: 'BangSubCategoryRoute',
|
||||
path: ':subCategory',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
TypedGoRoute<BangSearchRoute>(
|
||||
name: 'BangSearchRoute',
|
||||
path: 'bang_search',
|
||||
),
|
||||
],
|
||||
)
|
||||
class KagiRoute extends GoRouteData {
|
||||
@@ -45,10 +56,36 @@ class AboutRoute extends GoRouteData {
|
||||
}
|
||||
}
|
||||
|
||||
class BangRoute extends GoRouteData {
|
||||
class BangCategoriesRoute extends GoRouteData {
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return const BangScreen();
|
||||
return const BangCategoriesScreen();
|
||||
}
|
||||
}
|
||||
|
||||
class BangCategoryRoute extends GoRouteData {
|
||||
final String category;
|
||||
|
||||
const BangCategoryRoute({required this.category});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return BangListScreen(category: category);
|
||||
}
|
||||
}
|
||||
|
||||
class BangSubCategoryRoute extends GoRouteData {
|
||||
final String category;
|
||||
final String subCategory;
|
||||
|
||||
const BangSubCategoryRoute({
|
||||
required this.category,
|
||||
required this.subCategory,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return BangListScreen(category: category, subCategory: subCategory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,15 +25,27 @@ RouteBase get $kagiRoute => GoRouteData.$route(
|
||||
GoRouteData.$route(
|
||||
path: 'bangs',
|
||||
name: 'BangRoute',
|
||||
factory: $BangRouteExtension._fromState,
|
||||
factory: $BangCategoriesRouteExtension._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: 'search',
|
||||
name: 'BangSearchRoute',
|
||||
factory: $BangSearchRouteExtension._fromState,
|
||||
path: ':category',
|
||||
name: 'BangCategoryRoute',
|
||||
factory: $BangCategoryRouteExtension._fromState,
|
||||
routes: [
|
||||
GoRouteData.$route(
|
||||
path: ':subCategory',
|
||||
name: 'BangSubCategoryRoute',
|
||||
factory: $BangSubCategoryRouteExtension._fromState,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRouteData.$route(
|
||||
path: 'bang_search',
|
||||
name: 'BangSearchRoute',
|
||||
factory: $BangSearchRouteExtension._fromState,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -71,8 +83,9 @@ extension $AboutRouteExtension on AboutRoute {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $BangRouteExtension on BangRoute {
|
||||
static BangRoute _fromState(GoRouterState state) => BangRoute();
|
||||
extension $BangCategoriesRouteExtension on BangCategoriesRoute {
|
||||
static BangCategoriesRoute _fromState(GoRouterState state) =>
|
||||
BangCategoriesRoute();
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/bangs',
|
||||
@@ -88,11 +101,51 @@ extension $BangRouteExtension on BangRoute {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $BangCategoryRouteExtension on BangCategoryRoute {
|
||||
static BangCategoryRoute _fromState(GoRouterState state) => BangCategoryRoute(
|
||||
category: state.pathParameters['category']!,
|
||||
);
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/bangs/${Uri.encodeComponent(category)}',
|
||||
);
|
||||
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $BangSubCategoryRouteExtension on BangSubCategoryRoute {
|
||||
static BangSubCategoryRoute _fromState(GoRouterState state) =>
|
||||
BangSubCategoryRoute(
|
||||
category: state.pathParameters['category']!,
|
||||
subCategory: state.pathParameters['subCategory']!,
|
||||
);
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/bangs/${Uri.encodeComponent(category)}/${Uri.encodeComponent(subCategory)}',
|
||||
);
|
||||
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
|
||||
|
||||
void pushReplacement(BuildContext context) =>
|
||||
context.pushReplacement(location);
|
||||
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
extension $BangSearchRouteExtension on BangSearchRoute {
|
||||
static BangSearchRoute _fromState(GoRouterState state) => BangSearchRoute();
|
||||
|
||||
String get location => GoRouteData.$location(
|
||||
'/bangs/search',
|
||||
'/bang_search',
|
||||
);
|
||||
|
||||
void go(BuildContext context) => context.go(location);
|
||||
|
||||
@@ -138,7 +138,7 @@ class KagiScreen extends HookConsumerWidget {
|
||||
const Divider(),
|
||||
MenuItemButton(
|
||||
onPressed: () async {
|
||||
await context.push(BangRoute().location);
|
||||
await context.push(BangCategoriesRoute().location);
|
||||
},
|
||||
leadingIcon: const Icon(MdiIcons.exclamationThick),
|
||||
child: const Text('Bangs'),
|
||||
|
||||
@@ -37,7 +37,7 @@ class AppBarTitle extends HookConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final activeWebView = ref.watch(webViewTabControllerProvider);
|
||||
if (activeWebView == null) {
|
||||
return SizedBox.shrink();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final page = useValueListenable(activeWebView.page);
|
||||
|
||||
@@ -18,7 +18,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
class _InputField extends ConsumerWidget {
|
||||
final TextEditingController? controller;
|
||||
|
||||
const _InputField({required this.controller, super.key});
|
||||
const _InputField({required this.controller});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
|
||||
@@ -202,7 +202,7 @@ class SettingsScreen extends HookConsumerWidget {
|
||||
_buildSection(theme, 'Bangs'),
|
||||
ButtonListTile(
|
||||
title: 'Icon Cache',
|
||||
subtitle: 'Stores favicons for Bangs',
|
||||
subtitle: 'Stored favicons for Bangs',
|
||||
button: FilledButton.icon(
|
||||
onPressed: () async {
|
||||
await ref
|
||||
@@ -215,7 +215,7 @@ class SettingsScreen extends HookConsumerWidget {
|
||||
),
|
||||
ButtonListTile(
|
||||
title: 'Bang Frequencies',
|
||||
subtitle: 'Tracks Bang usage for recommendation history',
|
||||
subtitle: 'Tracked usage for Bang recommendations',
|
||||
button: FilledButton.icon(
|
||||
onPressed: () async {
|
||||
await ref
|
||||
|
||||
+10
-10
@@ -349,10 +349,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: file_picker
|
||||
sha256: "29c90806ac5f5fb896547720b73b17ee9aed9bba540dc5d91fe29f8c5745b10a"
|
||||
sha256: "2ca051989f69d1b2ca012b2cf3ccf78c70d40144f0861ff2c063493f7c8c3d45"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.0.3"
|
||||
version: "8.0.5"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -442,10 +442,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_markdown
|
||||
sha256: "9921f9deda326f8a885e202b1e35237eadfc1345239a0f6f0f1ff287e047547f"
|
||||
sha256: ff76a9300a06ad1f2b394e54c0b4beaaf6a95f95c98540c918b870221499bb10
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.1"
|
||||
version: "0.7.2"
|
||||
flutter_material_design_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -567,10 +567,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: go_router
|
||||
sha256: abec47eb8c8c36ebf41d0a4c64dbbe7f956e39a012b3aafc530e951bdc12fe3f
|
||||
sha256: cdae1b9c8bd7efadcef6112e81c903662ef2ce105cbd220a04bbb7c3425b5554
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.1.4"
|
||||
version: "14.2.0"
|
||||
go_router_builder:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -847,10 +847,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
|
||||
sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.4"
|
||||
version: "3.1.5"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1284,10 +1284,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: "360c4271613beb44db559547d02f8b0dc044741d0eeb9aa6ccdb47e8ec54c63a"
|
||||
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.2.3"
|
||||
version: "14.2.4"
|
||||
watcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user