mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 05:23:44 +08:00
feat:riverpod 迁移 HomeCountdown
This commit is contained in:
parent
a6507a6910
commit
c9bd9ed677
98
lib/ui/home/home_countdown_dialog_ui.dart
Normal file
98
lib/ui/home/home_countdown_dialog_ui.dart
Normal file
@ -0,0 +1,98 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:starcitizen_doctor/ui/home/home_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/widgets/widgets.dart';
|
||||
|
||||
class HomeCountdownDialogUI extends HookConsumerWidget {
|
||||
const HomeCountdownDialogUI({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final homeState = ref.watch(homeUIModelProvider);
|
||||
return ContentDialog(
|
||||
constraints:
|
||||
BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .65),
|
||||
title: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
FluentIcons.back,
|
||||
size: 22,
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
const SizedBox(width: 12),
|
||||
const Text("节日倒计时"),
|
||||
],
|
||||
),
|
||||
content: homeState.countdownFestivalListData == null
|
||||
? makeLoading(context)
|
||||
: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 12, right: 12),
|
||||
child: Column(
|
||||
children: [
|
||||
AlignedGridView.count(
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 12,
|
||||
crossAxisSpacing: 12,
|
||||
itemCount: homeState.countdownFestivalListData!.length,
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final item =
|
||||
homeState.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)),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import 'package:starcitizen_doctor/common/helper/system_helper.dart';
|
||||
import 'package:starcitizen_doctor/widgets/widgets.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import 'home_countdown_dialog_ui.dart';
|
||||
import 'home_ui_model.dart';
|
||||
|
||||
class HomeUI extends HookConsumerWidget {
|
||||
@ -36,7 +37,7 @@ class HomeUI extends HookConsumerWidget {
|
||||
? null
|
||||
: Button(
|
||||
child: const Text('查看详情'),
|
||||
onPressed: () => _showPlacard(),
|
||||
onPressed: () => _showPlacard(context, homeState),
|
||||
),
|
||||
onClose: homeState.appPlacardData?.alwaysShow == true
|
||||
? null
|
||||
@ -653,7 +654,7 @@ class HomeUI extends HookConsumerWidget {
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
shadowConfig: const ShadowConfig(disable: true),
|
||||
child: GestureDetector(
|
||||
onTap: () => _onTapFestival(),
|
||||
onTap: () => _onTapFestival(context),
|
||||
child: Container(
|
||||
width: width + 24,
|
||||
decoration: BoxDecoration(color: FluentTheme.of(context).cardColor),
|
||||
@ -722,9 +723,28 @@ class HomeUI extends HookConsumerWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_showPlacard() {}
|
||||
_showPlacard(BuildContext context, HomeUIModelState homeState) {
|
||||
switch (homeState.appPlacardData?.linkType) {
|
||||
case "external":
|
||||
launchUrlString(homeState.appPlacardData?.link);
|
||||
return;
|
||||
case "doc":
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return BaseUIContainer(
|
||||
// uiCreate: () => MDContentDialogUI(),
|
||||
// modelCreate: () => MDContentDialogUIModel(
|
||||
// appPlacardData?.title ?? "公告详情", appPlacardData?.link));
|
||||
// });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_onTapFestival() {}
|
||||
_onTapFestival(BuildContext context) {
|
||||
showDialog(
|
||||
context: context, builder: (context) => const HomeCountdownDialogUI());
|
||||
}
|
||||
}
|
||||
|
||||
class _HomeItemData {
|
||||
|
Loading…
Reference in New Issue
Block a user