✨ Lunar calendar festivals
This commit is contained in:
parent
d06df3d278
commit
9c3b61ce57
@ -414,6 +414,9 @@
|
|||||||
"celebrateBirthday": "Happy birthday, {}!",
|
"celebrateBirthday": "Happy birthday, {}!",
|
||||||
"celebrateMerryXmas": "Merry christmas, {}!",
|
"celebrateMerryXmas": "Merry christmas, {}!",
|
||||||
"celebrateNewYear": "Happy new year, {}!",
|
"celebrateNewYear": "Happy new year, {}!",
|
||||||
|
"celebrateLunarNewYear": "Happy lunar new year, {}!",
|
||||||
|
"celebrateMidAutumn": "Happy mid-autumn festival, {}!",
|
||||||
|
"celebrateDragonBoat": "Happy dragon boat festival, {}!",
|
||||||
"celebrateValentineDay": "Today is valentine's day, {}!",
|
"celebrateValentineDay": "Today is valentine's day, {}!",
|
||||||
"celebrateLaborDay": "Today is labor day, {}.",
|
"celebrateLaborDay": "Today is labor day, {}.",
|
||||||
"celebrateMotherDay": "Today is mother's day, {}.",
|
"celebrateMotherDay": "Today is mother's day, {}.",
|
||||||
@ -423,6 +426,9 @@
|
|||||||
"celebrateThanksgiving": "Today is thanksgiving day, {}!",
|
"celebrateThanksgiving": "Today is thanksgiving day, {}!",
|
||||||
"pendingBirthday": "Birthday in {}",
|
"pendingBirthday": "Birthday in {}",
|
||||||
"pendingMerryXmas": "Christmas in {}",
|
"pendingMerryXmas": "Christmas in {}",
|
||||||
|
"pendingLunarNewYear": "Lunar new year in {}",
|
||||||
|
"pendingMidAutumn": "Mid-autumn festival in {}",
|
||||||
|
"pendingDragonBoat": "Dragon boat festival in {}",
|
||||||
"pendingNewYear": "New year in {}",
|
"pendingNewYear": "New year in {}",
|
||||||
"pendingValentineDay": "Valentine's day in {}",
|
"pendingValentineDay": "Valentine's day in {}",
|
||||||
"pendingLaborDay": "Labor day in {}",
|
"pendingLaborDay": "Labor day in {}",
|
||||||
|
@ -410,6 +410,9 @@
|
|||||||
"dailyCheckNegativeHint6": "出门",
|
"dailyCheckNegativeHint6": "出门",
|
||||||
"dailyCheckNegativeHint6Description": "忘带伞遇上大雨",
|
"dailyCheckNegativeHint6Description": "忘带伞遇上大雨",
|
||||||
"celebrateBirthday": "生日快乐,{}!",
|
"celebrateBirthday": "生日快乐,{}!",
|
||||||
|
"celebrateLunarNewYear": "春节快乐,{}!",
|
||||||
|
"celebrateMidAutumn": "中秋节快乐,{}!",
|
||||||
|
"celebrateDragonBoat": "端午节快乐,{}!",
|
||||||
"celebrateMerryXmas": "圣诞快乐,{}!",
|
"celebrateMerryXmas": "圣诞快乐,{}!",
|
||||||
"celebrateNewYear": "新年快乐,{}!",
|
"celebrateNewYear": "新年快乐,{}!",
|
||||||
"celebrateValentineDay": "今天是情人节,{}!",
|
"celebrateValentineDay": "今天是情人节,{}!",
|
||||||
@ -419,6 +422,9 @@
|
|||||||
"celebrateFatherDay": "今天是父亲节,{}。",
|
"celebrateFatherDay": "今天是父亲节,{}。",
|
||||||
"celebrateHalloween": "快乐在圣诞节,{}!",
|
"celebrateHalloween": "快乐在圣诞节,{}!",
|
||||||
"celebrateThanksgiving": "今天是感恩节,{}!",
|
"celebrateThanksgiving": "今天是感恩节,{}!",
|
||||||
|
"pendingLunarNewYear": "{} 过春节",
|
||||||
|
"pendingMidAutumn": "{} 过中秋节",
|
||||||
|
"pendingDragonBoat": "{} 过端午节",
|
||||||
"pendingBirthday": "{} 过生日",
|
"pendingBirthday": "{} 过生日",
|
||||||
"pendingMerryXmas": "{} 过圣诞节",
|
"pendingMerryXmas": "{} 过圣诞节",
|
||||||
"pendingNewYear": "{} 跨年",
|
"pendingNewYear": "{} 跨年",
|
||||||
|
@ -279,6 +279,10 @@
|
|||||||
"one": "{} 個附件",
|
"one": "{} 個附件",
|
||||||
"other": "{} 個附件"
|
"other": "{} 個附件"
|
||||||
},
|
},
|
||||||
|
"messageTyping": {
|
||||||
|
"one": "{} 正在輸入",
|
||||||
|
"other": "{} 正在輸入"
|
||||||
|
},
|
||||||
"fieldAttachmentRandomId": "訪問 ID",
|
"fieldAttachmentRandomId": "訪問 ID",
|
||||||
"fieldAttachmentAlt": "概述文字",
|
"fieldAttachmentAlt": "概述文字",
|
||||||
"addAttachmentFromAlbum": "從相冊中添加附件",
|
"addAttachmentFromAlbum": "從相冊中添加附件",
|
||||||
@ -406,6 +410,9 @@
|
|||||||
"dailyCheckNegativeHint6": "出門",
|
"dailyCheckNegativeHint6": "出門",
|
||||||
"dailyCheckNegativeHint6Description": "忘帶傘遇上大雨",
|
"dailyCheckNegativeHint6Description": "忘帶傘遇上大雨",
|
||||||
"celebrateBirthday": "生日快樂,{}!",
|
"celebrateBirthday": "生日快樂,{}!",
|
||||||
|
"celebrateLunarNewYear": "春節快樂,{}!",
|
||||||
|
"celebrateMidAutumn": "中秋節快樂,{}!",
|
||||||
|
"celebrateDragonBoat": "端午節快樂,{}!",
|
||||||
"celebrateMerryXmas": "聖誕快樂,{}!",
|
"celebrateMerryXmas": "聖誕快樂,{}!",
|
||||||
"celebrateNewYear": "新年快樂,{}!",
|
"celebrateNewYear": "新年快樂,{}!",
|
||||||
"celebrateValentineDay": "今天是情人節,{}!",
|
"celebrateValentineDay": "今天是情人節,{}!",
|
||||||
@ -415,6 +422,9 @@
|
|||||||
"celebrateFatherDay": "今天是父親節,{}。",
|
"celebrateFatherDay": "今天是父親節,{}。",
|
||||||
"celebrateHalloween": "快樂在聖誕節,{}!",
|
"celebrateHalloween": "快樂在聖誕節,{}!",
|
||||||
"celebrateThanksgiving": "今天是感恩節,{}!",
|
"celebrateThanksgiving": "今天是感恩節,{}!",
|
||||||
|
"pendingLunarNewYear": "{} 過春節",
|
||||||
|
"pendingMidAutumn": "{} 過中秋節",
|
||||||
|
"pendingDragonBoat": "{} 過端午節",
|
||||||
"pendingBirthday": "{} 過生日",
|
"pendingBirthday": "{} 過生日",
|
||||||
"pendingMerryXmas": "{} 過聖誕節",
|
"pendingMerryXmas": "{} 過聖誕節",
|
||||||
"pendingNewYear": "{} 跨年",
|
"pendingNewYear": "{} 跨年",
|
||||||
|
@ -279,6 +279,10 @@
|
|||||||
"one": "{} 個附件",
|
"one": "{} 個附件",
|
||||||
"other": "{} 個附件"
|
"other": "{} 個附件"
|
||||||
},
|
},
|
||||||
|
"messageTyping": {
|
||||||
|
"one": "{} 正在輸入",
|
||||||
|
"other": "{} 正在輸入"
|
||||||
|
},
|
||||||
"fieldAttachmentRandomId": "訪問 ID",
|
"fieldAttachmentRandomId": "訪問 ID",
|
||||||
"fieldAttachmentAlt": "概述文字",
|
"fieldAttachmentAlt": "概述文字",
|
||||||
"addAttachmentFromAlbum": "從相冊中添加附件",
|
"addAttachmentFromAlbum": "從相冊中添加附件",
|
||||||
@ -406,6 +410,9 @@
|
|||||||
"dailyCheckNegativeHint6": "出門",
|
"dailyCheckNegativeHint6": "出門",
|
||||||
"dailyCheckNegativeHint6Description": "忘帶傘遇上大雨",
|
"dailyCheckNegativeHint6Description": "忘帶傘遇上大雨",
|
||||||
"celebrateBirthday": "生日快樂,{}!",
|
"celebrateBirthday": "生日快樂,{}!",
|
||||||
|
"celebrateLunarNewYear": "春節快樂,{}!",
|
||||||
|
"celebrateMidAutumn": "中秋節快樂,{}!",
|
||||||
|
"celebrateDragonBoat": "端午節快樂,{}!",
|
||||||
"celebrateMerryXmas": "聖誕快樂,{}!",
|
"celebrateMerryXmas": "聖誕快樂,{}!",
|
||||||
"celebrateNewYear": "新年快樂,{}!",
|
"celebrateNewYear": "新年快樂,{}!",
|
||||||
"celebrateValentineDay": "今天是情人節,{}!",
|
"celebrateValentineDay": "今天是情人節,{}!",
|
||||||
@ -415,6 +422,9 @@
|
|||||||
"celebrateFatherDay": "今天是父親節,{}。",
|
"celebrateFatherDay": "今天是父親節,{}。",
|
||||||
"celebrateHalloween": "快樂在聖誕節,{}!",
|
"celebrateHalloween": "快樂在聖誕節,{}!",
|
||||||
"celebrateThanksgiving": "今天是感恩節,{}!",
|
"celebrateThanksgiving": "今天是感恩節,{}!",
|
||||||
|
"pendingLunarNewYear": "{} 過春節",
|
||||||
|
"pendingMidAutumn": "{} 過中秋節",
|
||||||
|
"pendingDragonBoat": "{} 過端午節",
|
||||||
"pendingBirthday": "{} 過生日",
|
"pendingBirthday": "{} 過生日",
|
||||||
"pendingMerryXmas": "{} 過聖誕節",
|
"pendingMerryXmas": "{} 過聖誕節",
|
||||||
"pendingNewYear": "{} 跨年",
|
"pendingNewYear": "{} 跨年",
|
||||||
|
@ -3,9 +3,12 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:surface/providers/userinfo.dart';
|
import 'package:surface/providers/userinfo.dart';
|
||||||
|
|
||||||
// Stored as key: month, day
|
// Stored as key: month, day
|
||||||
const Map<String, (int, int)> kSpecialDays = {
|
final Map<String, (int, int)> kSpecialDays = {
|
||||||
// Birthday is dynamically generated according to the user's profile
|
// Birthday is dynamically generated according to the user's profile
|
||||||
'NewYear': (1, 1),
|
'NewYear': (1, 1),
|
||||||
|
'LunarNewYear': (lunarToGregorian(null, 1, 1).month, lunarToGregorian(null, 1, 1).day),
|
||||||
|
'MidAutumn': (lunarToGregorian(null, 8, 15).month, lunarToGregorian(null, 8, 15).day),
|
||||||
|
'DragonBoat': (lunarToGregorian(null, 5, 5).month, lunarToGregorian(null, 5, 5).day),
|
||||||
'ValentineDay': (2, 14),
|
'ValentineDay': (2, 14),
|
||||||
'LaborDay': (5, 1),
|
'LaborDay': (5, 1),
|
||||||
'MotherDay': (5, 11),
|
'MotherDay': (5, 11),
|
||||||
@ -19,6 +22,9 @@ const Map<String, (int, int)> kSpecialDays = {
|
|||||||
const Map<String, String> kSpecialDaysSymbol = {
|
const Map<String, String> kSpecialDaysSymbol = {
|
||||||
'Birthday': '🎂',
|
'Birthday': '🎂',
|
||||||
'NewYear': '🎉',
|
'NewYear': '🎉',
|
||||||
|
'LunarNewYear': '🎉',
|
||||||
|
'MidAutumn': '🥮',
|
||||||
|
'DragonBoat': '🐲',
|
||||||
'MerryXmas': '🎄',
|
'MerryXmas': '🎄',
|
||||||
'ValentineDay': '💑',
|
'ValentineDay': '💑',
|
||||||
'LaborDay': '🏋️',
|
'LaborDay': '🏋️',
|
||||||
@ -134,3 +140,45 @@ class SpecialDayProvider {
|
|||||||
return (elapsedDuration / totalDuration).clamp(0.0, 1.0);
|
return (elapsedDuration / totalDuration).clamp(0.0, 1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Map<int, LunarYear> lunarYearData = {
|
||||||
|
2025: LunarYear(
|
||||||
|
startDate: DateTime(2025, 1, 29),
|
||||||
|
months: [29, 30, 30, 29, 30, 29, 29, 30, 30, 29, 30, 29],
|
||||||
|
leapMonth: 0,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
class LunarYear {
|
||||||
|
final DateTime startDate;
|
||||||
|
final List<int> months;
|
||||||
|
final int leapMonth;
|
||||||
|
|
||||||
|
LunarYear({required this.startDate, required this.months, required this.leapMonth});
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime lunarToGregorian(int? year, int month, int day, {bool isLeapMonth = false}) {
|
||||||
|
year = year ?? DateTime.now().year;
|
||||||
|
final lunarYear = lunarYearData[year];
|
||||||
|
if (lunarYear == null) {
|
||||||
|
throw Exception('Lunar data for year $year not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
int leapMonth = lunarYear.leapMonth;
|
||||||
|
if (isLeapMonth && (leapMonth == 0 || leapMonth != month)) {
|
||||||
|
throw Exception('Invalid leap month for year $year');
|
||||||
|
}
|
||||||
|
|
||||||
|
int daysFromStart = 0;
|
||||||
|
for (int i = 0; i < month - 1; i++) {
|
||||||
|
daysFromStart += lunarYear.months[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLeapMonth) {
|
||||||
|
daysFromStart += lunarYear.months[month - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
daysFromStart += day - 1;
|
||||||
|
|
||||||
|
return lunarYear.startDate.add(Duration(days: daysFromStart));
|
||||||
|
}
|
||||||
|
@ -197,7 +197,7 @@ class _HomeDashSpecialDayWidgetState extends State<_HomeDashSpecialDayWidget> {
|
|||||||
return Card(
|
return Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: Text(kSpecialDaysSymbol[name] ?? '🎉').fontSize(24),
|
leading: Text(kSpecialDaysSymbol[name] ?? '🎉').fontSize(24),
|
||||||
title: Text('pending$name').tr(args: [RelativeTime(context).format(date)]),
|
title: Text('pending$name').tr(args: [RelativeTime(context).format(date).replaceFirst('in', '').trim()]),
|
||||||
subtitle: Row(
|
subtitle: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
Loading…
Reference in New Issue
Block a user