Birthday celebration

This commit is contained in:
LittleSheep 2024-11-28 00:04:45 +08:00
parent 9395e081f0
commit aa9724102b
3 changed files with 32 additions and 3 deletions

View File

@ -267,5 +267,6 @@
"dailyCheckNegativeHint5": "Gaming",
"dailyCheckNegativeHint5Description": "Lost connection at a crucial moment",
"dailyCheckNegativeHint6": "Going out",
"dailyCheckNegativeHint6Description": "Forgot your umbrella and got caught in the rain"
"dailyCheckNegativeHint6Description": "Forgot your umbrella and got caught in the rain",
"happyBirthday": "Happy birthday, {}!"
}

View File

@ -269,5 +269,6 @@
"dailyCheckNegativeHint5": "打游戏",
"dailyCheckNegativeHint5Description": "关键时刻断网",
"dailyCheckNegativeHint6": "出门",
"dailyCheckNegativeHint6Description": "忘带伞遇上大雨"
"dailyCheckNegativeHint6Description": "忘带伞遇上大雨",
"happyBirthday": "生日快乐,{}"
}

View File

@ -7,6 +7,7 @@ import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:flutter/material.dart';
import 'package:surface/providers/sn_network.dart';
import 'package:surface/providers/userinfo.dart';
import 'package:surface/types/check_in.dart';
import 'package:surface/widgets/dialog.dart';
@ -60,6 +61,7 @@ class _HomeScreenState extends State<HomeScreen> {
const SizedBox(),
],
),
_HomeDashSpecialDayWidget().padding(top: 8, horizontal: 8),
StaggeredGrid.count(
crossAxisCount: 2,
mainAxisSpacing: 8,
@ -71,7 +73,7 @@ class _HomeScreenState extends State<HomeScreen> {
child: card.child,
);
}).toList(),
).padding(all: 8),
).padding(horizontal: 8),
],
),
),
@ -79,6 +81,31 @@ class _HomeScreenState extends State<HomeScreen> {
}
}
class _HomeDashSpecialDayWidget extends StatelessWidget {
const _HomeDashSpecialDayWidget({super.key});
@override
Widget build(BuildContext context) {
final ua = context.watch<UserProvider>();
final today = DateTime.now();
final birthday = ua.user?.profile?.birthday?.toLocal();
final isBirthday = birthday != null &&
birthday.day == today.day &&
birthday.month == today.month;
return Column(
children: [
if (isBirthday)
Card(
child: ListTile(
leading: Text('🎂').fontSize(24),
title: Text('happyBirthday').tr(args: [ua.user?.nick ?? 'user']),
),
).padding(bottom: 8),
],
);
}
}
class _HomeDashCheckInWidget extends StatefulWidget {
const _HomeDashCheckInWidget({super.key});