From fc84e366aaef84ecc69c4e27ed2412f0978f20b8 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Wed, 12 Jun 2024 18:53:34 +0900 Subject: [PATCH 01/23] =?UTF-8?q?feat:=20=E7=94=BB=E9=9D=A2=E9=81=B7?= =?UTF-8?q?=E7=A7=BB=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=B8=E3=81=AE=E3=83=9C?= =?UTF-8?q?=E3=82=BF=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/features/debug_mode/lib/src/ui/debug_page.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/features/debug_mode/lib/src/ui/debug_page.dart b/packages/features/debug_mode/lib/src/ui/debug_page.dart index fb7a64bd..07d9d32b 100644 --- a/packages/features/debug_mode/lib/src/ui/debug_page.dart +++ b/packages/features/debug_mode/lib/src/ui/debug_page.dart @@ -42,6 +42,12 @@ class DebugPage extends ConsumerWidget { ); }, ), + _FixSizedElevatedButton( + title: '画面遷移', + onPressed: () async { + navigator.goNavigationPage(context); + }, + ), ], ), ), From af737dcedae24bf4ef6ea8e6c0db5f464504027b Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Wed, 12 Jun 2024 18:57:10 +0900 Subject: [PATCH 02/23] =?UTF-8?q?add:=20navigation=5Fpage.dart=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/src/ui/navigation_page.dart | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 packages/features/debug_mode/lib/src/ui/navigation_page.dart diff --git a/packages/features/debug_mode/lib/src/ui/navigation_page.dart b/packages/features/debug_mode/lib/src/ui/navigation_page.dart new file mode 100644 index 00000000..9861947c --- /dev/null +++ b/packages/features/debug_mode/lib/src/ui/navigation_page.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +class NavigationPage extends ConsumerWidget { + const NavigationPage({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + return Scaffold( + appBar: AppBar( + title: const Text('画面遷移ページ'), + ), + body: Center( + child: Column( + children: [ + _FixSizedElevatedButton( + title: '画面A', + onPressed: () async {}, + ), + _FixSizedElevatedButton( + title: '画面B', + onPressed: () async {}, + ), + ], + ), + ), + ); + } +} + +class _FixSizedElevatedButton extends StatelessWidget { + const _FixSizedElevatedButton({ + required String title, + required VoidCallback onPressed, + }) : _title = title, + _onPressed = onPressed; + + final String _title; + final VoidCallback _onPressed; + + @override + Widget build(BuildContext context) { + return FractionallySizedBox( + widthFactor: 0.8, + child: ElevatedButton( + onPressed: _onPressed, + child: Text(_title), + ), + ); + } +} From 0fc158a7026739abdd7bcef734e085fbe31299a2 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Wed, 12 Jun 2024 19:42:33 +0900 Subject: [PATCH 03/23] =?UTF-8?q?feat:=20NavigationPage=E3=81=B8=E3=81=AE?= =?UTF-8?q?=E9=81=B7=E7=A7=BB=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E6=BA=96=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../navigator/navigation_navigator.dart | 12 ++++++++ apps/app/lib/router/provider/router.dart | 2 ++ apps/app/lib/router/provider/router.g.dart | 24 +++++++++++++++ .../router/routes/navigation_page_route.dart | 22 ++++++++++++++ packages/cores/navigation/lib/navigators.dart | 1 + packages/cores/navigation/lib/providers.dart | 1 + .../lib/src/home/navigation/navigator.dart | 5 ++++ .../lib/src/home/navigation/provider.dart | 7 +++++ .../lib/src/home/navigation/provider.g.dart | 30 +++++++++++++++++++ .../features/debug_mode/lib/src/ui/index.dart | 1 + 10 files changed, 105 insertions(+) create mode 100644 apps/app/lib/router/navigator/navigation_navigator.dart create mode 100644 apps/app/lib/router/routes/navigation_page_route.dart create mode 100644 packages/cores/navigation/lib/src/home/navigation/navigator.dart create mode 100644 packages/cores/navigation/lib/src/home/navigation/provider.dart create mode 100644 packages/cores/navigation/lib/src/home/navigation/provider.g.dart diff --git a/apps/app/lib/router/navigator/navigation_navigator.dart b/apps/app/lib/router/navigator/navigation_navigator.dart new file mode 100644 index 00000000..bf3babd9 --- /dev/null +++ b/apps/app/lib/router/navigator/navigation_navigator.dart @@ -0,0 +1,12 @@ +import 'package:cores_navigation/navigators.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_app/router/provider/router.dart'; + +final class NavigationNavigatorImpl implements NavigationNavigator { + const NavigationNavigatorImpl(); + + @override + void goNavigationPage(BuildContext context) { + const NavigationPageRoute().go(context); + } +} diff --git a/apps/app/lib/router/provider/router.dart b/apps/app/lib/router/provider/router.dart index 9f4c7a91..79d4941c 100644 --- a/apps/app/lib/router/provider/router.dart +++ b/apps/app/lib/router/provider/router.dart @@ -9,6 +9,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_app/main_page.dart'; import 'package:flutter_app/router/navigator/home_navigator.dart'; +import 'package:flutter_app/router/navigator/navigation_navigator.dart'; import 'package:flutter_app/router/navigator/setting_navigator.dart'; import 'package:flutter_app/ui/home_page.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -21,6 +22,7 @@ part 'package:flutter_app/router/routes/main/home/web_page_route.dart'; part 'package:flutter_app/router/routes/main/main_page_shell_route.dart'; part 'package:flutter_app/router/routes/main/setting/setting_shell_branch.dart'; part 'package:flutter_app/router/routes/maintenance_page_route.dart'; +part 'package:flutter_app/router/routes/navigation_page_route.dart'; part 'router.g.dart'; final _rootNavigatorKey = GlobalKey(debugLabel: 'root'); diff --git a/apps/app/lib/router/provider/router.g.dart b/apps/app/lib/router/provider/router.g.dart index 0e1ebb9f..f48a9ea8 100644 --- a/apps/app/lib/router/provider/router.g.dart +++ b/apps/app/lib/router/provider/router.g.dart @@ -11,6 +11,7 @@ part of 'router.dart'; List get $appRoutes => [ $mainPageShellRoute, $maintenancePageRoute, + $navigationPageRoute, ]; RouteBase get $mainPageShellRoute => StatefulShellRouteData.$route( @@ -197,6 +198,29 @@ extension $MaintenancePageRouteExtension on MaintenancePageRoute { void replace(BuildContext context) => context.replace(location); } +RouteBase get $navigationPageRoute => GoRouteData.$route( + path: '/navigation', + factory: $NavigationPageRouteExtension._fromState, + ); + +extension $NavigationPageRouteExtension on NavigationPageRoute { + static NavigationPageRoute _fromState(GoRouterState state) => + const NavigationPageRoute(); + + String get location => GoRouteData.$location( + '/navigation', + ); + + void go(BuildContext context) => context.go(location); + + Future push(BuildContext context) => context.push(location); + + void pushReplacement(BuildContext context) => + context.pushReplacement(location); + + void replace(BuildContext context) => context.replace(location); +} + // ************************************************************************** // RiverpodGenerator // ************************************************************************** diff --git a/apps/app/lib/router/routes/navigation_page_route.dart b/apps/app/lib/router/routes/navigation_page_route.dart new file mode 100644 index 00000000..cf806bc9 --- /dev/null +++ b/apps/app/lib/router/routes/navigation_page_route.dart @@ -0,0 +1,22 @@ +part of 'package:flutter_app/router/provider/router.dart'; + +@TypedGoRoute( + path: NavigationPageRoute.path, +) +class NavigationPageRoute extends GoRouteData { + const NavigationPageRoute(); + + static const path = '/navigation'; + + @override + Widget build(BuildContext context, GoRouterState state) { + return ProviderScope( + overrides: [ + navigationNavigatorProvider.overrideWithValue( + const NavigationNavigatorImpl(), + ), + ], + child: const NavigationPage(), + ); + } +} diff --git a/packages/cores/navigation/lib/navigators.dart b/packages/cores/navigation/lib/navigators.dart index be83d886..c630aaf0 100644 --- a/packages/cores/navigation/lib/navigators.dart +++ b/packages/cores/navigation/lib/navigators.dart @@ -1,2 +1,3 @@ +export 'src/home/navigation//navigator.dart'; export 'src/home/navigator.dart'; export 'src/setting/navigator.dart'; diff --git a/packages/cores/navigation/lib/providers.dart b/packages/cores/navigation/lib/providers.dart index 0a92a2c8..f559e4b0 100644 --- a/packages/cores/navigation/lib/providers.dart +++ b/packages/cores/navigation/lib/providers.dart @@ -1,2 +1,3 @@ +export 'src/home/navigation/provider.dart'; export 'src/home/provider.dart'; export 'src/setting/provider.dart'; diff --git a/packages/cores/navigation/lib/src/home/navigation/navigator.dart b/packages/cores/navigation/lib/src/home/navigation/navigator.dart new file mode 100644 index 00000000..502d5d7f --- /dev/null +++ b/packages/cores/navigation/lib/src/home/navigation/navigator.dart @@ -0,0 +1,5 @@ +import 'package:flutter/material.dart'; + +abstract interface class NavigationNavigator { + void goNavigationPage(BuildContext context); +} diff --git a/packages/cores/navigation/lib/src/home/navigation/provider.dart b/packages/cores/navigation/lib/src/home/navigation/provider.dart new file mode 100644 index 00000000..b01f58c8 --- /dev/null +++ b/packages/cores/navigation/lib/src/home/navigation/provider.dart @@ -0,0 +1,7 @@ +import 'package:cores_navigation/src/home/navigation/navigator.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +part 'provider.g.dart'; + +@riverpod +external NavigationNavigator navigationNavigator(NavigationNavigatorRef ref); diff --git a/packages/cores/navigation/lib/src/home/navigation/provider.g.dart b/packages/cores/navigation/lib/src/home/navigation/provider.g.dart new file mode 100644 index 00000000..f106e6d7 --- /dev/null +++ b/packages/cores/navigation/lib/src/home/navigation/provider.g.dart @@ -0,0 +1,30 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'provider.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$navigationNavigatorHash() => + r'fa87b8f037c618f9f3172755899b7e11a551f874'; + +/// See also [navigationNavigator]. +@ProviderFor(navigationNavigator) +final navigationNavigatorProvider = + AutoDisposeProvider.internal( + (_) => throw UnsupportedError( + 'The provider "navigationNavigatorProvider" is expected to get overridden/scoped, ' + 'but was accessed without an override.', + ), + name: r'navigationNavigatorProvider', + debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') + ? null + : _$navigationNavigatorHash, + dependencies: null, + allTransitiveDependencies: null, +); + +typedef NavigationNavigatorRef = AutoDisposeProviderRef; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/packages/features/debug_mode/lib/src/ui/index.dart b/packages/features/debug_mode/lib/src/ui/index.dart index 7050ced0..c2546a40 100644 --- a/packages/features/debug_mode/lib/src/ui/index.dart +++ b/packages/features/debug_mode/lib/src/ui/index.dart @@ -1,2 +1,3 @@ export 'debug_page.dart'; export 'maintenance_page.dart'; +export 'navigation_page.dart'; From 62939a0df7a5ee82f1a6f639a78d612836cad37d Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Wed, 12 Jun 2024 19:42:57 +0900 Subject: [PATCH 04/23] =?UTF-8?q?feat:=20=E3=83=87=E3=83=90=E3=83=83?= =?UTF-8?q?=E3=82=B0=E7=94=BB=E9=9D=A2=E3=81=8B=E3=82=89=E7=94=BB=E9=9D=A2?= =?UTF-8?q?=E9=81=B7=E7=A7=BB=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/features/debug_mode/lib/src/ui/debug_page.dart | 2 ++ packages/features/debug_mode/pubspec.lock | 7 +++++++ packages/features/debug_mode/pubspec.yaml | 2 ++ 3 files changed, 11 insertions(+) diff --git a/packages/features/debug_mode/lib/src/ui/debug_page.dart b/packages/features/debug_mode/lib/src/ui/debug_page.dart index 07d9d32b..b71a016e 100644 --- a/packages/features/debug_mode/lib/src/ui/debug_page.dart +++ b/packages/features/debug_mode/lib/src/ui/debug_page.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:cores_core/app_status.dart'; +import 'package:cores_navigation/providers.dart'; import 'package:features_debug_mode/src/data/api/provider/exception_generator_api.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -10,6 +11,7 @@ class DebugPage extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + final navigator = ref.watch(navigationNavigatorProvider); return Scaffold( appBar: AppBar( title: const Text('Debug Mode'), diff --git a/packages/features/debug_mode/pubspec.lock b/packages/features/debug_mode/pubspec.lock index 3f657382..bb2d095f 100644 --- a/packages/features/debug_mode/pubspec.lock +++ b/packages/features/debug_mode/pubspec.lock @@ -190,6 +190,13 @@ packages: relative: true source: path version: "0.0.1" + cores_navigation: + dependency: "direct main" + description: + path: "../../cores/navigation" + relative: true + source: path + version: "0.0.1" crypto: dependency: transitive description: diff --git a/packages/features/debug_mode/pubspec.yaml b/packages/features/debug_mode/pubspec.yaml index d106333c..c5a1f82f 100644 --- a/packages/features/debug_mode/pubspec.yaml +++ b/packages/features/debug_mode/pubspec.yaml @@ -14,6 +14,8 @@ dependencies: path: ../../cores/data cores_designsystem: path: ../../cores/designsystem + cores_navigation: + path: ../../../packages/cores/navigation dio: ^5.4.0 flutter: sdk: flutter From 1a881b17e83fe2d5476fad75740e61b161e83dea Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 13:24:24 +0900 Subject: [PATCH 05/23] =?UTF-8?q?delete:=20navigation=5Fpage=5Froute?= =?UTF-8?q?=E3=81=AFdebug=5Fpage=5Froute=E3=81=AB=E7=B5=B1=E5=90=88?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=81=AE=E3=81=A7=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../router/routes/navigation_page_route.dart | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 apps/app/lib/router/routes/navigation_page_route.dart diff --git a/apps/app/lib/router/routes/navigation_page_route.dart b/apps/app/lib/router/routes/navigation_page_route.dart deleted file mode 100644 index cf806bc9..00000000 --- a/apps/app/lib/router/routes/navigation_page_route.dart +++ /dev/null @@ -1,22 +0,0 @@ -part of 'package:flutter_app/router/provider/router.dart'; - -@TypedGoRoute( - path: NavigationPageRoute.path, -) -class NavigationPageRoute extends GoRouteData { - const NavigationPageRoute(); - - static const path = '/navigation'; - - @override - Widget build(BuildContext context, GoRouterState state) { - return ProviderScope( - overrides: [ - navigationNavigatorProvider.overrideWithValue( - const NavigationNavigatorImpl(), - ), - ], - child: const NavigationPage(), - ); - } -} From 5a00caacb51a670b572a88a9ddc1838ebc4aee8a Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 13:28:08 +0900 Subject: [PATCH 06/23] =?UTF-8?q?rename:=20navigation=E5=B1=A4=E3=81=8B?= =?UTF-8?q?=E3=82=89debug=E5=B1=A4=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ion_navigator.dart => debug_navigator.dart} | 4 ++-- packages/cores/navigation/lib/navigators.dart | 2 +- packages/cores/navigation/lib/providers.dart | 2 +- .../home/{navigation => debug}/navigator.dart | 2 +- .../lib/src/home/debug/provider.dart | 7 +++++++ .../home/{navigation => debug}/provider.g.dart | 18 ++++++++---------- .../lib/src/home/navigation/provider.dart | 7 ------- 7 files changed, 20 insertions(+), 22 deletions(-) rename apps/app/lib/router/navigator/{navigation_navigator.dart => debug_navigator.dart} (71%) rename packages/cores/navigation/lib/src/home/{navigation => debug}/navigator.dart (65%) create mode 100644 packages/cores/navigation/lib/src/home/debug/provider.dart rename packages/cores/navigation/lib/src/home/{navigation => debug}/provider.g.dart (56%) delete mode 100644 packages/cores/navigation/lib/src/home/navigation/provider.dart diff --git a/apps/app/lib/router/navigator/navigation_navigator.dart b/apps/app/lib/router/navigator/debug_navigator.dart similarity index 71% rename from apps/app/lib/router/navigator/navigation_navigator.dart rename to apps/app/lib/router/navigator/debug_navigator.dart index bf3babd9..9230035e 100644 --- a/apps/app/lib/router/navigator/navigation_navigator.dart +++ b/apps/app/lib/router/navigator/debug_navigator.dart @@ -2,8 +2,8 @@ import 'package:cores_navigation/navigators.dart'; import 'package:flutter/material.dart'; import 'package:flutter_app/router/provider/router.dart'; -final class NavigationNavigatorImpl implements NavigationNavigator { - const NavigationNavigatorImpl(); +final class DebugNavigatorImpl implements DebugNavigator { + const DebugNavigatorImpl(); @override void goNavigationPage(BuildContext context) { diff --git a/packages/cores/navigation/lib/navigators.dart b/packages/cores/navigation/lib/navigators.dart index c630aaf0..c4b53171 100644 --- a/packages/cores/navigation/lib/navigators.dart +++ b/packages/cores/navigation/lib/navigators.dart @@ -1,3 +1,3 @@ -export 'src/home/navigation//navigator.dart'; +export 'src/home/debug/navigator.dart'; export 'src/home/navigator.dart'; export 'src/setting/navigator.dart'; diff --git a/packages/cores/navigation/lib/providers.dart b/packages/cores/navigation/lib/providers.dart index f559e4b0..2266b576 100644 --- a/packages/cores/navigation/lib/providers.dart +++ b/packages/cores/navigation/lib/providers.dart @@ -1,3 +1,3 @@ -export 'src/home/navigation/provider.dart'; +export 'src/home/debug/provider.dart'; export 'src/home/provider.dart'; export 'src/setting/provider.dart'; diff --git a/packages/cores/navigation/lib/src/home/navigation/navigator.dart b/packages/cores/navigation/lib/src/home/debug/navigator.dart similarity index 65% rename from packages/cores/navigation/lib/src/home/navigation/navigator.dart rename to packages/cores/navigation/lib/src/home/debug/navigator.dart index 502d5d7f..92fd88fc 100644 --- a/packages/cores/navigation/lib/src/home/navigation/navigator.dart +++ b/packages/cores/navigation/lib/src/home/debug/navigator.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -abstract interface class NavigationNavigator { +abstract interface class DebugNavigator { void goNavigationPage(BuildContext context); } diff --git a/packages/cores/navigation/lib/src/home/debug/provider.dart b/packages/cores/navigation/lib/src/home/debug/provider.dart new file mode 100644 index 00000000..5381c13e --- /dev/null +++ b/packages/cores/navigation/lib/src/home/debug/provider.dart @@ -0,0 +1,7 @@ +import 'package:cores_navigation/src/home/debug/navigator.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +part 'provider.g.dart'; + +@riverpod +external DebugNavigator debugNavigator(DebugNavigatorRef ref); diff --git a/packages/cores/navigation/lib/src/home/navigation/provider.g.dart b/packages/cores/navigation/lib/src/home/debug/provider.g.dart similarity index 56% rename from packages/cores/navigation/lib/src/home/navigation/provider.g.dart rename to packages/cores/navigation/lib/src/home/debug/provider.g.dart index f106e6d7..851cc486 100644 --- a/packages/cores/navigation/lib/src/home/navigation/provider.g.dart +++ b/packages/cores/navigation/lib/src/home/debug/provider.g.dart @@ -6,25 +6,23 @@ part of 'provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$navigationNavigatorHash() => - r'fa87b8f037c618f9f3172755899b7e11a551f874'; +String _$debugNavigatorHash() => r'970277996b93ee7b66a378adab09bdea78427b0f'; -/// See also [navigationNavigator]. -@ProviderFor(navigationNavigator) -final navigationNavigatorProvider = - AutoDisposeProvider.internal( +/// See also [debugNavigator]. +@ProviderFor(debugNavigator) +final debugNavigatorProvider = AutoDisposeProvider.internal( (_) => throw UnsupportedError( - 'The provider "navigationNavigatorProvider" is expected to get overridden/scoped, ' + 'The provider "debugNavigatorProvider" is expected to get overridden/scoped, ' 'but was accessed without an override.', ), - name: r'navigationNavigatorProvider', + name: r'debugNavigatorProvider', debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') ? null - : _$navigationNavigatorHash, + : _$debugNavigatorHash, dependencies: null, allTransitiveDependencies: null, ); -typedef NavigationNavigatorRef = AutoDisposeProviderRef; +typedef DebugNavigatorRef = AutoDisposeProviderRef; // ignore_for_file: type=lint // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/packages/cores/navigation/lib/src/home/navigation/provider.dart b/packages/cores/navigation/lib/src/home/navigation/provider.dart deleted file mode 100644 index b01f58c8..00000000 --- a/packages/cores/navigation/lib/src/home/navigation/provider.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:cores_navigation/src/home/navigation/navigator.dart'; -import 'package:riverpod_annotation/riverpod_annotation.dart'; - -part 'provider.g.dart'; - -@riverpod -external NavigationNavigator navigationNavigator(NavigationNavigatorRef ref); From 9231ef4980452ae43ce859e5c2802cccf9ac65d9 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 13:38:37 +0900 Subject: [PATCH 07/23] =?UTF-8?q?feat:=20debug=5Froute=E3=81=ABNavigationP?= =?UTF-8?q?ageRoute=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/app/lib/router/provider/router.dart | 3 +- apps/app/lib/router/provider/router.g.dart | 49 +++++++++---------- .../routes/main/home/debug_page_route.dart | 18 ++++++- 3 files changed, 41 insertions(+), 29 deletions(-) diff --git a/apps/app/lib/router/provider/router.dart b/apps/app/lib/router/provider/router.dart index 79d4941c..d782d879 100644 --- a/apps/app/lib/router/provider/router.dart +++ b/apps/app/lib/router/provider/router.dart @@ -8,8 +8,8 @@ import 'package:features_webview/webview.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_app/main_page.dart'; +import 'package:flutter_app/router/navigator/debug_navigator.dart'; import 'package:flutter_app/router/navigator/home_navigator.dart'; -import 'package:flutter_app/router/navigator/navigation_navigator.dart'; import 'package:flutter_app/router/navigator/setting_navigator.dart'; import 'package:flutter_app/ui/home_page.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -22,7 +22,6 @@ part 'package:flutter_app/router/routes/main/home/web_page_route.dart'; part 'package:flutter_app/router/routes/main/main_page_shell_route.dart'; part 'package:flutter_app/router/routes/main/setting/setting_shell_branch.dart'; part 'package:flutter_app/router/routes/maintenance_page_route.dart'; -part 'package:flutter_app/router/routes/navigation_page_route.dart'; part 'router.g.dart'; final _rootNavigatorKey = GlobalKey(debugLabel: 'root'); diff --git a/apps/app/lib/router/provider/router.g.dart b/apps/app/lib/router/provider/router.g.dart index f48a9ea8..ad016b03 100644 --- a/apps/app/lib/router/provider/router.g.dart +++ b/apps/app/lib/router/provider/router.g.dart @@ -11,7 +11,6 @@ part of 'router.dart'; List get $appRoutes => [ $mainPageShellRoute, $maintenancePageRoute, - $navigationPageRoute, ]; RouteBase get $mainPageShellRoute => StatefulShellRouteData.$route( @@ -29,8 +28,13 @@ RouteBase get $mainPageShellRoute => StatefulShellRouteData.$route( ), GoRouteData.$route( path: 'debug', - parentNavigatorKey: DebugPageRoute.$parentNavigatorKey, factory: $DebugPageRouteExtension._fromState, + routes: [ + GoRouteData.$route( + path: 'navigation', + factory: $NavigationPageRouteExtension._fromState, + ), + ], ), GoRouteData.$route( path: 'web', @@ -122,6 +126,24 @@ extension $DebugPageRouteExtension on DebugPageRoute { void replace(BuildContext context) => context.replace(location); } +extension $NavigationPageRouteExtension on NavigationPageRoute { + static NavigationPageRoute _fromState(GoRouterState state) => + const NavigationPageRoute(); + + String get location => GoRouteData.$location( + '/debug/navigation', + ); + + void go(BuildContext context) => context.go(location); + + Future push(BuildContext context) => context.push(location); + + void pushReplacement(BuildContext context) => + context.pushReplacement(location); + + void replace(BuildContext context) => context.replace(location); +} + extension $WebPageRouteExtension on WebPageRoute { static WebPageRoute _fromState(GoRouterState state) => const WebPageRoute(); @@ -198,29 +220,6 @@ extension $MaintenancePageRouteExtension on MaintenancePageRoute { void replace(BuildContext context) => context.replace(location); } -RouteBase get $navigationPageRoute => GoRouteData.$route( - path: '/navigation', - factory: $NavigationPageRouteExtension._fromState, - ); - -extension $NavigationPageRouteExtension on NavigationPageRoute { - static NavigationPageRoute _fromState(GoRouterState state) => - const NavigationPageRoute(); - - String get location => GoRouteData.$location( - '/navigation', - ); - - void go(BuildContext context) => context.go(location); - - Future push(BuildContext context) => context.push(location); - - void pushReplacement(BuildContext context) => - context.pushReplacement(location); - - void replace(BuildContext context) => context.replace(location); -} - // ************************************************************************** // RiverpodGenerator // ************************************************************************** diff --git a/apps/app/lib/router/routes/main/home/debug_page_route.dart b/apps/app/lib/router/routes/main/home/debug_page_route.dart index 57fa43f7..a1c2d8fa 100644 --- a/apps/app/lib/router/routes/main/home/debug_page_route.dart +++ b/apps/app/lib/router/routes/main/home/debug_page_route.dart @@ -5,10 +5,24 @@ class DebugPageRoute extends GoRouteData { static const path = 'debug'; - static final $parentNavigatorKey = _rootNavigatorKey; + @override + Widget build(BuildContext context, GoRouterState state) { + return ProviderScope( + overrides: [ + debugNavigatorProvider.overrideWithValue(const DebugNavigatorImpl()), + ], + child: const DebugPage(), + ); + } +} + +class NavigationPageRoute extends GoRouteData { + const NavigationPageRoute(); + + static const path = 'navigation'; @override Widget build(BuildContext context, GoRouterState state) { - return const DebugPage(); + return const NavigationPage(); } } From 4c35cb19128cf237c4bed64b3eaa543e3a527a98 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 13:39:53 +0900 Subject: [PATCH 08/23] =?UTF-8?q?feat:NavigationPage=E3=81=B8=E3=83=AB?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=82=92DebugPage=E3=81=AE=E4=B8=8B=E3=81=AE?= =?UTF-8?q?=E9=9A=8E=E5=B1=A4=E3=81=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/app/lib/router/routes/main/home/home_shell_branch.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/app/lib/router/routes/main/home/home_shell_branch.dart b/apps/app/lib/router/routes/main/home/home_shell_branch.dart index 9bcd8d63..5eb533f9 100644 --- a/apps/app/lib/router/routes/main/home/home_shell_branch.dart +++ b/apps/app/lib/router/routes/main/home/home_shell_branch.dart @@ -10,6 +10,11 @@ const homeShellBranch = TypedStatefulShellBranch( ), TypedGoRoute( path: DebugPageRoute.path, + routes: [ + TypedGoRoute( + path: NavigationPageRoute.path, + ), + ], ), TypedGoRoute( path: WebPageRoute.path, From 5185d9ac3d9b62db00f19d22aa4199eb1ad4d37a Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 13:40:17 +0900 Subject: [PATCH 09/23] =?UTF-8?q?fix:=E7=94=BB=E9=9D=A2=E9=81=B7=E7=A7=BB?= =?UTF-8?q?=E3=81=AB=E4=BD=BF=E3=81=86provider=E3=81=AE=E5=AE=9A=E7=BE=A9?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/features/debug_mode/lib/src/ui/debug_page.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/features/debug_mode/lib/src/ui/debug_page.dart b/packages/features/debug_mode/lib/src/ui/debug_page.dart index b71a016e..c4e72077 100644 --- a/packages/features/debug_mode/lib/src/ui/debug_page.dart +++ b/packages/features/debug_mode/lib/src/ui/debug_page.dart @@ -11,7 +11,7 @@ class DebugPage extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final navigator = ref.watch(navigationNavigatorProvider); + final navigator = ref.watch(debugNavigatorProvider); return Scaffold( appBar: AppBar( title: const Text('Debug Mode'), @@ -44,7 +44,7 @@ class DebugPage extends ConsumerWidget { ); }, ), - _FixSizedElevatedButton( + _FixSizedElevatedButton( title: '画面遷移', onPressed: () async { navigator.goNavigationPage(context); From 9548b7d33da0c5312cb57315a0037cc2e54efcf4 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 13:51:15 +0900 Subject: [PATCH 10/23] =?UTF-8?q?fix:=E7=94=BB=E9=9D=A2=E9=81=B7=E7=A7=BB?= =?UTF-8?q?=E3=81=AE=E9=96=A2=E6=95=B0=E3=81=AE=E6=9B=B8=E3=81=8D=E6=96=B9?= =?UTF-8?q?=E7=B0=A1=E6=BD=94=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/features/debug_mode/lib/src/ui/debug_page.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/features/debug_mode/lib/src/ui/debug_page.dart b/packages/features/debug_mode/lib/src/ui/debug_page.dart index c4e72077..f823847b 100644 --- a/packages/features/debug_mode/lib/src/ui/debug_page.dart +++ b/packages/features/debug_mode/lib/src/ui/debug_page.dart @@ -46,9 +46,7 @@ class DebugPage extends ConsumerWidget { ), _FixSizedElevatedButton( title: '画面遷移', - onPressed: () async { - navigator.goNavigationPage(context); - }, + onPressed: () => navigator.goNavigationPage(context), ), ], ), From cd110c3075c649fd95fceee1504b175b2184ba3a Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 13:56:36 +0900 Subject: [PATCH 11/23] =?UTF-8?q?add:=20page=5Fa,page=5Fb.dart=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/debug_mode/lib/src/ui/page_a.dart | 14 ++++++++++++++ .../features/debug_mode/lib/src/ui/page_b.dart | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 packages/features/debug_mode/lib/src/ui/page_a.dart create mode 100644 packages/features/debug_mode/lib/src/ui/page_b.dart diff --git a/packages/features/debug_mode/lib/src/ui/page_a.dart b/packages/features/debug_mode/lib/src/ui/page_a.dart new file mode 100644 index 00000000..34733184 --- /dev/null +++ b/packages/features/debug_mode/lib/src/ui/page_a.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; + +class PageA extends StatelessWidget { + const PageA({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('画面A'), + ), + ); + } +} diff --git a/packages/features/debug_mode/lib/src/ui/page_b.dart b/packages/features/debug_mode/lib/src/ui/page_b.dart new file mode 100644 index 00000000..9c0e02c8 --- /dev/null +++ b/packages/features/debug_mode/lib/src/ui/page_b.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; + +class PageB extends StatelessWidget { + const PageB({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('画面B'), + ), + ); + } +} From 17ff4c1e4219abfd98d521b5400ec6b01c97708f Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 14:14:31 +0900 Subject: [PATCH 12/23] =?UTF-8?q?add:debug=5Fpage=5Froute=E3=81=ABPageARou?= =?UTF-8?q?te,PageBRoute=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routes/main/home/debug_page_route.dart | 22 +++++++++++++++++++ .../features/debug_mode/lib/src/ui/index.dart | 2 ++ 2 files changed, 24 insertions(+) diff --git a/apps/app/lib/router/routes/main/home/debug_page_route.dart b/apps/app/lib/router/routes/main/home/debug_page_route.dart index a1c2d8fa..e9485ce6 100644 --- a/apps/app/lib/router/routes/main/home/debug_page_route.dart +++ b/apps/app/lib/router/routes/main/home/debug_page_route.dart @@ -26,3 +26,25 @@ class NavigationPageRoute extends GoRouteData { return const NavigationPage(); } } + +class PageARoute extends GoRouteData { + const PageARoute(); + + static const path = 'page_a'; + + @override + Widget build(BuildContext context, GoRouterState state) { + return const PageA(); + } +} + +class PageBRoute extends GoRouteData { + const PageBRoute(); + + static const path = 'page_b'; + + @override + Widget build(BuildContext context, GoRouterState state) { + return const PageB(); + } +} diff --git a/packages/features/debug_mode/lib/src/ui/index.dart b/packages/features/debug_mode/lib/src/ui/index.dart index c2546a40..dca236e8 100644 --- a/packages/features/debug_mode/lib/src/ui/index.dart +++ b/packages/features/debug_mode/lib/src/ui/index.dart @@ -1,3 +1,5 @@ export 'debug_page.dart'; export 'maintenance_page.dart'; export 'navigation_page.dart'; +export 'page_a.dart'; +export 'page_b.dart'; From 58354f987b73ae51049b723728bbd730db79dfe4 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 14:19:51 +0900 Subject: [PATCH 13/23] =?UTF-8?q?feat:=20=E7=94=BB=E9=9D=A2=E9=81=B7?= =?UTF-8?q?=E7=A7=BB=E3=81=AE=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/router/navigator/debug_navigator.dart | 9 ++++ apps/app/lib/router/provider/router.g.dart | 42 +++++++++++++++++++ .../routes/main/home/home_shell_branch.dart | 6 +++ .../lib/src/home/debug/navigator.dart | 2 + 4 files changed, 59 insertions(+) diff --git a/apps/app/lib/router/navigator/debug_navigator.dart b/apps/app/lib/router/navigator/debug_navigator.dart index 9230035e..938d47ec 100644 --- a/apps/app/lib/router/navigator/debug_navigator.dart +++ b/apps/app/lib/router/navigator/debug_navigator.dart @@ -9,4 +9,13 @@ final class DebugNavigatorImpl implements DebugNavigator { void goNavigationPage(BuildContext context) { const NavigationPageRoute().go(context); } + @override + void goPageA(BuildContext context) { + const PageARoute().go(context); + } + + @override + void goPageB(BuildContext context) { + const PageBRoute().go(context); + } } diff --git a/apps/app/lib/router/provider/router.g.dart b/apps/app/lib/router/provider/router.g.dart index ad016b03..076dd305 100644 --- a/apps/app/lib/router/provider/router.g.dart +++ b/apps/app/lib/router/provider/router.g.dart @@ -34,6 +34,14 @@ RouteBase get $mainPageShellRoute => StatefulShellRouteData.$route( path: 'navigation', factory: $NavigationPageRouteExtension._fromState, ), + GoRouteData.$route( + path: 'page_a', + factory: $PageARouteExtension._fromState, + ), + GoRouteData.$route( + path: 'page_b', + factory: $PageBRouteExtension._fromState, + ), ], ), GoRouteData.$route( @@ -144,6 +152,40 @@ extension $NavigationPageRouteExtension on NavigationPageRoute { void replace(BuildContext context) => context.replace(location); } +extension $PageARouteExtension on PageARoute { + static PageARoute _fromState(GoRouterState state) => const PageARoute(); + + String get location => GoRouteData.$location( + '/debug/page_a', + ); + + void go(BuildContext context) => context.go(location); + + Future push(BuildContext context) => context.push(location); + + void pushReplacement(BuildContext context) => + context.pushReplacement(location); + + void replace(BuildContext context) => context.replace(location); +} + +extension $PageBRouteExtension on PageBRoute { + static PageBRoute _fromState(GoRouterState state) => const PageBRoute(); + + String get location => GoRouteData.$location( + '/debug/page_b', + ); + + void go(BuildContext context) => context.go(location); + + Future push(BuildContext context) => context.push(location); + + void pushReplacement(BuildContext context) => + context.pushReplacement(location); + + void replace(BuildContext context) => context.replace(location); +} + extension $WebPageRouteExtension on WebPageRoute { static WebPageRoute _fromState(GoRouterState state) => const WebPageRoute(); diff --git a/apps/app/lib/router/routes/main/home/home_shell_branch.dart b/apps/app/lib/router/routes/main/home/home_shell_branch.dart index 5eb533f9..12cfb8d3 100644 --- a/apps/app/lib/router/routes/main/home/home_shell_branch.dart +++ b/apps/app/lib/router/routes/main/home/home_shell_branch.dart @@ -14,6 +14,12 @@ const homeShellBranch = TypedStatefulShellBranch( TypedGoRoute( path: NavigationPageRoute.path, ), + TypedGoRoute( + path: PageARoute.path, + ), + TypedGoRoute( + path: PageBRoute.path, + ), ], ), TypedGoRoute( diff --git a/packages/cores/navigation/lib/src/home/debug/navigator.dart b/packages/cores/navigation/lib/src/home/debug/navigator.dart index 92fd88fc..a5542954 100644 --- a/packages/cores/navigation/lib/src/home/debug/navigator.dart +++ b/packages/cores/navigation/lib/src/home/debug/navigator.dart @@ -2,4 +2,6 @@ import 'package:flutter/material.dart'; abstract interface class DebugNavigator { void goNavigationPage(BuildContext context); + void goPageA(BuildContext context); + void goPageB(BuildContext context); } From b8fad7c8aea87c8b35056ecf742fbb688214c70e Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 14:27:39 +0900 Subject: [PATCH 14/23] =?UTF-8?q?feat:view=E3=83=9A=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=8B=E3=82=89=E3=81=AE=E7=94=BB=E9=9D=A2=E9=81=B7=E7=A7=BB?= =?UTF-8?q?=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/debug_mode/lib/src/ui/navigation_page.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/features/debug_mode/lib/src/ui/navigation_page.dart b/packages/features/debug_mode/lib/src/ui/navigation_page.dart index 9861947c..b2612059 100644 --- a/packages/features/debug_mode/lib/src/ui/navigation_page.dart +++ b/packages/features/debug_mode/lib/src/ui/navigation_page.dart @@ -1,3 +1,4 @@ +import 'package:cores_navigation/providers.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -6,6 +7,7 @@ class NavigationPage extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + final navigator = ref.watch(debugNavigatorProvider); return Scaffold( appBar: AppBar( title: const Text('画面遷移ページ'), @@ -15,11 +17,11 @@ class NavigationPage extends ConsumerWidget { children: [ _FixSizedElevatedButton( title: '画面A', - onPressed: () async {}, + onPressed: () => navigator.goPageA(context), ), _FixSizedElevatedButton( title: '画面B', - onPressed: () async {}, + onPressed: () => navigator.goPageB(context), ), ], ), From b65b8147776bf31213944c7efac96eaff03b81e7 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 14:28:07 +0900 Subject: [PATCH 15/23] =?UTF-8?q?fix:override=E3=81=8C=E6=8A=9C=E3=81=91?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/app/lib/router/routes/main/home/debug_page_route.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/app/lib/router/routes/main/home/debug_page_route.dart b/apps/app/lib/router/routes/main/home/debug_page_route.dart index e9485ce6..eb30740a 100644 --- a/apps/app/lib/router/routes/main/home/debug_page_route.dart +++ b/apps/app/lib/router/routes/main/home/debug_page_route.dart @@ -23,7 +23,12 @@ class NavigationPageRoute extends GoRouteData { @override Widget build(BuildContext context, GoRouterState state) { - return const NavigationPage(); + return ProviderScope( + overrides: [ + debugNavigatorProvider.overrideWithValue(const DebugNavigatorImpl()), + ], + child: NavigationPage(), + ); } } From 1f02c3fcbfcf0e140a12b94e0f78bd7ba189229b Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 14:28:44 +0900 Subject: [PATCH 16/23] =?UTF-8?q?fix:=20NavigationPage=E3=81=A8=E3=81=AE?= =?UTF-8?q?=E3=83=AB=E3=83=BC=E3=83=88=E3=81=AE=E9=9A=8E=E5=B1=A4=E3=81=8C?= =?UTF-8?q?=E9=96=93=E9=81=95=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/app/lib/router/provider/router.g.dart | 22 ++++++++++--------- .../routes/main/home/home_shell_branch.dart | 14 +++++++----- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/apps/app/lib/router/provider/router.g.dart b/apps/app/lib/router/provider/router.g.dart index 076dd305..46d5e905 100644 --- a/apps/app/lib/router/provider/router.g.dart +++ b/apps/app/lib/router/provider/router.g.dart @@ -33,14 +33,16 @@ RouteBase get $mainPageShellRoute => StatefulShellRouteData.$route( GoRouteData.$route( path: 'navigation', factory: $NavigationPageRouteExtension._fromState, - ), - GoRouteData.$route( - path: 'page_a', - factory: $PageARouteExtension._fromState, - ), - GoRouteData.$route( - path: 'page_b', - factory: $PageBRouteExtension._fromState, + routes: [ + GoRouteData.$route( + path: 'page_a', + factory: $PageARouteExtension._fromState, + ), + GoRouteData.$route( + path: 'page_b', + factory: $PageBRouteExtension._fromState, + ), + ], ), ], ), @@ -156,7 +158,7 @@ extension $PageARouteExtension on PageARoute { static PageARoute _fromState(GoRouterState state) => const PageARoute(); String get location => GoRouteData.$location( - '/debug/page_a', + '/debug/navigation/page_a', ); void go(BuildContext context) => context.go(location); @@ -173,7 +175,7 @@ extension $PageBRouteExtension on PageBRoute { static PageBRoute _fromState(GoRouterState state) => const PageBRoute(); String get location => GoRouteData.$location( - '/debug/page_b', + '/debug/navigation/page_b', ); void go(BuildContext context) => context.go(location); diff --git a/apps/app/lib/router/routes/main/home/home_shell_branch.dart b/apps/app/lib/router/routes/main/home/home_shell_branch.dart index 12cfb8d3..80933f98 100644 --- a/apps/app/lib/router/routes/main/home/home_shell_branch.dart +++ b/apps/app/lib/router/routes/main/home/home_shell_branch.dart @@ -13,12 +13,14 @@ const homeShellBranch = TypedStatefulShellBranch( routes: [ TypedGoRoute( path: NavigationPageRoute.path, - ), - TypedGoRoute( - path: PageARoute.path, - ), - TypedGoRoute( - path: PageBRoute.path, + routes: [ + TypedGoRoute( + path: PageARoute.path, + ), + TypedGoRoute( + path: PageBRoute.path, + ), + ], ), ], ), From 76fbf9ca0c6c898d33c3ce9d4ce6270428b7e2ed Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 14:29:31 +0900 Subject: [PATCH 17/23] fix: add const --- apps/app/lib/router/routes/main/home/debug_page_route.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/app/lib/router/routes/main/home/debug_page_route.dart b/apps/app/lib/router/routes/main/home/debug_page_route.dart index eb30740a..2bdc4bac 100644 --- a/apps/app/lib/router/routes/main/home/debug_page_route.dart +++ b/apps/app/lib/router/routes/main/home/debug_page_route.dart @@ -27,7 +27,7 @@ class NavigationPageRoute extends GoRouteData { overrides: [ debugNavigatorProvider.overrideWithValue(const DebugNavigatorImpl()), ], - child: NavigationPage(), + child: const NavigationPage(), ); } } From 174d98ef1dba83dfd2dda4172efd1d5a2381f042 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 18:36:48 +0900 Subject: [PATCH 18/23] =?UTF-8?q?feat:debug=E3=83=9A=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=AE=E5=A4=9A=E8=A8=80=E8=AA=9E=E5=AF=BE=E5=BF=9C=E6=BA=96?= =?UTF-8?q?=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../debug_mode/assets/l10n/app_en.arb | 11 ++ .../debug_mode/assets/l10n/app_ja.arb | 10 + packages/features/debug_mode/l10n.yaml | 12 ++ packages/features/debug_mode/lib/l10n.dart | 1 + .../debug_mode/lib/src/gen/l10n/l10n.dart | 178 ++++++++++++++++++ .../debug_mode/lib/src/gen/l10n/l10n_en.dart | 32 ++++ .../debug_mode/lib/src/gen/l10n/l10n_ja.dart | 32 ++++ packages/features/debug_mode/pubspec.lock | 21 +++ packages/features/debug_mode/pubspec.yaml | 2 + 9 files changed, 299 insertions(+) create mode 100644 packages/features/debug_mode/assets/l10n/app_en.arb create mode 100644 packages/features/debug_mode/assets/l10n/app_ja.arb create mode 100644 packages/features/debug_mode/l10n.yaml create mode 100644 packages/features/debug_mode/lib/l10n.dart create mode 100644 packages/features/debug_mode/lib/src/gen/l10n/l10n.dart create mode 100644 packages/features/debug_mode/lib/src/gen/l10n/l10n_en.dart create mode 100644 packages/features/debug_mode/lib/src/gen/l10n/l10n_ja.dart diff --git a/packages/features/debug_mode/assets/l10n/app_en.arb b/packages/features/debug_mode/assets/l10n/app_en.arb new file mode 100644 index 00000000..76be1e59 --- /dev/null +++ b/packages/features/debug_mode/assets/l10n/app_en.arb @@ -0,0 +1,11 @@ +{ + "debugAppBar": "Debug Mode", + "showErrorSnackBar": "Show error SnackBar", + "enableMaintenanceMode": "Enable maintenance mode", + "enableForceUpdate": "Enable force update", + "navigation": "Go to NavigationPage", + "settingVersion": "Version", + "navigationPageAppBar": "Navigation Page", + "pageA": "Page A", + "pageB": "Page B" +} diff --git a/packages/features/debug_mode/assets/l10n/app_ja.arb b/packages/features/debug_mode/assets/l10n/app_ja.arb new file mode 100644 index 00000000..3e6f0869 --- /dev/null +++ b/packages/features/debug_mode/assets/l10n/app_ja.arb @@ -0,0 +1,10 @@ +{ + "debugAppBar": "デバッグモード", + "showErrorSnackBar": "エラーSnackBarを表示", + "enableMaintenanceMode": "メンテナンスモードを有効化", + "enableForceUpdate": "強制アップデートを有効化", + "navigation": "NavigationPageへ遷移", + "navigationPageAppBar": "画面遷移画面", + "pageA": "Page A", + "pageB": "Page B" +} diff --git a/packages/features/debug_mode/l10n.yaml b/packages/features/debug_mode/l10n.yaml new file mode 100644 index 00000000..22850b87 --- /dev/null +++ b/packages/features/debug_mode/l10n.yaml @@ -0,0 +1,12 @@ +arb-dir: assets/l10n +output-dir: lib/src/gen/l10n +template-arb-file: app_ja.arb +output-localization-file: l10n.dart +output-class: L10nDebug +synthetic-package: false +preferred-supported-locales: + - ja + - en +header: '// ignore_for_file: type=lint' +nullable-getter: false +format: true diff --git a/packages/features/debug_mode/lib/l10n.dart b/packages/features/debug_mode/lib/l10n.dart new file mode 100644 index 00000000..892633ee --- /dev/null +++ b/packages/features/debug_mode/lib/l10n.dart @@ -0,0 +1 @@ +export 'src/gen/l10n/l10n.dart' show L10nDebug; diff --git a/packages/features/debug_mode/lib/src/gen/l10n/l10n.dart b/packages/features/debug_mode/lib/src/gen/l10n/l10n.dart new file mode 100644 index 00000000..9c7ba112 --- /dev/null +++ b/packages/features/debug_mode/lib/src/gen/l10n/l10n.dart @@ -0,0 +1,178 @@ +// ignore_for_file: type=lint +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:intl/intl.dart' as intl; + +import 'l10n_en.dart'; +import 'l10n_ja.dart'; + +/// Callers can lookup localized strings with an instance of L10nDebug +/// returned by `L10nDebug.of(context)`. +/// +/// Applications need to include `L10nDebug.delegate()` in their app's +/// `localizationDelegates` list, and the locales they support in the app's +/// `supportedLocales` list. For example: +/// +/// ```dart +/// import 'l10n/l10n.dart'; +/// +/// return MaterialApp( +/// localizationsDelegates: L10nDebug.localizationsDelegates, +/// supportedLocales: L10nDebug.supportedLocales, +/// home: MyApplicationHome(), +/// ); +/// ``` +/// +/// ## Update pubspec.yaml +// /// +// /// Please make sure to update your pubspec.yaml to include the following +/// packages: +/// +/// ```yaml +/// dependencies: +/// # Internationalization support. +/// flutter_localizations: +/// sdk: flutter +/// intl: any # Use the pinned version from flutter_localizations +/// +/// # Rest of dependencies +/// ``` +/// +/// ## iOS Applications +/// +/// iOS applications define key application metadata, including supported +/// locales, in an Info.plist file that is built into the application bundle. +/// To configure the locales supported by your app, you’ll need to edit this +/// file. +/// +/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file. +/// Then, in the Project Navigator, open the Info.plist file under the Runner +/// project’s Runner folder. +/// +/// Next, select the Information Property List item, select Add Item from the +/// Editor menu, then select Localizations from the pop-up menu. +/// +/// Select and expand the newly-created Localizations item then, for each +/// locale your application supports, add a new item and select the locale +/// you wish to add from the pop-up menu in the Value field. This list should +/// be consistent with the languages listed in the L10nDebug.supportedLocales +/// property. +abstract class L10nDebug { + L10nDebug(String locale) + : localeName = intl.Intl.canonicalizedLocale(locale.toString()); + + final String localeName; + + static L10nDebug of(BuildContext context) { + return Localizations.of(context, L10nDebug)!; + } + + static const LocalizationsDelegate delegate = _L10nDebugDelegate(); + + /// A list of this localizations delegate along with the default localizations + /// delegates. + /// + /// Returns a list of localizations delegates containing this delegate along with + /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, + /// and GlobalWidgetsLocalizations.delegate. + /// + /// Additional delegates can be added by appending to this list in + /// MaterialApp. This list does not have to be used at all if a custom list + /// of delegates is preferred or required. + static const List> localizationsDelegates = + >[ + delegate, + GlobalMaterialLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ]; + + /// A list of this localizations delegate's supported locales. + static const List supportedLocales = [ + Locale('ja'), + Locale('en') + ]; + + /// No description provided for @debugAppBar. + /// + /// In ja, this message translates to: + /// **'デバッグモード'** + String get debugAppBar; + + /// No description provided for @showErrorSnackBar. + /// + /// In ja, this message translates to: + /// **'エラーSnackBarを表示'** + String get showErrorSnackBar; + + /// No description provided for @enableMaintenanceMode. + /// + /// In ja, this message translates to: + /// **'メンテナンスモードを有効化'** + String get enableMaintenanceMode; + + /// No description provided for @enableForceUpdate. + /// + /// In ja, this message translates to: + /// **'強制アップデートを有効化'** + String get enableForceUpdate; + + /// No description provided for @navigation. + /// + /// In ja, this message translates to: + /// **'NavigationPageへ遷移'** + String get navigation; + + /// No description provided for @navigationPageAppBar. + /// + /// In ja, this message translates to: + /// **'画面遷移画面'** + String get navigationPageAppBar; + + /// No description provided for @pageA. + /// + /// In ja, this message translates to: + /// **'Page A'** + String get pageA; + + /// No description provided for @pageB. + /// + /// In ja, this message translates to: + /// **'Page B'** + String get pageB; +} + +class _L10nDebugDelegate extends LocalizationsDelegate { + const _L10nDebugDelegate(); + + @override + Future load(Locale locale) { + return SynchronousFuture(lookupL10nDebug(locale)); + } + + @override + bool isSupported(Locale locale) => + ['en', 'ja'].contains(locale.languageCode); + + @override + bool shouldReload(_L10nDebugDelegate old) => false; +} + +L10nDebug lookupL10nDebug(Locale locale) { + // Lookup logic when only language code is specified. + switch (locale.languageCode) { + case 'en': + return L10nDebugEn(); + case 'ja': + return L10nDebugJa(); + } + + throw FlutterError( + 'L10nDebug.delegate failed to load unsupported locale "$locale". This is likely ' + 'an issue with the localizations generation tool. Please file an issue ' + 'on GitHub with a reproducible sample app and the gen-l10n configuration ' + 'that was used.'); +} diff --git a/packages/features/debug_mode/lib/src/gen/l10n/l10n_en.dart b/packages/features/debug_mode/lib/src/gen/l10n/l10n_en.dart new file mode 100644 index 00000000..29e7b602 --- /dev/null +++ b/packages/features/debug_mode/lib/src/gen/l10n/l10n_en.dart @@ -0,0 +1,32 @@ +// ignore_for_file: type=lint + +import 'l10n.dart'; + +/// The translations for English (`en`). +class L10nDebugEn extends L10nDebug { + L10nDebugEn([String locale = 'en']) : super(locale); + + @override + String get debugAppBar => 'Debug Mode'; + + @override + String get showErrorSnackBar => 'Show error SnackBar'; + + @override + String get enableMaintenanceMode => 'Enable maintenance mode'; + + @override + String get enableForceUpdate => 'Enable force update'; + + @override + String get navigation => 'Go to NavigationPage'; + + @override + String get navigationPageAppBar => 'Navigation Page'; + + @override + String get pageA => 'Page A'; + + @override + String get pageB => 'Page B'; +} diff --git a/packages/features/debug_mode/lib/src/gen/l10n/l10n_ja.dart b/packages/features/debug_mode/lib/src/gen/l10n/l10n_ja.dart new file mode 100644 index 00000000..705d6ac0 --- /dev/null +++ b/packages/features/debug_mode/lib/src/gen/l10n/l10n_ja.dart @@ -0,0 +1,32 @@ +// ignore_for_file: type=lint + +import 'l10n.dart'; + +/// The translations for Japanese (`ja`). +class L10nDebugJa extends L10nDebug { + L10nDebugJa([String locale = 'ja']) : super(locale); + + @override + String get debugAppBar => 'デバッグモード'; + + @override + String get showErrorSnackBar => 'エラーSnackBarを表示'; + + @override + String get enableMaintenanceMode => 'メンテナンスモードを有効化'; + + @override + String get enableForceUpdate => '強制アップデートを有効化'; + + @override + String get navigation => 'NavigationPageへ遷移'; + + @override + String get navigationPageAppBar => '画面遷移画面'; + + @override + String get pageA => 'Page A'; + + @override + String get pageB => 'Page B'; +} diff --git a/packages/features/debug_mode/pubspec.lock b/packages/features/debug_mode/pubspec.lock index bb2d095f..2773d5b9 100644 --- a/packages/features/debug_mode/pubspec.lock +++ b/packages/features/debug_mode/pubspec.lock @@ -145,6 +145,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.1" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" code_builder: dependency: transitive description: @@ -274,6 +282,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_riverpod: dependency: "direct main" description: @@ -343,6 +356,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + intl: + dependency: transitive + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" io: dependency: transitive description: diff --git a/packages/features/debug_mode/pubspec.yaml b/packages/features/debug_mode/pubspec.yaml index c5a1f82f..584ae817 100644 --- a/packages/features/debug_mode/pubspec.yaml +++ b/packages/features/debug_mode/pubspec.yaml @@ -19,6 +19,8 @@ dependencies: dio: ^5.4.0 flutter: sdk: flutter + flutter_localizations: + sdk: flutter flutter_riverpod: ^2.5.1 riverpod_annotation: ^2.3.5 From 5d5b1653776f90e7ec2bb50f263716afa7567c75 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 18:37:31 +0900 Subject: [PATCH 19/23] =?UTF-8?q?feat:=20debug=E3=83=9A=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=AB=E5=A4=9A=E8=A8=80=E8=AA=9E=E5=AF=BE=E5=BF=9C=E3=82=92?= =?UTF-8?q?=E3=82=B5=E3=83=9D=E3=83=BC=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/app/lib/main.dart | 3 +++ .../features/debug_mode/lib/src/ui/debug_page.dart | 12 +++++++----- .../debug_mode/lib/src/ui/navigation_page.dart | 8 +++++--- packages/features/debug_mode/lib/src/ui/page_a.dart | 4 +++- packages/features/debug_mode/lib/src/ui/page_b.dart | 4 +++- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/apps/app/lib/main.dart b/apps/app/lib/main.dart index caf6f1ed..647fde3a 100644 --- a/apps/app/lib/main.dart +++ b/apps/app/lib/main.dart @@ -5,6 +5,7 @@ import 'package:cores_core/ui.dart'; import 'package:cores_data/theme_mode.dart'; import 'package:cores_designsystem/themes.dart'; import 'package:cores_init/provider.dart'; +import 'package:features_debug_mode/l10n.dart'; import 'package:features_setting/l10n.dart'; import 'package:flutter/material.dart'; import 'package:flutter_app/app_initializer.dart'; @@ -61,10 +62,12 @@ class MainApp extends ConsumerWidget { localizationsDelegates: const [ ...L10n.localizationsDelegates, ...L10nSetting.localizationsDelegates, + ...L10nDebug.localizationsDelegates ], supportedLocales: const [ ...L10n.supportedLocales, ...L10nSetting.supportedLocales, + ...L10nDebug.supportedLocales ], scaffoldMessengerKey: SnackBarManager.rootScaffoldMessengerKey, routerConfig: ref.watch(routerProvider), diff --git a/packages/features/debug_mode/lib/src/ui/debug_page.dart b/packages/features/debug_mode/lib/src/ui/debug_page.dart index f823847b..cdb3072a 100644 --- a/packages/features/debug_mode/lib/src/ui/debug_page.dart +++ b/packages/features/debug_mode/lib/src/ui/debug_page.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:cores_core/app_status.dart'; import 'package:cores_navigation/providers.dart'; import 'package:features_debug_mode/src/data/api/provider/exception_generator_api.dart'; +import 'package:features_debug_mode/src/gen/l10n/l10n.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -12,15 +13,16 @@ class DebugPage extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final navigator = ref.watch(debugNavigatorProvider); + final l10n = L10nDebug.of(context); return Scaffold( appBar: AppBar( - title: const Text('Debug Mode'), + title: Text(l10n.debugAppBar), ), body: Center( child: Column( children: [ _FixSizedElevatedButton( - title: 'Show error SnackBar', + title: l10n.showErrorSnackBar, onPressed: () async { unawaited( ref.read(exceptionGeneratorApiProvider.notifier).request(), @@ -28,7 +30,7 @@ class DebugPage extends ConsumerWidget { }, ), _FixSizedElevatedButton( - title: 'Enable maintenance mode', + title: l10n.enableMaintenanceMode, onPressed: () async { ref .read(maintenanceModeProvider.notifier) @@ -36,7 +38,7 @@ class DebugPage extends ConsumerWidget { }, ), _FixSizedElevatedButton( - title: 'Enable force update', + title: l10n.enableForceUpdate, onPressed: () async { ref.read(forceUpdateVersionProvider.notifier).update( iosTargetVersion: '9.9.9', @@ -45,7 +47,7 @@ class DebugPage extends ConsumerWidget { }, ), _FixSizedElevatedButton( - title: '画面遷移', + title: l10n.navigation, onPressed: () => navigator.goNavigationPage(context), ), ], diff --git a/packages/features/debug_mode/lib/src/ui/navigation_page.dart b/packages/features/debug_mode/lib/src/ui/navigation_page.dart index b2612059..f39e088d 100644 --- a/packages/features/debug_mode/lib/src/ui/navigation_page.dart +++ b/packages/features/debug_mode/lib/src/ui/navigation_page.dart @@ -1,4 +1,5 @@ import 'package:cores_navigation/providers.dart'; +import 'package:features_debug_mode/l10n.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -8,19 +9,20 @@ class NavigationPage extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final navigator = ref.watch(debugNavigatorProvider); + final l10n = L10nDebug.of(context); return Scaffold( appBar: AppBar( - title: const Text('画面遷移ページ'), + title: Text(l10n.navigationPageAppBar), ), body: Center( child: Column( children: [ _FixSizedElevatedButton( - title: '画面A', + title: l10n.pageA, onPressed: () => navigator.goPageA(context), ), _FixSizedElevatedButton( - title: '画面B', + title: l10n.pageB, onPressed: () => navigator.goPageB(context), ), ], diff --git a/packages/features/debug_mode/lib/src/ui/page_a.dart b/packages/features/debug_mode/lib/src/ui/page_a.dart index 34733184..0b793d88 100644 --- a/packages/features/debug_mode/lib/src/ui/page_a.dart +++ b/packages/features/debug_mode/lib/src/ui/page_a.dart @@ -1,3 +1,4 @@ +import 'package:features_debug_mode/l10n.dart'; import 'package:flutter/material.dart'; class PageA extends StatelessWidget { @@ -5,9 +6,10 @@ class PageA extends StatelessWidget { @override Widget build(BuildContext context) { + final l10n = L10nDebug.of(context); return Scaffold( appBar: AppBar( - title: const Text('画面A'), + title: Text(l10n.pageA), ), ); } diff --git a/packages/features/debug_mode/lib/src/ui/page_b.dart b/packages/features/debug_mode/lib/src/ui/page_b.dart index 9c0e02c8..48d87ff1 100644 --- a/packages/features/debug_mode/lib/src/ui/page_b.dart +++ b/packages/features/debug_mode/lib/src/ui/page_b.dart @@ -1,3 +1,4 @@ +import 'package:features_debug_mode/l10n.dart'; import 'package:flutter/material.dart'; class PageB extends StatelessWidget { @@ -5,9 +6,10 @@ class PageB extends StatelessWidget { @override Widget build(BuildContext context) { + final l10n = L10nDebug.of(context); return Scaffold( appBar: AppBar( - title: const Text('画面B'), + title: Text(l10n.pageB), ), ); } From 6fa188d5846b6d8e447e5ed3a4394ee2b0f44a23 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 22:36:26 +0900 Subject: [PATCH 20/23] =?UTF-8?q?fix:=20=E3=82=AB=E3=83=B3=E3=83=9E?= =?UTF-8?q?=E3=81=A4=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/app/lib/main.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/app/lib/main.dart b/apps/app/lib/main.dart index 647fde3a..21d49707 100644 --- a/apps/app/lib/main.dart +++ b/apps/app/lib/main.dart @@ -62,12 +62,12 @@ class MainApp extends ConsumerWidget { localizationsDelegates: const [ ...L10n.localizationsDelegates, ...L10nSetting.localizationsDelegates, - ...L10nDebug.localizationsDelegates + ...L10nDebug.localizationsDelegates, ], supportedLocales: const [ ...L10n.supportedLocales, ...L10nSetting.supportedLocales, - ...L10nDebug.supportedLocales + ...L10nDebug.supportedLocales, ], scaffoldMessengerKey: SnackBarManager.rootScaffoldMessengerKey, routerConfig: ref.watch(routerProvider), From de1ca5f295cecc525929df6800fc22df3931d55b Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 22:57:53 +0900 Subject: [PATCH 21/23] =?UTF-8?q?fix:=E8=87=AA=E5=8B=95=E7=94=9F=E6=88=90?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E3=81=AB=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/features/debug_mode/lib/src/gen/l10n/l10n.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/features/debug_mode/lib/src/gen/l10n/l10n.dart b/packages/features/debug_mode/lib/src/gen/l10n/l10n.dart index 9c7ba112..e127e52d 100644 --- a/packages/features/debug_mode/lib/src/gen/l10n/l10n.dart +++ b/packages/features/debug_mode/lib/src/gen/l10n/l10n.dart @@ -27,8 +27,8 @@ import 'l10n_ja.dart'; /// ``` /// /// ## Update pubspec.yaml -// /// -// /// Please make sure to update your pubspec.yaml to include the following +/// +/// Please make sure to update your pubspec.yaml to include the following /// packages: /// /// ```yaml From c8980d5db5976db29278e5c83409b24d65a12b87 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 13 Jun 2024 23:02:38 +0900 Subject: [PATCH 22/23] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=83=95?= =?UTF-8?q?=E3=82=A9=E3=83=BC=E3=83=9E=E3=83=83=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/app/lib/router/navigator/debug_navigator.dart | 1 + apps/app/lib/router/routes/main/home/debug_page_route.dart | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/app/lib/router/navigator/debug_navigator.dart b/apps/app/lib/router/navigator/debug_navigator.dart index 938d47ec..e6e5c3ed 100644 --- a/apps/app/lib/router/navigator/debug_navigator.dart +++ b/apps/app/lib/router/navigator/debug_navigator.dart @@ -9,6 +9,7 @@ final class DebugNavigatorImpl implements DebugNavigator { void goNavigationPage(BuildContext context) { const NavigationPageRoute().go(context); } + @override void goPageA(BuildContext context) { const PageARoute().go(context); diff --git a/apps/app/lib/router/routes/main/home/debug_page_route.dart b/apps/app/lib/router/routes/main/home/debug_page_route.dart index 2bdc4bac..2c3d3843 100644 --- a/apps/app/lib/router/routes/main/home/debug_page_route.dart +++ b/apps/app/lib/router/routes/main/home/debug_page_route.dart @@ -27,7 +27,7 @@ class NavigationPageRoute extends GoRouteData { overrides: [ debugNavigatorProvider.overrideWithValue(const DebugNavigatorImpl()), ], - child: const NavigationPage(), + child: const NavigationPage(), ); } } From 280b14a597ca2bcc809f5d04d8f361020089d02e Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Tue, 18 Jun 2024 16:11:30 +0900 Subject: [PATCH 23/23] wip --- .../lib/src/ui/navigation_page.dart | 121 +++++++++++++-- packages/features/debug_mode/pubspec.lock | 143 +++++++++++++++++- packages/features/debug_mode/pubspec.yaml | 3 + 3 files changed, 252 insertions(+), 15 deletions(-) diff --git a/packages/features/debug_mode/lib/src/ui/navigation_page.dart b/packages/features/debug_mode/lib/src/ui/navigation_page.dart index f39e088d..ff0069b4 100644 --- a/packages/features/debug_mode/lib/src/ui/navigation_page.dart +++ b/packages/features/debug_mode/lib/src/ui/navigation_page.dart @@ -1,37 +1,132 @@ import 'package:cores_navigation/providers.dart'; import 'package:features_debug_mode/l10n.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_app/router/provider/router.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; class NavigationPage extends ConsumerWidget { const NavigationPage({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { - final navigator = ref.watch(debugNavigatorProvider); + // GoRoute returnGoRoute(RouteBase route) { + // print('jikkou'); + // if (route is StatefulShellRoute) { + // print('route is statefulshelroute'); + // late GoRoute routeFromStatefulShellRoute; + // + // route.routes.forEach((subRoute) { + // print('subroute-------------$subRoute'); + // routeFromStatefulShellRoute = subRoute as GoRoute; + // }); + // //多分ここはforEach回ってるだけで、二回目のsubrouteしかreturnされていないんだと思う + // return routeFromStatefulShellRoute; + // } else { + // return route as GoRoute; + // } + // } + + GoRoute returnGoRoute(RouteBase route) { + if (route is StatefulShellRoute) { + print('route is statefulshelroute'); + + for (final subRoute in route.routes) { + if (subRoute is GoRoute) { + return subRoute; + } + } + + // 万が一GoRouteが見つからなかった場合に備えて例外を発生させる + throw Exception('No GoRoute found in StatefulShellRoute'); + } else if (route is GoRoute) { + return route; + } else { + // ここでも例外を発生させる + throw Exception('Invalid RouteBase: No GoRoute found'); + } + } + final l10n = L10nDebug.of(context); + final goRoutes = + ref.watch(routerProvider).configuration.routes.toGoRoutes(); + print('goRoutes----------------$goRoutes'); return Scaffold( appBar: AppBar( title: Text(l10n.navigationPageAppBar), ), - body: Center( - child: Column( - children: [ - _FixSizedElevatedButton( - title: l10n.pageA, - onPressed: () => navigator.goPageA(context), - ), - _FixSizedElevatedButton( - title: l10n.pageB, - onPressed: () => navigator.goPageB(context), - ), - ], + body: SingleChildScrollView( + child: Center( + child: Column( + children: ref.watch(routerProvider).configuration.routes.map((e) { + final route = returnGoRoute(e); + print(route); + return _Route( + routes: [route], + ); + }).toList(), + ), ), ), ); } } +class _Route extends StatelessWidget { + const _Route({ + required List routes, + List parent = const [], + }) : _routes = routes, + _parent = parent; + + final List _routes; + final List _parent; + + @override + Widget build(BuildContext context) { + return Column( + children: _routes.map( + (route) { + // print(route.routes.isNotEmpty); + print('route--------$route'); + if (route.routes.isNotEmpty) { + return _Route( + routes: route.routes.cast(), + parent: [..._parent, route], + ); + } + return _FixSizedElevatedButton( + title: [..._parent, route].map((e) => e.path).join('/'), + onPressed: () async => context.push( + [..._parent, route].map((e) => e.path).join('/'), + ), + ); + }, + ).toList(), + ); + } +} + +extension _ToGoRoutes on List { + List toGoRoutes() { + final goRoutes = []; + for (final route in this) { + switch (route) { + case GoRoute(): + final childRoutes = route.routes; + if (childRoutes.isEmpty) { + goRoutes.add(route); + } else { + goRoutes.addAll(childRoutes.toGoRoutes()); + } + case ShellRoute() || StatefulShellRoute(): + goRoutes.addAll(route.routes.toGoRoutes()); + } + } + return goRoutes; + } +} + class _FixSizedElevatedButton extends StatelessWidget { const _FixSizedElevatedButton({ required String title, diff --git a/packages/features/debug_mode/pubspec.lock b/packages/features/debug_mode/pubspec.lock index 2773d5b9..18bcd1ef 100644 --- a/packages/features/debug_mode/pubspec.lock +++ b/packages/features/debug_mode/pubspec.lock @@ -198,6 +198,13 @@ packages: relative: true source: path version: "0.0.1" + cores_init: + dependency: transitive + description: + path: "../../cores/init" + relative: true + source: path + version: "0.0.1" cores_navigation: dependency: "direct main" description: @@ -253,6 +260,27 @@ packages: url: "https://pub.dev" source: hosted version: "5.4.0" + features_github_repository: + dependency: transitive + description: + path: "../github_repository" + relative: true + source: path + version: "0.0.1" + features_setting: + dependency: transitive + description: + path: "../setting" + relative: true + source: path + version: "0.0.1" + features_webview: + dependency: transitive + description: + path: "../webview" + relative: true + source: path + version: "0.0.1" ffi: dependency: transitive description: @@ -282,6 +310,77 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_app: + dependency: "direct main" + description: + path: "../../../apps/app" + relative: true + source: path + version: "0.0.1" + flutter_hooks: + dependency: transitive + description: + name: flutter_hooks + sha256: cde36b12f7188c85286fba9b38cc5a902e7279f36dd676967106c041dc9dde70 + url: "https://pub.dev" + source: hosted + version: "0.20.5" + flutter_inappwebview: + dependency: transitive + description: + name: flutter_inappwebview + sha256: "3e9a443a18ecef966fb930c3a76ca5ab6a7aafc0c7b5e14a4a850cf107b09959" + url: "https://pub.dev" + source: hosted + version: "6.0.0" + flutter_inappwebview_android: + dependency: transitive + description: + name: flutter_inappwebview_android + sha256: d247f6ed417f1f8c364612fa05a2ecba7f775c8d0c044c1d3b9ee33a6515c421 + url: "https://pub.dev" + source: hosted + version: "1.0.13" + flutter_inappwebview_internal_annotations: + dependency: transitive + description: + name: flutter_inappwebview_internal_annotations + sha256: "5f80fd30e208ddded7dbbcd0d569e7995f9f63d45ea3f548d8dd4c0b473fb4c8" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter_inappwebview_ios: + dependency: transitive + description: + name: flutter_inappwebview_ios + sha256: f363577208b97b10b319cd0c428555cd8493e88b468019a8c5635a0e4312bd0f + url: "https://pub.dev" + source: hosted + version: "1.0.13" + flutter_inappwebview_macos: + dependency: transitive + description: + name: flutter_inappwebview_macos + sha256: b55b9e506c549ce88e26580351d2c71d54f4825901666bd6cfa4be9415bb2636 + url: "https://pub.dev" + source: hosted + version: "1.0.11" + flutter_inappwebview_platform_interface: + dependency: transitive + description: + name: flutter_inappwebview_platform_interface + sha256: "545fd4c25a07d2775f7d5af05a979b2cac4fbf79393b0a7f5d33ba39ba4f6187" + url: "https://pub.dev" + source: hosted + version: "1.0.10" + flutter_inappwebview_web: + dependency: transitive + description: + name: flutter_inappwebview_web + sha256: d8c680abfb6fec71609a700199635d38a744df0febd5544c5a020bd73de8ee07 + url: "https://pub.dev" + source: hosted + version: "1.0.8" flutter_localizations: dependency: "direct main" description: flutter @@ -324,6 +423,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + go_router: + dependency: "direct main" + description: + name: go_router + sha256: b465e99ce64ba75e61c8c0ce3d87b66d8ac07f0b35d0a7e0263fcfc10f99e836 + url: "https://pub.dev" + source: hosted + version: "13.2.5" graphs: dependency: transitive description: @@ -332,6 +439,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.1" + hooks_riverpod: + dependency: transitive + description: + name: hooks_riverpod + sha256: "45b2030a18bcd6dbd680c2c91bc3b33e3fe7c323e3acb5ecec93a613e2fbaa8a" + url: "https://pub.dev" + source: hosted + version: "2.5.1" hotreloader: dependency: transitive description: @@ -340,6 +455,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" + http: + dependency: transitive + description: + name: http + sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba + url: "https://pub.dev" + source: hosted + version: "1.2.0" http_multi_server: dependency: transitive description: @@ -376,10 +499,10 @@ packages: dependency: transitive description: name: js - sha256: "4186c61b32f99e60f011f7160e32c89a758ae9b1d0c6d28e2c02ef0382300e2b" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.7.0" + version: "0.6.7" json_annotation: dependency: transitive description: @@ -436,6 +559,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" + package_info_plus: + dependency: transitive + description: + name: package_info_plus + sha256: "88bc797f44a94814f2213db1c9bd5badebafdfb8290ca9f78d4b9ee2a3db4d79" + url: "https://pub.dev" + source: hosted + version: "5.0.1" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: "9bc8ba46813a4cc42c66ab781470711781940780fd8beddd0c3da62506d3a6c6" + url: "https://pub.dev" + source: hosted + version: "2.0.1" path: dependency: transitive description: diff --git a/packages/features/debug_mode/pubspec.yaml b/packages/features/debug_mode/pubspec.yaml index 584ae817..d79bc35f 100644 --- a/packages/features/debug_mode/pubspec.yaml +++ b/packages/features/debug_mode/pubspec.yaml @@ -16,6 +16,8 @@ dependencies: path: ../../cores/designsystem cores_navigation: path: ../../../packages/cores/navigation + flutter_app: + path: ../../../apps/app dio: ^5.4.0 flutter: sdk: flutter @@ -23,6 +25,7 @@ dependencies: sdk: flutter flutter_riverpod: ^2.5.1 riverpod_annotation: ^2.3.5 + go_router: ^13.0.1 dev_dependencies: build_runner: ^2.4.7