Skip to content

Commit 0806441

Browse files
committed
feat(home): randomize some texts
1 parent 6542463 commit 0806441

18 files changed

+281
-149
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
### Added
11+
12+
- A little bit of random in text descriptions.
13+
- Event description is selectable.
14+
1015
### Changed
1116

1217
- Prefer error icon instead of chip on most screens.

app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"supportsTablet": true
9191
},
9292
"name": "Le Poulailler",
93-
"newArchEnabled": true,
93+
"newArchEnabled": false,
9494
"orientation": "portrait",
9595
"owner": "coworking-metz",
9696
"packagerOpts": {

package-lock.json

Lines changed: 15 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"i18next": "^25.3.2",
7373
"intl-pluralrules": "^2.0.1",
7474
"lodash.set": "^4.3.2",
75-
"lottie-react-native": "7.1.0",
75+
"lottie-react-native": "7.2.4",
7676
"markdown-it-plain-text": "^0.3.0",
7777
"moti": "^0.30.0",
7878
"patch-package": "^8.0.0",
@@ -92,7 +92,7 @@
9292
"react-native-open-maps": "^0.4.3",
9393
"react-native-progress-wheel": "^2.1.0",
9494
"react-native-read-more-text": "^1.1.2",
95-
"react-native-reanimated": "~3.16.6",
95+
"react-native-reanimated": "~3.18.0",
9696
"react-native-reanimated-carousel": "4.0.2",
9797
"react-native-safe-area-context": "4.12.0",
9898
"react-native-screens": "~4.4.0",

src/app/(public)/attendance.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MaterialCommunityIcons } from '@expo/vector-icons';
22
import { useIsFocused } from '@react-navigation/native';
33
import { useQuery } from '@tanstack/react-query';
44
import dayjs from 'dayjs';
5-
import { capitalize, isNil } from 'lodash';
5+
import { capitalize, isNil, sample } from 'lodash';
66
import React, { useMemo, useState } from 'react';
77
import { useTranslation } from 'react-i18next';
88
import { View } from 'react-native';
@@ -98,12 +98,22 @@ const Attendance = () => {
9898
return groups;
9999
}, [currentMembers]);
100100

