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.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) => "";
|
|
|
|
}
|