版本更新
This commit is contained in:
parent
20d1a38988
commit
c6389adc2f
@ -17,28 +17,41 @@ import 'package:package_info_plus/package_info_plus.dart';
|
|||||||
class AboutappLogic extends GetxController {
|
class AboutappLogic extends GetxController {
|
||||||
final AboutappState state = AboutappState();
|
final AboutappState state = AboutappState();
|
||||||
String version = "";
|
String version = "";
|
||||||
|
UpdateInfo? _updateInfo;
|
||||||
|
bool isUpdate = false;
|
||||||
|
String currentVersion = "";
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() async{
|
||||||
super.onInit();
|
super.onInit();
|
||||||
getVersion();
|
getVersion();
|
||||||
|
var data = await DioManager.instance.get(url: Api.APP_VERSION);
|
||||||
|
var bean = BaseResponse<UpdateInfo>.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();
|
// getAppVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
getVersion() async {
|
getVersion() async {
|
||||||
final info = await PackageInfo.fromPlatform();
|
final info = await PackageInfo.fromPlatform();
|
||||||
version = info.version;
|
currentVersion = "V:${info.version}";
|
||||||
|
//version = info.version;
|
||||||
update();
|
update();
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
getUpVersion() async {
|
getUpVersion() async {
|
||||||
var data = await DioManager.instance.get(url: Api.APP_VERSION);
|
if(isUpdate){
|
||||||
var bean = BaseResponse<UpdateInfo>.fromJson(
|
showReportDialog(Get.context!, _updateInfo!.constraint == 0, _updateInfo!);
|
||||||
data, (data) => UpdateInfo.fromJson(data));
|
|
||||||
if (bean.isSuccess() && bean.data.update == 1) {
|
|
||||||
showReportDialog(Get.context!, bean.data.constraint == 0, bean.data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void showReportDialog(
|
void showReportDialog(
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
import 'package:circle_app/util/util.dart';
|
import 'package:circle_app/util/util.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import '../../components/my_app_bar.dart';
|
import '../../components/my_app_bar.dart';
|
||||||
import '../../network/dio_manager.dart';
|
|
||||||
import '../dialog/UpdateDialog.dart';
|
|
||||||
import 'logic.dart';
|
import 'logic.dart';
|
||||||
|
|
||||||
|
|
||||||
@ -52,6 +52,14 @@ class AboutappPage extends StatelessWidget {
|
|||||||
) ,)
|
) ,)
|
||||||
,
|
,
|
||||||
SizedBox(height: 20.sp),
|
SizedBox(height: 20.sp),
|
||||||
|
Text(
|
||||||
|
logic.currentVersion,
|
||||||
|
style: TextStyle(
|
||||||
|
color: const Color(0xFFF7FAFA),
|
||||||
|
fontSize: 12.sp,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 10.sp),
|
||||||
Text(
|
Text(
|
||||||
'圈子',
|
'圈子',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@ -123,15 +131,14 @@ class AboutappPage extends StatelessWidget {
|
|||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: (){
|
onTap: (){
|
||||||
navigateToPrivacyPolicy();
|
navigateToPrivacyPolicy();
|
||||||
|
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
Text(
|
||||||
'隐私政策',
|
'隐私政策',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Color(0xFFF7FAFA),
|
color: const Color(0xFFF7FAFA),
|
||||||
fontSize: 16,
|
fontSize: 16.sp,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
@ -160,7 +167,7 @@ class AboutappPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Container(
|
logic.isUpdate? Container(
|
||||||
width: 6.sp,
|
width: 6.sp,
|
||||||
height: 5.sp,
|
height: 5.sp,
|
||||||
margin: EdgeInsets.only(top: 1.sp, right: 8.sp),
|
margin: EdgeInsets.only(top: 1.sp, right: 8.sp),
|
||||||
@ -168,7 +175,7 @@ class AboutappPage extends StatelessWidget {
|
|||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
borderRadius: BorderRadius.circular(3.sp),
|
borderRadius: BorderRadius.circular(3.sp),
|
||||||
),
|
),
|
||||||
),
|
):Container(),
|
||||||
Text(
|
Text(
|
||||||
logic.version,
|
logic.version,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|||||||
@ -19,15 +19,12 @@ class UpdateDialog extends StatefulWidget {
|
|||||||
_CustomDialogState createState() => _CustomDialogState();
|
_CustomDialogState createState() => _CustomDialogState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double myProgress = 0;
|
||||||
|
|
||||||
class _CustomDialogState extends State<UpdateDialog> {
|
class _CustomDialogState extends State<UpdateDialog> {
|
||||||
double progress = 0;
|
|
||||||
bool isDownload = false;
|
bool isDownload = false;
|
||||||
|
|
||||||
void incrementCounter() {
|
void incrementCounter() {}
|
||||||
setState(() {
|
|
||||||
progress = progress + 0.1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDownloadUi() {
|
void setDownloadUi() {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -90,37 +87,34 @@ class _CustomDialogState extends State<UpdateDialog> {
|
|||||||
height: 70.sp,
|
height: 70.sp,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
SizedBox(
|
||||||
margin: EdgeInsets.only(
|
height: 65.sp,
|
||||||
top: 12.sp, left: 14.sp, right: 14.sp),
|
child: ListView(
|
||||||
alignment: Alignment.center,
|
children: [
|
||||||
child: Text(
|
Container(
|
||||||
widget.updateInfo.updateInfo,
|
margin: EdgeInsets.only(
|
||||||
textAlign: TextAlign.center,
|
top: 12.sp, left: 14.sp, right: 14.sp),
|
||||||
style: TextStyle(
|
alignment: Alignment.center,
|
||||||
color: const Color(0xCCF7FAFA), fontSize: 16.sp),
|
child: Text(
|
||||||
|
widget.updateInfo.updateInfo,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
color: const Color(0xCCF7FAFA),
|
||||||
|
fontSize: 16.sp),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
isDownload
|
isDownload
|
||||||
? GestureDetector(
|
? GestureDetector(
|
||||||
onTap: () async {
|
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();
|
//incrementCounter();
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.only(top: 24.sp),
|
margin: EdgeInsets.only(top: 24.sp),
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
value: progress,
|
value: myProgress,
|
||||||
backgroundColor: Colors.grey,
|
backgroundColor: Colors.grey,
|
||||||
valueColor: const AlwaysStoppedAnimation<Color>(
|
valueColor: const AlwaysStoppedAnimation<Color>(
|
||||||
Colors.blue),
|
Colors.blue),
|
||||||
@ -130,8 +124,19 @@ class _CustomDialogState extends State<UpdateDialog> {
|
|||||||
)
|
)
|
||||||
: GestureDetector(
|
: GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
setDownloadUi();
|
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);
|
//Navigator.pop(context);
|
||||||
// logic.setBlock();
|
// logic.setBlock();
|
||||||
@ -168,32 +173,42 @@ class _CustomDialogState extends State<UpdateDialog> {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
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 {
|
updataApk(String downloadUrl) async {
|
||||||
//SmartDialog.showLoading();
|
//SmartDialog.showLoading();
|
||||||
var filePath = await getApplicationSupportDirectoryPath();
|
var filePath = await getApplicationSupportDirectoryPath();
|
||||||
filePath = filePath + "kuayou.apk";
|
filePath = filePath + "leyuan.apk";
|
||||||
var data = await DioManager.instance
|
var data = await DioManager.instance
|
||||||
.download(
|
.download(downloadUrl, filePath, (received, total) {
|
||||||
"https://xidi-official-website.oss-cn-shenzhen.aliyuncs.com/%E8%B7%A8%E5%8F%8B_2.3.4.apk",
|
double progress = received / total * 100;
|
||||||
filePath, (received, total) {
|
setState(() {
|
||||||
double progress = received / total * 100;
|
myProgress = received / total;
|
||||||
print('Download progress: $progress%');
|
});
|
||||||
})
|
print('Download progress: $progress%');
|
||||||
.then((value) => print(value))
|
})
|
||||||
.catchError((error) {
|
.then((value) => {print(value)})
|
||||||
// SmartDialog.dismiss();
|
.catchError((error) {
|
||||||
print(error);
|
// SmartDialog.dismiss();
|
||||||
});
|
print(error);
|
||||||
//await AppInstaller.installApk(filePath, actionRequired: false);
|
});
|
||||||
|
// await AppInstaller.installApk(filePath, actionRequired: false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UpdateInfo {
|
class UpdateInfo {
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import 'package:circle_app/network/dio_manager.dart';
|
|||||||
import 'package:circle_app/util/util.dart';
|
import 'package:circle_app/util/util.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import '../circle/view.dart';
|
import '../circle/view.dart';
|
||||||
|
|||||||
@ -25,9 +25,9 @@ void main() {
|
|||||||
runApp(const MyApp());
|
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<MyApp> {
|
|||||||
initIM() {
|
initIM() {
|
||||||
coreInstance.init(
|
coreInstance.init(
|
||||||
sdkAppID:
|
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, // 界面语言配置,若不配置,则跟随系统语言
|
// language: LanguageEnum.en, // 界面语言配置,若不配置,则跟随系统语言
|
||||||
loglevel: LogLevelEnum.V2TIM_LOG_DEBUG,
|
loglevel: LogLevelEnum.V2TIM_LOG_DEBUG,
|
||||||
onTUIKitCallbackListener: (TIMCallback callbackValue) {
|
onTUIKitCallbackListener: (TIMCallback callbackValue) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user