Skip to content

Commit

Permalink
resolved the conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrice-mokfembam2 committed Oct 3, 2024
2 parents ea8382d + ad2a743 commit a35f614
Show file tree
Hide file tree
Showing 35 changed files with 1,696 additions and 109 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/presubmit_sabitu_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cSpell.words": ["Getx", "grey"]
}
123 changes: 120 additions & 3 deletions sabitou_clients/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

analyzer:
plugins:
- dart_code_linter
exclude:
- sabitou_clients/**/build/**
- sabitou_clients/**/test/**
- sabitou_clients/ios/**
- sabitou_clients/android/**
- sabitou_clients/web/**
- sabitou_clients/windows/**
- sabitou_clients/linux/**
- sabitou_clients/macos/**
language:
strict-casts: true
strict-raw-types: true
errors:
# treat missing required parameters as a warning (not a hint).
missing_required_param: warning

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
Expand All @@ -22,7 +41,8 @@ linter:
# producing the lint.
rules:
- prefer_const_constructors
- avoid_print
- avoid_print:
severity: error
- use_key_in_widget_constructors
- prefer_single_quotes
- avoid_redundant_argument_values
Expand Down Expand Up @@ -97,7 +117,6 @@ linter:
- prefer_mixin
- public_member_api_docs
- type_annotate_public_apis
- slash_for_doc_comments
- unnecessary_const
- unnecessary_lambdas
- unnecessary_new
Expand All @@ -123,7 +142,6 @@ linter:
- prefer_if_null_operators
- prefer_spread_collections
- recursive_getters
- unawaited_futures
- unnecessary_null_in_if_null_operators
- use_function_type_syntax_for_parameters
#
Expand All @@ -133,5 +151,104 @@ linter:
- require_trailing_commas
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
dart_code_linter:
exclude:
exclude:
- sabitou_clients/**/build/**
- sabitou_clients/test/**
- sabitou_clients/ios/**
- sabitou_clients/android/**
- sabitou_clients/web/**
- sabitou_clients/windows/**
- sabitou_clients/linux/**
- sabitou_clients/macos/**
metrics:
cyclomatic-complexity: 25
number-of-parameters: 3
maximum-nesting-level: 8
source-lines-of-code: 90
min-identifier-length: 2

anti-patterns:
- long-method:
severity: error
rules:
# Dart rules.
- avoid-collection-methods-with-unrelated-types:
severity: style
- avoid-global-state:
severity: style
- avoid-late-keyword:
severity: style
- avoid-missing-enum-constant-in-map:
severity: style
- avoid-nested-conditional-expressions:
severity: style
- avoid-non-null-assertion:
severity: error
- avoid-throw-in-catch-block
- avoid-unnecessary-type-assertions
- avoid-unnecessary-type-casts
- avoid-unrelated-type-assertions
- avoid-unused-parameters:
severity: style
- binary-expression-operand-order:
severity: style
- double-literal-format:
severity: style
- format-comment:
severity: error
- member-ordering:
severity: style
order:
- fields
- getters-setters
- methods
- newline-before-return:
severity: error
- no-boolean-literal-compare:
severity: style
- no-empty-block:
severity: style
- no-equal-then-else:
severity: style
- no-object-declaration:
severity: style
- prefer-async-await:
severity: style
- prefer-conditional-expressions:
severity: style
- prefer-correct-type-name:
severity: style
- prefer-first:
severity: style
- prefer-last:
severity: style
- prefer-trailing-comma:
severity: error

# Flutter rules.
- always-remove-listener:
severity: error
- avoid-border-all:
severity: error
- avoid-returning-widgets:
severity: error
- avoid-unnecessary-setstate:
severity: error
- avoid-wrapping-in-padding:
severity: error
- prefer-const-border-radius:
severity: error
- prefer-extracting-callbacks:
severity: style
- avoid-shrink-wrap-in-lists:
severity: error
- avoid-wrapping-in-padding:
severity: error
- prefer-correct-edge-insets-constructor:
severity: error
- prefer-using-list-view:
severity: error
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
Binary file added sabitou_clients/assets/fonts/RobotoSlab-Bold.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
58 changes: 46 additions & 12 deletions sabitou_clients/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

import 'screens/login_screen.dart';
import 'screens/signup_screen.dart';
import 'routes/app_routes.dart';
import 'services/internationalization/app_translations.dart';
import 'services/internationalization/internationalization.dart';
import 'services/storage/app_storate.dart';
import 'services/themes/app_themes.dart';
import 'themes/themes.dart';
import 'utils/constants.dart';

/// The logger configuration.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();

await _initServices();
runApp(const MyApp());
}

Expand All @@ -25,28 +32,55 @@ class MyApp extends StatelessWidget {
debugShowCheckedModeBanner: false,
initialBinding: AppBinding(),
translations: AppTranslations(),
supportedLocales: AppInternationalization.supportedLocales,
supportedLocales: AppInternationalizationService.supportedLocales,
locale: Get.deviceLocale,
fallbackLocale: const Locale('en'),
getPages: AppRouter.pageRoutes,
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],

home: const Login(),
darkTheme: Themes.darkTheme.toTheme,
theme: Themes.lightTheme.toTheme,
themeMode: AppThemeService.to.themeMode,
);
}
}

/// The application binding.
class AppBinding extends Bindings {
@override
void dependencies() {
// Initialize the services and repositories.
final AppInternationalization appInternationalization =
AppInternationalization(Get.deviceLocale ?? const Locale('en'));
Future<void> _initServices() async {
setUrlStrategy(PathUrlStrategy());

// Register internationalization services.
Get.put<AppInternationalization>(appInternationalization, permanent: true);
}
/// Initialize the get storage service.
await GetStorage.init();
final appStorage = AppStorageService(AppStorageType.getStorage);
Get.put<AppStorageService>(
appStorage,
permanent: true,
);

// Initialize the services and repositories.
final languageCode =
AppStorageService.to.read<String>(PreferencesKey.language);

final AppInternationalizationService appInternationalization =
AppInternationalizationService(
languageCode != null
? Locale(languageCode)
: Get.deviceLocale ?? const Locale('en'),
appStorage,
);

// Register internationalization services.
Get.put<AppInternationalizationService>(
appInternationalization,
permanent: true,
);

/// Register theme service.
final themeService = AppThemeService(appStorage);
Get.put<AppThemeService>(themeService, permanent: true);
await themeService.init();
}
87 changes: 87 additions & 0 deletions sabitou_clients/lib/routes/app_routes.dart
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;
}
}
15 changes: 15 additions & 0 deletions sabitou_clients/lib/routes/middleware_page.dart
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;
}
}
Loading

0 comments on commit a35f614

Please sign in to comment.