feat: save module
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user