chore : delete auth package because each project has different auth , must be separated auth logic
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import 'package:rasadyar_auth/auth.dart';
|
||||
|
||||
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
@@ -6,7 +6,6 @@ final di = GetIt.instance;
|
||||
|
||||
Future<void> setupPreInjection() async {
|
||||
await setupAllCoreProvider();
|
||||
await setupAuthDI();
|
||||
di.registerSingleton<DioRemote>(
|
||||
DioRemote(baseUrl: 'https://everestacademy.ir/'),
|
||||
instanceName: 'baseRemote',
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import 'package:rasadyar_app/presentation/routes/app_pages.dart';
|
||||
import 'package:rasadyar_auth/data/models/local/module/module_model.dart';
|
||||
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/inspection.dart';
|
||||
import 'package:rasadyar_livestock/presentation/routes/app_pages.dart';
|
||||
|
||||
class AuthService extends GetxService {
|
||||
var tokenService = Get.find<TokenStorageService>();
|
||||
RxBool accessRes = false.obs;
|
||||
RxBool refAccessRes = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
ever(tokenService.accessToken, (callback) {
|
||||
accessRes.value = (callback != null);
|
||||
});
|
||||
|
||||
ever(tokenService.refreshToken, (callback) {
|
||||
refAccessRes.value = (callback != null);
|
||||
});
|
||||
|
||||
everAll([accessRes, refAccessRes], (_) {
|
||||
if (accessRes.value && refAccessRes.value) {
|
||||
var targetPage = getTargetPage(tokenService.appModule.value);
|
||||
Get.offAllNamed(targetPage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_app/infrastructure/service/app_navigation_observer.dart';
|
||||
import 'package:rasadyar_app/presentation/routes/app_pages.dart';
|
||||
import 'package:rasadyar_auth/auth.dart';
|
||||
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'infrastructure/di/di.dart';
|
||||
import 'infrastructure/service/auth_service.dart';
|
||||
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await setupPreInjection();
|
||||
|
||||
await setupPreInjection();
|
||||
Get.put(TokenStorageService());
|
||||
await Get.find<TokenStorageService>().init();
|
||||
|
||||
|
||||
Get.put(AuthMiddleware());
|
||||
Get.put(AuthService());
|
||||
runApp(MyApp());
|
||||
|
||||
// runApp(DevicePreview(builder: (context) => ForDevicePreview(),));
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:rasadyar_auth/data/models/local/module/module_model.dart';
|
||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class ModulesLogic extends GetxController {
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/presentation/routes/pages.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/inspection.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
@@ -11,10 +11,7 @@ class ModulesPage extends GetView<ModulesLogic> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'انتخاب سامانه',
|
||||
style: AppFonts.yekan18.copyWith(color: Colors.white),
|
||||
),
|
||||
title: Text('انتخاب سامانه', style: AppFonts.yekan18.copyWith(color: Colors.white)),
|
||||
centerTitle: true,
|
||||
backgroundColor: AppColor.blueNormal,
|
||||
),
|
||||
@@ -28,7 +25,15 @@ class ModulesPage extends GetView<ModulesLogic> {
|
||||
icon: module.icon,
|
||||
onTap: () {
|
||||
controller.selectedIndex.value = index;
|
||||
Get.toNamed(AuthPaths.auth, arguments: module.module);
|
||||
switch (module.module) {
|
||||
case Module.inspection:
|
||||
Get.toNamed(InspectionRoutes.init);
|
||||
break;
|
||||
case Module.liveStocks:
|
||||
case Module.chicken:
|
||||
Get.toNamed(InspectionRoutes.init);
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
@@ -4,10 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rasadyar_app/data/model/app_info_model.dart';
|
||||
import 'package:rasadyar_app/presentation/routes/app_pages.dart';
|
||||
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/inspection.dart';
|
||||
import 'package:rasadyar_inspection/presentation/routes/app_routes.dart';
|
||||
|
||||
class SplashLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
late final AnimationController scaleController;
|
||||
@@ -158,7 +155,7 @@ class SplashLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
|
||||
final module = tokenService.appModule.value;
|
||||
final target = getTargetPage(module);
|
||||
Get.offAndToNamed(InspectionRoutes.init);
|
||||
Get.offAndToNamed(target);
|
||||
} catch (e, st) {
|
||||
debugPrint("onReady error: $e\n$st");
|
||||
}
|
||||
@@ -227,7 +224,6 @@ class SplashLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
|
||||
if (success) {
|
||||
_updateFilePath.value = filePath;
|
||||
|
||||
}
|
||||
|
||||
onUpdateDownload.value = false;
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import 'package:rasadyar_app/presentation/pages/splash/logic.dart';
|
||||
import 'package:rasadyar_app/presentation/pages/splash/view.dart';
|
||||
import 'package:rasadyar_app/presentation/pages/system_design/system_design.dart';
|
||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||
import 'package:rasadyar_auth/presentation/routes/pages.dart';
|
||||
import 'package:rasadyar_chicken/chicken.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/inspection.dart';
|
||||
import 'package:rasadyar_livestock/presentation/routes/app_pages.dart';
|
||||
|
||||
|
||||
part 'app_paths.dart';
|
||||
|
||||
sealed class AppPages {
|
||||
@@ -26,7 +23,7 @@ sealed class AppPages {
|
||||
),
|
||||
|
||||
...InspectionPages.pages,
|
||||
...AuthPages.pages,
|
||||
|
||||
...LiveStockPages.pages,
|
||||
...ChickenPages.pages,
|
||||
];
|
||||
@@ -41,6 +38,6 @@ String getTargetPage(Module? value) {
|
||||
case Module.chicken:
|
||||
return ChickenRoutes.init;
|
||||
default:
|
||||
return InspectionRoutes.init;
|
||||
return AppPaths.moduleList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@ sealed class AppPaths {
|
||||
AppPaths._();
|
||||
|
||||
static const String splash = '/splash';
|
||||
static const String moduleList = '/moduleList';
|
||||
static const String systemDesignPage = '/systemDesignPage';
|
||||
}
|
||||
|
||||
24
lib/presentation/routes/auth_route_resolver_impl.dart
Normal file
24
lib/presentation/routes/auth_route_resolver_impl.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import 'package:rasadyar_app/presentation/routes/app_pages.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/inspection.dart';
|
||||
import 'package:rasadyar_livestock/presentation/routes/app_pages.dart';
|
||||
|
||||
class AppAuthRouteResolver implements AuthRouteResolver {
|
||||
@override
|
||||
String getAuthRouteForModule(Module module) {
|
||||
switch (module) {
|
||||
case Module.inspection:
|
||||
return InspectionRoutes.auth;
|
||||
case Module.liveStocks:
|
||||
return LiveStockRoutes.auth;
|
||||
case Module.chicken:
|
||||
return ChickenRoutes.auth;
|
||||
default:
|
||||
throw UnimplementedError('No auth route for module: $module');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String getFallbackRoute() => AppPaths.moduleList;
|
||||
}
|
||||
31
packages/auth/.gitignore
vendored
31
packages/auth/.gitignore
vendored
@@ -1,31 +0,0 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
migrate_working_dir/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
|
||||
/pubspec.lock
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
build/
|
||||
@@ -1,10 +0,0 @@
|
||||
# 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: "ea121f8859e4b13e47a8f845e4586164519588bc"
|
||||
channel: "stable"
|
||||
|
||||
project_type: package
|
||||
@@ -1,3 +0,0 @@
|
||||
## 0.0.1
|
||||
|
||||
* TODO: Describe initial release.
|
||||
@@ -1 +0,0 @@
|
||||
TODO: Add your license here.
|
||||
@@ -1,39 +0,0 @@
|
||||
<!--
|
||||
This README describes the package. If you publish this package to pub.dev,
|
||||
this README's contents appear on the landing page for your package.
|
||||
|
||||
For information about how to write a good package README, see the guide for
|
||||
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).
|
||||
|
||||
For general information about developing packages, see the Dart guide for
|
||||
[creating packages](https://dart.dev/guides/libraries/create-packages)
|
||||
and the Flutter guide for
|
||||
[developing packages and plugins](https://flutter.dev/to/develop-packages).
|
||||
-->
|
||||
|
||||
TODO: Put a short description of the package here that helps potential users
|
||||
know whether this package might be useful for them.
|
||||
|
||||
## Features
|
||||
|
||||
TODO: List what your package can do. Maybe include images, gifs, or videos.
|
||||
|
||||
## Getting started
|
||||
|
||||
TODO: List prerequisites and provide or point to information on how to
|
||||
start using the package.
|
||||
|
||||
## Usage
|
||||
|
||||
TODO: Include short and useful examples for package users. Add longer examples
|
||||
to `/example` folder.
|
||||
|
||||
```dart
|
||||
const like = 'sample';
|
||||
```
|
||||
|
||||
## Additional information
|
||||
|
||||
TODO: Tell users more about the package: where to find more information, how to
|
||||
contribute to the package, how to file issues, what response they can expect
|
||||
from the package authors, and more.
|
||||
@@ -1,4 +0,0 @@
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
@@ -1,6 +0,0 @@
|
||||
targets:
|
||||
$default:
|
||||
builders:
|
||||
json_serializable:
|
||||
options:
|
||||
field_rename: snake
|
||||
@@ -1,8 +0,0 @@
|
||||
/// Support for doing something awesome.
|
||||
///
|
||||
/// More dartdocs go here.
|
||||
library;
|
||||
|
||||
export 'data/services/auth_middelware.dart';
|
||||
export 'data/di/auth_di.dart';
|
||||
export 'data/models/local/module/module_model.dart';
|
||||
@@ -1,14 +0,0 @@
|
||||
enum ApiEnvironment {
|
||||
dam(url: 'https://api.dam.rasadyar.net/');
|
||||
|
||||
const ApiEnvironment({required this.url});
|
||||
|
||||
final String url;
|
||||
|
||||
String get baseUrl {
|
||||
switch (this) {
|
||||
case ApiEnvironment.dam:
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class DioErrorHandler {
|
||||
void handle(DioException error) {
|
||||
switch (error.response?.statusCode) {
|
||||
case 401:
|
||||
_handleGeneric(error);
|
||||
break;
|
||||
case 403:
|
||||
_handleGeneric(error);
|
||||
break;
|
||||
|
||||
case 410:
|
||||
_handle410();
|
||||
break;
|
||||
default:
|
||||
_handleGeneric(error);
|
||||
}
|
||||
}
|
||||
|
||||
//wrong password/user name => "detail": "No active account found with the given credentials" - 401
|
||||
void _handle410() {
|
||||
Get.showSnackbar(_errorSnackBar('نام کاربری یا رمز عبور اشتباه است'));
|
||||
}
|
||||
|
||||
//wrong captcha => "detail": "Captcha code is incorrect" - 403
|
||||
void _handle403() {}
|
||||
|
||||
void _handleGeneric(DioException error) {
|
||||
Get.showSnackbar(
|
||||
_errorSnackBar(
|
||||
error.response?.data.keys.first == 'is_user'
|
||||
? 'کاربر با این شماره تلفن وجود ندارد'
|
||||
: error.response?.data[error.response?.data.keys.first] ??
|
||||
'خطا در برقراری ارتباط با سرور',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
GetSnackBar _errorSnackBar(String message) {
|
||||
return GetSnackBar(
|
||||
titleText: Text(
|
||||
'خطا',
|
||||
style: AppFonts.yekan14.copyWith(color: Colors.white),
|
||||
),
|
||||
messageText: Text(
|
||||
message,
|
||||
style: AppFonts.yekan12.copyWith(color: Colors.white),
|
||||
),
|
||||
backgroundColor: AppColor.error,
|
||||
margin: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
borderRadius: 12,
|
||||
duration: Duration(milliseconds: 3500),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
import 'package:rasadyar_auth/data/repositories/auth_repository_imp.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../di/auth_di.dart';
|
||||
import 'constant.dart';
|
||||
|
||||
/*
|
||||
class DioRemoteManager {
|
||||
DioRemote? _currentClient;
|
||||
ApiEnvironment? _currentEnv;
|
||||
|
||||
Future<DioRemote> setEnvironment([ApiEnvironment env = ApiEnvironment.dam]) async {
|
||||
if (_currentEnv != env) {
|
||||
_currentClient = DioRemote(
|
||||
baseUrl: env.baseUrl,
|
||||
interceptors: AppInterceptor(
|
||||
refreshTokenCallback: () async{
|
||||
return null;
|
||||
},
|
||||
),
|
||||
);
|
||||
await _currentClient?.init();
|
||||
_currentEnv = env;
|
||||
}
|
||||
return _currentClient!;
|
||||
}
|
||||
|
||||
DioRemote get currentClient {
|
||||
if (_currentClient == null) {
|
||||
throw Exception('Call setEnvironment() before accessing DioRemote.');
|
||||
}
|
||||
|
||||
return _currentClient!;
|
||||
}
|
||||
|
||||
ApiEnvironment? get currentEnv => _currentEnv;
|
||||
}
|
||||
|
||||
Future<void> switchAuthEnvironment(ApiEnvironment env) async {
|
||||
final manager = diAuth.get<DioRemoteManager>();
|
||||
|
||||
final dioRemote = await manager.setEnvironment(env);
|
||||
|
||||
if (diAuth.isRegistered<AuthRepositoryImpl>()) {
|
||||
await diAuth.unregister<AuthRepositoryImpl>();
|
||||
}
|
||||
|
||||
diAuth.registerLazySingleton<AuthRepositoryImpl>(() => AuthRepositoryImpl(dioRemote));
|
||||
}
|
||||
*/
|
||||
@@ -1,62 +0,0 @@
|
||||
import 'package:rasadyar_auth/data/common/dio_error_handler.dart';
|
||||
import 'package:rasadyar_auth/data/models/response/auth/auth_response_model.dart';
|
||||
import 'package:rasadyar_auth/data/repositories/auth_repository_imp.dart';
|
||||
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../common/dio_manager.dart';
|
||||
|
||||
GetIt diAuth = GetIt.instance;
|
||||
|
||||
Future<void> setupAuthDI() async {
|
||||
|
||||
diAuth.registerLazySingleton<AppInterceptor>(
|
||||
() => AppInterceptor(
|
||||
refreshTokenCallback: () async {
|
||||
var tokenService = Get.find<TokenStorageService>();
|
||||
final authRepo = diAuth.get<AuthRepositoryImpl>();
|
||||
|
||||
final refreshToken = tokenService.refreshToken.value;
|
||||
if (refreshToken == null) return null;
|
||||
|
||||
final result = await authRepo.loginWithRefreshToken(
|
||||
authRequest: {"refresh_token": refreshToken},
|
||||
);
|
||||
|
||||
if (result is AuthResponseModel) {
|
||||
await tokenService.saveAccessToken(result.access!);
|
||||
return result.access;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
saveTokenCallback: (String newToken) async {
|
||||
//
|
||||
},
|
||||
clearTokenCallback: () async {
|
||||
//await tokenService.clearTokens(); // حذف همه توکنها
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
diAuth.registerLazySingleton<DioRemote>(
|
||||
() => DioRemote(interceptors: diAuth.get<AppInterceptor>()),
|
||||
);
|
||||
|
||||
final dioRemote = diAuth.get<DioRemote>();
|
||||
await dioRemote.init();
|
||||
diAuth.registerSingleton<AuthRepositoryImpl>(AuthRepositoryImpl(dioRemote));
|
||||
diAuth.registerLazySingleton<DioErrorHandler>(() => DioErrorHandler());
|
||||
}
|
||||
|
||||
Future<void> newSetupAuthDI(String newUrl) async {
|
||||
diAuth.registerLazySingleton<DioRemote>(
|
||||
() => DioRemote(baseUrl: newUrl, interceptors: diAuth.get<AppInterceptor>()),
|
||||
instanceName: 'newRemote',
|
||||
);
|
||||
final dioRemote = diAuth.get<DioRemote>(instanceName: 'newRemote');
|
||||
await dioRemote.init();
|
||||
diAuth.registerSingleton<AuthRepositoryImpl>(
|
||||
AuthRepositoryImpl(dioRemote),
|
||||
instanceName: 'newUrl',
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import 'package:rasadyar_auth/data/models/response/user_info/user_info_model.dart';
|
||||
|
||||
import '../models/response/auth/auth_response_model.dart';
|
||||
import '../models/response/captcha/captcha_response_model.dart';
|
||||
import '../models/response/user_profile_model/user_profile_model.dart';
|
||||
|
||||
abstract class AuthRepository {
|
||||
Future<UserProfileModel?> login({required Map<String, dynamic> authRequest});
|
||||
|
||||
Future<CaptchaResponseModel?> captcha();
|
||||
|
||||
Future<void> logout();
|
||||
|
||||
Future<bool> hasAuthenticated();
|
||||
|
||||
Future<AuthResponseModel?> loginWithRefreshToken({
|
||||
required Map<String, dynamic> authRequest,
|
||||
});
|
||||
|
||||
Future<UserInfoModel?> getUserInfo(String phoneNumber);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../../presentation/routes/pages.dart';
|
||||
|
||||
class AuthMiddleware extends GetMiddleware {
|
||||
var tokenService = Get.find<TokenStorageService>();
|
||||
|
||||
@override
|
||||
RouteSettings? redirect(String? route) {
|
||||
final refreshToken = tokenService.refreshToken.value;
|
||||
final accessToken = tokenService.accessToken.value;
|
||||
|
||||
if (refreshToken == null || accessToken == null) {
|
||||
return RouteSettings(name: AuthPaths.auth, arguments: Module.chicken);
|
||||
}
|
||||
return super.redirect(route);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import 'package:rasadyar_auth/presentation/pages/modules/logic.dart';
|
||||
import 'package:rasadyar_auth/presentation/pages/modules/view.dart';
|
||||
import 'package:rasadyar_auth/presentation/widget/captcha/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../pages/auth/logic.dart';
|
||||
import '../pages/auth/view.dart';
|
||||
|
||||
part 'paths.dart';
|
||||
|
||||
sealed class AuthPages {
|
||||
AuthPages._();
|
||||
|
||||
static List<GetPage> pages = [
|
||||
GetPage(
|
||||
name: AuthPaths.moduleList,
|
||||
page: () => ModulesPage(),
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() => ModulesLogic());
|
||||
}),
|
||||
),
|
||||
|
||||
GetPage(
|
||||
name: AuthPaths.auth,
|
||||
page: () => AuthPage(),
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() => AuthLogic());
|
||||
Get.lazyPut(() => CaptchaWidgetLogic());
|
||||
}),
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
part of 'pages.dart';
|
||||
|
||||
sealed class AuthPaths {
|
||||
AuthPaths._();
|
||||
|
||||
static const String moduleList = '/moduleList';
|
||||
static const String auth = '/Auth';
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
name: rasadyar_auth
|
||||
description: "A new Flutter project."
|
||||
version: 1.0.3
|
||||
publish_to: 'none'
|
||||
|
||||
|
||||
environment:
|
||||
sdk: ^3.8.1
|
||||
flutter: ">=1.17.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
rasadyar_core:
|
||||
path: ../core
|
||||
##code generation
|
||||
freezed_annotation: ^3.1.0
|
||||
json_annotation: ^4.9.0
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^6.0.0
|
||||
##code generation
|
||||
build_runner: ^2.6.0
|
||||
hive_ce_generator: ^1.9.3
|
||||
freezed: ^3.2.0
|
||||
json_serializable: ^6.10.0
|
||||
|
||||
##test
|
||||
mocktail: ^1.0.4
|
||||
get_test: ^4.0.1
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
@@ -1,33 +0,0 @@
|
||||
import 'package:rasadyar_auth/data/repositories/auth_repository_imp.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../di/chicken_di.dart';
|
||||
import 'constant.dart';
|
||||
|
||||
/*class DioRemoteManager {
|
||||
DioRemote? _currentClient;
|
||||
ApiEnvironment? _currentEnv;
|
||||
|
||||
Future<DioRemote> setEnvironment([
|
||||
ApiEnvironment env = ApiEnvironment.dam,
|
||||
]) async {
|
||||
if (_currentEnv != env) {
|
||||
_currentClient = DioRemote(baseUrl: env.baseUrl);
|
||||
await _currentClient?.init();
|
||||
_currentEnv = env;
|
||||
}
|
||||
return _currentClient!;
|
||||
}
|
||||
|
||||
DioRemote get currentClient {
|
||||
if (_currentClient == null) {
|
||||
throw Exception('Call setEnvironment() before accessing DioRemote.');
|
||||
}
|
||||
|
||||
return _currentClient!;
|
||||
}
|
||||
|
||||
ApiEnvironment? get currentEnv => _currentEnv;
|
||||
}*/
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
|
||||
import 'package:rasadyar_auth/presentation/routes/pages.dart';
|
||||
import 'package:rasadyar_chicken/data/datasource/local/chicken_local_imp.dart';
|
||||
import 'package:rasadyar_chicken/data/datasource/remote/chicken_remote_imp.dart';
|
||||
import 'package:rasadyar_chicken/data/repositories/chicken_repository_imp.dart';
|
||||
import 'package:rasadyar_chicken/hive_registrar.g.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
GetIt diChicken = GetIt.instance;
|
||||
@@ -24,7 +22,7 @@ Future<void> setupChickenDI() async {
|
||||
},
|
||||
clearTokenCallback: () async {
|
||||
await tokenService.deleteTokens();
|
||||
Get.offAllNamed(AuthPaths.auth, arguments: Module.chicken);
|
||||
Get.offAllNamed(ChickenRoutes.auth, arguments: Module.chicken);
|
||||
},
|
||||
authArguments: Module.chicken,
|
||||
),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
import 'package:rasadyar_chicken/data/models/request/steward_allocation/steward_allocation_request.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/root/logic.dart';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
import 'package:rasadyar_chicken/data/models/request/steward_allocation/steward_allocation_request.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/root/logic.dart';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
|
||||
import 'package:rasadyar_chicken/data/models/request/create_steward_free_bar/create_steward_free_bar.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_province_city_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
|
||||
import 'package:rasadyar_chicken/chicken.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/bar_information/bar_information.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
|
||||
import 'package:rasadyar_chicken/data/models/request/change_password/change_password_request_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_province_city_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/user_profile/user_profile.dart';
|
||||
|
||||
@@ -2,8 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||
import 'package:rasadyar_auth/presentation/routes/pages.dart';
|
||||
import 'package:rasadyar_chicken/chicken.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_province_city_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/user_profile/user_profile.dart';
|
||||
|
||||
@@ -621,7 +620,7 @@ class ProfilePage extends GetView<ProfileLogic> {
|
||||
onPressed: () async {
|
||||
await controller.rootLogic.tokenService.deleteTokens().then((value) {
|
||||
Get.back();
|
||||
Get.offAllNamed(AuthPaths.auth, arguments: Module.chicken);
|
||||
Get.offAllNamed(ChickenRoutes.auth, arguments: Module.chicken);
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
import 'package:rasadyar_chicken/data/datasource/local/chicken_local_imp.dart';
|
||||
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
|
||||
import 'package:rasadyar_chicken/data/models/local/widely_used_local_model.dart';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
|
||||
import 'package:rasadyar_chicken/data/models/request/conform_allocation/conform_allocation.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
|
||||
import 'package:rasadyar_chicken/data/models/request/conform_allocation/conform_allocation.dart';
|
||||
import 'package:rasadyar_chicken/data/models/request/submit_steward_allocation/submit_steward_allocation.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
|
||||
import 'package:rasadyar_chicken/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_province_city_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/out_province_carcasses_buyer/out_province_carcasses_buyer.dart';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
|
||||
import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_province_city_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/out_province_carcasses_buyer/out_province_carcasses_buyer.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/root/logic.dart';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
|
||||
import 'package:rasadyar_chicken/data/models/request/steward_free_sale_bar/steward_free_sale_bar_request.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_province_city_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/out_province_carcasses_buyer/out_province_carcasses_buyer.dart';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
|
||||
import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/segmentation_model/segmentation_model.dart';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:rasadyar_auth/auth.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/buy/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/buy/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/buy_in_province/logic.dart';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
sealed class ChickenRoutes {
|
||||
ChickenRoutes._();
|
||||
|
||||
static const auth = '/AuthChicken';
|
||||
static const _base = '/chicken';
|
||||
static const init = '$_base/';
|
||||
static const home = '$_base/home';
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||
import 'package:rasadyar_auth/presentation/routes/pages.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
|
||||
|
||||
const int timeDebounce = 1200;
|
||||
|
||||
|
||||
void handleGeneric(DioException error,[void Function()? onError]) {
|
||||
void handleGeneric(DioException error, [void Function()? onError]) {
|
||||
Get.showSnackbar(_errorSnackBar('اعتبار توکن شما منقضی شده است لطفا دوباره وارد شوید'));
|
||||
|
||||
Get.offAllNamed(AuthPaths.auth, arguments: Module.chicken);
|
||||
Get.offAllNamed(ChickenRoutes.auth, arguments: Module.chicken);
|
||||
}
|
||||
|
||||
GetSnackBar _errorSnackBar(String message) {
|
||||
@@ -24,4 +20,4 @@ GetSnackBar _errorSnackBar(String message) {
|
||||
duration: Duration(milliseconds: 3500),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ dependencies:
|
||||
sdk: flutter
|
||||
rasadyar_core:
|
||||
path: ../core
|
||||
rasadyar_auth:
|
||||
path: ../auth
|
||||
|
||||
##code generation
|
||||
freezed_annotation: ^3.1.0
|
||||
json_annotation: ^4.9.0
|
||||
|
||||
@@ -38,11 +38,15 @@ export 'package:rasadyar_core/presentation/utils/utils.dart';
|
||||
export 'package:rasadyar_core/presentation/widget/widget.dart';
|
||||
|
||||
//models
|
||||
export 'data/model/pagination_model/pagination_model.dart';
|
||||
export 'data/model/model.dart';
|
||||
//data
|
||||
export 'data/services/services.dart';
|
||||
//infrastructure
|
||||
export 'infrastructure/infrastructure.dart';
|
||||
export 'infrastructure/local/hive_local_storage.dart';
|
||||
export 'injection/di.dart';
|
||||
//routing
|
||||
export 'routing/auth_route_resolver.dart';
|
||||
export 'utils/extension/date_time_utils.dart';
|
||||
export 'utils/extension/num_utils.dart';
|
||||
export 'utils/extension/string_utils.dart';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/data/model/local/user_local/user_local_model.dart';
|
||||
|
||||
part 'module_model.freezed.dart';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
@@ -75,6 +74,136 @@ as Module,
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ModuleModel].
|
||||
extension ModuleModelPatterns on ModuleModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ModuleModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ModuleModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ModuleModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ModuleModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ModuleModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ModuleModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String title, String icon, Module module)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ModuleModel() when $default != null:
|
||||
return $default(_that.title,_that.icon,_that.module);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String title, String icon, Module module) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ModuleModel():
|
||||
return $default(_that.title,_that.icon,_that.module);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String title, String icon, Module module)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ModuleModel() when $default != null:
|
||||
return $default(_that.title,_that.icon,_that.module);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
3
packages/core/lib/data/model/model.dart
Normal file
3
packages/core/lib/data/model/model.dart
Normal file
@@ -0,0 +1,3 @@
|
||||
export 'local/module/module_model.dart';
|
||||
export 'local/user_local/user_local_model.dart';
|
||||
export 'pagination_model/pagination_model.dart';
|
||||
@@ -1,6 +1,5 @@
|
||||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
@@ -79,6 +78,136 @@ as List<T>?,
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [PaginationModel].
|
||||
extension PaginationModelPatterns<T> on PaginationModel<T> {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _PaginationModel<T> value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _PaginationModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _PaginationModel<T> value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _PaginationModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _PaginationModel<T> value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _PaginationModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int? count, String? next, String? previous, List<T>? results)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PaginationModel() when $default != null:
|
||||
return $default(_that.count,_that.next,_that.previous,_that.results);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int? count, String? next, String? previous, List<T>? results) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PaginationModel():
|
||||
return $default(_that.count,_that.next,_that.previous,_that.results);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int? count, String? next, String? previous, List<T>? results)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PaginationModel() when $default != null:
|
||||
return $default(_that.count,_that.next,_that.previous,_that.results);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable(genericArgumentFactories: true)
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
@@ -79,6 +78,136 @@ as String?,
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LoginRequestModel].
|
||||
extension LoginRequestModelPatterns on LoginRequestModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _LoginRequestModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginRequestModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _LoginRequestModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginRequestModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _LoginRequestModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginRequestModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? username, String? password, String? captchaCode, String? captchaKey)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginRequestModel() when $default != null:
|
||||
return $default(_that.username,_that.password,_that.captchaCode,_that.captchaKey);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? username, String? password, String? captchaCode, String? captchaKey) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginRequestModel():
|
||||
return $default(_that.username,_that.password,_that.captchaCode,_that.captchaKey);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? username, String? password, String? captchaCode, String? captchaKey)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginRequestModel() when $default != null:
|
||||
return $default(_that.username,_that.password,_that.captchaCode,_that.captchaKey);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
@@ -10,14 +10,14 @@ _LoginRequestModel _$LoginRequestModelFromJson(Map<String, dynamic> json) =>
|
||||
_LoginRequestModel(
|
||||
username: json['username'] as String?,
|
||||
password: json['password'] as String?,
|
||||
captchaCode: json['captcha_code'] as String?,
|
||||
captchaKey: json['captcha_key'] as String?,
|
||||
captchaCode: json['captchaCode'] as String?,
|
||||
captchaKey: json['captchaKey'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LoginRequestModelToJson(_LoginRequestModel instance) =>
|
||||
<String, dynamic>{
|
||||
'username': instance.username,
|
||||
'password': instance.password,
|
||||
'captcha_code': instance.captchaCode,
|
||||
'captcha_key': instance.captchaKey,
|
||||
'captchaCode': instance.captchaCode,
|
||||
'captchaKey': instance.captchaKey,
|
||||
};
|
||||
@@ -1,6 +1,5 @@
|
||||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
@@ -78,6 +77,136 @@ as bool?,
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [AuthResponseModel].
|
||||
extension AuthResponseModelPatterns on AuthResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _AuthResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AuthResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _AuthResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AuthResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _AuthResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AuthResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? refresh, String? access, bool? otpStatus)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AuthResponseModel() when $default != null:
|
||||
return $default(_that.refresh,_that.access,_that.otpStatus);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? refresh, String? access, bool? otpStatus) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AuthResponseModel():
|
||||
return $default(_that.refresh,_that.access,_that.otpStatus);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? refresh, String? access, bool? otpStatus)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AuthResponseModel() when $default != null:
|
||||
return $default(_that.refresh,_that.access,_that.otpStatus);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
@@ -10,12 +10,12 @@ _AuthResponseModel _$AuthResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_AuthResponseModel(
|
||||
refresh: json['refresh'] as String?,
|
||||
access: json['access'] as String?,
|
||||
otpStatus: json['otp_status'] as bool?,
|
||||
otpStatus: json['otpStatus'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AuthResponseModelToJson(_AuthResponseModel instance) =>
|
||||
<String, dynamic>{
|
||||
'refresh': instance.refresh,
|
||||
'access': instance.access,
|
||||
'otp_status': instance.otpStatus,
|
||||
'otpStatus': instance.otpStatus,
|
||||
};
|
||||
@@ -1,6 +1,5 @@
|
||||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
@@ -79,6 +78,136 @@ as String?,
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [CaptchaResponseModel].
|
||||
extension CaptchaResponseModelPatterns on CaptchaResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _CaptchaResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CaptchaResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _CaptchaResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CaptchaResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _CaptchaResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CaptchaResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? captchaKey, String? captchaImage, String? imageType, String? imageDecode)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CaptchaResponseModel() when $default != null:
|
||||
return $default(_that.captchaKey,_that.captchaImage,_that.imageType,_that.imageDecode);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? captchaKey, String? captchaImage, String? imageType, String? imageDecode) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CaptchaResponseModel():
|
||||
return $default(_that.captchaKey,_that.captchaImage,_that.imageType,_that.imageDecode);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? captchaKey, String? captchaImage, String? imageType, String? imageDecode)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CaptchaResponseModel() when $default != null:
|
||||
return $default(_that.captchaKey,_that.captchaImage,_that.imageType,_that.imageDecode);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
@@ -9,17 +9,17 @@ part of 'captcha_response_model.dart';
|
||||
_CaptchaResponseModel _$CaptchaResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _CaptchaResponseModel(
|
||||
captchaKey: json['captcha_key'] as String?,
|
||||
captchaImage: json['captcha_image'] as String?,
|
||||
imageType: json['image_type'] as String?,
|
||||
imageDecode: json['image_decode'] as String?,
|
||||
captchaKey: json['captchaKey'] as String?,
|
||||
captchaImage: json['captchaImage'] as String?,
|
||||
imageType: json['imageType'] as String?,
|
||||
imageDecode: json['imageDecode'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CaptchaResponseModelToJson(
|
||||
_CaptchaResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'captcha_key': instance.captchaKey,
|
||||
'captcha_image': instance.captchaImage,
|
||||
'image_type': instance.imageType,
|
||||
'image_decode': instance.imageDecode,
|
||||
'captchaKey': instance.captchaKey,
|
||||
'captchaImage': instance.captchaImage,
|
||||
'imageType': instance.imageType,
|
||||
'imageDecode': instance.imageDecode,
|
||||
};
|
||||
@@ -1,6 +1,5 @@
|
||||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
@@ -79,6 +78,136 @@ as String?,
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [UserInfoModel].
|
||||
extension UserInfoModelPatterns on UserInfoModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _UserInfoModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UserInfoModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _UserInfoModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UserInfoModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _UserInfoModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UserInfoModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool? isUser, String? address, String? backend, String? apiKey)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UserInfoModel() when $default != null:
|
||||
return $default(_that.isUser,_that.address,_that.backend,_that.apiKey);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool? isUser, String? address, String? backend, String? apiKey) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UserInfoModel():
|
||||
return $default(_that.isUser,_that.address,_that.backend,_that.apiKey);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool? isUser, String? address, String? backend, String? apiKey)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UserInfoModel() when $default != null:
|
||||
return $default(_that.isUser,_that.address,_that.backend,_that.apiKey);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
@@ -8,16 +8,16 @@ part of 'user_info_model.dart';
|
||||
|
||||
_UserInfoModel _$UserInfoModelFromJson(Map<String, dynamic> json) =>
|
||||
_UserInfoModel(
|
||||
isUser: json['is_user'] as bool?,
|
||||
isUser: json['isUser'] as bool?,
|
||||
address: json['address'] as String?,
|
||||
backend: json['backend'] as String?,
|
||||
apiKey: json['api_key'] as String?,
|
||||
apiKey: json['apiKey'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UserInfoModelToJson(_UserInfoModel instance) =>
|
||||
<String, dynamic>{
|
||||
'is_user': instance.isUser,
|
||||
'isUser': instance.isUser,
|
||||
'address': instance.address,
|
||||
'backend': instance.backend,
|
||||
'api_key': instance.apiKey,
|
||||
'apiKey': instance.apiKey,
|
||||
};
|
||||
@@ -1,6 +1,5 @@
|
||||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
@@ -91,6 +90,136 @@ as List<String>?,
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [UserProfileModel].
|
||||
extension UserProfileModelPatterns on UserProfileModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _UserProfileModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UserProfileModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _UserProfileModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UserProfileModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _UserProfileModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UserProfileModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? accessToken, String? expiresIn, String? scope, String? expireTime, String? mobile, String? fullname, String? firstname, String? lastname, String? city, String? province, String? nationalCode, String? nationalId, String? birthday, String? image, int? baseOrder, List<String>? role)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UserProfileModel() when $default != null:
|
||||
return $default(_that.accessToken,_that.expiresIn,_that.scope,_that.expireTime,_that.mobile,_that.fullname,_that.firstname,_that.lastname,_that.city,_that.province,_that.nationalCode,_that.nationalId,_that.birthday,_that.image,_that.baseOrder,_that.role);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? accessToken, String? expiresIn, String? scope, String? expireTime, String? mobile, String? fullname, String? firstname, String? lastname, String? city, String? province, String? nationalCode, String? nationalId, String? birthday, String? image, int? baseOrder, List<String>? role) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UserProfileModel():
|
||||
return $default(_that.accessToken,_that.expiresIn,_that.scope,_that.expireTime,_that.mobile,_that.fullname,_that.firstname,_that.lastname,_that.city,_that.province,_that.nationalCode,_that.nationalId,_that.birthday,_that.image,_that.baseOrder,_that.role);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? accessToken, String? expiresIn, String? scope, String? expireTime, String? mobile, String? fullname, String? firstname, String? lastname, String? city, String? province, String? nationalCode, String? nationalId, String? birthday, String? image, int? baseOrder, List<String>? role)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UserProfileModel() when $default != null:
|
||||
return $default(_that.accessToken,_that.expiresIn,_that.scope,_that.expireTime,_that.mobile,_that.fullname,_that.firstname,_that.lastname,_that.city,_that.province,_that.nationalCode,_that.nationalId,_that.birthday,_that.image,_that.baseOrder,_that.role);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
@@ -8,40 +8,40 @@ part of 'user_profile_model.dart';
|
||||
|
||||
_UserProfileModel _$UserProfileModelFromJson(Map<String, dynamic> json) =>
|
||||
_UserProfileModel(
|
||||
accessToken: json['access_token'] as String?,
|
||||
expiresIn: json['expires_in'] as String?,
|
||||
accessToken: json['accessToken'] as String?,
|
||||
expiresIn: json['expiresIn'] as String?,
|
||||
scope: json['scope'] as String?,
|
||||
expireTime: json['expire_time'] as String?,
|
||||
expireTime: json['expireTime'] as String?,
|
||||
mobile: json['mobile'] as String?,
|
||||
fullname: json['fullname'] as String?,
|
||||
firstname: json['firstname'] as String?,
|
||||
lastname: json['lastname'] as String?,
|
||||
city: json['city'] as String?,
|
||||
province: json['province'] as String?,
|
||||
nationalCode: json['national_code'] as String?,
|
||||
nationalId: json['national_id'] as String?,
|
||||
nationalCode: json['nationalCode'] as String?,
|
||||
nationalId: json['nationalId'] as String?,
|
||||
birthday: json['birthday'] as String?,
|
||||
image: json['image'] as String?,
|
||||
baseOrder: (json['base_order'] as num?)?.toInt(),
|
||||
baseOrder: (json['baseOrder'] as num?)?.toInt(),
|
||||
role: (json['role'] as List<dynamic>?)?.map((e) => e as String).toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UserProfileModelToJson(_UserProfileModel instance) =>
|
||||
<String, dynamic>{
|
||||
'access_token': instance.accessToken,
|
||||
'expires_in': instance.expiresIn,
|
||||
'accessToken': instance.accessToken,
|
||||
'expiresIn': instance.expiresIn,
|
||||
'scope': instance.scope,
|
||||
'expire_time': instance.expireTime,
|
||||
'expireTime': instance.expireTime,
|
||||
'mobile': instance.mobile,
|
||||
'fullname': instance.fullname,
|
||||
'firstname': instance.firstname,
|
||||
'lastname': instance.lastname,
|
||||
'city': instance.city,
|
||||
'province': instance.province,
|
||||
'national_code': instance.nationalCode,
|
||||
'national_id': instance.nationalId,
|
||||
'nationalCode': instance.nationalCode,
|
||||
'nationalId': instance.nationalId,
|
||||
'birthday': instance.birthday,
|
||||
'image': instance.image,
|
||||
'base_order': instance.baseOrder,
|
||||
'baseOrder': instance.baseOrder,
|
||||
'role': instance.role,
|
||||
};
|
||||
23
packages/core/lib/data/services/auth_middelware.dart
Normal file
23
packages/core/lib/data/services/auth_middelware.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class AuthMiddleware extends GetMiddleware {
|
||||
final tokenService = Get.find<TokenStorageService>();
|
||||
final authRouteResolver = Get.find<AuthRouteResolver>();
|
||||
|
||||
@override
|
||||
RouteSettings? redirect(String? route) {
|
||||
final refreshToken = tokenService.refreshToken.value;
|
||||
final accessToken = tokenService.accessToken.value;
|
||||
final module = tokenService.appModule.value;
|
||||
|
||||
if (refreshToken == null || accessToken == null) {
|
||||
if (module != null) {
|
||||
final authRoute = authRouteResolver.getAuthRouteForModule(module);
|
||||
return RouteSettings(name: authRoute, arguments: module);
|
||||
}
|
||||
return RouteSettings(name: authRouteResolver.getFallbackRoute());
|
||||
}
|
||||
return super.redirect(route);
|
||||
}
|
||||
}
|
||||
2
packages/core/lib/data/services/services.dart
Normal file
2
packages/core/lib/data/services/services.dart
Normal file
@@ -0,0 +1,2 @@
|
||||
export 'auth_middelware.dart';
|
||||
export 'token_storage_service.dart';
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||
import 'package:rasadyar_auth/hive_registrar.g.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/hive_registrar.g.dart';
|
||||
|
||||
class TokenStorageService extends GetxService {
|
||||
static const String _tokenBoxName = 'TokenBox';
|
||||
@@ -3,7 +3,7 @@
|
||||
// Check in to version control
|
||||
|
||||
import 'package:hive_ce/hive.dart';
|
||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||
import 'package:rasadyar_core/data/model/local/user_local/user_local_model.dart';
|
||||
|
||||
extension HiveRegistrar on HiveInterface {
|
||||
void registerAdapters() {
|
||||
@@ -1,27 +1,26 @@
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:rasadyar_core/data/services/auth_middelware.dart';
|
||||
import 'package:rasadyar_core/infrastructure/local/hive_local_storage.dart';
|
||||
|
||||
final diCore = GetIt.instance;
|
||||
|
||||
Future<void> setupAllCoreProvider() async {
|
||||
diCore.registerSingleton(AuthMiddleware());
|
||||
await _setUpLogger();
|
||||
await _setupLocalStorage();
|
||||
await _setupRemote();
|
||||
await diCore.allReady();
|
||||
}
|
||||
|
||||
Future<void> _setUpLogger() async{
|
||||
Future<void> _setUpLogger() async {
|
||||
diCore.registerSingleton<Logger>(Logger());
|
||||
}
|
||||
|
||||
Future<void> _setupLocalStorage() async {
|
||||
diCore.registerSingleton<HiveLocalStorage>(HiveLocalStorage());
|
||||
print('====> HiveLocalStorage registered');
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<void> _setupRemote() async {
|
||||
// diCore.registerSingleton<HiveLocalStorage>(HiveLocalStorage());
|
||||
// diCore.registerSingleton<HiveLocalStorage>(HiveLocalStorage());
|
||||
}
|
||||
|
||||
6
packages/core/lib/routing/auth_route_resolver.dart
Normal file
6
packages/core/lib/routing/auth_route_resolver.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
import 'package:rasadyar_core/data/model/local/user_local/user_local_model.dart';
|
||||
|
||||
abstract class AuthRouteResolver {
|
||||
String getAuthRouteForModule(Module module);
|
||||
String getFallbackRoute();
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export 'resource.dart';
|
||||
export 'safe_call_utils.dart';
|
||||
export 'safe_call_utils.dart';
|
||||
export 'safe_call.dart';
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:rasadyar_core/data/model/response/auth/auth_response_model.dart';
|
||||
import 'package:rasadyar_core/data/model/response/captcha/captcha_response_model.dart';
|
||||
import 'package:rasadyar_core/data/model/response/user_info/user_info_model.dart';
|
||||
import 'package:rasadyar_core/data/model/response/user_profile_model/user_profile_model.dart';
|
||||
|
||||
abstract class AuthRepository {
|
||||
Future<UserProfileModel?> login({required Map<String, dynamic> authRequest});
|
||||
|
||||
Future<CaptchaResponseModel?> captcha();
|
||||
|
||||
Future<void> logout();
|
||||
|
||||
Future<bool> hasAuthenticated();
|
||||
|
||||
Future<AuthResponseModel?> loginWithRefreshToken({required Map<String, dynamic> authRequest});
|
||||
|
||||
Future<UserInfoModel?> getUserInfo(String phoneNumber);
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'package:rasadyar_auth/data/models/response/user_info/user_info_model.dart';
|
||||
import 'package:rasadyar_auth/data/models/response/user_profile_model/user_profile_model.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../models/response/auth/auth_response_model.dart';
|
||||
import '../models/response/captcha/captcha_response_model.dart';
|
||||
import 'package:rasadyar_core/data/model/response/auth/auth_response_model.dart';
|
||||
import 'package:rasadyar_core/data/model/response/captcha/captcha_response_model.dart';
|
||||
import 'package:rasadyar_core/data/model/response/user_info/user_info_model.dart';
|
||||
import 'package:rasadyar_core/data/model/response/user_profile_model/user_profile_model.dart';
|
||||
import 'auth_repository.dart';
|
||||
|
||||
class AuthRepositoryImpl implements AuthRepository {
|
||||
@@ -13,10 +12,8 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
AuthRepositoryImpl(this._httpClient);
|
||||
|
||||
@override
|
||||
Future<UserProfileModel?> login({
|
||||
required Map<String, dynamic> authRequest,
|
||||
}) async {
|
||||
var res = await _httpClient.post<UserProfileModel?>(
|
||||
Future<UserProfileModel?> login({required Map<String, dynamic> authRequest}) async {
|
||||
var res = await _httpClient.post<UserProfileModel?>(
|
||||
'/api/login/',
|
||||
data: authRequest,
|
||||
fromJson: UserProfileModel.fromJson,
|
||||
@@ -66,14 +63,10 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
Future<UserInfoModel?> getUserInfo(String phoneNumber) async {
|
||||
var res = await _httpClient.post<UserInfoModel?>(
|
||||
'https://userbackend.rasadyaar.ir/api/send_otp/',
|
||||
data: {
|
||||
"mobile": phoneNumber,
|
||||
"state": ""
|
||||
},
|
||||
data: {"mobile": phoneNumber, "state": ""},
|
||||
fromJson: UserInfoModel.fromJson,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
);
|
||||
return res.data;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,12 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/auth.dart';
|
||||
import 'package:rasadyar_auth/data/common/dio_error_handler.dart';
|
||||
import 'package:rasadyar_auth/data/models/request/login_request/login_request_model.dart';
|
||||
import 'package:rasadyar_auth/data/models/response/user_info/user_info_model.dart';
|
||||
import 'package:rasadyar_auth/data/models/response/user_profile_model/user_profile_model.dart';
|
||||
import 'package:rasadyar_auth/data/repositories/auth_repository_imp.dart';
|
||||
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
import 'package:rasadyar_auth/presentation/widget/captcha/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import '../../../data/models/local/user_local/user_local_model.dart';
|
||||
import 'package:rasadyar_core/data/model/request/login_request/login_request_model.dart';
|
||||
import 'package:rasadyar_core/data/model/response/user_info/user_info_model.dart';
|
||||
import 'package:rasadyar_core/data/model/response/user_profile_model/user_profile_model.dart';
|
||||
import 'package:rasadyar_inspection/data/repositories/auth_repository_imp.dart';
|
||||
import 'package:rasadyar_inspection/presentation/widget/captcha/logic.dart';
|
||||
|
||||
enum AuthType { useAndPass, otp }
|
||||
|
||||
@@ -44,7 +38,7 @@ class AuthLogic extends GetxController {
|
||||
RxInt secondsRemaining = 120.obs;
|
||||
Timer? _timer;
|
||||
|
||||
AuthRepositoryImpl authRepository = diAuth.get<AuthRepositoryImpl>();
|
||||
//AuthRepositoryImpl authRepository = diAuth.get<AuthRepositoryImpl>();
|
||||
|
||||
final Module _module = Get.arguments;
|
||||
|
||||
@@ -71,7 +65,6 @@ class AuthLogic extends GetxController {
|
||||
return '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
@@ -128,9 +121,9 @@ class AuthLogic extends GetxController {
|
||||
|
||||
Future<void> submitLoginForm2() async {
|
||||
if (!_isFormValid()) return;
|
||||
AuthRepositoryImpl authTmp = diAuth.get<AuthRepositoryImpl>(instanceName: 'newUrl');
|
||||
//AuthRepositoryImpl authTmp = diAuth.get<AuthRepositoryImpl>(instanceName: 'newUrl');
|
||||
isLoading.value = true;
|
||||
await safeCall<UserProfileModel?>(
|
||||
/* await safeCall<UserProfileModel?>(
|
||||
call: () => authTmp.login(
|
||||
authRequest: {
|
||||
"username": usernameController.value.text,
|
||||
@@ -144,32 +137,32 @@ class AuthLogic extends GetxController {
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
if (error is DioException) {
|
||||
diAuth.get<DioErrorHandler>().handle(error);
|
||||
// diAuth.get<DioErrorHandler>().handle(error);
|
||||
}
|
||||
captchaController.getCaptcha();
|
||||
},
|
||||
);
|
||||
);*/
|
||||
isLoading.value = false;
|
||||
}
|
||||
|
||||
Future<void> getUserInfo(String value) async {
|
||||
isLoading.value = true;
|
||||
await safeCall<UserInfoModel?>(
|
||||
/*await safeCall<UserInfoModel?>(
|
||||
call: () async => await authRepository.getUserInfo(value),
|
||||
onSuccess: (result) async {
|
||||
if (result != null) {
|
||||
await newSetupAuthDI(result.backend ?? '');
|
||||
//await newSetupAuthDI(result.backend ?? '');
|
||||
await tokenStorageService.saveApiKey(result.apiKey ?? '');
|
||||
await tokenStorageService.saveBaseUrl(result.backend ?? '');
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
if (error is DioException) {
|
||||
diAuth.get<DioErrorHandler>().handle(error);
|
||||
// diAuth.get<DioErrorHandler>().handle(error);
|
||||
}
|
||||
captchaController.getCaptcha();
|
||||
},
|
||||
);
|
||||
);*/
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/presentation/widget/captcha/view.dart';
|
||||
import 'package:rasadyar_auth/presentation/widget/clear_button.dart';
|
||||
import 'package:rasadyar_auth/presentation/widget/logo_widget.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/presentation/widget/captcha/view.dart';
|
||||
import 'package:rasadyar_inspection/presentation/widget/clear_button.dart';
|
||||
import 'package:rasadyar_inspection/presentation/widget/logo_widget.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
@@ -109,9 +109,6 @@ class AuthPage extends GetView<AuthLogic> {
|
||||
onChanged: (value) async {
|
||||
controller.usernameController.value.text = value;
|
||||
controller.usernameController.refresh();
|
||||
if (value.length == 11) {
|
||||
await controller.getUserInfo(value);
|
||||
}
|
||||
},
|
||||
prefixIcon: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 6, 8),
|
||||
@@ -124,11 +121,11 @@ class AuthPage extends GetView<AuthLogic> {
|
||||
})
|
||||
: null,
|
||||
validator: (value) {
|
||||
/* if (value == null || value.isEmpty) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '⚠️ شماره موبایل را وارد کنید';
|
||||
} else if (value.length < 10) {
|
||||
return '⚠️ شماره موبایل باید 11 رقم باشد';
|
||||
}*/
|
||||
}
|
||||
return null;
|
||||
},
|
||||
style: AppFonts.yekan13,
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/presentation/pages/auth/logic.dart';
|
||||
import 'package:rasadyar_inspection/presentation/pages/auth/view.dart';
|
||||
import 'package:rasadyar_inspection/presentation/pages/filter/logic.dart';
|
||||
import 'package:rasadyar_inspection/presentation/pages/pages.dart';
|
||||
import 'package:rasadyar_inspection/presentation/pages/users/logic.dart';
|
||||
@@ -12,10 +14,10 @@ sealed class InspectionPages {
|
||||
GetPage(
|
||||
name: InspectionRoutes.init,
|
||||
page: () => RootPage(),
|
||||
|
||||
middlewares:[ AuthMiddleware()],
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() =>RootLogic());
|
||||
Get.lazyPut(() =>InspectorFilterLogic());
|
||||
Get.lazyPut(() => RootLogic());
|
||||
Get.lazyPut(() => InspectorFilterLogic());
|
||||
Get.lazyPut(() => InspectionMapLogic());
|
||||
Get.lazyPut(() => BaseLogic());
|
||||
Get.lazyPut(() => UsersLogic());
|
||||
@@ -59,5 +61,10 @@ sealed class InspectionPages {
|
||||
page: () => AddMobileInspectorPage(),
|
||||
binding: BindingsBuilder.put(() => AddMobileInspectorLogic()),
|
||||
),
|
||||
GetPage(
|
||||
name: InspectionRoutes.auth,
|
||||
page: () => AuthPage(),
|
||||
binding: BindingsBuilder.put(() => AuthLogic()),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ sealed class InspectionRoutes {
|
||||
InspectionRoutes._();
|
||||
|
||||
static const init = '/supervision';
|
||||
static const inspectionAction = '$init/action';
|
||||
static const auth = '/AuthSupervision';
|
||||
static const inspectionUserProfile = '$init/userSettings';
|
||||
static const inspectionLocationDetails = '$init/locationDetails';
|
||||
static const inspectionAddSupervision = '$inspectionLocationDetails/addSupervision';
|
||||
static const inspectionAddMobileInspector = '$inspectionLocationDetails/addMobileInspector';
|
||||
static const inspectionRegistrationOfViolation = '$inspectionAddSupervision/RegistrationOfViolation';
|
||||
static const inspectionDisplayInformation = '$inspectionRegistrationOfViolation/DisplayInformation';
|
||||
static const inspectionRegistrationOfViolation =
|
||||
'$inspectionAddSupervision/RegistrationOfViolation';
|
||||
static const inspectionDisplayInformation =
|
||||
'$inspectionRegistrationOfViolation/DisplayInformation';
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/di/auth_di.dart';
|
||||
import 'package:rasadyar_auth/data/models/response/captcha/captcha_response_model.dart';
|
||||
import 'package:rasadyar_auth/data/repositories/auth_repository_imp.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/data/model/response/captcha/captcha_response_model.dart';
|
||||
import 'package:rasadyar_inspection/data/repositories/auth_repository_imp.dart';
|
||||
|
||||
class CaptchaWidgetLogic extends GetxController with StateMixin<CaptchaResponseModel> {
|
||||
TextEditingController textController = TextEditingController();
|
||||
RxnString captchaKey = RxnString();
|
||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
AuthRepositoryImpl authRepository = diAuth.get<AuthRepositoryImpl>();
|
||||
//AuthRepositoryImpl authRepository = .get<AuthRepositoryImpl>();
|
||||
final Random random = Random();
|
||||
|
||||
@override
|
||||
@@ -31,8 +30,7 @@ class CaptchaWidgetLogic extends GetxController with StateMixin<CaptchaResponseM
|
||||
change(null, status: RxStatus.loading());
|
||||
textController.clear();
|
||||
await Future.delayed(Duration(milliseconds: 800));
|
||||
captchaKey.value = (random.nextInt(900000)+100000).toString();
|
||||
captchaKey.value = (random.nextInt(900000) + 100000).toString();
|
||||
change(value, status: RxStatus.success());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/presentation/pages/auth/logic.dart';
|
||||
import 'package:rasadyar_auth/presentation/widget/clear_button.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/presentation/pages/auth/logic.dart';
|
||||
import 'package:rasadyar_inspection/presentation/widget/clear_button.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
@@ -1080,13 +1080,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
rasadyar_auth:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "../auth"
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.3"
|
||||
rasadyar_core:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
@@ -11,5 +11,3 @@ dependencies:
|
||||
sdk: flutter
|
||||
rasadyar_core:
|
||||
path: ../core
|
||||
rasadyar_auth:
|
||||
path: ../auth
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:rasadyar_auth/auth.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/presentation/widget/map/logic.dart';
|
||||
import 'package:rasadyar_livestock/presentation/page/map/logic.dart';
|
||||
|
||||
@@ -3,6 +3,7 @@ part of 'app_pages.dart';
|
||||
sealed class LiveStockRoutes {
|
||||
LiveStockRoutes._();
|
||||
|
||||
static const auth = '/AuthLiveStock';
|
||||
static const init = '/liveStock';
|
||||
static const requests = '/requests';
|
||||
static const profile = '/profile';
|
||||
|
||||
@@ -13,8 +13,7 @@ dependencies:
|
||||
sdk: flutter
|
||||
rasadyar_core:
|
||||
path: ../core
|
||||
rasadyar_auth:
|
||||
path: ../auth
|
||||
|
||||
##code generation
|
||||
freezed_annotation: ^3.1.0
|
||||
json_annotation: ^4.9.0
|
||||
|
||||
37
pubspec.lock
37
pubspec.lock
@@ -45,10 +45,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: asn1lib
|
||||
sha256: "0511d6be23b007e95105ae023db599aea731df604608978dada7f9faf2637623"
|
||||
sha256: "9a8f69025044eb466b9b60ef3bc3ac99b4dc6c158ae9c56d25eeccf5bc56d024"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.6.4"
|
||||
version: "1.6.5"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -125,10 +125,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: built_value
|
||||
sha256: "082001b5c3dc495d4a42f1d5789990505df20d8547d42507c29050af6933ee27"
|
||||
sha256: "0b1b12a0a549605e5f04476031cd0bc91ead1d7c8e830773a18ee54179b3cb62"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.10.1"
|
||||
version: "8.11.0"
|
||||
change_app_package_name:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -245,10 +245,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_style
|
||||
sha256: "5b236382b47ee411741447c1f1e111459c941ea1b3f2b540dde54c210a3662af"
|
||||
sha256: "8a0e5fba27e8ee025d2ffb4ee820b4e6e2cf5e4246a6b1a477eb66866947e0bb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
version: "3.1.1"
|
||||
dartx:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -577,10 +577,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: geolocator_android
|
||||
sha256: "114072db5d1dce0ec0b36af2697f55c133bc89a2c8dd513e137c0afe59696ed4"
|
||||
sha256: "179c3cb66dfa674fc9ccbf2be872a02658724d1c067634e2c427cf6df7df901a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.1+1"
|
||||
version: "5.0.2"
|
||||
geolocator_apple:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -745,10 +745,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_android
|
||||
sha256: "317a5d961cec5b34e777b9252393f2afbd23084aa6e60fcf601dcf6341b9ebeb"
|
||||
sha256: "6fae381e6af2bbe0365a5e4ce1db3959462fa0c4d234facf070746024bb80c8d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.8.12+23"
|
||||
version: "0.8.12+24"
|
||||
image_picker_for_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1169,10 +1169,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: posix
|
||||
sha256: f0d7856b6ca1887cfa6d1d394056a296ae33489db914e365e2044fdada449e62
|
||||
sha256: "6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.2"
|
||||
version: "6.0.3"
|
||||
pretty_dio_logger:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1205,13 +1205,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
rasadyar_auth:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "packages/auth"
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.3"
|
||||
rasadyar_chicken:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -1232,7 +1225,7 @@ packages:
|
||||
path: "packages/inspection"
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.1"
|
||||
version: "1.2.0"
|
||||
rasadyar_livestock:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -1252,10 +1245,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shamsi_date
|
||||
sha256: b6c79ff34ddfb1e9e4761347f18e30afdd7d16cc3db77defd5a40e2d93894c51
|
||||
sha256: "0383fddc9bce91e9e08de0c909faf93c3ab3a0e532abd271fb0dcf5d0617487b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
shelf:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -21,9 +21,6 @@ dependencies:
|
||||
rasadyar_inspection:
|
||||
path: ./packages/inspection
|
||||
|
||||
rasadyar_auth:
|
||||
path: ./packages/auth
|
||||
|
||||
rasadyar_livestock:
|
||||
path: ./packages/livestock
|
||||
|
||||
@@ -31,8 +28,6 @@ dependencies:
|
||||
path: ./packages/chicken
|
||||
|
||||
|
||||
|
||||
|
||||
##code generation
|
||||
freezed_annotation: ^3.1.0
|
||||
json_annotation: ^4.9.0
|
||||
|
||||
Reference in New Issue
Block a user