Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion apps/mobile/src/app/chores/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ export default function ChoreDetailScreen() {
retry: 1,
})

const choreTitle = useMemo(() => {
const choreItem = data?.chores?.find(c => c._id === id)
if (!choreItem) return <LoadingSkeletonLine width="75%" height={21.25} style={{ marginBottom: 8 }} />

const plantName = choreItem.plant?.name || 'Unknown'

let detail: string
if (choreItem.fertilizers && choreItem.fertilizers.length > 0) {
detail = choreItem.fertilizers.map(f => {
const fertObj = typeof f.fertilizer === 'object' ? f.fertilizer : null
const name = fertObj?.name || ''
return f.amount ? `${name} (${f.amount})` : name
}).join(', ')
} else {
detail = choreItem.description || ''
}

const recurrence = choreItem.recurAmount && choreItem.recurUnit
? ` every ${choreItem.recurAmount} ${choreItem.recurUnit}${choreItem.recurAmount === 1 ? '' : 's'}`
: ''

return `${plantName}: ${detail}${recurrence}`
}, [data, id])

// Fetch fertilizers for edit form
const {
data: fertilizersData,
Expand Down Expand Up @@ -267,7 +291,7 @@ export default function ChoreDetailScreen() {
<ScreenTitle
isLoading={isRefetching}
>
Chore
{choreTitle}
</ScreenTitle>

{(isLoading && (
Expand Down
20 changes: 13 additions & 7 deletions apps/mobile/src/components/ScreenTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ export function ScreenTitle({
<View style={styles.headerTitleContainer}>
<Text style={styles.title}>{children}</Text>

{isLoading && (
<ActivityIndicator
color={palette.textPrimary}
size='small'
/>
)}
<View style={styles.loadingIndicatorContainer}>
{isLoading && (
<ActivityIndicator
color={palette.textPrimary}
size='small'
/>
)}
</View>
</View>

{buttons && (
Expand All @@ -42,13 +44,17 @@ const styles = StyleSheet.create({
},
headerTitleContainer: {
flexDirection: 'row',
alignItems: 'center',
alignItems: 'flex-start',
columnGap: 12,
},
title: {
fontSize: 18,
fontWeight: '700',
color: palette.textPrimary,
maxWidth: '90%',
},
loadingIndicatorContainer: {
width: '8%',
},
headerButtons: {
flexDirection: 'row',
Expand Down