增加节日倒计时

This commit is contained in:
xkeyC 2023-11-03 23:03:19 +08:00
parent 0388b5fb1d
commit c2fc30ac09
13 changed files with 187 additions and 63 deletions

BIN
assets/countdown/alen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
assets/countdown/pirate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
assets/countdown/red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -13,8 +13,8 @@ import 'package:window_manager/window_manager.dart';
import '../base/ui.dart'; import '../base/ui.dart';
class AppConf { class AppConf {
static const String appVersion = "2.9.7 Beta"; static const String appVersion = "2.9.8 Beta";
static const int appVersionCode = 23; static const int appVersionCode = 24;
static const String appVersionDate = "2023-11-01"; static const String appVersionDate = "2023-11-01";
static const String gitlabHomeUrl = static const String gitlabHomeUrl =

View File

@ -0,0 +1,92 @@
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:starcitizen_doctor/base/ui.dart';
import 'package:starcitizen_doctor/widgets/countdown_time_text.dart';
import 'countdown_dialog_ui_model.dart';
class CountdownDialogUI extends BaseUI<CountdownDialogUIModel> {
@override
Widget? buildBody(BuildContext context, CountdownDialogUIModel model) {
return ContentDialog(
constraints:
BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .65),
title: Row(
children: [
IconButton(
icon: const Icon(
FluentIcons.back,
size: 22,
),
onPressed: model.onBack),
const SizedBox(width: 12),
const Text("节日倒计时"),
],
),
content: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(left: 12, right: 12),
child: Column(
children: [
AlignedGridView.count(
crossAxisCount: 3,
mainAxisSpacing: 12,
crossAxisSpacing: 12,
itemCount: model.countdownFestivalListData.length,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
final item = model.countdownFestivalListData[index];
return Container(
decoration: BoxDecoration(
color: FluentTheme.of(context).cardColor,
borderRadius: BorderRadius.circular(12),
),
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
if (item.icon != null && item.icon != "") ...[
ClipRRect(
borderRadius: BorderRadius.circular(1000),
child: Image.asset(
"assets/countdown/${item.icon}",
width: 38,
height: 38,
),
),
const SizedBox(width: 12),
] else
const SizedBox(width: 50),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"${item.name}",
),
CountdownTimeText(
targetTime: DateTime.fromMillisecondsSinceEpoch(
item.time ?? 0),
)
],
)
],
),
),
);
},
),
const SizedBox(height: 12),
Text(
"* 以上节日日期由人工收录、维护,可能存在错误,欢迎反馈!",
style: TextStyle(
fontSize: 13, color: Colors.white.withOpacity(.3)),
)
],
),
),
),
);
}
@override
String getUITitle(BuildContext context, CountdownDialogUIModel model) => "";
}

View File

@ -0,0 +1,12 @@
import 'package:starcitizen_doctor/base/ui_model.dart';
import 'package:starcitizen_doctor/data/countdown_festival_item_data.dart';
class CountdownDialogUIModel extends BaseUIModel {
final List<CountdownFestivalItemData> countdownFestivalListData;
CountdownDialogUIModel(this.countdownFestivalListData);
onBack() {
Navigator.pop(context!);
}
}

View File

