|
|
@@ -34,6 +34,7 @@ import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
import 'package:install_plugin/install_plugin.dart';
|
|
|
+import 'package:launch_review/launch_review.dart';
|
|
|
import 'package:lpinyin/lpinyin.dart';
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
|
|
@@ -2351,175 +2352,221 @@ updateDialog(AndroidAppVersionBeanData data, BuildContext context) {
|
|
|
showDialog(
|
|
|
context: context,
|
|
|
builder: (BuildContext context) {
|
|
|
- return StreamBuilder<Object>(builder: (context, snapshot) {
|
|
|
- return Material(
|
|
|
- color: Colors.black12,
|
|
|
- child: Center(
|
|
|
- child: Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- borderRadius: BorderRadius.circular(16),
|
|
|
- color: Colors.white,
|
|
|
- ),
|
|
|
- height: 165,
|
|
|
- margin: EdgeInsets.symmetric(horizontal: 18),
|
|
|
- padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
|
|
|
- child: StatefulBuilder(
|
|
|
- builder: (BuildContext context,
|
|
|
- void Function(void Function()) setState) {
|
|
|
- EventBus().on('更新进度条', (arg) {
|
|
|
- p = arg;
|
|
|
- setState(() {});
|
|
|
- });
|
|
|
- EventBus().on('允许安装', (arg) {
|
|
|
- downloadCompleted = true;
|
|
|
- filePath = arg;
|
|
|
- setState(() {});
|
|
|
- });
|
|
|
- if (startUpdate) {
|
|
|
- return Column(
|
|
|
- children: [
|
|
|
- Container(
|
|
|
- height: 88,
|
|
|
- child: Column(
|
|
|
- children: [
|
|
|
- Container(
|
|
|
- child: MyViews()
|
|
|
- .myText('更新中...', MyColors.c333333, 16),
|
|
|
- ),
|
|
|
- SizedBox(
|
|
|
- height: 15,
|
|
|
- child: ClipRRect(
|
|
|
- borderRadius: BorderRadius.circular(7.5),
|
|
|
- child: LinearProgressIndicator(
|
|
|
- backgroundColor: Colors.grey[200],
|
|
|
- valueColor: AlwaysStoppedAnimation(
|
|
|
- MyColors.cFF4233),
|
|
|
- value: downloadCompleted
|
|
|
- ? 1
|
|
|
- : NumUtil.divide(p, 100),
|
|
|
+ return WillPopScope(
|
|
|
+ onWillPop: () {
|
|
|
+ return Future.value(false);
|
|
|
+ },
|
|
|
+ child: StreamBuilder<Object>(builder: (context, snapshot) {
|
|
|
+ return Material(
|
|
|
+ color: Colors.black12,
|
|
|
+ child: Center(
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.circular(16),
|
|
|
+ color: Colors.white,
|
|
|
+ ),
|
|
|
+ height: 165,
|
|
|
+ margin: EdgeInsets.symmetric(horizontal: 18),
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
|
|
|
+ child: StatefulBuilder(
|
|
|
+ builder: (BuildContext context,
|
|
|
+ void Function(void Function()) setState) {
|
|
|
+ EventBus().on('更新进度条', (arg) {
|
|
|
+ p = arg;
|
|
|
+ setState(() {});
|
|
|
+ });
|
|
|
+ EventBus().on('允许安装', (arg) {
|
|
|
+ downloadCompleted = true;
|
|
|
+ filePath = arg;
|
|
|
+ setState(() {});
|
|
|
+ });
|
|
|
+ if (startUpdate) {
|
|
|
+ return Column(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ height: 88,
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ child: MyViews()
|
|
|
+ .myText('更新中...', MyColors.c333333, 16),
|
|
|
+ ),
|
|
|
+ SizedBox(
|
|
|
+ height: 15,
|
|
|
+ child: ClipRRect(
|
|
|
+ borderRadius: BorderRadius.circular(7.5),
|
|
|
+ child: LinearProgressIndicator(
|
|
|
+ backgroundColor: Colors.grey[200],
|
|
|
+ valueColor: AlwaysStoppedAnimation(
|
|
|
+ MyColors.cFF4233),
|
|
|
+ value: downloadCompleted
|
|
|
+ ? 1
|
|
|
+ : NumUtil.divide(p, 100),
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
- ),
|
|
|
- ],
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
+ ],
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
+ ),
|
|
|
),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- height: 0.5,
|
|
|
- color: MyColors.cE7E7E7,
|
|
|
- margin: EdgeInsets.only(bottom: 12),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- margin: EdgeInsets.symmetric(horizontal: 20),
|
|
|
- child: GestureDetector(
|
|
|
- behavior: HitTestBehavior.translucent,
|
|
|
- onTap: () {
|
|
|
- if (downloadCompleted) {
|
|
|
- installApk(filePath);
|
|
|
- }
|
|
|
- },
|
|
|
- child: Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- borderRadius: BorderRadius.circular(20),
|
|
|
- color: downloadCompleted
|
|
|
- ? MyColors.cFF4233
|
|
|
- : MyColors.c999999),
|
|
|
- height: 40,
|
|
|
- child: MyViews().myText('安装', Colors.white, 14),
|
|
|
- alignment: Alignment.center,
|
|
|
+ Container(
|
|
|
+ height: 0.5,
|
|
|
+ color: MyColors.cE7E7E7,
|
|
|
+ margin: EdgeInsets.only(bottom: 12),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.symmetric(horizontal: 20),
|
|
|
+ child: GestureDetector(
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ onTap: () {
|
|
|
+ if (downloadCompleted) {
|
|
|
+ installApk(filePath);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.circular(20),
|
|
|
+ color: downloadCompleted
|
|
|
+ ? MyColors.cFF4233
|
|
|
+ : MyColors.c999999),
|
|
|
+ height: 40,
|
|
|
+ child: MyViews().myText('安装', Colors.white, 14),
|
|
|
+ alignment: Alignment.center,
|
|
|
+ ),
|
|
|
),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ return Column(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ height: 88,
|
|
|
+ child: MyViews().myText(
|
|
|
+ data.force
|
|
|
+ ? '检查到新版本(v${data.version}),请更新'
|
|
|
+ : '检查到新版本(v${data.version}),请问是否更新',
|
|
|
+ MyColors.c333333,
|
|
|
+ 14),
|
|
|
+ margin: EdgeInsets.symmetric(horizontal: 20),
|
|
|
+ alignment: Alignment.center,
|
|
|
),
|
|
|
- )
|
|
|
- ],
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- );
|
|
|
- } else {
|
|
|
- return Column(
|
|
|
- children: [
|
|
|
- Container(
|
|
|
- height: 88,
|
|
|
- child: MyViews().myText(
|
|
|
- data.force ? '检查到新版本,请更新' : '检查到新版本,请问是否更新',
|
|
|
- MyColors.c333333,
|
|
|
- 14),
|
|
|
- margin: EdgeInsets.symmetric(horizontal: 20),
|
|
|
- alignment: Alignment.center,
|
|
|
- ),
|
|
|
- Container(
|
|
|
- height: 0.5,
|
|
|
- color: MyColors.cE7E7E7,
|
|
|
- margin: EdgeInsets.only(bottom: 12),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- margin: EdgeInsets.symmetric(horizontal: 10),
|
|
|
- child: Row(
|
|
|
- children: [
|
|
|
- Expanded(
|
|
|
- child: GestureDetector(
|
|
|
- onTap: () {
|
|
|
- if (data.force) {
|
|
|
- EventBus().off('允许安装');
|
|
|
- EventBus().off('更新进度条');
|
|
|
- SystemNavigator.pop();
|
|
|
- } else {
|
|
|
- EventBus().off('允许安装');
|
|
|
- EventBus().off('更新进度条');
|
|
|
- Navigator.pop(context);
|
|
|
- }
|
|
|
- },
|
|
|
- behavior: HitTestBehavior.translucent,
|
|
|
- child: Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- borderRadius: BorderRadius.only(
|
|
|
- topLeft: Radius.circular(20),
|
|
|
- bottomLeft: Radius.circular(20),
|
|
|
- ),
|
|
|
- border: Border.all(
|
|
|
- color: MyColors.cFF4233,
|
|
|
- width: 1.1),
|
|
|
- color: Colors.white),
|
|
|
- child: MyViews()
|
|
|
- .myText('暂不更新', MyColors.cFF4233, 14),
|
|
|
- height: 40,
|
|
|
- alignment: Alignment.center,
|
|
|
+ Container(
|
|
|
+ height: 0.5,
|
|
|
+ color: MyColors.cE7E7E7,
|
|
|
+ margin: EdgeInsets.only(bottom: 12),
|
|
|
+ ),
|
|
|
+ data.force
|
|
|
+ ? Container(
|
|
|
+ margin: EdgeInsets.symmetric(horizontal: 10),
|
|
|
+ child: Expanded(
|
|
|
+ child: GestureDetector(
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ onTap: () {
|
|
|
+ if (Platform.isAndroid) {
|
|
|
+ downloadAPK(data, context);
|
|
|
+ startUpdate = true;
|
|
|
+ setState(() {});
|
|
|
+ } else if (Platform.isIOS) {
|
|
|
+ LaunchReview.launch(
|
|
|
+ iOSAppId: appStoreID);
|
|
|
+ } else {
|
|
|
+ Navigator.pop(context);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius:
|
|
|
+ BorderRadius.circular(20),
|
|
|
+ color: MyColors.cFF4233),
|
|
|
+ height: 40,
|
|
|
+ child: MyViews()
|
|
|
+ .myText('立即更新', Colors.white, 14),
|
|
|
+ alignment: Alignment.center,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
),
|
|
|
- ),
|
|
|
- ),
|
|
|
- Expanded(
|
|
|
- child: GestureDetector(
|
|
|
- behavior: HitTestBehavior.translucent,
|
|
|
- onTap: () {
|
|
|
- downloadAPK(data, context);
|
|
|
- startUpdate = true;
|
|
|
- setState(() {});
|
|
|
- },
|
|
|
- child: Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- borderRadius: BorderRadius.only(
|
|
|
- topRight: Radius.circular(20),
|
|
|
- bottomRight: Radius.circular(20),
|
|
|
+ )
|
|
|
+ : Container(
|
|
|
+ margin: EdgeInsets.symmetric(horizontal: 10),
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ Expanded(
|
|
|
+ child: GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ if (data.force) {
|
|
|
+ EventBus().off('允许安装');
|
|
|
+ EventBus().off('更新进度条');
|
|
|
+ SystemNavigator.pop();
|
|
|
+ } else {
|
|
|
+ EventBus().off('允许安装');
|
|
|
+ EventBus().off('更新进度条');
|
|
|
+ Navigator.pop(context);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.only(
|
|
|
+ topLeft: Radius.circular(20),
|
|
|
+ bottomLeft: Radius.circular(20),
|
|
|
+ ),
|
|
|
+ border: Border.all(
|
|
|
+ color: MyColors.cFF4233,
|
|
|
+ width: 1.1),
|
|
|
+ color: Colors.white),
|
|
|
+ child: MyViews().myText(
|
|
|
+ '暂不更新', MyColors.cFF4233, 14),
|
|
|
+ height: 40,
|
|
|
+ alignment: Alignment.center,
|
|
|
+ ),
|
|
|
),
|
|
|
- color: MyColors.cFF4233),
|
|
|
- height: 40,
|
|
|
- child: MyViews()
|
|
|
- .myText('立即更新', Colors.white, 14),
|
|
|
- alignment: Alignment.center,
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: GestureDetector(
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ onTap: () {
|
|
|
+ if (Platform.isAndroid) {
|
|
|
+ downloadAPK(data, context);
|
|
|
+ startUpdate = true;
|
|
|
+ setState(() {});
|
|
|
+ } else if (Platform.isIOS) {
|
|
|
+ LaunchReview.launch(
|
|
|
+ iOSAppId: appStoreID);
|
|
|
+ } else {
|
|
|
+ Navigator.pop(context);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.only(
|
|
|
+ topRight: Radius.circular(20),
|
|
|
+ bottomRight:
|
|
|
+ Radius.circular(20),
|
|
|
+ ),
|
|
|
+ color: MyColors.cFF4233),
|
|
|
+ height: 40,
|
|
|
+ child: MyViews()
|
|
|
+ .myText('立即更新', Colors.white, 14),
|
|
|
+ alignment: Alignment.center,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
),
|
|
|
- ),
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- )
|
|
|
- ],
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- );
|
|
|
- }
|
|
|
- },
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
- ),
|
|
|
- );
|
|
|
- });
|
|
|
+ );
|
|
|
+ }),
|
|
|
+ );
|
|
|
},
|
|
|
);
|
|
|
}
|