diff --git a/assets/birthday-butterfly.png b/assets/birthday-butterfly.png new file mode 100644 index 0000000000..2e0c091800 Binary files /dev/null and b/assets/birthday-butterfly.png differ diff --git a/src/components/delight/BirthdayCard.tsx b/src/components/delight/BirthdayCard.tsx new file mode 100644 index 0000000000..ae436d907a --- /dev/null +++ b/src/components/delight/BirthdayCard.tsx @@ -0,0 +1,85 @@ +import {View} from 'react-native' +import {Image} from 'expo-image' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {usePreferencesQuery} from '#/state/queries/preferences' +import {useSession} from '#/state/session' +import {atoms as a, tokens} from '#/alf' +import {Button, ButtonIcon} from '#/components/Button' +import {GradientFill} from '#/components/GradientFill' +import {Heart2_Filled_Stroke2_Corner0_Rounded as HeartIcon} from '#/components/icons/Heart2' +import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/Times' +import {Text} from '#/components/Typography' +import {account, useStorage} from '#/storage' + +export function BirthdayCard() { + const {data: preferences} = usePreferencesQuery() + const {currentAccount} = useSession() + const {_} = useLingui() + const [birthdayDismissYear, setBirthdayDismissYear] = useStorage(account, [ + currentAccount?.did ?? 'pwi', + 'birthdayDismissYear', + ]) + + const year = new Date().getUTCFullYear() + + if ( + !preferences || + !preferences.birthDate || + !isYourBirthday(preferences.birthDate) || + birthdayDismissYear === year + ) { + return null + } + + return ( + + + + + + + Happy Birthday! + + + Best wishes from all of us at the Bluesky team{' '} + + + + + + + + + ) +} + +function isYourBirthday(birthday: Date) { + const today = new Date() + return ( + today.getUTCDate() === birthday.getUTCDate() && + today.getUTCMonth() === birthday.getUTCMonth() + ) +} diff --git a/src/screens/Profile/Header/Shell.tsx b/src/screens/Profile/Header/Shell.tsx index 9e868c4749..721b552da1 100644 --- a/src/screens/Profile/Header/Shell.tsx +++ b/src/screens/Profile/Header/Shell.tsx @@ -25,6 +25,7 @@ import {LoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder' import {UserAvatar} from '#/view/com/util/UserAvatar' import {UserBanner} from '#/view/com/util/UserBanner' import {atoms as a, platform, useTheme} from '#/alf' +import {BirthdayCard} from '#/components/delight/BirthdayCard' import {useDialogControl} from '#/components/Dialog' import {ArrowLeft_Stroke2_Corner0_Rounded as ArrowLeftIcon} from '#/components/icons/Arrow' import {EditLiveDialog} from '#/components/live/EditLiveDialog' @@ -195,6 +196,8 @@ let ProfileHeaderShell = ({ )} + +