feat(mobile-next): 导入官方 openim-flutter-demo 固定基线 3.8.3-patch.3 并完成双构建
- 上游: github.com/OpenIMSDK/openim-flutter-demo tag 3.8.3-patch.3 commit b3dfdb1e8aaeaaf6f0793e10cadd20d5c184a31f - 并行目录 mobile-next/ 原样导入(含 LICENSE),不覆盖现网 mobile/ - 锁定 Flutter 3.24.5 / Dart 3.5.4 / JDK 17 / Gradle 7.6.3 / AGP 7.3.1 - 实测 Android debug 与 release 构建均成功(见 docs/mobile-next-baseline-import.md) - 本提交可单独回退:git revert 1db1229(重写前) Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,194 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim_common/openim_common.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:percent_indicator/linear_percent_indicator.dart';
|
||||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:sprintf/sprintf.dart';
|
||||
|
||||
class UpgradeViewV2 extends StatefulWidget {
|
||||
final Function()? onLater;
|
||||
final Function()? onIgnore;
|
||||
final Function() onNow;
|
||||
final UpgradeInfoV2 upgradeInfo;
|
||||
final PackageInfo packageInfo;
|
||||
final PublishSubject? subject;
|
||||
|
||||
const UpgradeViewV2({
|
||||
super.key,
|
||||
this.onLater,
|
||||
this.onIgnore,
|
||||
required this.onNow,
|
||||
required this.upgradeInfo,
|
||||
required this.packageInfo,
|
||||
this.subject,
|
||||
});
|
||||
|
||||
@override
|
||||
State<UpgradeViewV2> createState() => _UpgradeViewV2State();
|
||||
}
|
||||
|
||||
class _UpgradeViewV2State extends State<UpgradeViewV2> {
|
||||
double _progress = 0.0;
|
||||
bool _showProgress = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
widget.subject?.stream.listen((progress) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_progress = progress;
|
||||
});
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void _startDownload() {
|
||||
if (Platform.isAndroid) {
|
||||
Get.back();
|
||||
} else {
|
||||
if (!widget.upgradeInfo.needForceUpdate!) {
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
widget.onNow.call();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return !widget.upgradeInfo.needForceUpdate!;
|
||||
},
|
||||
child: Center(
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 46.w),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 12.w,
|
||||
vertical: 12.h,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
StrRes.upgradeFind,
|
||||
style: TextStyle(
|
||||
color: const Color(0xFF333333),
|
||||
fontSize: 18.sp,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Text(
|
||||
sprintf(StrRes.upgradeVersion, [
|
||||
'${widget.upgradeInfo.buildVersion!} + ${widget.upgradeInfo.buildVersionNo!}',
|
||||
'${widget.packageInfo.version} + ${widget.packageInfo.buildNumber}'
|
||||
]),
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
color: const Color(0xFF333333),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Text(
|
||||
StrRes.upgradeDescription,
|
||||
style: TextStyle(
|
||||
color: const Color(0xFF333333),
|
||||
fontSize: 16.sp,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 4.h,
|
||||
),
|
||||
Text(
|
||||
widget.upgradeInfo.buildUpdateDescription ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
color: const Color(0xFF333333),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
if (!widget.upgradeInfo.needForceUpdate! && !_showProgress)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
_buildButton(
|
||||
text: StrRes.upgradeIgnore,
|
||||
onTap: widget.onIgnore ?? () => Get.back(),
|
||||
),
|
||||
_buildButton(
|
||||
text: StrRes.upgradeLater,
|
||||
onTap: widget.onLater ?? () => Get.back(),
|
||||
),
|
||||
_buildButton(
|
||||
text: StrRes.upgradeNow,
|
||||
onTap: _startDownload,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (widget.upgradeInfo.needForceUpdate! && !_showProgress)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
_buildButton(
|
||||
text: StrRes.upgradeNow,
|
||||
onTap: _startDownload,
|
||||
)
|
||||
],
|
||||
),
|
||||
if (_showProgress)
|
||||
SizedBox(
|
||||
height: 44.h,
|
||||
child: Center(
|
||||
child: LinearPercentIndicator(
|
||||
lineHeight: 20.h,
|
||||
percent: _progress,
|
||||
center: "${(_progress * 100).toInt()}%".toText..style = TextStyle(fontSize: 12.sp),
|
||||
linearStrokeCap: LinearStrokeCap.roundAll,
|
||||
backgroundColor: Colors.grey.withOpacity(0.5),
|
||||
progressColor: Colors.blueAccent,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildButton({required String text, Function()? onTap}) => Ink(
|
||||
height: 44.h,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 14.w,
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: const Color(0xFF1B72EC),
|
||||
fontSize: 16.sp,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user