diff --git a/android/.gitignore b/android/.gitignore index 0a741cb..772c300 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -9,3 +9,4 @@ GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app key.properties +app/google-services.json \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index 6c01a20..44699a6 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -23,20 +23,20 @@ if (flutterVersionName == null) { apply plugin: 'com.android.application' apply plugin: 'kotlin-android' +apply plugin: 'com.google.gms.google-services' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.gow_mobile" - minSdkVersion 16 - targetSdkVersion 30 + minSdkVersion 21 + targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } @@ -56,4 +56,6 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation platform('com.google.firebase:firebase-bom:29.1.0') + implementation 'com.google.firebase:firebase-analytics' } diff --git a/android/build.gradle b/android/build.gradle index c505a86..9f0555d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.5.0' repositories { google() jcenter() @@ -7,6 +7,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.google.gms:google-services:4.3.10' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/lib/main.dart b/lib/main.dart index a3acc43..d0e5922 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,43 +1,39 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:sizer/sizer.dart'; import 'core/init/constants/app_constants.dart'; import 'core/init/constants/language_constants.dart'; import 'product/init/app/app_init.dart'; -import 'product/init/navigation/navigation_manager.dart'; -import 'product/init/navigation/navigation_route.dart'; +import 'product/init/router/app_router.dart'; import 'product/init/theme/app_theme.dart'; -import 'view/shop/tab/shop_tab_view.dart'; Future main() async { await AppInitiliaze().initBeforeAppStart(); runApp( - MultiProvider( - providers: [Provider(create: (context) => NavigationService())], - child: EasyLocalization( - supportedLocales: LanguageConstants.instance.supportedLocales, - path: AppConstants.ASSETS_LANG_PATH, - child: MyApp()), - ), + EasyLocalization( + supportedLocales: LanguageConstants.instance.supportedLocales, + path: AppConstants.ASSETS_LANG_PATH, + child: MyApp()), ); } -// ignore: use_key_in_widget_constructors class MyApp extends StatelessWidget { + MyApp({Key? key}) : super(key: key); + + final appRouter = AppRouter(); + @override Widget build(BuildContext context) { return Sizer( builder: (BuildContext context, Orientation orientation, DeviceType deviceType) { - return MaterialApp( + return MaterialApp.router( localizationsDelegates: context.localizationDelegates, supportedLocales: context.supportedLocales, locale: context.locale, - home: ShopTabView(), - onGenerateRoute: NavigationRoute().generateRoute, - navigatorKey: context.read().navigatorKey, theme: ThemeManager.craeteTheme(AppThemeLight()), + routerDelegate: appRouter.delegate(), + routeInformationParser: appRouter.defaultRouteParser(), ); }, // child:, diff --git a/lib/product/init/navigation/navigation_route.dart b/lib/product/init/navigation/navigation_route.dart index 5f09e58..fbc4b86 100644 --- a/lib/product/init/navigation/navigation_route.dart +++ b/lib/product/init/navigation/navigation_route.dart @@ -10,21 +10,23 @@ class NavigationRoute { Route generateRoute(RouteSettings args) { switch (NavigationEnums.deafult.normalValue(args.name)) { case NavigationEnums.deafult: - return _normalNavigate(const SplashView()); + return _normalNavigate(const SplashPage()); case NavigationEnums.home: - return _normalNavigate(ShopTabView()); + return _normalNavigate(ShopTabPage()); case NavigationEnums.login: - return _fadeRouteNavigate(AuthenticationTabView()); + return _fadeRouteNavigate(AuthenticationTabPage()); default: throw Exception('$this not found'); } } - MaterialPageRoute _normalNavigate(Widget widget, {RouteSettings? settings, bool isFullScreen = false}) { - return MaterialPageRoute(builder: (context) => widget, settings: settings, fullscreenDialog: isFullScreen); + MaterialPageRoute _normalNavigate(Widget widget, + {RouteSettings? settings, bool isFullScreen = false}) { + return MaterialPageRoute( + builder: (context) => widget, settings: settings, fullscreenDialog: isFullScreen); } PageRoute _fadeRouteNavigate(Widget widget, {RouteSettings? settings}) { diff --git a/lib/product/init/network/network_config.dart b/lib/product/init/network/network_config.dart index 759739c..aa22457 100644 --- a/lib/product/init/network/network_config.dart +++ b/lib/product/init/network/network_config.dart @@ -9,7 +9,10 @@ class NetworkConfig { NetworkConfig() { if (Platform.isAndroid) { - baseUrl = 'http://10.0.2.2:3000/'; + // for Genymotion emulator + baseUrl = 'http://10.0.3.2:3000/'; + // for default AVD emulator + // baseUrl = 'http://10.0.2.2:3000/'; } else { baseUrl = 'http://localhost:3000/'; } diff --git a/lib/product/init/network/network_route_paths.dart b/lib/product/init/network/network_route_paths.dart index 58abc48..78520e7 100644 --- a/lib/product/init/network/network_route_paths.dart +++ b/lib/product/init/network/network_route_paths.dart @@ -9,5 +9,5 @@ class NetworkRoutePath { final String login = "login"; final String forgot = "forgot"; - final String signUp = "signup"; + final String signUp = "register"; } diff --git a/lib/product/init/router/app_router.dart b/lib/product/init/router/app_router.dart new file mode 100644 index 0000000..56478fe --- /dev/null +++ b/lib/product/init/router/app_router.dart @@ -0,0 +1,18 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../view/authentication/tab/authentication_tab_view.dart'; +import '../../../view/common/splash/view/splash_view.dart'; +import '../../../view/shop/tab/shop_tab_view.dart'; + +part 'app_router.gr.dart'; + +@MaterialAutoRouter( + replaceInRouteName: 'Page,Route', + routes: [ + AutoRoute(page: SplashPage, initial: true), + AutoRoute(page: AuthenticationTabPage), + AutoRoute(page: ShopTabPage), + ], +) +class AppRouter extends _$AppRouter {} diff --git a/lib/product/init/router/app_router.gr.dart b/lib/product/init/router/app_router.gr.dart new file mode 100644 index 0000000..fc9a8c7 --- /dev/null +++ b/lib/product/init/router/app_router.gr.dart @@ -0,0 +1,96 @@ +// ************************************************************************** +// AutoRouteGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// AutoRouteGenerator +// ************************************************************************** +// +// ignore_for_file: type=lint + +part of 'app_router.dart'; + +class _$AppRouter extends RootStackRouter { + _$AppRouter([GlobalKey? navigatorKey]) : super(navigatorKey); + + @override + final Map pagesMap = { + SplashRoute.name: (routeData) { + return MaterialPageX( + routeData: routeData, child: const SplashPage()); + }, + AuthenticationTabRoute.name: (routeData) { + final args = routeData.argsAs( + orElse: () => const AuthenticationTabRouteArgs()); + return MaterialPageX( + routeData: routeData, child: AuthenticationTabPage(key: args.key)); + }, + ShopTabRoute.name: (routeData) { + final args = routeData.argsAs( + orElse: () => const ShopTabRouteArgs()); + return MaterialPageX( + routeData: routeData, child: ShopTabPage(key: args.key)); + } + }; + + @override + List get routes => [ + RouteConfig(SplashRoute.name, path: '/'), + RouteConfig(AuthenticationTabRoute.name, + path: '/authentication-tab-page'), + RouteConfig(ShopTabRoute.name, path: '/shop-tab-page') + ]; +} + +/// generated route for +/// [SplashPage] +class SplashRoute extends PageRouteInfo { + const SplashRoute() : super(SplashRoute.name, path: '/'); + + static const String name = 'SplashRoute'; +} + +/// generated route for +/// [AuthenticationTabPage] +class AuthenticationTabRoute extends PageRouteInfo { + AuthenticationTabRoute({Key? key}) + : super(AuthenticationTabRoute.name, + path: '/authentication-tab-page', + args: AuthenticationTabRouteArgs(key: key)); + + static const String name = 'AuthenticationTabRoute'; +} + +class AuthenticationTabRouteArgs { + const AuthenticationTabRouteArgs({this.key}); + + final Key? key; + + @override + String toString() { + return 'AuthenticationTabRouteArgs{key: $key}'; + } +} + +/// generated route for +/// [ShopTabPage] +class ShopTabRoute extends PageRouteInfo { + ShopTabRoute({Key? key}) + : super(ShopTabRoute.name, + path: '/shop-tab-page', args: ShopTabRouteArgs(key: key)); + + static const String name = 'ShopTabRoute'; +} + +class ShopTabRouteArgs { + const ShopTabRouteArgs({this.key}); + + final Key? key; + + @override + String toString() { + return 'ShopTabRouteArgs{key: $key}'; + } +} diff --git a/lib/product/init/state/project_global_states.dart b/lib/product/init/state/project_global_states.dart index c00cfd6..aee1c29 100644 --- a/lib/product/init/state/project_global_states.dart +++ b/lib/product/init/state/project_global_states.dart @@ -1,5 +1,4 @@ import 'package:flutter/cupertino.dart'; -import '../navigation/navigation_manager.dart'; import 'package:provider/provider.dart'; import 'package:provider/single_child_widget.dart'; @@ -15,6 +14,6 @@ class ProjectGlobalStates { final List _independentServices = [ Provider(create: (context) => ProductContext(context)), - Provider(create: (_) => NavigationService()), + // Provider(create: (_) => NavigationService()), ]; } diff --git a/lib/product/service/auth/authentication_service.dart b/lib/product/service/auth/authentication_service.dart index 7b076c2..9245f74 100644 --- a/lib/product/service/auth/authentication_service.dart +++ b/lib/product/service/auth/authentication_service.dart @@ -1,6 +1,9 @@ +import 'dart:developer' as developer; + import 'package:vexana/vexana.dart'; import '../../../view/authentication/login/model/login_model.dart'; +import '../../../view/authentication/signup/model/sign_up_model.dart'; import '../../model/email/email_model.dart'; import '../../model/response/normal_response.dart'; import '../../model/user/user_auth_model.dart'; @@ -25,8 +28,7 @@ abstract class IAuthenticationService { IAuthenticationService(this.networkManager); Future loginUserRequest(LoginModel model); - Future createUser(LoginModel model); - + Future createUser(SignUpModel model); Future forgotPassword(EmailModel model); } @@ -35,28 +37,51 @@ class AuthenticationService extends IAuthenticationService { @override Future loginUserRequest(LoginModel model) async { - final response = await networkManager.send(_AuthtenicationPathEnum.login.rawValue, - parseModel: UserAuthModel(), method: RequestType.POST, data: model); + try { + final response = await networkManager.send( + _AuthtenicationPathEnum.login.rawValue, + parseModel: UserAuthModel(), + method: RequestType.POST, + data: model, + ); - return response.data; + return response.data; + } catch (e) { + developer.log('loginUserRequest error: $e'); + return null; + } } @override - Future createUser(LoginModel model) async { - final response = await networkManager.send(_AuthtenicationPathEnum.register.rawValue, - parseModel: UserAuthModel(), method: RequestType.POST, data: model); + Future createUser(SignUpModel model) async { + try { + final response = await networkManager.send( + _AuthtenicationPathEnum.register.rawValue, + parseModel: UserAuthModel(), + method: RequestType.POST, + data: model, + ); - return response.data; + return response.data; + } catch (e) { + developer.log('createUser error: $e'); + return null; + } } @override Future forgotPassword(EmailModel model) async { - final response = await networkManager.send( - _AuthtenicationPathEnum.forgot.rawValue, - parseModel: NormalResponseModel(), - method: RequestType.POST, - data: model); + try { + final response = await networkManager.send( + _AuthtenicationPathEnum.forgot.rawValue, + parseModel: NormalResponseModel(), + method: RequestType.POST, + data: model); - return response.data; + return response.data; + } catch (e) { + developer.log('forgotPassword error: $e'); + return null; + } } } diff --git a/lib/product/widget/button/login_button.dart b/lib/product/widget/button/login_button.dart index f0de010..7cbb286 100644 --- a/lib/product/widget/button/login_button.dart +++ b/lib/product/widget/button/login_button.dart @@ -24,14 +24,19 @@ class _LoginButtonState extends State { return Padding( padding: context.paddingLow, child: ElevatedButton( - style: ElevatedButton.styleFrom(primary: context.colorScheme.onError, padding: context.paddingLow), - onPressed: () async { - _changeLoading(); - await widget.onCompleted(); - _changeLoading(); - }, + style: ElevatedButton.styleFrom( + primary: context.colorScheme.onError, padding: context.paddingLow), + onPressed: _isLoading + ? () {} + : () async { + _changeLoading(); + await widget.onCompleted(); + _changeLoading(); + }, child: Center( - child: _isLoading ? CircularProgressIndicator(color: context.colorScheme.onSecondary) : Text(widget.title), + child: _isLoading + ? CircularProgressIndicator(color: context.colorScheme.onSecondary) + : Text(widget.title), ), ), ); diff --git a/lib/product/widget/form/login_form_widget.dart b/lib/product/widget/form/login_form_widget.dart index 288b4f4..d28f59a 100644 --- a/lib/product/widget/form/login_form_widget.dart +++ b/lib/product/widget/form/login_form_widget.dart @@ -9,18 +9,40 @@ import '../field/password_field.dart'; class LoginFormWidget extends StatefulWidget { const LoginFormWidget({Key? key, required this.onComplete}) : super(key: key); + final Future Function(LoginModel model) onComplete; + @override _LoginFormWidgetState createState() => _LoginFormWidgetState(); } class _LoginFormWidgetState extends State { - final TextEditingController _userNameController = TextEditingController(); - final TextEditingController _passwordController = TextEditingController(); + late final TextEditingController _userNameController; + late final TextEditingController _passwordController; + + late final GlobalKey _loginFormKey; + + late final bool _formAutoValidate; + + @override + void initState() { + super.initState(); + _userNameController = TextEditingController(); + _passwordController = TextEditingController(); - final GlobalKey _loginFormKey = GlobalKey(); + _loginFormKey = GlobalKey(); - bool _formAutoValidate = false; + _formAutoValidate = false; + } + + @override + void dispose() { + _userNameController.dispose(); + _passwordController.dispose(); + + _loginFormKey.currentState?.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { @@ -45,7 +67,12 @@ class _LoginFormWidgetState extends State { Future _checkSignUpForm() async { if (_loginFormKey.currentState?.validate() ?? false) { - await widget.onComplete(LoginModel(email: _userNameController.text, password: _passwordController.text)); + await widget.onComplete( + LoginModel( + email: _userNameController.text.trim(), + password: _passwordController.text, + ), + ); } else { if (_formAutoValidate) return; _formAutoValidate = true; diff --git a/lib/product/widget/form/signup_form_widget.dart b/lib/product/widget/form/signup_form_widget.dart index 381d648..b1fe8de 100644 --- a/lib/product/widget/form/signup_form_widget.dart +++ b/lib/product/widget/form/signup_form_widget.dart @@ -1,34 +1,53 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import '../../init/lang/locale_keys.g.dart'; import 'package:kartal/kartal.dart'; import '../../../../core/components/input/icon_form_field.dart'; import '../../../../core/init/constants/image_constants.dart'; -import '../../../../view/authentication/login/model/login_model.dart'; +import '../../../view/authentication/signup/model/sign_up_model.dart'; +import '../../init/lang/locale_keys.g.dart'; import '../button/login_button.dart'; import '../field/password_field.dart'; -import 'package:kartal/kartal.dart'; -import 'package:easy_localization/easy_localization.dart'; - class SignupFormView extends StatefulWidget { const SignupFormView({Key? key, required this.onComplete}) : super(key: key); - final Future Function(LoginModel model) onComplete; + + final Future Function(SignUpModel model) onComplete; @override _SignupFormViewState createState() => _SignupFormViewState(); } class _SignupFormViewState extends State { - final TextEditingController _userNameController = TextEditingController(); - final TextEditingController _userMailController = TextEditingController(); + late final TextEditingController _userNameController; + late final TextEditingController _userMailController; + late final TextEditingController _passwordController; + + late final GlobalKey _loginFormKey; - final TextEditingController _passwordController = TextEditingController(); + late final bool _formAutoValidate; - final GlobalKey _loginFormKey = GlobalKey(); + @override + void initState() { + super.initState(); + _userNameController = TextEditingController(); + _userMailController = TextEditingController(); + _passwordController = TextEditingController(); + + _loginFormKey = GlobalKey(); + + _formAutoValidate = false; + } - bool _formAutoValidate = false; + @override + void dispose() { + _userNameController.dispose(); + _userMailController.dispose(); + _passwordController.dispose(); + + _loginFormKey.currentState?.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { @@ -67,7 +86,13 @@ class _SignupFormViewState extends State { Future _checkSignUpForm() async { if (_loginFormKey.currentState?.validate() ?? false) { - await widget.onComplete(LoginModel(email: _userNameController.text, password: _passwordController.text)); + await widget.onComplete( + SignUpModel( + displayName: _userNameController.text, + email: _userMailController.text.trim(), + password: _passwordController.text, + ), + ); } else { _changeValidate(); } diff --git a/lib/view/authentication/forgot/viewModel/forgot_view_model.dart b/lib/view/authentication/forgot/viewModel/forgot_view_model.dart index 64a52ff..12910a2 100644 --- a/lib/view/authentication/forgot/viewModel/forgot_view_model.dart +++ b/lib/view/authentication/forgot/viewModel/forgot_view_model.dart @@ -1,8 +1,11 @@ +import 'dart:developer' as developer; + import 'package:flutter/material.dart'; +import 'package:mobx/mobx.dart'; + import '../../../../core/init/app/base/base_view_model.dart'; import '../../../../product/model/email/email_model.dart'; import '../../../../product/service/auth/authentication_service.dart'; -import 'package:mobx/mobx.dart'; part 'forgot_view_model.g.dart'; @@ -22,7 +25,9 @@ abstract class _ForgotViewModelBase with Store, BaseViewModel { void init() {} Future sendToResetEmail() async { - final response = await _authenticationService.forgotPassword(EmailModel(email: textEditingController.text)); - print(response?.message); + final response = + await _authenticationService.forgotPassword(EmailModel(email: textEditingController.text)); + + developer.log('${response?.message}'); } } diff --git a/lib/view/authentication/login/view-model/login_view_model.dart b/lib/view/authentication/login/view-model/login_view_model.dart index aec464b..b61c32b 100644 --- a/lib/view/authentication/login/view-model/login_view_model.dart +++ b/lib/view/authentication/login/view-model/login_view_model.dart @@ -1,8 +1,12 @@ +import 'dart:developer' as developer; + +import 'package:auto_route/auto_route.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mobx/mobx.dart'; import '../../../../core/init/app/base/base_view_model.dart'; +import '../../../../product/init/router/app_router.dart'; import '../../../../product/service/auth/authentication_service.dart'; import '../model/login_model.dart'; @@ -26,6 +30,12 @@ abstract class _LoginViewModelBase with Store, BaseViewModel { Future checkUserLoginRequest(LoginModel model) async { final response = await _authenticationService.loginUserRequest(model); + + developer.log('${response?.email}'); + + if (response != null) { + context.replaceRoute(ShopTabRoute()); + } } void customDispose() {} diff --git a/lib/view/authentication/signup/model/sign_up_model.dart b/lib/view/authentication/signup/model/sign_up_model.dart index ffa7e39..306db13 100644 --- a/lib/view/authentication/signup/model/sign_up_model.dart +++ b/lib/view/authentication/signup/model/sign_up_model.dart @@ -7,9 +7,9 @@ part 'sign_up_model.g.dart'; class SignUpModel extends INetworkModel { final String? email; final String? password; - final String? name; + final String? displayName; - SignUpModel({this.email, this.password, this.name}); + SignUpModel({this.email, this.password, this.displayName}); @override SignUpModel fromJson(Map json) => _$SignUpModelFromJson(json); diff --git a/lib/view/authentication/signup/model/sign_up_model.g.dart b/lib/view/authentication/signup/model/sign_up_model.g.dart index 261c166..32368e0 100644 --- a/lib/view/authentication/signup/model/sign_up_model.g.dart +++ b/lib/view/authentication/signup/model/sign_up_model.g.dart @@ -9,12 +9,12 @@ part of 'sign_up_model.dart'; SignUpModel _$SignUpModelFromJson(Map json) => SignUpModel( email: json['email'] as String?, password: json['password'] as String?, - name: json['name'] as String?, + displayName: json['displayName'] as String?, ); Map _$SignUpModelToJson(SignUpModel instance) => { 'email': instance.email, 'password': instance.password, - 'name': instance.name, + 'displayName': instance.displayName, }; diff --git a/lib/view/authentication/signup/view-model/sign_up_view_model.dart b/lib/view/authentication/signup/view-model/sign_up_view_model.dart index 8e50696..261ea88 100644 --- a/lib/view/authentication/signup/view-model/sign_up_view_model.dart +++ b/lib/view/authentication/signup/view-model/sign_up_view_model.dart @@ -1,9 +1,13 @@ +import 'dart:developer' as developer; + +import 'package:auto_route/auto_route.dart'; import 'package:flutter/cupertino.dart'; import 'package:mobx/mobx.dart'; import '../../../../core/init/app/base/base_view_model.dart'; +import '../../../../product/init/router/app_router.dart'; import '../../../../product/service/auth/authentication_service.dart'; -import '../../login/model/login_model.dart'; +import '../model/sign_up_model.dart'; part 'sign_up_view_model.g.dart'; @@ -21,7 +25,13 @@ abstract class _SignUpViewModelBase with Store, BaseViewModel { @override void init() {} - Future createUser(LoginModel model) async { + Future createUser(SignUpModel model) async { final response = await _authenticationService.createUser(model); + + developer.log('$response'); + + if (response != null) { + context.replaceRoute(ShopTabRoute()); + } } } diff --git a/lib/view/authentication/tab/authentication_tab_view.dart b/lib/view/authentication/tab/authentication_tab_view.dart index 9a84672..60a80b2 100644 --- a/lib/view/authentication/tab/authentication_tab_view.dart +++ b/lib/view/authentication/tab/authentication_tab_view.dart @@ -7,8 +7,8 @@ import '../forgot/view/forgot_view.dart'; import '../login/view/login_view.dart'; import '../signup/view/sign_up_view.dart'; -class AuthenticationTabView extends StatelessWidget { - AuthenticationTabView({Key? key}) : super(key: key); +class AuthenticationTabPage extends StatelessWidget { + AuthenticationTabPage({Key? key}) : super(key: key); final List _tabbarView = [const SignUpView(), const LoginView(), const ForgotView()]; diff --git a/lib/view/common/splash/view/splash_view.dart b/lib/view/common/splash/view/splash_view.dart index 7443908..a035fa2 100644 --- a/lib/view/common/splash/view/splash_view.dart +++ b/lib/view/common/splash/view/splash_view.dart @@ -8,8 +8,8 @@ import '../../../../product/base/base_state.dart'; import '../../../../product/init/lang/locale_keys.g.dart'; import '../viewModel/splash_view_model.dart'; -class SplashView extends StatelessWidget with BaseState { - const SplashView({Key? key}) : super(key: key); +class SplashPage extends StatelessWidget with BaseState { + const SplashPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/view/common/splash/viewModel/splash_view_model.dart b/lib/view/common/splash/viewModel/splash_view_model.dart index dc25020..3449896 100644 --- a/lib/view/common/splash/viewModel/splash_view_model.dart +++ b/lib/view/common/splash/viewModel/splash_view_model.dart @@ -1,11 +1,10 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:kartal/kartal.dart'; import 'package:mobx/mobx.dart'; -import 'package:provider/provider.dart'; import '../../../../core/init/app/base/base_view_model.dart'; -import '../../../../product/init/navigation/navigation_enums.dart'; -import '../../../../product/init/navigation/navigation_manager.dart'; +import '../../../../product/init/router/app_router.dart'; part 'splash_view_model.g.dart'; @@ -17,11 +16,13 @@ abstract class _SplashViewModelBase with Store, BaseViewModel { @override void init() { + // TODO: Need to check if the user logged in or not navigateToHome(); } Future navigateToHome() async { await Future.delayed(context.durationSlow); - context.read().navigateToPageClear(path: NavigationEnums.login.rawValue); + + context.replaceRoute(AuthenticationTabRoute()); } } diff --git a/lib/view/shop/tab/shop_tab_view.dart b/lib/view/shop/tab/shop_tab_view.dart index 5cdc504..531ad9c 100644 --- a/lib/view/shop/tab/shop_tab_view.dart +++ b/lib/view/shop/tab/shop_tab_view.dart @@ -1,14 +1,14 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:kartal/src/context_extension.dart'; +import 'package:kartal/kartal.dart'; import '../../../core/init/constants/image_constants.dart'; import '../../../product/utility/padding/padding_all.dart'; import '../../../product/utility/size/widget_size.dart'; import 'model/tab_model.dart'; -class ShopTabView extends StatelessWidget { - ShopTabView({Key? key}) : super(key: key); +class ShopTabPage extends StatelessWidget { + ShopTabPage({Key? key}) : super(key: key); final _items = TabModels.create().tabItems; @@ -25,7 +25,8 @@ class ShopTabView extends StatelessWidget { ), body: TabBarView(children: _items.map((e) => e.page).toList()), bottomNavigationBar: BottomAppBar( - child: TabBar(tabs: _items.map((e) => Tab(text: e.title.tr(), icon: Icon(e.icon))).toList()), + child: + TabBar(tabs: _items.map((e) => Tab(text: e.title.tr(), icon: Icon(e.icon))).toList()), ), ), ); @@ -49,7 +50,8 @@ class ShopTabView extends StatelessWidget { padding: PagePaddingAll.halfNormal(), child: FittedBox( child: Text('5', - style: context.textTheme.subtitle1?.copyWith(color: context.colorScheme.onSecondary))), + style: context.textTheme.subtitle1 + ?.copyWith(color: context.colorScheme.onSecondary))), )), ), ) diff --git a/pubspec.lock b/pubspec.lock index 55d82b6..453eb13 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -28,7 +28,7 @@ packages: name: args url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.3.0" async: dependency: transitive description: @@ -43,6 +43,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.2.4" + auto_route_generator: + dependency: "direct dev" + description: + name: auto_route_generator + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.3" boolean_selector: dependency: transitive description: @@ -98,14 +105,14 @@ packages: name: built_collection url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "5.1.1" built_value: dependency: transitive description: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.0.4" + version: "8.1.4" cached_network_image: dependency: "direct main" description: @@ -154,7 +161,7 @@ packages: name: cli_util url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.3.5" clock: dependency: transitive description: @@ -182,7 +189,7 @@ packages: name: convert url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" crypto: dependency: transitive description: @@ -203,14 +210,14 @@ packages: name: csv url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "5.0.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.4" dart_style: dependency: transitive description: @@ -231,7 +238,7 @@ packages: name: device_info url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.3" device_info_platform_interface: dependency: transitive description: @@ -240,12 +247,19 @@ packages: source: hosted version: "2.0.1" device_preview: - dependency: "direct dev" + dependency: "direct main" description: name: device_preview url: "https://pub.dartlang.org" source: hosted version: "1.0.0" + diacritic: + dependency: transitive + description: + name: diacritic + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" dio: dependency: transitive description: @@ -287,14 +301,14 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.2" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" + version: "6.1.2" fixnum: dependency: transitive description: @@ -363,7 +377,7 @@ packages: name: font_awesome_flutter url: "https://pub.dartlang.org" source: hosted - version: "9.0.0" + version: "9.2.0" freezed_annotation: dependency: transitive description: @@ -384,7 +398,7 @@ packages: name: glob url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" google_fonts: dependency: "direct main" description: @@ -412,7 +426,7 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.1" + version: "0.13.4" http_multi_server: dependency: transitive description: @@ -456,7 +470,7 @@ packages: source: hosted version: "4.4.0" json_serializable: - dependency: "direct main" + dependency: "direct dev" description: name: json_serializable url: "https://pub.dartlang.org" @@ -468,7 +482,7 @@ packages: name: kartal url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.3.1" lints: dependency: transitive description: @@ -489,7 +503,7 @@ packages: name: logging url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" lottie: dependency: "direct main" description: @@ -503,7 +517,7 @@ packages: name: mask_text_input_formatter url: "https://pub.dartlang.org" source: hosted - version: "2.0.0-nullsafety.2" + version: "2.1.0" matcher: dependency: transitive description: @@ -531,7 +545,7 @@ packages: name: mime url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" mobx: dependency: "direct main" description: @@ -566,14 +580,49 @@ packages: name: package_config url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" - package_info: + version: "2.0.2" + package_info_plus: dependency: transitive description: - name: package_info + name: package_info_plus url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "1.4.0" + package_info_plus_linux: + dependency: transitive + description: + name: package_info_plus_linux + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + package_info_plus_macos: + dependency: transitive + description: + name: package_info_plus_macos + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + package_info_plus_web: + dependency: transitive + description: + name: package_info_plus_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + package_info_plus_windows: + dependency: transitive + description: + name: package_info_plus_windows + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" path: dependency: transitive description: @@ -601,63 +650,77 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.9" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + path_provider_ios: + dependency: transitive + description: + name: path_provider_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.7" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.5" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.5" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.3" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.5" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" + version: "1.11.1" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.0.2" + version: "4.4.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.2" pool: dependency: transitive description: @@ -671,7 +734,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.1" + version: "4.2.4" provider: dependency: "direct main" description: @@ -685,14 +748,14 @@ packages: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" pubspec_parse: dependency: transitive description: name: pubspec_parse url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.2.0" retry: dependency: transitive description: @@ -713,14 +776,14 @@ packages: name: sembast url: "https://pub.dartlang.org" source: hosted - version: "3.0.0+4" + version: "3.1.2" share: dependency: transitive description: name: share url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.4" shared_preferences: dependency: transitive description: @@ -755,7 +818,7 @@ packages: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.3" shared_preferences_platform_interface: dependency: transitive description: @@ -769,7 +832,7 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.3" shared_preferences_windows: dependency: transitive description: @@ -783,7 +846,7 @@ packages: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" shelf_web_socket: dependency: transitive description: @@ -921,42 +984,56 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.3" + version: "6.0.20" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.15" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.15" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "3.0.0" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "3.0.0" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.5" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.8" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "3.0.0" uuid: dependency: transitive description: @@ -984,7 +1061,7 @@ packages: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" web_socket_channel: dependency: transitive description: @@ -998,21 +1075,21 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.4.1" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.2.0+1" xml: dependency: transitive description: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.0.2" + version: "5.3.1" yaml: dependency: transitive description: @@ -1022,4 +1099,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.15.0 <3.0.0" - flutter: ">=2.10.0-0" + flutter: ">=2.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 7212859..6ced300 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,20 +1,8 @@ name: gow_mobile description: A new Flutter project. -# The following line prevents the package from being accidentally published to -# pub.dev using `pub publish`. This is preferred for private packages. publish_to: "none" # Remove this line if you wish to publish to pub.dev -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: @@ -23,48 +11,49 @@ environment: dependencies: flutter: sdk: flutter - cupertino_icons: ^1.0.2 + + # Translations easy_localization: ^3.0.0 easy_localization_loader: ^1.0.0 - flutter_mobx: ^2.0.1 - font_awesome_flutter: ^9.0.0 - # Google - vexana: ^2.2.1 + # State Management + flutter_mobx: ^2.0.1 mobx: ^2.0.0 + provider: ^6.0.0 # Route - auto_route: ^3.1.3 + auto_route: ^3.2.4 - # Utility - lottie: ^1.1.0 + # Favourites kartal: ^2.0.0 - flutter_svg: ^1.0.3 + vexana: ^2.2.1 + + # Utility cached_network_image: ^3.1.0 - provider: ^6.0.0 + cupertino_icons: ^1.0.2 + device_preview: ^1.0.0 + flutter_svg: ^1.0.3 + font_awesome_flutter: ^9.0.0 google_fonts: ^2.1.0 - sizer: ^2.0.15 - json_serializable: ^6.1.1 json_annotation: ^4.4.0 + lottie: ^1.1.0 + sizer: ^2.0.15 dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^1.0.4 + # Code generators + auto_route_generator: ^3.2.3 build_runner: ^2.1.1 + json_serializable: ^6.1.1 mobx_codegen: ^2.0.2 - device_preview: ^1.0.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec -# The following section is specific to Flutter. + # Rules + flutter_lints: ^1.0.4 + flutter: - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true - # To add assets to your application, add an assets section, like this: assets: - assets/translations/ - assets/image/ diff --git a/test/service/auth_service_test.dart b/test/service/auth_service_test.dart new file mode 100644 index 0000000..3bf0c84 --- /dev/null +++ b/test/service/auth_service_test.dart @@ -0,0 +1,60 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:gow_mobile/product/init/network/project_network_manager.dart'; +import 'package:gow_mobile/product/model/email/email_model.dart'; +import 'package:gow_mobile/product/service/auth/authentication_service.dart'; +import 'package:gow_mobile/view/authentication/login/model/login_model.dart'; +import 'package:gow_mobile/view/authentication/signup/model/sign_up_model.dart'; + +void main() { + IAuthenticationService? loginService; + setUp(() { + loginService = AuthenticationService(ProjectNetworkManager.instance.networkManager); + }); + test('loginUserRequest method test with auth user.', () async { + final checkUser = await loginService?.loginUserRequest( + LoginModel(email: 'ali@veli.com', password: '123456'), + ); + + expect(checkUser, isNotNull); + }); + + test('loginUserRequest method test with error secenario', () async { + final checkUser = await loginService?.loginUserRequest( + LoginModel(email: 'ali@veli.com', password: '12345666'), + ); + + expect(checkUser, isNull); + }); + + test('createUser method test with success', () async { + final checkUser = await loginService?.createUser( + SignUpModel(displayName: 'ali', email: 'ali@mali.com', password: '123456'), + ); + + expect(checkUser, isNotNull); + }); + + test('createUser method test with error secenario', () async { + final checkUser = await loginService?.createUser( + SignUpModel(displayName: 'ali', email: 'ali@sali', password: '123456'), + ); + + expect(checkUser, isNull); + }); + + test('createUser method test with error secenario', () async { + final checkUser = await loginService?.createUser( + SignUpModel(displayName: 'ali', email: 'ali@sali.com', password: '1'), + ); + + expect(checkUser, isNull); + }); + + test('forgotPassword method test with success', () async { + final checkUser = await loginService?.forgotPassword( + EmailModel(email: 'ali@veli.com'), + ); + + expect(checkUser, isNotNull); + }); +} diff --git a/test/service/login_service_test.dart b/test/service/login_service_test.dart deleted file mode 100644 index d11579c..0000000 --- a/test/service/login_service_test.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:gow_mobile/product/init/network/project_network_manager.dart'; -import 'package:gow_mobile/product/model/email/email_model.dart'; -import 'package:gow_mobile/product/service/auth/authentication_service.dart'; -import 'package:gow_mobile/view/authentication/login/model/login_model.dart'; - -void main() { - IAuthenticationService? loginService; - setUp(() { - loginService = AuthenticationService(ProjectNetworkManager.instance.networkManager); - }); - test('loginUserRequest method test with auth user.', () async { - final checkUser = await loginService?.loginUserRequest(LoginModel(email: 'vb@test.com', password: '123456')); - - expect(checkUser, isNotNull); - }); - - test('loginUserRequest method test with error secenario', () async { - final checkUser = await loginService?.loginUserRequest(LoginModel(email: 'vb@test.com', password: '1223456')); - - expect(checkUser, isNotNull); - }); - - test('createUser method test with sucess', () async { - final checkUser = await loginService?.createUser(LoginModel(email: 'yarita4619@aline9.com', password: '123456')); - - expect(checkUser, isNotNull); - }); - - test('forgotUser method test with sucess', () async { - final checkUser = await loginService?.forgotPassword(EmailModel(email: 'yarita4619@aline9.com')); - - expect(checkUser, isNotNull); - }); -}