Skip to content

Commit

Permalink
Pulled origin main
Browse files Browse the repository at this point in the history
  • Loading branch information
Eldar2021 committed Feb 3, 2024
2 parents c6bab47 + c6f0dda commit 83e832b
Show file tree
Hide file tree
Showing 40 changed files with 428 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analyze_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.16.8"
flutter-version: "3.16.9"
channel: "stable"
- run: flutter doctor

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
cache: gradle
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.16.8"
flutter-version: "3.16.9"
channel: "stable"
- run: flutter doctor

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.16.8"
flutter-version: "3.16.9"
channel: "stable"
architecture: x64
- run: flutter doctor
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.16.8"
flutter-version: "3.16.9"
channel: stable
- uses: actions/setup-java@v3
with:
Expand All @@ -32,10 +32,10 @@ jobs:
with:
api-level: 29
arch: x86_64
script: melos integration-test-app
script: melos integration-test

- uses: actions/upload-artifact@v3
if: always()
with:
name: my-artifact
path: ./app/screenshots/*
path: ./screenshots/*
4 changes: 2 additions & 2 deletions .github/workflows/ci_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.16.8"
flutter-version: "3.16.9"
channel: stable
- run: flutter doctor -v

Expand All @@ -41,7 +41,7 @@ jobs:
os_version: "16.2"

- name: Integration Test
run: melos integration-test-app
run: melos integration-test

- uses: actions/upload-artifact@v3
if: always()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ melos test
## Integration tests
* run integration tests in `test_driver` directory:
```shell
melos integration-test-app
melos integration-test
```

## Fmt
Expand Down
30 changes: 30 additions & 0 deletions app/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "67457e669f79e9f8d13d7a68fe09775fefbb79f4"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
- platform: web
create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
1 change: 1 addition & 0 deletions app/lib/app/app.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export 'logic/app_cubit.dart';
export 'logic/auth_cubit.dart';
export 'router/app_router.dart';
export 'router/parse_parameters.dart';
export 'services/app_service.dart';
export 'services/auth_service.dart';
export 'services/theme_service.dart';
Expand Down
2 changes: 2 additions & 0 deletions app/lib/app/logic/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ class AuthCubit extends Cubit<AuthState> {
await service.changeGender(gender);
emit(state.copyWith(user: state.user?.copyWith(gender: gender)));
}

bool get isAuthedticated => state.user != null;
}
222 changes: 174 additions & 48 deletions app/lib/app/router/app_router.dart
Original file line number Diff line number Diff line change
@@ -1,54 +1,180 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';

import 'package:my_quran/models/models.dart';
import 'package:my_quran/app/app.dart';
import 'package:my_quran/modules/modules.dart';

class AppRouter {
const AppRouter();

static const String main = '/';
static const String home = '/home';
static const String hatim = '/hatim';
static const String quran = '/quran';
static const String read = '/read';
static const String login = '/login';
static const String signIn = '/sign-in';

static const String settingsPage = '/settings';
static const String langSettings = '/lang-settings';
static const String genderSettings = '/gender-settings';
static const String themeSettings = '/theme-settings';
static const String aboutUs = '/about-us';
static const String contactUs = '/contect-us';
static const String developers = '/developers';
static const String devModeView = '/dev-mode-view';

static Route<void> onGenerateRoute(RouteSettings settings, User? user) {
return switch (settings.name) {
main => CupertinoPageRoute(builder: (_) => user != null ? const MainView() : const LoginView()),
home => CupertinoPageRoute(builder: (_) => const HomeView()),
hatim => CupertinoPageRoute(builder: (_) => const HatimView()),
quran => CupertinoPageRoute(builder: (_) => const QuranView()),
login => CupertinoPageRoute(builder: (_) => const LoginView()),
signIn => CupertinoPageRoute(builder: (_) => const SignInView()),
settingsPage => CupertinoPageRoute(builder: (_) => const SettingsView()),
aboutUs => CupertinoPageRoute(builder: (_) => const AboutUsVuew()),
contactUs => CupertinoPageRoute(builder: (_) => const ContactUsView()),
developers => CupertinoPageRoute(builder: (_) => const DevelopersView()),
genderSettings => CupertinoPageRoute(builder: (_) => const GenderSettingView()),
langSettings => CupertinoPageRoute(builder: (_) => const LangSettingsView()),
themeSettings => CupertinoPageRoute(builder: (_) => const ThemeSettingsView()),
devModeView => CupertinoPageRoute(builder: (_) => const DevModeView()),
read => CupertinoPageRoute<bool>(
builder: (_) {
final args = settings.arguments!;
return ReadView(
(args as Map<String, dynamic>)['pages'] as List<int>,
isHatim: args['isHatim'] as bool,
);
},
final _rootNavigatorKey = GlobalKey<NavigatorState>();
final _sectionNavigatorKey1 = GlobalKey<NavigatorState>(debugLabel: 'home');
final _sectionNavigatorKey2 = GlobalKey<NavigatorState>(debugLabel: 'quran');
final _sectionNavigatorKey3 = GlobalKey<NavigatorState>(debugLabel: 'quran-audio');
final _sectionNavigatorKey4 = GlobalKey<NavigatorState>(debugLabel: 'settings');

@immutable
final class AppRouter {
const AppRouter._();

static const home = 'home';
static const hatim = 'hatim';
static const quran = 'quran';
static const quranAudio = 'quran-audio';

static const read = 'read';
static const hatimRead = 'hatim-read';
static const login = 'login';

static const settingsPage = 'settings';
static const langSettings = 'lang-settings';
static const genderSettings = 'gender-settings';
static const themeSettings = 'theme-settings';
static const aboutUs = 'about-us';
static const contactUs = 'contect-us';
static const developers = 'developers';
static const devModeView = 'dev-mode-view';

static final router = GoRouter(
initialLocation: '/home',
navigatorKey: _rootNavigatorKey,
debugLogDiagnostics: true,
routes: [
GoRoute(
path: '/',
builder: (context, state) => const Scaffold(
body: Center(child: Text('Init')),
),
_ => throw Exception('no builder specified for route named: [${settings.name}]'),
};
),
GoRoute(
path: '/$login',
name: login,
builder: (context, state) => const LoginView(),
),
GoRoute(
path: '/$devModeView',
name: devModeView,
builder: (context, state) => const DevModeView(),
),
StatefulShellRoute.indexedStack(
builder: (context, state, navigationShell) => MainView(navigationShell),
branches: [
StatefulShellBranch(
navigatorKey: _sectionNavigatorKey1,
routes: [
GoRoute(
path: '/$home',
name: home,
builder: (context, state) => const HomeView(),
routes: homeSubRoutes,
),
],
),
StatefulShellBranch(
navigatorKey: _sectionNavigatorKey2,
routes: [
GoRoute(
path: '/$quran',
name: quran,
builder: (context, state) => const QuranView(),
routes: quranSubRoutes,
),
],
),
StatefulShellBranch(
navigatorKey: _sectionNavigatorKey3,
routes: [
GoRoute(
path: '/$quranAudio',
name: quranAudio,
builder: (context, state) => const QuranAudioView(),
),
],
),
StatefulShellBranch(
navigatorKey: _sectionNavigatorKey4,
routes: [
GoRoute(
path: '/$settingsPage',
name: settingsPage,
builder: (context, state) => const SettingsView(),
routes: settingsSubRoutes,
),
],
),
],
),
],
redirect: (context, state) {
return !context.read<AuthCubit>().isAuthedticated ? '/$login' : null;
},
);

static List<RouteBase> get homeSubRoutes {
return [
GoRoute(
path: hatim,
name: hatim,
builder: (context, state) => const HatimView(),
routes: [
GoRoute(
path: '$hatimRead/:isHatim/:pages',
name: hatimRead,
parentNavigatorKey: _rootNavigatorKey,
builder: (context, state) {
final args = ParseParams.parseRead(state.pathParameters);
return ReadView(args.$1, isHatim: args.$2);
},
),
],
),
];
}

static List<RouteBase> get quranSubRoutes {
return [
GoRoute(
path: '$read/:isHatim/:pages',
name: read,
parentNavigatorKey: _rootNavigatorKey,
builder: (context, state) {
final args = ParseParams.parseRead(state.pathParameters);
return ReadView(args.$1, isHatim: args.$2);
},
),
];
}

static List<RouteBase> get settingsSubRoutes {
return [
GoRoute(
path: genderSettings,
name: genderSettings,
builder: (context, state) => const GenderSettingView(),
),
GoRoute(
path: langSettings,
name: langSettings,
builder: (context, state) => const LangSettingsView(),
),
GoRoute(
path: themeSettings,
name: themeSettings,
builder: (context, state) => const ThemeSettingsView(),
),
GoRoute(
path: aboutUs,
name: aboutUs,
builder: (context, state) => const AboutUsVuew(),
),
GoRoute(
path: contactUs,
name: contactUs,
builder: (context, state) => const ContactUsView(),
),
GoRoute(
path: developers,
name: developers,
builder: (context, state) => const DevelopersView(),
),
];
}
}
20 changes: 20 additions & 0 deletions app/lib/app/router/parse_parameters.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'dart:developer';

import 'package:meta/meta.dart';

@immutable
final class ParseParams {
const ParseParams._();

static (List<int>, bool) parseRead(Map<String, String> args) {
try {
final isHatim = args['isHatim'] == 'true';
final p1 = args['pages'] ?? '[1]';
final pages = p1.substring(1, p1.length - 1).split(',').map(int.parse).toList();
return (pages, isHatim);
} catch (e) {
log(e.toString());
return ([1], false);
}
}
}
7 changes: 2 additions & 5 deletions app/lib/app/view/app_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,14 @@ class QuranApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MaterialApp(
return MaterialApp.router(
title: 'MyQuranKhatm',
debugShowCheckedModeBanner: false,
locale: context.watch<AppCubit>().state.currentLocale,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: context.watch<AppCubit>().state.theme.themeData,
onGenerateRoute: (settings) => AppRouter.onGenerateRoute(
settings,
context.read<AuthCubit>().state.user,
),
routerConfig: AppRouter.router,
);
}
}
Loading

0 comments on commit 83e832b

Please sign in to comment.