Skip to content

Commit 9f2bfc3

Browse files
Merge pull request #53 from binarapps/fix/remove-account-button-and-alert
Fix/remove account button and alert
2 parents 0441c78 + 84406d2 commit 9f2bfc3

11 files changed

Lines changed: 173 additions & 90 deletions

File tree

src/contexts/ColorSchemeContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type ColorSchemeName = Exclude<SettingColorSchemeName, 'system'>
77
export type ColorSchemeContextType = {
88
colorSchemeSetting: SettingColorSchemeName
99
colorScheme: ColorSchemeName
10+
isDarkTheme: boolean
1011
setColorSchemeSetting: (newColorScheme: SettingColorSchemeName) => void
1112
}
1213

src/design-system/bottomSheets/BottomSheet.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
11
import { Box } from '@baca/design-system/components/Box'
2-
import { useSafeAreaInsets } from '@baca/hooks'
2+
import { useSafeAreaInsets, useTheme } from '@baca/hooks'
33
import {
44
BottomSheetModal,
55
BottomSheetBackdrop,
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()
29+
const { colors } = useTheme()
3430

3531
const handleClose = useCallback(() => {
3632
bottomSheetRef?.current?.snapToPosition(-1)
@@ -49,16 +45,24 @@ export const BottomSheet = ({
4945
snapPoints={[screenHeight - top - 24]}
5046
backdropComponent={renderBackdrop}
5147
enableDynamicSizing
48+
backgroundStyle={{
49+
// eslint-disable-next-line react-native/no-inline-styles
50+
backgroundColor: colors.bg.primary,
51+
}}
52+
handleIndicatorStyle={{
53+
// eslint-disable-next-line react-native/no-inline-styles
54+
backgroundColor: colors.alpha.black[100],
55+
}}
5256
>
5357
<BottomSheetView>
5458
<BottomSheetHeader
59+
iconConfig={iconConfig}
5560
title={title}
5661
numberOfLines={numberOfTitleLines}
5762
showCloseButton={showCloseButton}
5863
onClose={handleClose}
5964
/>
60-
<Box pb="1px" bg="bg.brand.primary" />
61-
65+
{isDivider && <Box pb="1px" bg="bg.brand.primary" />}
6266
{children}
6367
</BottomSheetView>
6468
</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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
"session_expired": {
1010
"description": "Try to log in again",
1111
"title": "Your current session expired"
12-
},
13-
"remove_account": {
14-
"description": "Are you sure you want to delete your account?",
15-
"title": "Attention!",
16-
"confirm": "Yes, delete"
1712
}
1813
},
1914
"bottom_tabs": {
@@ -34,8 +29,7 @@
3429
"save": "Save",
3530
"search": "Search",
3631
"try_again_later": "Please try again later",
37-
"try_again": "Try again",
38-
"remove_account": "Remove account"
32+
"try_again": "Try again"
3933
},
4034
"errors": {
4135
"invalid_email": "Niepoprawny adres e-mail",
@@ -234,8 +228,14 @@
234228
"copy_push_token": "Copy push token",
235229
"current_theme": "Current theme: {{theme}}",
236230
"sign_out": "Sign out!",
237-
"selected": " - selected",
238-
"remove_account": "Remove account"
231+
"selected": " - selected"
232+
},
233+
"profile_screen": {
234+
"profile": "Profile",
235+
"update_your_details": "Update your personal details here.",
236+
"remove_account": "Remove account",
237+
"are_you_sure": "Are you sure?",
238+
"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."
239239
},
240240
"sign_in_screen": {
241241
"do_not_have_an_account": "Don't have an account?",

src/i18n/translations/pl.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
"session_expired": {
1010
"description": "Spróbuj zalogować się ponownie",
1111
"title": "Twoja sesja wygasła"
12-
},
13-
"remove_account": {
14-
"description": "Czy na pewno chcesz usunąć swoje konto?",
15-
"title": "Uwaga!",
16-
"confirm": "Tak, usuń"
1712
}
1813
},
1914
"bottom_tabs": {
@@ -34,8 +29,7 @@
3429
"save": "Zapisz",
3530
"search": "Szukaj",
3631
"try_again_later": "Proszę spróbuj ponownie później",
37-
"try_again": "Spróbuj ponownie",
38-
"remove_account": "Usuń konto"
32+
"try_again": "Spróbuj ponownie"
3933
},
4034
"errors": {
4135
"invalid_email": "Niepoprawny adres e-mail",
@@ -232,8 +226,14 @@
232226
"settings_screen": {
233227
"current_theme": "Current theme: {{theme}}",
234228
"selected": " - wybrano",
235-
"sign_out": "Wyloguj!",
236-
"remove_account": "Usuń konto"
229+
"sign_out": "Wyloguj!"
230+
},
231+
"profile_screen": {
232+
"profile": "Profil",
233+
"update_your_details": "Zaktualizuj swoje dane osobowe tutaj.",
234+
"remove_account": "Usuń konto",
235+
"are_you_sure": "Jesteś pewny/a?",
236+
"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"
237237
},
238238
"sign_in_screen": {
239239
"do_not_have_an_account": "Nie masz konta?",

src/providers/ColorSchemeProvider.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,16 @@ export const ColorSchemeProvider: FC<PropsWithChildren> = ({ children }) => {
5454
[colorSchemeSetting, setItem]
5555
)
5656

57+
const isDarkTheme = useMemo(() => colorScheme === 'dark', [colorScheme])
58+
5759
const value: ColorSchemeContextType = useMemo(
5860
() => ({
5961
colorScheme,
6062
colorSchemeSetting,
63+
isDarkTheme,
6164
setColorSchemeSetting: setNewColorSchemeSetting,
6265
}),
63-
[colorScheme, colorSchemeSetting, setNewColorSchemeSetting]
66+
[colorScheme, colorSchemeSetting, isDarkTheme, setNewColorSchemeSetting]
6467
)
6568

6669
return <ColorSchemeContextProvider value={value}>{children}</ColorSchemeContextProvider>

0 commit comments

Comments
 (0)