Skip to content

Commit

Permalink
project is working without any module implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmourad98 committed Jan 2, 2023
1 parent 9ec48f4 commit 71d2457
Show file tree
Hide file tree
Showing 16 changed files with 488 additions and 122 deletions.
45 changes: 0 additions & 45 deletions lib/app/app.dart

This file was deleted.

1 change: 0 additions & 1 deletion lib/app/app_route_names.dart

This file was deleted.

18 changes: 0 additions & 18 deletions lib/app/app_router.dart

This file was deleted.

80 changes: 65 additions & 15 deletions lib/app_entry_point.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,73 @@
import 'dart:io';

import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:stacked/stacked.dart';
import 'package:untitled05/core/app_routing/app_router.dart';
import 'package:untitled05/core/delegations/helpers/app_entry_point_environment_helper.dart';
import 'package:untitled05/core/delegations/helpers/base_view_model_helper.dart';
import 'package:untitled05/core/layers/data/enums/environment_type.dart';

class AppEntryPoint extends HookWidget {
final EnvironmentType environmentType;

import 'app/app.dart';
const AppEntryPoint(this.environmentType, {Key? key,}) : super(key: key,);

class AppRoot{
static const _myApp = MyApp();
@override
Widget build(BuildContext context,) {
///Hooks
late final TransitionBuilder botToastBuilder;
useEffect(
() {
botToastBuilder = BotToastInit();
_deviceOrientation();
return () => _dispose();
},
const [],
);

static init() async{
HttpOverrides.global = MyHttpOverrides();
WidgetsFlutterBinding.ensureInitialized();
runApp(_myApp,);
///Builders
return ViewModelBuilder<_AppEntryPointViewModel>.reactive(
viewModelBuilder: () => _AppEntryPointViewModel(),
onModelReady: (viewModel,) => viewModel.onModelReady(),
fireOnModelReadyOnce: true,
builder: (_, viewModel, __,) => MaterialApp(
builder: (buildContext, childWidget,) {
childWidget = botToastBuilder(buildContext, childWidget,);
return childWidget.renderTreeHandler(
environmentType,
const [],
);
},
navigatorObservers: [
AppRouter.instance.navObserver,
BotToastNavigatorObserver(),
],
onGenerateRoute: AppRouter.onGenerateRoute,
navigatorKey: AppRouter.instance.navKey,
debugShowCheckedModeBanner: false,
useInheritedMediaQuery: true,
),
);
}

void _dispose() {}

void _deviceOrientation() {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp,],);
}
}

class MyHttpOverrides extends HttpOverrides{
class _AppEntryPointViewModel extends ReactiveViewModel with BaseViewModelHelper {
@override
HttpClient createHttpClient(SecurityContext? context,){
return super.createHttpClient(context,)
..badCertificateCallback = (X509Certificate cert, String host, int port,) => true;
}
}
void onClose() {}

@override
void onModelReady() {}

@override
void dispose() { super.dispose(); }

@override
List<ReactiveServiceMixin> get reactiveServices => [];
}
3 changes: 3 additions & 0 deletions lib/core/app_routing/app_route_names.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class AppRouteNames{
//static const phoneVerificationRoute = "phone-verification";
}
28 changes: 28 additions & 0 deletions lib/core/app_routing/app_router.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/material.dart';

class AppRouter{
AppRouter._();
static AppRouter? _appRouter;
static AppRouter get instance { _appRouter ??= AppRouter._(); return _appRouter!; }

final GlobalKey<NavigatorState> _navKey = GlobalKey<NavigatorState>();
GlobalKey<NavigatorState> get navKey => _navKey;
final NavigatorObserver _navObserver = NavigatorObserver();
NavigatorObserver get navObserver => _navObserver;

static Route? onGenerateRoute(RouteSettings routeSettings,){
switch (routeSettings.name){
// case AppRouteNames.phoneVerificationRoute:
// return _routeTo(() => const PhoneVerificationRoute(),);
default:
return _routeTo(() => const SizedBox.expand(child: Center(child: Text("No View",),),),);
}
}

static Route? _routeTo(Widget Function() widgetFunction,){
return MaterialPageRoute(
builder: (_,) => widgetFunction(),
);
}

}
58 changes: 58 additions & 0 deletions lib/core/delegations/helpers/app_colors_helper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';