@ -205,70 +205,76 @@ class HomeUI extends BaseUI<HomeUIModel> {
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
Container( Tilt(
width: width + 24, borderRadius: BorderRadius.circular(12),
decoration: BoxDecoration( shadowConfig: const ShadowConfig(disable: true),
color: FluentTheme.of(context).cardColor, child: GestureDetector(
borderRadius: BorderRadius.circular(12)), onTap: ()=> model.onTapFestival(),
child: Padding( child: Container(
padding: const EdgeInsets.only( width: width + 24,
left: 12, right: 12, top: 6, bottom: 6), decoration: BoxDecoration(
child: (model.countdownFestivalListData == null) color: FluentTheme.of(context).cardColor),
? SizedBox( child: Padding(
width: width, padding: const EdgeInsets.only(
height: 62, left: 12, right: 12, top: 6, bottom: 6),
child: const Center( child: (model.countdownFestivalListData == null)
child: ProgressRing(), ? SizedBox(
), width: width,
) height: 62,
: SizedBox( child: const Center(
width: width, child: ProgressRing(),
height: 62, ),
child: Swiper( )
itemCount: : SizedBox(
model.countdownFestivalListData!.length, width: width,
autoplay: true, height: 62,
autoplayDelay: 5000, child: Swiper(
itemBuilder: (context, index) { itemCount: model
final item = model .countdownFestivalListData!.length,
.countdownFestivalListData![index]; autoplay: true,
return Row( autoplayDelay: 5000,
mainAxisAlignment: itemBuilder: (context, index) {
MainAxisAlignment.spaceEvenly, final item = model
children: [ .countdownFestivalListData![index];
if (item.icon != null && return Row(
item.icon != "") ...[ mainAxisAlignment:
ClipRRect( MainAxisAlignment.spaceEvenly,
borderRadius:
BorderRadius.circular(1000),
child: Image.asset(
"assets/countdown/${item.icon}",
width: 48,
height: 48,
),
),
],
Column(
children: [ children: [
Text( if (item.icon != null &&
item.name ?? "", item.icon != "") ...[
style: const TextStyle( ClipRRect(
fontSize: 15), borderRadius:
), BorderRadius.circular(1000),
const SizedBox(height: 3), child: Image.asset(
CountdownTimeText( "assets/countdown/${item.icon}",
targetTime: DateTime width: 48,
.fromMillisecondsSinceEpoch( height: 48,
item.time ?? 0), ),
),
],
Column(
children: [
Text(
item.name ?? "",
style: const TextStyle(
fontSize: 15),
),
const SizedBox(height: 3),
CountdownTimeText(
targetTime: DateTime
.fromMillisecondsSinceEpoch(
item.time ?? 0),
),
],
), ),
], ],
), );
], },
); ),
}, ),
), )),
), ),
)), ),
], ],
), ),
if (model.appWebLocalizationVersionsData == null) if (model.appWebLocalizationVersionsData == null)

View File

@ -14,6 +14,7 @@ import 'package:starcitizen_doctor/common/helper/system_helper.dart';
import 'package:starcitizen_doctor/data/app_placard_data.dart'; import 'package:starcitizen_doctor/data/app_placard_data.dart';
import 'package:starcitizen_doctor/data/app_web_localization_versions_data.dart'; import 'package:starcitizen_doctor/data/app_web_localization_versions_data.dart';
import 'package:starcitizen_doctor/data/countdown_festival_item_data.dart'; import 'package:starcitizen_doctor/data/countdown_festival_item_data.dart';
import 'package:starcitizen_doctor/ui/home/countdown/countdown_dialog_ui_model.dart';
import 'package:starcitizen_doctor/ui/home/dialogs/md_content_dialog_ui.dart'; import 'package:starcitizen_doctor/ui/home/dialogs/md_content_dialog_ui.dart';
import 'package:starcitizen_doctor/ui/home/dialogs/md_content_dialog_ui_model.dart'; import 'package:starcitizen_doctor/ui/home/dialogs/md_content_dialog_ui_model.dart';
import 'package:starcitizen_doctor/ui/home/localization/localization_ui_model.dart'; import 'package:starcitizen_doctor/ui/home/localization/localization_ui_model.dart';
@ -24,6 +25,7 @@ import 'package:starcitizen_doctor/ui/home/webview/webview.dart';
import 'package:starcitizen_doctor/ui/home/webview/webview_localization_capture_ui_model.dart'; import 'package:starcitizen_doctor/ui/home/webview/webview_localization_capture_ui_model.dart';
import 'package:url_launcher/url_launcher_string.dart'; import 'package:url_launcher/url_launcher_string.dart';
import 'countdown/countdown_dialog_ui.dart';
import 'localization/localization_ui.dart'; import 'localization/localization_ui.dart';
import 'performance/performance_ui.dart'; import 'performance/performance_ui.dart';
import 'webview/webview_localization_capture_ui.dart'; import 'webview/webview_localization_capture_ui.dart';
@ -519,4 +521,16 @@ class HomeUIModel extends BaseUIModel {
_isGameRunning[installPath] = false; _isGameRunning[installPath] = false;
notifyListeners(); notifyListeners();
} }
onTapFestival() {
if (countdownFestivalListData == null) return;
showDialog(
context: context!,
builder: (context) {
return BaseUIContainer(
uiCreate: () => CountdownDialogUI(),
modelCreate: () =>
CountdownDialogUIModel(countdownFestivalListData!));
});
}
} }