101+
const emptyTitle = useMemo(() => {
102+
const i18nEmptyTitle = t('attendance.empty.title', { returnObjects: true });
103+
return Array.isArray(i18nEmptyTitle) ? sample(i18nEmptyTitle) : i18nEmptyTitle;
104+
}, [t, currentMembersUpdatedAt]);
105+
106+
const emptyDescription = useMemo(() => {
107+
const text = t('attendance.empty.description', { returnObjects: true });
108+
return Array.isArray(text) ? sample(text) : text;
109+
}, [t, currentMembersUpdatedAt]);
110+
101111
return (
102112
<>
103113
<ServiceLayout
104114
contentStyle={tw`pt-6 pb-12 gap-6`}
105115
description={t('attendance.description')}
106-
title={t('attendance.title', { count: currentMembers?.length })}
116+
title={t('attendance.title', { count: currentMembers?.length ?? 0 })}
107117
onRefresh={refetchCurrentMembers}>
108118
<View style={tw`flex flex-row items-center gap-2 min-h-6 px-6`}>
109119
{!isNil(durationSinceLastFetch) ? (
@@ -190,13 +200,13 @@ const Attendance = () => {
190200
entering={FadeInLeft.duration(500)}
191201
numberOfLines={1}
192202
style={tw`text-xl text-center font-bold tracking-tight text-slate-900 dark:text-gray-200`}>
193-
{t('attendance.empty.title')}
203+
{emptyTitle}
194204
</AppText>
195205
<AppText
196206
entering={FadeInLeft.duration(500).delay(150)}
197207
numberOfLines={2}
198208
style={tw`text-base text-center text-slate-500 dark:text-slate-400`}>
199-
{t('attendance.empty.description')}
209+
{emptyDescription}
200210
</AppText>
201211
</View>
202212
)}

src/app/(public)/events/[eventId].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export default function CalendarEventPage() {
152152
/>
153153
) : null}
154154
{event.description ? (
155-
<AppText style={tw`text-base font-normal text-gray-500 mx-6 mt-6`}>
155+
<AppText selectable style={tw`text-base font-normal text-gray-500 mx-6 mt-6`}>
156156
{event.description}
157157
</AppText>
158158
) : null}

src/app/(public)/home.tsx

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useQuery } from '@tanstack/react-query';
33
import dayjs from 'dayjs';
44
import { NetworkStateType, useNetworkState } from 'expo-network';
55
import { Link } from 'expo-router';
6-
import { includes } from 'lodash';
6+
import { includes, sample } from 'lodash';
77
import React, { useCallback, useEffect, useMemo, useState } from 'react';
88
import { useTranslation } from 'react-i18next';
99
import { ScrollView, View } from 'react-native';
@@ -16,19 +16,20 @@ import Animated, {
1616
FadeOutDown,
1717
StretchInY,
1818
} from 'react-native-reanimated';
19+
import { toast } from 'sonner-native';
20+
import tw, { useDeviceContext } from 'twrnc';
1921
import AppText from '@/components/AppText';
2022
import AppTouchable from '@/components/AppTouchable';
2123
import ErrorBadge from '@/components/ErrorBagde';
22-
import { type PeriodType } from '@/components/Events/PeriodBottomSheet';
2324
import AppointmentCard from '@/components/Home/AppointmentCard';
2425
import AttendanceCount from '@/components/Home/AttendanceCount';
2526
import BalanceBottomSheet from '@/components/Home/BalanceBottomSheet';
2627
import BalanceCard from '@/components/Home/BalanceCard';
2728
import BirthdayBottomSheet from '@/components/Home/BirthdayBottomSheet';
2829
import BirthdayCard from '@/components/Home/BirthdayCard';
29-
import CalendarEmptyState from '@/components/Home/CalendarEmptyState';
3030
import CalendarEventCard from '@/components/Home/CalendarEventCard';
3131
import DevicesCard from '@/components/Home/DevicesCard';
32+
import HomeCalendarEmptyState from '@/components/Home/HomeCalendarEmptyState';
3233
import HomeLayout from '@/components/Home/HomeLayout';
3334
import MembershipBottomSheet from '@/components/Home/MembershipBottomSheet';
3435
import MembershipCard from '@/components/Home/MembershipCard';
@@ -56,8 +57,6 @@ import {
5657
import useAuthStore from '@/stores/auth';
5758
import useSettingsStore from '@/stores/settings';
5859
import useToastStore from '@/stores/toast';
59-
import { toast } from 'sonner-native';
60-
import tw, { useDeviceContext } from 'twrnc';
6160

6261
const MAX_WIDTH = 672; // tw`max-w-2xl`
6362

@@ -167,6 +166,7 @@ export default function HomeScreen() {
167166
data: calendarEvents,
168167
isLoading: isLoadingCalendarEvents,
169168
isFetching: isFetchingCalendarEvents,
169+
dataUpdatedAt: calendarEventsUpdatedAt,
170170
refetch: refreshCalendarEvents,
171171
error: calendarEventsError,
172172
} = useQuery({
@@ -186,18 +186,6 @@ export default function HomeScreen() {
186186
);
187187
}, [calendarEvents, activeSince]);
188188

189-
const firstPeriodWithEvents: PeriodType = useMemo(() => {
190-
const [nextEvent] = nextCalendarEvents?.filter(({ end }) => dayjs().isBefore(end)) || [];
191-
if (nextEvent) {
192-
if (dayjs(nextEvent.start).isSame(dayjs(), 'week')) {
193-
return 'week';
194-
} else if (dayjs(nextEvent.start).isSame(dayjs(), 'month')) {
195-
return 'month';
196-
}
197-
}
198-
return null;
199-
}, [nextCalendarEvents]);
200-
201189
const onRefresh = useCallback(() => {
202190
return Promise.all([
203191
authStore.user?.id && refetchProfile(),
@@ -210,10 +198,10 @@ export default function HomeScreen() {
210198

211199
const onSuccessiveTaps = useCallback(() => {
212200
toastStore.add({
213-
message: t('home.onSuccessiveTaps.message'),
201+
message: `${sample(t('home.onSuccessiveTaps.message', { returnObjects: true }))}`,
214202
type: 'info',
215203
action: {
216-
label: t('home.onSuccessiveTaps.action'),
204+
label: `${sample(t('home.onSuccessiveTaps.action', { returnObjects: true }))}`,
217205
onPress: async () => {
218206
toast.dismiss();
219207
contact();
@@ -337,6 +325,7 @@ export default function HomeScreen() {
337325
error={
338326
currentMembersError && !isSilentError(currentMembersError) ? currentMembersError : null
339327
}
328+
lastFetch={currentMembersUpdatedAt}
340329
loading={isLoadingCurrentMembers}
341330
members={currentMembers}
342331
style={tw`mt-4`}
@@ -478,19 +467,11 @@ export default function HomeScreen() {
478467
</Animated.View>
479468
))
480469
) : (
481-
<CalendarEmptyState
482-
description={t('home.calendar.empty.label')}
483-
style={tw`w-full h-full mt-4`}>
484-
<Link
485-
asChild
486-
href={['/events', firstPeriodWithEvents && `period=${firstPeriodWithEvents}`]
487-
.filter(Boolean)
488-
.join('?')}>
489-
<AppText style={tw`text-base font-normal text-amber-500 text-center mt-4`}>
490-
{t('home.calendar.empty.action')}
491-
</AppText>
492-
</Link>
493-
</CalendarEmptyState>
470+
<HomeCalendarEmptyState
471+
events={nextCalendarEvents}
472+
lastFetch={calendarEventsUpdatedAt}
473+
style={tw`w-full h-full mt-4`}
474+
/>
494475
)}
495476
</ScrollView>
496477
</Animated.View>

src/components/AppText.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import Animated, { AnimatedProps } from 'react-native-reanimated';
44
import { AnimatedText } from 'react-native-reanimated/lib/typescript/component/Text';
55
import { getFamilyForWeight } from '@/helpers/text';
66

7-
const AppText: ForwardRefRenderFunction<AnimatedText, AnimatedProps<TextProps>> = (
7+
export type AppTextProps = AnimatedProps<TextProps>;
8+
9+
const AppText: ForwardRefRenderFunction<AnimatedText, AppTextProps> = (
810
{ children, style, ...otherProps },
911
ref,
1012
) => {

src/components/Devices/PairDeviceBottomSheet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ const PairDeviceBottomSheet = ({
242242
animation.current?.play(100, 150);
243243
}, [animation]);
244244

245-
const enddAnimation = useCallback(() => {
245+
const endAnimation = useCallback(() => {
246246
setLoopAnimation(false);
247247
setEndAnimation(false);
248248
animation.current?.play(150, 250);
@@ -258,7 +258,7 @@ const PairDeviceBottomSheet = ({
258258

259259
const onAnimationFinish = useCallback(() => {
260260
if (shouldEndAnimation) {
261-
enddAnimation();
261+
endAnimation();
262262
} else if (shouldLoopAnimation) {
263263
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
264264
continueAnimation();

0 commit comments

Comments
 (0)