소스 검색

更新app ui

周睿 2 년 전
부모
커밋
ccdb7bfbd2
2개의 변경된 파일27개의 추가작업 그리고 10개의 파일을 삭제
  1. 26 9
      lib/service/all_init.dart
  2. 1 1
      third_party/common_pub

+ 26 - 9
lib/service/all_init.dart

@@ -1,8 +1,12 @@
+import 'package:common_pub/common_pub_platform_interface.dart';
+import 'package:flutter/material.dart';
 import 'package:get/get.dart';
+import 'package:package_info_plus/package_info_plus.dart';
 import 'api.dart';
 import 'app.dart';
+import 'package:common_pub/pb.dart' as pb;
 
-Future<void> initBeforeApp()async{
+Future<void> initBeforeApp() async {
   // final flavor = await getFlavor();
   // if(flavor=='dev'){
   //   GlobalVar.apiHost='totapi-lc.beswell.com';
@@ -16,14 +20,27 @@ Future<void> initBeforeApp()async{
   // }
 }
 
-
-
-
-Future<void> allInit()async{
-
-
+Future<void> allInit() async {
   Get.put<AppService>(await AppService().init());
   Get.put<ApiService>(await ApiService().init());
 
-
-}
+  ApiService api = Get.find();
+  final packageInfo = await PackageInfo.fromPlatform();
+  final appVersion = packageInfo.version;
+  final updateInfo = await api.stub
+      .toGetUpdateVersion(pb.ToGetUpdateVersionRequest(vCode: appVersion));
+
+  if (updateInfo.needUpdate) {
+    final pStream =
+        CommonPubPlatform.instance.updateApp(updateInfo.vUrl, updateInfo.vCode);
+    final value = 0.0.obs;
+    value.bindStream(pStream);
+
+    await Get.dialog(
+        AlertDialog(
+          title: const Text('软件更新'),
+          content: Obx(() =>  LinearProgressIndicator(value: value.value)),
+        ),
+        barrierDismissible: false);
+  }
+}

+ 1 - 1
third_party/common_pub

@@ -1 +1 @@
-Subproject commit 641e80f1a992f3afdade5ae766a5c65f60df96e2
+Subproject commit 7cac58592cc48ad7afd08f0c01d44e5892f5bac0