|
|
|
@ -20,9 +20,11 @@ import 'package:huixiang/union/union_page.dart';
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
import 'package:huixiang/utils/bridge.dart'; |
|
|
|
|
import 'package:huixiang/utils/event_type.dart'; |
|
|
|
|
import 'package:huixiang/utils/flutter_utils.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:huixiang/utils/native_event_handler.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/update_dialog.dart'; |
|
|
|
|
import 'package:package_info/package_info.dart'; |
|
|
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_interface.dart'; |
|
|
|
@ -50,8 +52,6 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
|
|
|
|
|
final GlobalKey homePageKey = GlobalKey(); |
|
|
|
|
// List<String> iconn; |
|
|
|
|
ApiService apiService; |
|
|
|
|
String version = "1.0.1"; |
|
|
|
|
AppUpdate appUpdate; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -80,7 +80,6 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
|
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
|
|
|
|
|
|
EasyLoading.instance |
|
|
|
|
..indicatorType = EasyLoadingIndicatorType.circle |
|
|
|
|
// ..indicatorType = EasyLoadingIndicatorType.wave |
|
|
|
@ -327,19 +326,30 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
|
|
|
|
|
|
|
|
|
|
///app自动更新 |
|
|
|
|
appAutoUpdate() async { |
|
|
|
|
if (apiService == null) { |
|
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
|
if (apiService == null) { |
|
|
|
|
apiService = ApiService( |
|
|
|
|
Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: value.getString("token"), |
|
|
|
|
showLoading: true |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
PackageInfo packageInfo = await PackageInfo.fromPlatform(); |
|
|
|
|
BaseData<AppUpdate> baseData = await apiService.appVersion().catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
if(version != appUpdate?.appLastVersion ?? ""){ |
|
|
|
|
showAlertDialog(version); |
|
|
|
|
if(AppUtils.versionCompare(packageInfo.version,baseData.data?.appLastVersion) |
|
|
|
|
&& AppUtils.versionCompare(value.getString("appLastVersion")??"1.0.0",baseData.data?.appLastVersion)){ |
|
|
|
|
showDialog( |
|
|
|
|
context: context, |
|
|
|
|
barrierDismissible: false, |
|
|
|
|
builder: (BuildContext context) { |
|
|
|
|
return WillPopScope( |
|
|
|
|
child:UpdateDialog(packageInfo.version,baseData.data), |
|
|
|
|
onWillPop: () async { |
|
|
|
|
return Future.value(false); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
}else{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -475,18 +485,6 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///app更新弹窗 |
|
|
|
|
showAlertDialog(version) { |
|
|
|
|
//显示对话框 |
|
|
|
|
showDialog( |
|
|
|
|
context: context, |
|
|
|
|
builder: (BuildContext context) { |
|
|
|
|
return UpdateDialog(version,appUpdate); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Widget bottomNavigationBigItem(text, index) { |
|
|
|
|
// var isSelected = index == clickIndex; |
|
|
|
|
// return Expanded( |
|
|
|
|