class AppColors {
static const Color kcPrimaryColor = Color(0xff22A45D,);
static const Color kcMediumGreyColor = Color(0xff868686,);
static const Color redColor = Color.fromARGB(255, 225, 16, 16,);
static const Color redColor_1 = Color.fromARGB(255, 231, 29, 115,);
static const Color blueColor_1 = Color.fromARGB(255, 54, 169, 225,);
static const Color blueColor_2 = Color.fromARGB(255, 45, 46, 131,);
static const Color whiteColor = Color.fromARGB(255, 255, 255, 255,);
static const Color transparentColor = Colors.transparent;
static const Color blackColor = Color.fromARGB(255, 14, 13, 13,);
static const Color blackShadowColor = Color.fromARGB(255, 207, 203, 203,);
static const Color blackShadowColor_2 = Color.fromARGB(255, 224, 223, 223,);
static const Color greyColor = Color.fromARGB(255, 225, 222, 222,);
static const Color greyBackgroundColor = Color.fromARGB(255, 241, 239, 239,);
static const Color yellowColor_1 = Color.fromARGB(255, 243, 146, 0,);
static const Color greyIosBottomSheetBackgroundColor = Color.fromRGBO(248, 248, 248, 0.82,);
static const Color blueColor = Color.fromRGBO(59, 134, 255, 1,);
static const Color blue100Color = Color.fromRGBO(3, 97, 219, 1,);
static const Color blue150Color = Color.fromRGBO(0, 47, 108, 1,);
static const Color blue200Color = Color.fromRGBO(0, 45, 110, 1,);
static const Color blue300Color = Color.fromRGBO(57, 45, 93, 1,);
static const Color blueAccentColor = Color.fromRGBO(0, 180, 225, 1,);
static const Color blueNbsColor = Color.fromRGBO(36, 135, 201, 1,);
static const Color turquoiseColor = Color.fromRGBO(0, 157, 175, 1,);
static const Color cyanColor = Color.fromRGBO(0, 175, 162, 1,);
static const Color sendMessageColor = Color.fromRGBO(229, 255, 253, 1,);
static const Color grey25Color = Color.fromRGBO(248, 248, 248, 1,);
static const Color grey50Color = Color.fromRGBO(246, 246, 246, 1,);
static const Color grey75Color = Color.fromRGBO(241, 241, 241, 1,);
static const Color grey100Color = Color.fromRGBO(230, 230, 230, 1,);
static const Color grey200Color = Color.fromRGBO(165, 165, 165, 1,);
static const Color grey500Color = Color.fromRGBO(117, 120, 123, 1,);
static const Color greenColor = Color.fromRGBO(43, 159, 0, 1,);
static const Color newGreenColor = Color.fromRGBO(0, 210, 122, 1.0,);
static const Color markerGreenColor = Color.fromRGBO(0, 175, 162, 1,);
static const Color darkGreenColor = Color.fromRGBO(0, 110, 102, 1,);
static const Color lightOrangeColor = Color.fromRGBO(255, 221, 0, 1,);
static const Color orangeColor = Color.fromRGBO(255, 143, 28, 1,);
static const Color deepOrangeColor = Color.fromRGBO(128, 66, 2, 1.0,);
static const Color darkOrangeColor = Color.fromRGBO(255, 196, 0, 1,);
static const Color brightRedColor = Color.fromRGBO(255, 88, 93, 1,);
static const Color brightPinkColor = Color.fromRGBO(193, 9, 150, 1.0,);
static const Color grey = Color.fromRGBO(0, 47, 108, 0.38,);
static const Color deemedRedColor = Color.fromRGBO(217, 5, 22, 1.0,);
static const Color notificationRedColor = Color.fromRGBO(255, 0, 0, 1,);
static const Color mainYellowColor = Color(0xFFFFBE19,);
static const Color secondMainYellowColor = Color(0xFFE7907D,);
static const Color mainGreenLightColor = Color.fromRGBO(76, 156, 31, 1,);
static const Color mainAppBarColor = Color.fromRGBO(74, 160, 69, 1,);
static const Color mainSeparatorColor = Color.fromRGBO(74, 160, 69, 0.23,);
static const Color mainGreenDarkColor = Color.fromRGBO(31, 110, 26, 1,);
static const Color mainBackgroundColor = Color.fromRGBO(248, 248, 248, 1,);
static const Color mainGreyColor = Color.fromRGBO(48, 48, 48, 1.0,);
static const Color profilePhotoGreyColor = Color.fromRGBO(175, 172, 172, 1.0,);
static const Color graspGreenColor = Color.fromRGBO(149, 193, 31, 1.0,);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:dartz/dartz.dart';
import 'package:flutter/material.dart';
import 'package:untitled05/core/layers/data/enums/environment_type.dart';
import 'package:untitled05/core/layers/presentation/shared_views/app_life_cycle_wrapper.dart';

extension AppEntryPointEnvHelper on Widget? {
///Here all the test env wrapping widgets must be implemented !
Widget renderTreeHandler(EnvironmentType environmentType, List<Tuple3<AppLifecycleState, AppLifecycleState, Function>> appliedStateChangedProcedures,) {
final extShadow = this ?? const SizedBox.expand();

///App Lifecycle manger
final Widget mainWidget = AppLifeCycleWrapper(extShadow, appliedStateChangedProcedures,);

///
switch (environmentType) {

///ProductionMode
case EnvironmentType.production:
case EnvironmentType.acceptance:

///Development Mode
case EnvironmentType.testing:
return mainWidget;

///Development Mode
case EnvironmentType.development:
return mainWidget;
}
}
}
35 changes: 35 additions & 0 deletions lib/core/delegations/helpers/base_view_model_helper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart';
import 'package:stacked/stacked.dart';

import 'package:untitled05/core/layers/presentation/shared_views/custom_circular_loader.dart';

mixin BaseViewModelHelper on BaseViewModel {
void onModelReady();
void onClose();

static Future<T> runGenericBusyFutureAsFuture<T>(Future<T> Function() asyncFunction,) async {
BotToast.showCustomLoading(
toastBuilder: (cancelFunc,) => const CustomLoader(),
crossPage: true,
clickClose: true,
align: Alignment.center,
);
final T _response = await asyncFunction();
BotToast.closeAllLoading();
return _response;
}

///Run multiple futures
Future runFutureMethods(Future<void> Function() asyncFunction, {Object? busyObject,}) async {
await runBusyFuture(asyncFunction(), busyObject: busyObject,);
return;
}

///Run multiple futures
Future waitMultipleFutures(List<Future> futureList, [Object? busyObject,]) async {
await runBusyFuture(Future.wait(futureList, eagerError: true,), busyObject: busyObject,);
return;
}
}
7 changes: 7 additions & 0 deletions lib/core/delegations/services/app_life_cycle_services.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'dart:async';
import 'dart:ui';
import 'package:dartz/dartz.dart';

class AppLifeCycleService {
static StreamController<Tuple2<AppLifecycleState?, AppLifecycleState?>> appLifeCycleListenableStreamController = StreamController.broadcast();
}
1 change: 1 addition & 0 deletions lib/core/layers/data/enums/environment_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enum EnvironmentType { production, acceptance, testing, development, }
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'dart:developer';
import 'package:dartz/dartz.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:untitled05/core/delegations/services/app_life_cycle_services.dart';

class AppLifeCycleWrapper extends HookWidget {
final Widget child;
final List<Tuple3<AppLifecycleState, AppLifecycleState, Function>> appliedStateChangedProcedures;

const AppLifeCycleWrapper(this.child, this.appliedStateChangedProcedures, {Key? key,}) : super(key: key);

@override
Widget build(BuildContext context) {
///Hooks
useOnAppLifecycleStateChange(_onAppLifeCycleIsChanged,);

///return widget
return child;
}

void _onAppLifeCycleIsChanged(AppLifecycleState? prevState, AppLifecycleState? currentState,) {
log(prevState.toString(), name: 'AppStateLog-PrevState',);
log(currentState.toString(), name: 'AppStateLog-CurrentState',);

///AppLife cycle stream syncing
AppLifeCycleService.appLifeCycleListenableStreamController.add(Tuple2(prevState, currentState,),);

///Managing entry point level actions
for (final element in appliedStateChangedProcedures) {
if (element.value1 == prevState && element.value2 == currentState) {
element.value3.call();
}
}
}
}
Loading

0 comments on commit 71d2457

Please sign in to comment.