app_update_view.dart 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import 'package:trackoffical_app/logger.dart';
  5. import 'package:trackoffical_app/pb.dart' as pb;
  6. import 'package:trackoffical_app/service/app.dart';
  7. import 'package:trackoffical_app/widget/will_exit_after_2_back.dart';
  8. import '../styles/theme.dart';
  9. class AppUpdateController extends GetxController {
  10. final downloadProcess = 0.0.obs;
  11. Timer? _ticker;
  12. @override
  13. void onReady() {
  14. // var arg = Get.arguments;
  15. // if (arg is pb.GetUpdateVersionReply){
  16. // App.to.updateApp(arg).then((value){
  17. // info('下载完成');
  18. // }, onError: (e){
  19. // warn('安装失败:', e);
  20. // });
  21. // }
  22. // _ticker = Timer.periodic(100.milliseconds, (timer) {
  23. // App.to.getUpdateAppProcess().then((value) => downloadProcess.value = value);
  24. // });
  25. }
  26. @override
  27. void onClose(){
  28. _ticker?.cancel();
  29. }
  30. }
  31. class AppUpdateView extends GetView<AppUpdateController> {
  32. // final pb.GetUpdateVersionReply data;
  33. //
  34. // const AppUpdateView(this.data, {super.key});
  35. //
  36. // static Bindings bindings() {
  37. // return BindingsBuilder(() {
  38. // Get.put<AppUpdateController>(AppUpdateController());
  39. // });
  40. // }
  41. //
  42. // static void show(pb.GetUpdateVersionReply updateInfo) {
  43. // Get.offAll(
  44. // AppUpdateView(updateInfo),
  45. // binding: AppUpdateView.bindings(),
  46. // arguments: updateInfo
  47. // );
  48. // }
  49. @override
  50. Widget build(BuildContext context) {
  51. return WillExitAfter2Back(child: Scaffold(
  52. body: Container(
  53. width: double.infinity,
  54. height: double.infinity,
  55. padding: const EdgeInsets.all(24),
  56. child: Center(
  57. child: Column(
  58. mainAxisSize: MainAxisSize.min,
  59. children: [
  60. const SizedBox(height: 100),
  61. Image.asset('assets/images/sign_in_logo.png', height: 45.77),
  62. const SizedBox(height: 45.35),
  63. Image.asset('assets/images/ic_logo_rect.png', height: 54),
  64. const SizedBox(height: 21),
  65. Text('小飞龙定向软件升级',
  66. style: context.textTheme.titleLarge?.copyWith(fontSize: 13, color: const Color(0xffaaaaaa))),
  67. const SizedBox(height: 24),
  68. Flexible(
  69. flex: 1,
  70. child: Container(
  71. padding: const EdgeInsets.all(24),
  72. height: 400,
  73. width: double.infinity,
  74. child: SizedBox(
  75. width: double.infinity,
  76. child: Column(
  77. crossAxisAlignment: CrossAxisAlignment.start,
  78. children: [
  79. const Text('更新内容:'),
  80. // Text(data.vMemo)
  81. ],
  82. ) ,
  83. ) ,
  84. ),
  85. ),
  86. const SizedBox(height: 24),
  87. SizedBox(
  88. height: 17.42,
  89. child: ClipRRect(
  90. borderRadius: const BorderRadius.all(Radius.circular(8.71)),
  91. child: Obx(() => LinearProgressIndicator(
  92. value: controller.downloadProcess.value),
  93. ) )
  94. ),
  95. const SizedBox(height: 100)
  96. ],
  97. ),
  98. ),
  99. ),
  100. )) ;
  101. }
  102. }
  103. void main() async {
  104. var c = AppUpdateController();
  105. c.downloadProcess.value = 0.5;
  106. Get.put(c);
  107. // runApp(GetMaterialApp(
  108. // theme: appThemeData(),
  109. // home: AppUpdateView(pb.GetUpdateVersionReply()..vMemo= "更新内容")));
  110. }