From 921b62c994e05f6613b6b85779447159c2ce665b Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Thu, 20 Apr 2023 22:00:44 +0900 Subject: [PATCH 1/2] =?UTF-8?q?:+1:=20=E3=82=B9=E3=82=B1=E3=82=B8=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E4=B8=80=E8=A6=A7=E3=83=9A=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=AE=E3=83=91=E3=82=B9=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/frontend/lib/src/router/router.dart | 10 +++++----- apps/frontend/lib/src/router/router.g.dart | 15 ++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/frontend/lib/src/router/router.dart b/apps/frontend/lib/src/router/router.dart index 5d894e85..46ad8235 100644 --- a/apps/frontend/lib/src/router/router.dart +++ b/apps/frontend/lib/src/router/router.dart @@ -44,12 +44,12 @@ class SettingsRoute extends GoRouteData { build(BuildContext context, GoRouterState state) => const SettingsScreen(); } -/// スケジュールページルート -@TypedGoRoute( - path: '/schedule', +/// スケジュール一覧ページルート +@TypedGoRoute( + path: '/schedules', ) -class ScheduleRoute extends GoRouteData { - const ScheduleRoute(); +class ScheduleListRoute extends GoRouteData { + const ScheduleListRoute(); @override build(BuildContext context, GoRouterState state) => const SchedulePage(); diff --git a/apps/frontend/lib/src/router/router.g.dart b/apps/frontend/lib/src/router/router.g.dart index a699fa70..665410a0 100644 --- a/apps/frontend/lib/src/router/router.g.dart +++ b/apps/frontend/lib/src/router/router.g.dart @@ -10,7 +10,7 @@ List get $appRoutes => [ $rootRoute, $loginRoute, $settingsRoute, - $scheduleRoute, + $scheduleListRoute, ]; RouteBase get $rootRoute => GoRouteData.$route( @@ -73,16 +73,17 @@ extension $SettingsRouteExtension on SettingsRoute { context.pushReplacement(location); } -RouteBase get $scheduleRoute => GoRouteData.$route( - path: '/schedule', - factory: $ScheduleRouteExtension._fromState, +RouteBase get $scheduleListRoute => GoRouteData.$route( + path: '/schedules', + factory: $ScheduleListRouteExtension._fromState, ); -extension $ScheduleRouteExtension on ScheduleRoute { - static ScheduleRoute _fromState(GoRouterState state) => const ScheduleRoute(); +extension $ScheduleListRouteExtension on ScheduleListRoute { + static ScheduleListRoute _fromState(GoRouterState state) => + const ScheduleListRoute(); String get location => GoRouteData.$location( - '/schedule', + '/schedules', ); void go(BuildContext context) => context.go(location); From 661a115208e3c474717088569d0789bec6c9f965 Mon Sep 17 00:00:00 2001 From: Ryo Takeuchi Date: Thu, 20 Apr 2023 22:02:50 +0900 Subject: [PATCH 2/2] =?UTF-8?q?:+1:=20=E3=83=88=E3=83=83=E3=83=97=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=8B=E3=82=89=E3=82=B9=E3=82=B1=E3=82=B8?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E3=83=AB=E4=B8=80=E8=A6=A7=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=B8=E3=81=AE=E9=81=B7=E7=A7=BB=E3=82=92=E3=82=A2?= =?UTF-8?q?=E3=83=97=E3=83=AA=E3=82=B1=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E5=B1=A4=E3=81=A7=E8=A1=8C=E3=81=86=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/frontend/lib/src/router/router.dart | 3 +++ packages/feature/top/example/lib/main.dart | 1 + packages/feature/top/lib/src/ui/top_page.dart | 13 +++++++++---- packages/feature/top/lib/src/ui/top_page_body.dart | 8 +++++--- .../top/lib/src/ui/top_page_for_mobile.dart | 14 ++++++++++---- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/apps/frontend/lib/src/router/router.dart b/apps/frontend/lib/src/router/router.dart index 46ad8235..4bd64674 100644 --- a/apps/frontend/lib/src/router/router.dart +++ b/apps/frontend/lib/src/router/router.dart @@ -19,6 +19,9 @@ class RootRoute extends GoRouteData { onSettingsActionPressed: (BuildContext context) { context.push('/settings'); }, + onScheduleListButtonPressed: () { + const ScheduleListRoute().push(context); + }, ); } diff --git a/packages/feature/top/example/lib/main.dart b/packages/feature/top/example/lib/main.dart index 0538f3e0..26935fa5 100644 --- a/packages/feature/top/example/lib/main.dart +++ b/packages/feature/top/example/lib/main.dart @@ -18,6 +18,7 @@ class TopPageTest extends HookConsumerWidget { return MaterialApp( home: TopPage( onSettingsActionPressed: (BuildContext context) {}, + onScheduleListButtonPressed: () {}, ), ); } diff --git a/packages/feature/top/lib/src/ui/top_page.dart b/packages/feature/top/lib/src/ui/top_page.dart index a875961b..95088cb6 100644 --- a/packages/feature/top/lib/src/ui/top_page.dart +++ b/packages/feature/top/lib/src/ui/top_page.dart @@ -3,12 +3,15 @@ import 'package:flutter/material.dart'; import 'package:feature_top/src/ui/top_page_for_mobile.dart'; class TopPage extends StatelessWidget { - const TopPage( - {super.key, - required void Function(BuildContext context) onSettingsActionPressed}) - : _onSettingsActionPressed = onSettingsActionPressed; + const TopPage({ + super.key, + required void Function(BuildContext context) onSettingsActionPressed, + required VoidCallback onScheduleListButtonPressed, + }) : _onSettingsActionPressed = onSettingsActionPressed, + _onScheduleListButtonPressed = onScheduleListButtonPressed; final void Function(BuildContext context) _onSettingsActionPressed; + final VoidCallback _onScheduleListButtonPressed; @override Widget build(BuildContext context) { @@ -16,9 +19,11 @@ class TopPage extends StatelessWidget { return kIsWeb ? TopPageForMobile( onSettingsActionPressed: () => _onSettingsActionPressed(context), + onScheduleListButtonPressed: _onScheduleListButtonPressed, ) : TopPageForMobile( onSettingsActionPressed: () => _onSettingsActionPressed(context), + onScheduleListButtonPressed: _onScheduleListButtonPressed, ); } } diff --git a/packages/feature/top/lib/src/ui/top_page_body.dart b/packages/feature/top/lib/src/ui/top_page_body.dart index 778764be..58de6f0a 100644 --- a/packages/feature/top/lib/src/ui/top_page_body.dart +++ b/packages/feature/top/lib/src/ui/top_page_body.dart @@ -1,11 +1,13 @@ import 'package:feature_top/src/ui/top_page_schedule_tile.dart'; import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; class TopPageBody extends StatelessWidget { const TopPageBody({ super.key, - }); + required VoidCallback onScheduleListButtonPressed, + }) : _onScheduleListButtonPressed = onScheduleListButtonPressed; + + final VoidCallback _onScheduleListButtonPressed; @override Widget build(BuildContext context) { @@ -15,8 +17,8 @@ class TopPageBody extends StatelessWidget { Align( alignment: Alignment.centerRight, child: TextButton( + onPressed: _onScheduleListButtonPressed, child: const Text('スケジュール一覧を見る'), - onPressed: () => context.go('/schedule'), ), ), const Spacer(), diff --git a/packages/feature/top/lib/src/ui/top_page_for_mobile.dart b/packages/feature/top/lib/src/ui/top_page_for_mobile.dart index 65d04463..994ddecc 100644 --- a/packages/feature/top/lib/src/ui/top_page_for_mobile.dart +++ b/packages/feature/top/lib/src/ui/top_page_for_mobile.dart @@ -2,11 +2,15 @@ import 'package:feature_top/src/ui/top_page_body.dart'; import 'package:flutter/material.dart'; class TopPageForMobile extends StatelessWidget { - const TopPageForMobile( - {super.key, required VoidCallback onSettingsActionPressed}) - : _onSettingsActionPressed = onSettingsActionPressed; + const TopPageForMobile({ + super.key, + required VoidCallback onSettingsActionPressed, + required VoidCallback onScheduleListButtonPressed, + }) : _onSettingsActionPressed = onSettingsActionPressed, + _onScheduleListButtonPressed = onScheduleListButtonPressed; final VoidCallback _onSettingsActionPressed; + final VoidCallback _onScheduleListButtonPressed; @override Widget build(BuildContext context) { @@ -22,7 +26,9 @@ class TopPageForMobile extends StatelessWidget { icon: const Icon(Icons.settings)) ], ), - body: const TopPageBody(), + body: TopPageBody( + onScheduleListButtonPressed: _onScheduleListButtonPressed, + ), ); } }