You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
4.3 KiB
137 lines
4.3 KiB
import 'dart:io'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
import 'package:flutter/material.dart'; |
|
import 'package:huixiang/utils/bridge.dart'; |
|
import 'package:huixiang/utils/font_weight.dart'; |
|
import 'package:path_provider/path_provider.dart'; |
|
|
|
class UpdateDialog extends StatefulWidget { |
|
final String version; |
|
|
|
UpdateDialog(this.version); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _UpdateDialog(); |
|
} |
|
} |
|
|
|
class _UpdateDialog extends State<UpdateDialog> { |
|
@override |
|
Widget build(BuildContext context) { |
|
return Material( |
|
type: MaterialType.transparency, |
|
child: Center( |
|
child: Container( |
|
width: MediaQuery.of(context).size.width - 80.w, |
|
height: 180.h, |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.circular(8), |
|
), |
|
child: Column( |
|
children: [ |
|
Container( |
|
width: double.infinity, |
|
height: 110.h, |
|
alignment: Alignment.center, |
|
padding: EdgeInsets.all(20), |
|
child: Column( |
|
children: [ |
|
Text( |
|
"检测到新版本 v${widget.version}", |
|
style: TextStyle( |
|
fontSize: 18.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFF353535), |
|
), |
|
), |
|
Text( |
|
"是否需要更新到最新版本?", |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF353535), |
|
), |
|
), |
|
], |
|
) |
|
), |
|
Container( |
|
color: Color(0x1A000000), |
|
height: 1.h, |
|
), |
|
Container( |
|
height: 69.h, |
|
child: Row( |
|
mainAxisSize: MainAxisSize.max, |
|
children: [ |
|
Expanded( |
|
child: InkWell( |
|
onTap: () { |
|
Navigator.of(context).pop(); |
|
}, |
|
child: Container( |
|
width: double.infinity, |
|
height: 90.h, |
|
alignment: Alignment.center, |
|
child: Text( |
|
"下次再说", |
|
style: TextStyle( |
|
fontSize: 17.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF353535), |
|
), |
|
), |
|
), |
|
), |
|
flex: 1, |
|
), |
|
Container( |
|
color: Color(0x1A000000), |
|
width: 1.h, |
|
), |
|
Expanded( |
|
child: InkWell( |
|
onTap: () { |
|
Bridge.toAppStore().then((value) { |
|
}); |
|
Navigator.of(context).pop(); |
|
}, |
|
child: Container( |
|
width: double.infinity, |
|
height: 90.h, |
|
alignment: Alignment.center, |
|
child: Text( |
|
"立即更新", |
|
style: TextStyle( |
|
fontSize: 17.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF32A060), |
|
), |
|
), |
|
), |
|
), |
|
flex: 1, |
|
), |
|
], |
|
), |
|
), |
|
], |
|
), |
|
), |
|
), |
|
); |
|
} |
|
|
|
|
|
Future<String> _findLocalPath(BuildContext context) async { |
|
final directory = Theme.of(context).platform == TargetPlatform.android |
|
? await getExternalStorageDirectory() |
|
: await getApplicationDocumentsDirectory(); |
|
return directory.path; |
|
} |
|
|
|
|
|
}
|
|
|