-
Notifications
You must be signed in to change notification settings - Fork 0
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
c423f5a
commit 60bd76f
Showing
14 changed files
with
345 additions
and
165 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:get_storage/get_storage.dart'; | ||
|
||
import '../screens/connection/connection_view.dart'; | ||
import '../screens/dashboard/dashboard_view.dart'; | ||
import '../screens/registration/registration_view.dart'; | ||
import '../utils/constants.dart'; | ||
import 'middleware_page.dart'; | ||
import 'pages_routes.dart'; | ||
|
||
/// The app routes. | ||
final class AppRouter { | ||
/// The list of app routes. | ||
static List<GetPage<dynamic>> get pageRoutes => [ | ||
GetPage( | ||
name: PagesRoutes.home.pattern, | ||
middlewares: [HomeMiddleware()], | ||
page: () => const MiddlewarePage( | ||
child: DashboardView(), | ||
), | ||
), | ||
GetPage( | ||
name: PagesRoutes.connection.pattern, | ||
page: () => const MiddlewarePage( | ||
child: ConnectionView(), | ||
), | ||
), | ||
GetPage( | ||
name: PagesRoutes.registration.pattern, | ||
page: () => const MiddlewarePage( | ||
child: RegistrationView(), | ||
), | ||
), | ||
]; | ||
|
||
/// Navigates to nex page. | ||
static void push(String uri, {Object? extra}) { | ||
Get.toNamed(uri, arguments: extra); | ||
} | ||
|
||
/// Navigates to next page and replace all the stack page. | ||
static void go(String uri, {Object? extra}) { | ||
Get.offAllNamed(uri, arguments: extra); | ||
} | ||
|
||
/// Navigates to next page and replace the previous page. | ||
static void pushReplacementNamed( | ||
String uri, { | ||
Object? extra, | ||
}) { | ||
Get.offNamed(uri, arguments: extra); | ||
} | ||
|
||
/// Gets the current route name. | ||
static String getCurrentLocation(BuildContext context) { | ||
return Get.currentRoute; | ||
} | ||
|
||
/// Checks if there are routes to pop. | ||
static bool canPop(BuildContext context) { | ||
return Get.key.currentState?.canPop() ?? | ||
false; // Check if there are routes to pop | ||
} | ||
|
||
/// Pops the current route. | ||
static void onPop(BuildContext context) { | ||
Get.back(); // Use Get.back() to pop the current route | ||
} | ||
} | ||
|
||
/// The first open time middleware. | ||
class HomeMiddleware extends GetMiddleware { | ||
final _box = GetStorage(); | ||
|
||
@override | ||
RouteSettings? redirect(String? route) { | ||
final bool isFirstOpenTime = | ||
_box.read(PreferencesKey.isFirstOpenTime) ?? true; | ||
|
||
if (isFirstOpenTime) { | ||
return RouteSettings(name: PagesRoutes.connection.pattern); | ||
} | ||
|
||
/// [TODO] verify whether the user is registered or not. | ||
return null; | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
sabitou_clients/lib/screens/connection/connection_view.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
/// The login view. | ||
final class ConnectionView extends StatelessWidget { | ||
/// Constructor of new [ConnectionView]. | ||
const ConnectionView({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Placeholder(); | ||
} | ||
} |
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,14 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
/// The home screen. | ||
final class DashboardView extends StatelessWidget { | ||
/// Constructor of new [DashboardView]. | ||
const DashboardView({ | ||
super.key, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Placeholder(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
sabitou_clients/lib/screens/registration/registration_view.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
/// The registration screen. | ||
final class RegistrationView extends StatelessWidget { | ||
/// Constructor of new [RegistrationView]. | ||
const RegistrationView({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Placeholder(); | ||
} | ||
} |
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
Oops, something went wrong.