-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4f94ef
commit 46a73ca
Showing
49 changed files
with
560 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:quote_generator/common/common.dart'; | ||
|
||
class ErrorScreen extends StatelessWidget { | ||
const ErrorScreen({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final l10n = context.l10n; | ||
final textTheme = context.textTheme; | ||
return Scaffold( | ||
appBar: AppBar( | ||
centerTitle: true, | ||
title: Text( | ||
l10n.something_went_wrong, | ||
style: textTheme.headlineMedium, | ||
), | ||
), | ||
body: Center( | ||
child: ElevatedButton( | ||
onPressed: () => context.go(RouteLocation.createdByYou), | ||
child: Text( | ||
l10n.go_to_home, | ||
style: textTheme.bodyMedium, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export 'routes_config.dart'; | ||
export 'routes_provider.dart'; | ||
export 'routes.dart'; | ||
export 'routes_name.dart'; | ||
export 'routes_location.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:flutter/foundation.dart' show immutable; | ||
|
||
@immutable | ||
class RouteLocation { | ||
const RouteLocation._(); | ||
//routeLocation | ||
static String get splash => '/splash'; | ||
static String get detailScreen => '/quoteDetails'; | ||
static String get discovery => '/discovery'; | ||
static String get createQuote => '/createQuote'; | ||
static String get settings => '/settings'; | ||
static String get createdByYou => '/createdByYou'; | ||
static String get search => '/search'; | ||
static String get favorites => '/favorites'; | ||
static String get auth => '/auth'; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:quote_generator/common/common.dart'; | ||
import 'package:quote_generator/common/navigation/routers/error_screen.dart'; | ||
import 'package:quote_generator/features/auth/auth.dart'; | ||
|
||
final navigationKey = GlobalKey<NavigatorState>(); | ||
|
||
final routerProvider = Provider<GoRouter>( | ||
(ref) { | ||
final authState = ref.watch(authStateChangesProvider); | ||
|
||
return GoRouter( | ||
initialLocation: RouteLocation.splash, | ||
navigatorKey: navigationKey, | ||
routes: routes, | ||
errorBuilder: (context, state) => const ErrorScreen(), | ||
redirect: (context, state) { | ||
if (authState.isLoading || authState.hasError) return null; | ||
final isAuth = authState.valueOrNull != null; | ||
final isSplash = state.location == RouteLocation.splash; | ||
if (isSplash) { | ||
return isAuth ? RouteLocation.createdByYou : RouteLocation.auth; | ||
} | ||
final isLoggedIn = state.location == RouteLocation.auth; | ||
if (isLoggedIn) return isAuth ? RouteLocation.createdByYou : null; | ||
return isAuth ? null : RouteLocation.splash; | ||
}, | ||
); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.