feat: save module

This commit is contained in:
2025-09-02 17:28:02 +03:30
parent 3945e04ae1
commit ebec27b630
7 changed files with 192 additions and 33 deletions

View File

@@ -3,7 +3,7 @@ import 'dart:io';
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_app/infrastructure/service/local_storage_service.dart';
import 'package:rasadyar_core/core.dart';
class SplashLogic extends GetxController with GetTickerProviderStateMixin {
@@ -18,6 +18,7 @@ class SplashLogic extends GetxController with GetTickerProviderStateMixin {
final platform = MethodChannel('apk_installer');
final Dio _dio = Dio();
var tokenService = Get.find<TokenStorageService>();
var localService = Get.find<LocalStorageService>();
AppInfoModel? appInfoModel;
@override
@@ -86,25 +87,26 @@ class SplashLogic extends GetxController with GetTickerProviderStateMixin {
children: [
const Text('در حال دانلود بروزرسانی برنامه...'),
Obx(
() => Row(
spacing: 8,
children: [
Expanded(
child: LinearProgressIndicator(
value: percent.value,
color: AppColor.greenNormal,
minHeight: 4,
),
() =>
Row(
spacing: 8,
children: [
Expanded(
child: LinearProgressIndicator(
value: percent.value,
color: AppColor.greenNormal,
minHeight: 4,
),
),
SizedBox(
width: 55.w,
child: Text(
'${(percent.value * 100).toStringAsFixed(2)}%',
textAlign: TextAlign.center,
),
),
],
),
SizedBox(
width: 55.w,
child: Text(
'${(percent.value * 100).toStringAsFixed(2)}%',
textAlign: TextAlign.center,
),
),
],
),
),
Row(
@@ -117,9 +119,9 @@ class SplashLogic extends GetxController with GetTickerProviderStateMixin {
height: 40.h,
onPressed: data.value != null
? () {
installApk();
Get.back();
}
installApk();
Get.back();
}
: null,
text: 'نصب',
);
@@ -154,11 +156,17 @@ class SplashLogic extends GetxController with GetTickerProviderStateMixin {
if (isUpdateNeeded) return;
tokenService.getModule();
final module = tokenService.appModule.value;
final target = getTargetModule(module);
if (target.values.first != null) {
await target.values.first;
final target = localService.getTargetPage(module);
if (target != null) {
var funs = localService.getFunctionsList(target.functions);
await Future.wait(funs ?? []);
Get.offAndToNamed(target.route!);
}
Get.offAndToNamed(target.keys.first);
} catch (e, st) {
debugPrint("onReady error: $e\n$st");
}