-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(router): implement GoRouter navigation system #32
Changes from all commits
8f0a4a2
3e8857f
cfd5227
fc87b2a
03da6c4
d83ac50
faee112
23eaac6
f263f4c
8679c1e
62d5734
c6c80a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"title": "¡Hola, Mundo!", | ||
"subtitle": "Bienvenido a Localización", | ||
"description": "Has pulsado el botón tantas veces:", | ||
"switch_language": "Cambiar idioma" | ||
"description": "Has pulsado el botón tantas veces:", | ||
"switch_language": "Cambiar idioma", | ||
"applications": "Aplicaciones" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"title": "Bonjour", | ||
"subtitle": "Bienvenue dans Localisation", | ||
"description": "Vous avez appuyé sur le bouton autant de fois :", | ||
"switch_language": "Changer de langue" | ||
} | ||
"description": "Vous avez appuyé sur le bouton autant de fois :", | ||
"switch_language": "Changer de langue", | ||
"applications": "Applications" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:bloc/bloc.dart'; | ||
import '../../../src/features/main/language/presentation/bloc/language_bloc.dart'; | ||
|
||
const languagePrefsKey = 'languagePrefs'; | ||
|
||
class LanguageBloc extends Bloc<LanguageEvent, LanguageState> { | ||
LanguageBloc() : super(const LanguageState()) { | ||
on<ChangeLanguage>(onChangeLanguage); | ||
} | ||
Future<void> onChangeLanguage( | ||
ChangeLanguage event, | ||
Emitter<LanguageState> emit, | ||
) async { | ||
emit(state.copyWith(selectedLanguage: event.selectedLanguage)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:gui/src/features/splash/presentation/screen/splash_screen.dart'; | ||
import 'basic_routes.dart'; | ||
import 'registration_routes.dart'; | ||
|
||
final GoRouter routerConfig = GoRouter( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all this parts used for register route. we need another route for basic route. so create two file one for basic route and another for registration route. |
||
debugLogDiagnostics: true, | ||
routes: [ | ||
GoRoute( | ||
path: '/', | ||
builder: (context, state) => SplashScreen(), | ||
), | ||
...basicRoutes, | ||
...registrationRoutes, | ||
], | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:gui/src/features/dashboard/presentation/screen/dashboard_page.dart'; | ||
import 'package:gui/src/features/password/presentation/screen/password_page.dart'; | ||
import 'route_name.dart'; | ||
|
||
final List<GoRoute> basicRoutes = [ | ||
GoRoute( | ||
path: AppRoute.basicPassword.fullPath, | ||
name: AppRoute.basicPassword.name, | ||
builder: (context, state) => PasswordPage( | ||
fromRegistrationRoute: | ||
state.matchedLocation.contains(AppRoute.finish.name), | ||
), | ||
routes: [ | ||
GoRoute( | ||
path: AppRoute.basicDashboard.path, | ||
name: AppRoute.basicDashboard.name, | ||
builder: (context, state) => const DashboardPage(), | ||
), | ||
], | ||
), | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:gui/src/features/confirmation_seed/presentation/screen/confirmation_seed_page.dart'; | ||
import 'package:gui/src/features/dashboard/presentation/screen/dashboard_page.dart'; | ||
import 'package:gui/src/features/finish/presentation/screen/finish_page.dart'; | ||
import 'package:gui/src/features/initialize_mode/presentation/screen/initialize_mode_page.dart'; | ||
import 'package:gui/src/features/initializing/presentation/screen/initializing_page.dart'; | ||
import 'package:gui/src/features/master_password/presentation/screen/master_password_page.dart'; | ||
import 'package:gui/src/features/password/presentation/screen/password_page.dart'; | ||
import 'package:gui/src/features/restoration_seed/presentation/screen/restoration_seed_page.dart'; | ||
import 'package:gui/src/features/validator_config/presentation/screen/validator_config_page.dart'; | ||
import 'package:gui/src/features/welcome/presentation/screen/welcome_page.dart'; | ||
import 'route_name.dart'; | ||
|
||
final List<GoRoute> registrationRoutes = [ | ||
GoRoute( | ||
path: AppRoute.welcome.fullPath, | ||
name: AppRoute.welcome.name, | ||
builder: (context, state) => const WelcomePage(), | ||
routes: [ | ||
GoRoute( | ||
path: AppRoute.initializeMode.path, | ||
name: AppRoute.initializeMode.name, | ||
builder: (context, state) => const InitializeModePage(), | ||
routes: [ | ||
GoRoute( | ||
path: AppRoute.restorationSeed.path, | ||
name: AppRoute.restorationSeed.name, | ||
builder: (context, state) => const RestorationSeedPage(), | ||
routes: [ | ||
GoRoute( | ||
path: AppRoute.confirmationSeed.path, | ||
name: AppRoute.confirmationSeed.name, | ||
builder: (context, state) => const ConfirmationSeedPage(), | ||
routes: [ | ||
GoRoute( | ||
path: AppRoute.masterPassword.path, | ||
name: AppRoute.masterPassword.name, | ||
builder: (context, state) => const MasterPasswordPage(), | ||
routes: [ | ||
GoRoute( | ||
path: AppRoute.validatorConfig.path, | ||
name: AppRoute.validatorConfig.name, | ||
builder: (context, state) => | ||
const ValidatorConfigPage(), | ||
routes: [ | ||
GoRoute( | ||
path: AppRoute.initializing.path, | ||
name: AppRoute.initializing.name, | ||
builder: (context, state) => | ||
const InitializingPage(), | ||
routes: [ | ||
GoRoute( | ||
path: AppRoute.finish.path, | ||
name: AppRoute.finish.name, | ||
builder: (context, state) => const FinishPage(), | ||
routes: [ | ||
GoRoute( | ||
path: AppRoute.password.path, | ||
name: AppRoute.password.name, | ||
builder: (context, state) => PasswordPage( | ||
fromRegistrationRoute: state | ||
.matchedLocation | ||
.contains(AppRoute.finish.name), | ||
), | ||
routes: [ | ||
GoRoute( | ||
path: AppRoute.dashboard.path, | ||
name: AppRoute.dashboard.name, | ||
builder: (context, state) => | ||
const DashboardPage(), | ||
), | ||
], | ||
), | ||
], | ||
), | ||
], | ||
), | ||
], | ||
), | ||
], | ||
), | ||
], | ||
), | ||
], | ||
), | ||
], | ||
), | ||
], | ||
), | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
enum AppRoute { | ||
splash, | ||
welcome, | ||
initializeMode, | ||
restorationSeed, | ||
confirmationSeed, | ||
masterPassword, | ||
validatorConfig, | ||
initializing, | ||
finish, | ||
password, | ||
dashboard, | ||
basicPassword, | ||
basicDashboard; | ||
|
||
String get fullPath => '/$name'; | ||
String get path => name; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:gui/src/core/router/route_name.dart'; | ||
|
||
class ConfirmationSeedPage extends StatelessWidget { | ||
const ConfirmationSeedPage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Confirmation Seed Page'), | ||
), | ||
body: Center( | ||
child: ElevatedButton( | ||
onPressed: () { | ||
context.goNamed(AppRoute.masterPassword.name); | ||
}, | ||
child: Text('Navigate to ${AppRoute.masterPassword.name}'), | ||
), | ||
), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class DashboardPage extends StatelessWidget { | ||
const DashboardPage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Dashboard Page'), | ||
), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:gui/src/core/router/route_name.dart'; | ||
|
||
class FinishPage extends StatelessWidget { | ||
const FinishPage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Finish Page'), | ||
), | ||
body: Center( | ||
child: ElevatedButton( | ||
onPressed: () { | ||
context.goNamed(AppRoute.password.name); | ||
}, | ||
child: Text('Navigate to ${AppRoute.password.name}'), | ||
), | ||
), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:gui/src/core/router/route_name.dart'; | ||
|
||
class InitializeModePage extends StatelessWidget { | ||
const InitializeModePage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Initialize Mode'), | ||
), | ||
body: Center( | ||
child: ElevatedButton( | ||
onPressed: () { | ||
context.goNamed(AppRoute.restorationSeed.name); | ||
}, | ||
child: Text('Navigate to ${AppRoute.restorationSeed.name}'), | ||
), | ||
), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:gui/src/core/router/route_name.dart'; | ||
|
||
class InitializingPage extends StatelessWidget { | ||
const InitializingPage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Initializing Page'), | ||
), | ||
body: Center( | ||
child: ElevatedButton( | ||
onPressed: () { | ||
context.goNamed(AppRoute.finish.name); | ||
}, | ||
child: Text('Navigate to ${AppRoute.finish.name}'), | ||
), | ||
), | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please if dont use remove it
@phoenixit99