-
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
Showing
35 changed files
with
1,696 additions
and
109 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,3 +147,16 @@ jobs: | |
|
||
# Validate that our code has a consistent format. | ||
- run: ./scripts/run_dart_format.sh sabitou_clients | ||
static-analysis: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
# Install pre-requisites. | ||
- uses: actions/checkout@v4 | ||
- uses: subosito/[email protected] | ||
with: | ||
flutter-version: ${{ env.FLUTTER_SDK_VERSION }} | ||
cache: true | ||
|
||
# Run static analysis on all packages. | ||
- run: ./scripts/run_static_analysis.sh sabitou_clients |
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,3 @@ | ||
{ | ||
"cSpell.words": ["Getx", "grey"] | ||
} |
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,87 @@ | ||
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() { | ||
return Get.currentRoute; | ||
} | ||
|
||
/// Checks if there are routes to pop. | ||
static bool canPop() { | ||
return Get.key.currentState?.canPop() ?? false; | ||
} | ||
|
||
/// Pops the current route. | ||
static void onPop() { | ||
Get.back(); | ||
} | ||
} | ||
|
||
/// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
/// The middle page. | ||
final class MiddlewarePage extends StatelessWidget { | ||
/// The widget to display under the page. | ||
final Widget child; | ||
|
||
/// Constructor of new [MiddlewarePage]. | ||
const MiddlewarePage({super.key, required this.child}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return child; | ||
} | ||
} |
Oops, something went wrong.