Merge branch with resolved conflicts - restructured features and added new modules

This commit is contained in:
2025-12-17 10:26:39 +03:30
484 changed files with 55236 additions and 4255 deletions

View File

@@ -4,10 +4,11 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/data/common/dio_error_handler.dart';
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
import 'package:rasadyar_chicken/data/models/response/user_info/user_info_model.dart';
import 'package:rasadyar_chicken/data/models/response/user_profile_model/user_profile_model.dart';
import 'package:rasadyar_chicken/data/repositories/auth/auth_repository.dart';
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/user_info/user_info_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/user_profile_model/user_profile_model.dart';
import 'package:rasadyar_chicken/features/common/data/repositories/auth/auth_repository.dart';
import 'package:rasadyar_chicken/features/common/presentation/routes/routes.dart';
import 'package:rasadyar_chicken/features/steward/presentation/routes/routes.dart';
import 'package:rasadyar_chicken/presentation/widget/captcha/logic.dart';
import 'package:rasadyar_core/core.dart';
@@ -28,7 +29,8 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
Rx<GlobalKey<FormState>> formKeySentOtp = GlobalKey<FormState>().obs;
Rx<TextEditingController> usernameController = TextEditingController().obs;
Rx<TextEditingController> passwordController = TextEditingController().obs;
Rx<TextEditingController> phoneOtpNumberController = TextEditingController().obs;
Rx<TextEditingController> phoneOtpNumberController =
TextEditingController().obs;
Rx<TextEditingController> otpCodeController = TextEditingController().obs;
var captchaController = Get.find<CaptchaWidgetLogic>();
@@ -56,12 +58,18 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
void onInit() {
super.onInit();
_textAnimationController =
AnimationController(vsync: this, duration: const Duration(milliseconds: 1200))
AnimationController(
vsync: this,
duration: const Duration(milliseconds: 1200),
)
..repeat(reverse: true, count: 2).whenComplete(() {
showCard.value = true;
});
textAnimation = CurvedAnimation(parent: _textAnimationController, curve: Curves.easeInOut);
textAnimation = CurvedAnimation(
parent: _textAnimationController,
curve: Curves.easeInOut,
);
initUserPassData();
getDeviceModel();
@@ -98,7 +106,8 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
}
bool _isFormValid() {
final isCaptchaValid = captchaController.formKey.currentState?.validate() ?? false;
final isCaptchaValid =
captchaController.formKey.currentState?.validate() ?? false;
final isFormValid = formKey.currentState?.validate() ?? false;
return isCaptchaValid && isFormValid;
}
@@ -117,13 +126,33 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
onSuccess: (result) async {
await gService.saveSelectedModule(_module);
await tokenStorageService.saveModule(_module);
await tokenStorageService.saveAccessToken(_module, result?.accessToken ?? '');
await tokenStorageService.saveRefreshToken(_module, result?.accessToken ?? '');
await tokenStorageService.saveAccessToken(
_module,
result?.accessToken ?? '',
);
await tokenStorageService.saveRefreshToken(
_module,
result?.accessToken ?? '',
);
var tmpRoles = result?.role?.where((element) {
final allowedRoles = {'poultryscience', 'steward', 'killhouse'};
final allowedRoles = {
'poultryscience',
'steward',
'killhouse',
'provinceinspector',
'cityjahad',
'jahad',
'vetfarm',
'provincesupervisor',
'superadmin',
};
final lowerElement = element.toString().toLowerCase().trim();
return allowedRoles.contains(lowerElement);
}).toList();
if (tmpRoles?.length==1) {
await tokenStorageService.saveRoles(_module, tmpRoles ?? []);
}
await tokenStorageService.saveRoles(_module, tmpRoles ?? []);
if (rememberMe.value) {
@@ -142,11 +171,15 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
},
);
if (tmpRoles!.length > 1) {
Get.offAndToNamed(ChickenRoutes.role);
Get.offAndToNamed(CommonRoutes.role);
/* if (tmpRoles!.length > 1) {
Get.offAndToNamed(CommonRoutes.role);
} else {
Get.offAllNamed(ChickenRoutes.initSteward);
}
Get.offAllNamed(StewardRoutes.initSteward);
} */
},
onError: (error, stackTrace) {
if (error is DioException) {
@@ -183,7 +216,9 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
}
void initUserPassData() {
UserLocalModel? userLocalModel = tokenStorageService.getUserLocal(Module.chicken);
UserLocalModel? userLocalModel = tokenStorageService.getUserLocal(
Module.chicken,
);
if (userLocalModel?.username != null && userLocalModel?.password != null) {
usernameController.value.text = userLocalModel?.username ?? '';
passwordController.value.text = userLocalModel?.password ?? '';
@@ -196,18 +231,14 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
if (Platform.isAndroid) {
final info = await deviceInfo.androidInfo;
print('Device: ${info.manufacturer} ${info.model}');
print('Android version: ${info.version.release}');
deviceName.value =
'Device:${info.manufacturer} Model:${info.model} version ${info.version.release}';
} else if (Platform.isIOS) {
final info = await deviceInfo.iosInfo;
print('Device: ${info.utsname.machine} (${info.name})');
print('System version: ${info.systemVersion}');
deviceName.value =
'Device:${info.utsname.machine} Model:${info.model} version ${info.systemVersion}';
} else {
print('Unsupported platform');
}
} else {}
}
}