1 - multi module in Auth select save selected module
 2 - add flutter gen for assets builder
This commit is contained in:
2025-05-19 16:16:33 +03:30
parent 982329a3eb
commit 905e407ccd
46 changed files with 1431 additions and 407 deletions

View File

@@ -3,6 +3,7 @@ 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/local/module/module_model.dart';
import 'package:rasadyar_auth/data/models/request/login_request/login_request_model.dart';
import 'package:rasadyar_auth/data/models/response/auth/auth_response_model.dart';
import 'package:rasadyar_auth/data/repositories/auth_repository_imp.dart';
@@ -10,6 +11,8 @@ import 'package:rasadyar_auth/data/services/token_storage_service.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';
enum AuthType { useAndPass, otp }
enum AuthStatus { init }
@@ -42,6 +45,8 @@ class AuthLogic extends GetxController {
AuthRepositoryImpl authRepository = diAuth.get<AuthRepositoryImpl>();
final Module _module = Get.arguments;
void startTimer() {
_timer?.cancel();
secondsRemaining.value = 120;
@@ -73,8 +78,8 @@ class AuthLogic extends GetxController {
@override
void onReady() {
// TODO: implement onReady
super.onReady();
iLog('module111 : ${_module.toString()}');
}
@override
@@ -106,14 +111,16 @@ class AuthLogic extends GetxController {
Future<void> submitLoginForm() async {
if (!_isFormValid()) return;
iLog('module222 : ${_module.toString()}');
final loginRequestModel = _buildLoginRequest();
isLoading.value = true;
await safeCall<AuthResponseModel?>(
call: () => authRepository.login(authRequest: loginRequestModel.toJson()),
onSuccess: (result) async {
await tokenStorageService.saveRefreshToken(result!.refresh!);
await tokenStorageService.saveAccessToken(result!.access!);
await tokenStorageService.saveModule(_module);
await tokenStorageService.saveRefreshToken(result?.refresh ?? '');
await tokenStorageService.saveAccessToken(result?.access ?? '');
//Get.offAndToNamed(Routes.home);
},
onError: (error, stackTrace) {

View File

@@ -109,7 +109,10 @@ class AuthPage extends GetView<AuthLogic> {
},
prefixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 6, 8),
child: vecWidget(Assets.vecCallSvg),
child: Assets.vec.callSvg.svg(
width: 12,
height: 12,
),
),
suffixIcon:
phoneController.value.text
@@ -168,7 +171,10 @@ class AuthPage extends GetView<AuthLogic> {
labelStyle: AppFonts.yekan13,
prefixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 8, 8),
child: vecWidget(Assets.vecKeySvg),
child: Assets.vec.keySvg.svg(
width: 12,
height: 12,
),
),
boxConstraints: const BoxConstraints(
maxHeight: 34,

View File

@@ -1,7 +1,16 @@
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 {
List<ModuleModel> moduleList=[
ModuleModel(title: 'بازرسی', icon: Assets.icons.inspection.path, module: Module.inspection),
ModuleModel(title: 'دام', icon: Assets.icons.liveStock.path, module: Module.liveStocks),
];
RxnInt selectedIndex = RxnInt(null);
@override
@@ -9,6 +18,9 @@ class ModulesLogic extends GetxController {
super.onReady();
}
@override
void onClose() {
super.onClose();

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rasadyar_auth/presentation/routes/pages.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
@@ -8,8 +9,37 @@ class ModulesPage extends GetView<ModulesLogic> {
@override
Widget build(BuildContext context) {
final ModulesLogic logic = Get.put(ModulesLogic());
return Scaffold(
appBar: AppBar(
title: Text(
'انتخاب سامانه',
style: AppFonts.yekan18.copyWith(color: Colors.white),
),
centerTitle: true,
backgroundColor: AppColor.blueNormal,
),
body: GridView.builder(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 20),
return Container();
itemBuilder: (context, index) {
final module = controller.moduleList[index];
return CardIcon(
title: module.title,
icon: module.icon,
onTap: () {
controller.selectedIndex.value = index;
Get.toNamed(AuthPaths.auth, arguments: module.module);
},
);
},
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
),
physics: BouncingScrollPhysics(),
itemCount: controller.moduleList.length,
),
);
}
}

View File

@@ -1,3 +1,5 @@
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';
@@ -12,10 +14,9 @@ sealed class AuthPages {
static List<GetPage> pages = [
GetPage(
name: AuthPaths.moduleList,
page: () => AuthPage(),
page: () => ModulesPage(),
binding: BindingsBuilder(() {
Get.lazyPut(() => AuthLogic());
Get.lazyPut(() => CaptchaWidgetLogic());
Get.lazyPut(() => ModulesLogic());
}),
),

View File

@@ -9,7 +9,10 @@ class LogoWidget extends StatelessWidget {
return Column(
children: [
Row(),
Image.asset(Assets.imagesInnerSplash, width: 120, height: 120),
Assets.images.innerSplash.image(
width: 150,
height: 150,
),
Text(
'سامانه رصدیار',
style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyNormal),