Skip to content

Commit

Permalink
feat(mobile): improve category select sheet (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkdev98 committed Sep 18, 2024
1 parent c3e4eb3 commit 0aeee11
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions apps/mobile/components/transaction/select-category-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { cssInterop } from 'nativewind'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { BottomSheet } from '../common/bottom-sheet'
import GenericIcon from '../common/generic-icon'
import { Badge } from '../ui/badge'
import { Button } from '../ui/button'
import { Text } from '../ui/text'

Expand Down Expand Up @@ -97,27 +98,28 @@ export function SelectCategoryField({
contentContainerClassName="px-2"
keyboardDismissMode="on-drag"
renderSectionHeader={({ section: { title } }) => (
<Text className="bg-card py-2 text-center font-medium text-base">
{title}
</Text>
<Badge className="mx-auto my-2 px-8" variant="secondary">
<Text className="text-base uppercase">{title}</Text>
</Badge>
)}
contentContainerStyle={{ paddingBottom: bottom + 16 }}
renderItem={({ section, index }) =>
index === 0 ? (
<FlatList
data={section.data}
numColumns={4}
numColumns={3}
columnWrapperClassName="flex-wrap"
keyExtractor={(i) => i.id}
showsVerticalScrollIndicator={false}
showsHorizontalScrollIndicator={false}
extraData={[value]}
renderItem={({ item, index: idx }) => (
<>
<View className="w-[25%] items-center justify-center p-1.5">
<View className="w-[33%] items-center justify-center p-2">
<Button
size="icon"
className="flex h-20 w-full flex-1 flex-grow flex-col gap-2 px-2"
variant={value === item ? 'secondary' : 'ghost'}
className="flex h-20 w-full flex-1 flex-grow flex-col px-2 pt-1.5"
variant={value === item.id ? 'secondary' : 'ghost'}
onPress={async () => {
Haptics.selectionAsync()
sheetRef.current?.close()
Expand All @@ -139,15 +141,15 @@ export function SelectCategoryField({
bounce
loop
animationType="bounce"
className="!text-sm line-clamp-1 text-center text-muted-foreground"
className="!text-base line-clamp-1 text-center text-muted-foreground"
>
{item.name}
</TextTicker>
</Button>
</View>

{idx === section.data.length - 1 && (
<View className="w-[25%] items-center justify-center p-1.5">
<View className="w-[33%] items-center justify-center p-1.5">
<Link href="/category/new-category" asChild>
<Button
size="icon"
Expand Down

0 comments on commit 0aeee11

Please sign in to comment.