app/lib/ui/settings/upgrade_dialog_ui.dart

105 lines
4.0 KiB
Dart
Raw Normal View History

2023-10-09 09:32:07 +08:00
import 'package:flutter/material.dart' show Material;
import 'package:starcitizen_doctor/base/ui_model.dart';
2024-01-29 20:44:00 +08:00
import 'package:starcitizen_doctor/common/conf/app_conf.dart';
import 'package:starcitizen_doctor/common/conf/url_conf.dart';
2023-10-09 09:32:07 +08:00
import 'upgrade_dialog_ui_model.dart';
class UpgradeDialogUI extends BaseUI<UpgradeDialogUIModel> {
@override
Widget? buildBody(BuildContext context, UpgradeDialogUIModel model) {
return Material(
child: ContentDialog(
2023-10-16 23:26:33 +08:00
title: Text("发现新版本 -> ${model.targetVersion}"),
2023-10-09 09:32:07 +08:00
constraints:
BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .55),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(left: 24, right: 24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
if (model.description == null) ...[
const Center(
child: Column(
children: [
ProgressRing(),
SizedBox(height: 16),
Text("正在获取新版本详情...")
],
),
)
] else
2023-12-05 21:26:46 +08:00
...makeMarkdownView(model.description!,
2024-01-29 20:44:00 +08:00
attachmentsUrl: URLConf.giteaAttachmentsUrl),
2023-10-09 09:32:07 +08:00
],
),
),
)),
if (model.isUsingDiversion) ...[
const SizedBox(height: 24),
GestureDetector(
onTap: model.launchReleaseUrl,
child: Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white.withOpacity(.1),
borderRadius: BorderRadius.circular(7)),
child: Text(
"提示:当前正在使用分流服务器进行更新,可能会出现下载速度下降,但有助于我们进行成本控制,若下载异常请点击这里跳转手动安装。",
style: TextStyle(
fontSize: 14, color: Colors.white.withOpacity(.7)),
),
),
),
],
2023-10-09 09:32:07 +08:00
if (model.isUpgrading) ...[
const SizedBox(height: 24),
Row(
children: [
Text(model.progress == 100
? "正在安装: "
: "正在下载: ${model.progress?.toStringAsFixed(2) ?? 0}% "),
Expanded(
child: ProgressBar(
value: model.progress == 100 ? null : model.progress,
)),
],
),
],
],
),
actions: model.isUpgrading
? null
: [
if (model.downloadUrl.isNotEmpty)
FilledButton(
onPressed: model.doUpgrade,
child: const Padding(
padding: EdgeInsets.only(
top: 4, bottom: 4, left: 8, right: 8),
child: Text("立即更新"),
)),
2023-10-10 21:07:45 +08:00
if (AppConf.appVersionCode >=
2023-10-09 09:32:07 +08:00
(AppConf.networkVersionData?.minVersionCode ?? 0))
Button(
onPressed: model.doCancel,
child: const Padding(
padding: EdgeInsets.only(
top: 4, bottom: 4, left: 8, right: 8),
child: Text("下次吧"),
)),
],
),
);
}
@override
String getUITitle(BuildContext context, UpgradeDialogUIModel model) => "";
}