|
...
|
...
|
@@ -31,9 +31,9 @@ class UpdateModel { |
|
|
|
}
|
|
|
|
|
|
|
|
//版本更新弹框
|
|
|
|
showUpdateDialog(BuildContext context, Version version) {
|
|
|
|
showUpdateDialog(BuildContext pageContext, Version version) {
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
context: pageContext,
|
|
|
|
builder: (context) {
|
|
|
|
Widget widget = Container(
|
|
|
|
decoration: BoxDecoration(
|
|
...
|
...
|
@@ -96,7 +96,7 @@ class UpdateModel { |
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
downloadApk(context, version.file_url);
|
|
|
|
downloadApk(pageContext, version.file_url);
|
|
|
|
} else {
|
|
|
|
InstallPlugin.gotoAppStore(
|
|
|
|
"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1510697490");
|
|
...
|
...
|
@@ -141,10 +141,20 @@ class UpdateModel { |
|
|
|
if (permissions[PermissionGroup.storage] == PermissionStatus.granted) {
|
|
|
|
final dir = await getExternalStorageDirectory();
|
|
|
|
String savePath = dir.path + "/one_key";
|
|
|
|
Directory directory=new Directory(savePath);
|
|
|
|
if(directory.existsSync()){//删除历史apk
|
|
|
|
final List<FileSystemEntity> files=directory.listSync();
|
|
|
|
for(FileSystemEntity file in files){
|
|
|
|
file.deleteSync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
showDownloadProgress(context);
|
|
|
|
DioUtil().download(file_url, savePath, onProgress: (received, total) {
|
|
|
|
int progress = ((received / total) * 100).round();
|
|
|
|
_progress = progress;
|
|
|
|
_setState(() {});
|
|
|
|
if(_progress!=100){
|
|
|
|
int progress = ((received / total) * 100).round();
|
|
|
|
_progress = progress;
|
|
|
|
_setState(() {});
|
|
|
|
}
|
|
|
|
if (received == total) {
|
|
|
|
//下载完成
|
|
|
|
InstallPlugin.installApk(savePath, "com.naji.one_key");
|
|
...
|
...
|
@@ -154,15 +164,15 @@ class UpdateModel { |
|
|
|
}
|
|
|
|
|
|
|
|
//显示下载进度条
|
|
|
|
Function showDownloadProgress(BuildContext context) {
|
|
|
|
showDownloadProgress(BuildContext context) {
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: false,
|
|
|
|
builder: (context) {
|
|
|
|
builder: (ct) {
|
|
|
|
return AlertDialog(
|
|
|
|
content: StatefulBuilder(builder: (context, setState) {
|
|
|
|
if (_progress == 100) {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
if (_progress==100) {
|
|
|
|
Navigator.of(ct).pop();
|
|
|
|
}
|
|
|
|
_setState = setState;
|
|
|
|
return Column(
|
|
...
|
...
|
@@ -177,6 +187,5 @@ class UpdateModel { |
|
|
|
);
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
return _setState;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|