diff --git a/circle_app/lib/app/aboutapp/logic.dart b/circle_app/lib/app/aboutapp/logic.dart index 2aa683d..839941e 100644 --- a/circle_app/lib/app/aboutapp/logic.dart +++ b/circle_app/lib/app/aboutapp/logic.dart @@ -17,28 +17,41 @@ import 'package:package_info_plus/package_info_plus.dart'; class AboutappLogic extends GetxController { final AboutappState state = AboutappState(); String version = ""; - + UpdateInfo? _updateInfo; + bool isUpdate = false; + String currentVersion = ""; @override - void onInit() { + void onInit() async{ super.onInit(); getVersion(); + var data = await DioManager.instance.get(url: Api.APP_VERSION); + var bean = BaseResponse.fromJson( + data, (data) => UpdateInfo.fromJson(data)); + if (bean.isSuccess()) { + isUpdate = bean.data.update == 1; + _updateInfo = bean.data; + version = bean.data.version; + update(); + // showReportDialog(Get.context!, bean.data.constraint == 0, bean.data); + } + + //getVersion(); // getAppVersion(); } getVersion() async { final info = await PackageInfo.fromPlatform(); - version = info.version; + currentVersion = "V:${info.version}"; + //version = info.version; update(); return version; } getUpVersion() async { - var data = await DioManager.instance.get(url: Api.APP_VERSION); - var bean = BaseResponse.fromJson( - data, (data) => UpdateInfo.fromJson(data)); - if (bean.isSuccess() && bean.data.update == 1) { - showReportDialog(Get.context!, bean.data.constraint == 0, bean.data); + if(isUpdate){ + showReportDialog(Get.context!, _updateInfo!.constraint == 0, _updateInfo!); } + } void showReportDialog( diff --git a/circle_app/lib/app/aboutapp/view.dart b/circle_app/lib/app/aboutapp/view.dart index 136cd67..ccda56f 100644 --- a/circle_app/lib/app/aboutapp/view.dart +++ b/circle_app/lib/app/aboutapp/view.dart @@ -1,11 +1,11 @@ + + import 'package:circle_app/util/util.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../components/my_app_bar.dart'; -import '../../network/dio_manager.dart'; -import '../dialog/UpdateDialog.dart'; import 'logic.dart'; @@ -52,6 +52,14 @@ class AboutappPage extends StatelessWidget { ) ,) , SizedBox(height: 20.sp), + Text( + logic.currentVersion, + style: TextStyle( + color: const Color(0xFFF7FAFA), + fontSize: 12.sp, + ), + ), + SizedBox(height: 10.sp), Text( '圈子', style: TextStyle( @@ -123,15 +131,14 @@ class AboutappPage extends StatelessWidget { behavior: HitTestBehavior.opaque, onTap: (){ navigateToPrivacyPolicy(); - }, child: Row( children: [ - const Text( + Text( '隐私政策', style: TextStyle( - color: Color(0xFFF7FAFA), - fontSize: 16, + color: const Color(0xFFF7FAFA), + fontSize: 16.sp, ), ), const Spacer(), @@ -160,7 +167,7 @@ class AboutappPage extends StatelessWidget { ), ), const Spacer(), - Container( + logic.isUpdate? Container( width: 6.sp, height: 5.sp, margin: EdgeInsets.only(top: 1.sp, right: 8.sp), @@ -168,7 +175,7 @@ class AboutappPage extends StatelessWidget { color: Colors.red, borderRadius: BorderRadius.circular(3.sp), ), - ), + ):Container(), Text( logic.version, style: TextStyle( diff --git a/circle_app/lib/app/dialog/UpdateDialog.dart b/circle_app/lib/app/dialog/UpdateDialog.dart index 571e906..791b9e1 100644 --- a/circle_app/lib/app/dialog/UpdateDialog.dart +++ b/circle_app/lib/app/dialog/UpdateDialog.dart @@ -19,15 +19,12 @@ class UpdateDialog extends StatefulWidget { _CustomDialogState createState() => _CustomDialogState(); } +double myProgress = 0; + class _CustomDialogState extends State { - double progress = 0; bool isDownload = false; - void incrementCounter() { - setState(() { - progress = progress + 0.1; - }); - } + void incrementCounter() {} void setDownloadUi() { setState(() { @@ -90,37 +87,34 @@ class _CustomDialogState extends State { height: 70.sp, ), ), - Container( - margin: EdgeInsets.only( - top: 12.sp, left: 14.sp, right: 14.sp), - alignment: Alignment.center, - child: Text( - widget.updateInfo.updateInfo, - textAlign: TextAlign.center, - style: TextStyle( - color: const Color(0xCCF7FAFA), fontSize: 16.sp), + SizedBox( + height: 65.sp, + child: ListView( + children: [ + Container( + margin: EdgeInsets.only( + top: 12.sp, left: 14.sp, right: 14.sp), + alignment: Alignment.center, + child: Text( + widget.updateInfo.updateInfo, + textAlign: TextAlign.center, + style: TextStyle( + color: const Color(0xCCF7FAFA), + fontSize: 16.sp), + ), + ) + ], ), ), isDownload ? GestureDetector( onTap: () async { - if (Platform.isIOS) { - final String appStoreUrl = 'https://apps.apple.com/app/id$iOSAPPid'; // App Store链接示例 - if (await canLaunch(appStoreUrl)) { - await launch(appStoreUrl); - } else { - throw 'Could not open App Store.'; - } - } else { - updataApk(widget.updateInfo.downloadUrl); - } - //incrementCounter(); }, child: Container( margin: EdgeInsets.only(top: 24.sp), child: CircularProgressIndicator( - value: progress, + value: myProgress, backgroundColor: Colors.grey, valueColor: const AlwaysStoppedAnimation( Colors.blue), @@ -130,8 +124,19 @@ class _CustomDialogState extends State { ) : GestureDetector( behavior: HitTestBehavior.opaque, - onTap: () { - setDownloadUi(); + onTap: () async { + if (Platform.isIOS) { + final String appStoreUrl = + 'https://apps.apple.com/app/id$IOS_APP_ID'; // App Store链接示例 + if (await canLaunch(appStoreUrl)) { + await launch(appStoreUrl); + } else { + throw 'Could not open App Store.'; + } + } else { + updataApk(widget.updateInfo.downloadUrl); + setDownloadUi(); + } //Navigator.pop(context); // logic.setBlock(); @@ -168,32 +173,42 @@ class _CustomDialogState extends State { ) ], ), - ) + ), + Positioned( + right: 8.sp, + top: 8.sp, + child: widget.isDismiss? GestureDetector( + onTap: (){ + + Navigator.pop(context); + }, + child: Icon(Icons.close,color: Colors.white,size: 24.sp,)):Container()) ], ), ), ), ); } -} -updataApk(String downloadUrl) async { - //SmartDialog.showLoading(); - var filePath = await getApplicationSupportDirectoryPath(); - filePath = filePath + "kuayou.apk"; - var data = await DioManager.instance - .download( - "https://xidi-official-website.oss-cn-shenzhen.aliyuncs.com/%E8%B7%A8%E5%8F%8B_2.3.4.apk", - filePath, (received, total) { - double progress = received / total * 100; - print('Download progress: $progress%'); - }) - .then((value) => print(value)) - .catchError((error) { - // SmartDialog.dismiss(); - print(error); - }); - //await AppInstaller.installApk(filePath, actionRequired: false); + updataApk(String downloadUrl) async { + //SmartDialog.showLoading(); + var filePath = await getApplicationSupportDirectoryPath(); + filePath = filePath + "leyuan.apk"; + var data = await DioManager.instance + .download(downloadUrl, filePath, (received, total) { + double progress = received / total * 100; + setState(() { + myProgress = received / total; + }); + print('Download progress: $progress%'); + }) + .then((value) => {print(value)}) + .catchError((error) { + // SmartDialog.dismiss(); + print(error); + }); + // await AppInstaller.installApk(filePath, actionRequired: false); + } } class UpdateInfo { diff --git a/circle_app/lib/app/home/logic.dart b/circle_app/lib/app/home/logic.dart index 734a957..2c76ead 100644 --- a/circle_app/lib/app/home/logic.dart +++ b/circle_app/lib/app/home/logic.dart @@ -6,7 +6,6 @@ import 'package:circle_app/network/dio_manager.dart'; import 'package:circle_app/util/util.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../circle/view.dart'; diff --git a/circle_app/lib/main.dart b/circle_app/lib/main.dart index 8c4a5c0..009d82e 100644 --- a/circle_app/lib/main.dart +++ b/circle_app/lib/main.dart @@ -25,9 +25,9 @@ void main() { runApp(const MyApp()); } -int IMsdkAppID = 1400799631; +int IM_SDK_APP_ID = 1400799631; -String iOSAPPid = ""; +String IOS_APP_ID = ""; @@ -216,7 +216,7 @@ class _MyAppState extends State { initIM() { coreInstance.init( sdkAppID: - IMsdkAppID, // Replace 0 with the SDKAppID of your IM application when integrating + IM_SDK_APP_ID, // Replace 0 with the SDKAppID of your IM application when integrating // language: LanguageEnum.en, // 界面语言配置,若不配置,则跟随系统语言 loglevel: LogLevelEnum.V2TIM_LOG_DEBUG, onTUIKitCallbackListener: (TIMCallback callbackValue) {