Skip to content

Commit ee3916d

Browse files
committed
set divider in bottom sheet as optional; add iconConfig; move types to separate file
1 parent d699f61 commit ee3916d

7 files changed

Lines changed: 87 additions & 40 deletions

File tree

src/design-system/bottomSheets/BottomSheet.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,25 @@ import {
66
BottomSheetBackdropProps,
77
BottomSheetView,
88
} from '@gorhom/bottom-sheet'
9-
import { RefObject, useCallback } from 'react'
9+
import { useCallback } from 'react'
1010
import { Dimensions } from 'react-native'
1111

1212
import { BottomSheetScrollView } from './BootomSheetScrollables'
1313
import { BottomSheetHeader } from './BottomSheetHeader'
14+
import { BottomSheetProps } from './types'
1415

1516
const screenHeight = Dimensions.get('screen').height
1617

17-
type Props = {
18-
bottomSheetRef: RefObject<BottomSheetModal>
19-
children: JSX.Element | JSX.Element[]
20-
title?: string
21-
showCloseButton?: boolean
22-
numberOfTitleLines?: number
23-
}
24-
2518
export { BottomSheetScrollView }
2619
export const BottomSheet = ({
2720
children,
2821
title,
22+
iconConfig,
23+
isDivider = true,
2924
showCloseButton = true,
3025
numberOfTitleLines,
3126
bottomSheetRef,
32-
}: Props) => {
27+
}: BottomSheetProps) => {
3328
const { top } = useSafeAreaInsets()
3429

3530
const handleClose = useCallback(() => {
@@ -52,13 +47,13 @@ export const BottomSheet = ({
5247
>
5348
<BottomSheetView>
5449
<BottomSheetHeader
50+
iconConfig={iconConfig}
5551
title={title}
5652
numberOfLines={numberOfTitleLines}
5753
showCloseButton={showCloseButton}
5854
onClose={handleClose}
5955
/>
60-
<Box pb="1px" bg="bg.brand.primary" />
61-
56+
{isDivider && <Box pb="1px" bg="bg.brand.primary" />}
6257
{children}
6358
</BottomSheetView>
6459
</BottomSheetModal>

src/design-system/bottomSheets/BottomSheet.web.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
import { Modal } from '@baca/components/Modal'
22
import { useBoolean, useWeb } from '@baca/hooks'
3-
import { BottomSheetModal } from '@gorhom/bottom-sheet'
4-
import { RefObject, useCallback, useImperativeHandle } from 'react'
3+
import { useCallback, useImperativeHandle } from 'react'
54
import { ScrollView } from 'react-native'
65

76
import { BottomSheetHeader } from './BottomSheetHeader'
7+
import { BottomSheetProps } from './types'
88
import { Box } from '../components/Box'
99

10-
type Props = {
11-
bottomSheetRef: RefObject<BottomSheetModal>
12-
children: JSX.Element | JSX.Element[]
13-
title?: string
14-
showCloseButton?: boolean
15-
numberOfTitleLines?: number
16-
}
17-
1810
export const BottomSheetScrollView = ScrollView
1911
export const BottomSheet = ({
2012
children,
13+
iconConfig,
14+
isDivider = true,
2115
title,
2216
showCloseButton = true,
2317
numberOfTitleLines,
2418
bottomSheetRef,
25-
}: Props) => {
19+
}: BottomSheetProps) => {
2620
const [isOpen, setIsOpen] = useBoolean(false)
2721
const { webContentWidth } = useWeb()
2822

@@ -63,8 +57,9 @@ export const BottomSheet = ({
6357
numberOfLines={numberOfTitleLines}
6458
showCloseButton={showCloseButton}
6559
onClose={setIsOpen.off}
60+
iconConfig={iconConfig}
6661
/>
67-
<Box pb="1px" bg="bg.brand.primary" />
62+
{isDivider && <Box pb="1px" bg="bg.brand.primary" />}
6863
{children}
6964
</Box>
7065
</Modal>

src/design-system/bottomSheets/BottomSheetHeader.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { BottomSheetHeaderProps } from './types'
12
import { Box } from '../components/Box'
23
import { Icon } from '../components/Icon'
34
import { Row } from '../components/Row'
@@ -9,22 +10,25 @@ export const BottomSheetHeader = ({
910
numberOfLines = undefined,
1011
showCloseButton,
1112
onClose,
12-
}: {
13-
title?: string
14-
numberOfLines?: number
15-
showCloseButton?: boolean
16-
onClose?: () => void
17-
}) => {
13+
iconConfig,
14+
}: BottomSheetHeaderProps) => {
1815
if (!showCloseButton && !title) {
1916
return null
2017
}
2118

2219
return (
2320
<Row alignItems="center">
21+
{iconConfig && (
22+
<Box backgroundColor={iconConfig.bgColor} p={3} borderRadius={100} ml={4} mt={4}>
23+
<Icon name={iconConfig.name} size={24} color={iconConfig.color} />
24+
</Box>
25+
)}
2426
<Box flex={1} px={4}>
25-
<Text.MdBold numberOfLines={numberOfLines} allowFontScaling={false}>
26-
{title}
27-
</Text.MdBold>
27+
{title && (
28+
<Text.MdBold numberOfLines={numberOfLines} allowFontScaling={false}>
29+
{title}
30+
</Text.MdBold>
31+
)}
2832
</Box>
2933
{showCloseButton && (
3034
<Touchable onPress={onClose} hitSlop={10} p={4} pl={8}>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { IconNames } from '@baca/types/icon'
2+
import { BottomSheetModal } from '@gorhom/bottom-sheet'
3+
import { RefObject } from 'react'
4+
5+
export type BottomSheetIconConfigProps = {
6+
name: IconNames
7+
color: ColorNames
8+
bgColor: ColorNames
9+
}
10+
11+
export type BottomSheetProps = {
12+
bottomSheetRef: RefObject<BottomSheetModal>
13+
children: JSX.Element | JSX.Element[]
14+
isDivider?: boolean
15+
title?: string
16+
showCloseButton?: boolean
17+
numberOfTitleLines?: number
18+
iconConfig?: BottomSheetIconConfigProps
19+
}
20+
21+
export type BottomSheetHeaderProps = {
22+
title?: string
23+
numberOfLines?: number
24+
showCloseButton?: boolean
25+
onClose?: () => void
26+
iconConfig?: BottomSheetIconConfigProps
27+
}

src/design-system/bottomSheets/useBottomSheets.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@ import { BottomSheetModal } from '@gorhom/bottom-sheet'
22
import { useCallback, useRef } from 'react'
33

44
import { BottomSheet } from './BottomSheet'
5+
import { BottomSheetIconConfigProps } from './types'
56

6-
export const useBottomSheet = ({ title = '' }) => {
7+
export const useBottomSheet = ({ title = '', isDivider = true }) => {
78
const bottomSheetRef = useRef<BottomSheetModal>(null)
89

9-
const bottomSheetComponentRenderFunction = (children: JSX.Element | JSX.Element[]) => {
10+
const bottomSheetComponentRenderFunction = (
11+
children: JSX.Element | JSX.Element[],
12+
iconConfig?: BottomSheetIconConfigProps
13+
) => {
1014
return (
11-
<BottomSheet title={title} bottomSheetRef={bottomSheetRef}>
15+
<BottomSheet
16+
title={title}
17+
isDivider={isDivider}
18+
bottomSheetRef={bottomSheetRef}
19+
iconConfig={iconConfig}
20+
>
1221
{children}
1322
</BottomSheet>
1423
)
@@ -18,8 +27,13 @@ export const useBottomSheet = ({ title = '' }) => {
1827
bottomSheetRef.current?.present?.()
1928
}, [])
2029

30+
const closeBottomSheet = useCallback(() => {
31+
bottomSheetRef.current?.close?.()
32+
}, [])
33+
2134
return {
2235
bottomSheetComponentRenderFunction,
36+
closeBottomSheet,
2337
presentBottomSheet,
2438
}
2539
}

src/i18n/translations/en.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,14 @@
234234
"copy_push_token": "Copy push token",
235235
"current_theme": "Current theme: {{theme}}",
236236
"sign_out": "Sign out!",
237-
"selected": " - selected",
238-
"remove_account": "Remove account"
237+
"selected": " - selected"
238+
},
239+
"profile_screen": {
240+
"profile": "Profile",
241+
"update_your_details": "Update your personal details here.",
242+
"remove_account": "Remove account",
243+
"are_you_sure": "Are you sure?",
244+
"remove_account_desc": "This action cannot be undone.\n\nYou will lose access to your account. If you have an active subscription you will lose access to it.\n\nPlease make sure you are certain about this action."
239245
},
240246
"sign_in_screen": {
241247
"do_not_have_an_account": "Don't have an account?",

src/i18n/translations/pl.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,14 @@
232232
"settings_screen": {
233233
"current_theme": "Current theme: {{theme}}",
234234
"selected": " - wybrano",
235-
"sign_out": "Wyloguj!",
236-
"remove_account": "Usuń konto"
235+
"sign_out": "Wyloguj!"
236+
},
237+
"profile_screen": {
238+
"profile": "Profil",
239+
"update_your_details": "Zaktualizuj swoje dane osobowe tutaj.",
240+
"remove_account": "Usuń konto",
241+
"are_you_sure": "Jesteś pewny/a?",
242+
"remove_account_desc": "Tej akcji nie można cofnąć.\n\nUtracisz dostęp do swojego konta. Jeśli masz aktywną subskrypcję, utracisz do niej dostęp.\n\nUpewnij się, że jesteś pewien tej akcji"
237243
},
238244
"sign_in_screen": {
239245
"do_not_have_an_account": "Nie masz konta?",

0 commit comments

Comments
 (0)