Skip to content

Commit 5c30e47

Browse files
committed
FlashList working properly
1 parent cc0eb78 commit 5c30e47

5 files changed

Lines changed: 16 additions & 224 deletions

File tree

src/design-system/bottomSheets/BottomSheet.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {
99
import { useCallback } from 'react'
1010
import { Dimensions } from 'react-native'
1111

12-
import { BottomSheetScrollView } from './BootomSheetScrollables'
1312
import { BottomSheetHeader } from './BottomSheetHeader'
13+
import { BottomSheetScrollView } from './BottomSheetScrollables'
1414
import { BottomSheetProps } from './types'
1515

1616
const screenHeight = Dimensions.get('screen').height
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// export { BottomSheetFlashList } from '@gorhom/bottom-sheet'
2-
export { BottomSheetFlashList } from './BootomSheetScrollables'
2+
export { BottomSheetFlashList } from './BottomSheetScrollables'

src/design-system/bottomSheets/BootomSheetScrollables.tsx renamed to src/design-system/bottomSheets/BottomSheetScrollables.tsx

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './useBottomSheets'
2+
export * from './BottomSheet'
Lines changed: 13 additions & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
import { useTheme } from '@baca/hooks'
1+
import {
2+
Box,
3+
BottomSheet,
4+
Icon,
5+
Row,
6+
SelectItemProps,
7+
SelectKey,
8+
SelectProps,
9+
Text,
10+
Touchable,
11+
} from '@baca/design-system'
12+
import { useTheme, useCallback, useMemo, useRef } from '@baca/hooks'
213
import { BottomSheetModal } from '@gorhom/bottom-sheet'
3-
import { useCallback, useMemo, useRef } from 'react'
414
import { Keyboard, StyleSheet, Dimensions, Platform, useWindowDimensions } from 'react-native'
515
import { TouchableOpacity } from 'react-native-gesture-handler'
616

7-
import { Box } from './Box'
8-
import { Icon } from './Icon'
9-
import { Row } from './Row'
10-
import { Text } from './Text'
11-
import { Touchable } from './Touchables/Touchable'
12-
import { SelectKey, SelectItemProps, SelectProps } from './types'
13-
import { BottomSheet } from '../bottomSheets/BottomSheet'
14-
import { BottomSheetFlashList } from '../bottomSheets/BottomSheetFlashList'
17+
import { BottomSheetFlashList } from '../bottomSheets/BottomSheetScrollables'
1518

1619
const BOTTOM_SHEET_CONTENT_HEIGHT = Dimensions.get('screen').height / 1.5
1720

@@ -212,215 +215,3 @@ const styles = StyleSheet.create({
212215
paddingVertical: 12,
213216
},
214217
})
215-
216-
// import { useTheme } from '@baca/hooks'
217-
// import { BottomSheetModal } from '@gorhom/bottom-sheet'
218-
// import { useCallback, useMemo, useRef } from 'react'
219-
// import { Keyboard, StyleSheet, Dimensions, Platform } from 'react-native'
220-
// import { TouchableOpacity } from 'react-native-gesture-handler'
221-
222-
// import { Box } from './Box'
223-
// import { Icon } from './Icon'
224-
// import { Row } from './Row'
225-
// import { Text } from './Text'
226-
// import { Touchable } from './Touchables/Touchable'
227-
// import { SelectKey, SelectItemProps, SelectProps } from './types'
228-
// import { BottomSheet } from '../bottomSheets/BottomSheet'
229-
// import { BottomSheetFlashList } from '../bottomSheets/BottomSheetFlashList'
230-
231-
// const BOTTOM_SHEET_CONTENT_HEIGHT = Dimensions.get('screen').height / 1.5
232-
// const BOTTOM_SHEET_CONTENT_WIDTH = Dimensions.get('screen').width / 3
233-
234-
// const SelectItem = <T extends SelectKey>({
235-
// item,
236-
// setValue,
237-
// maxSelectedItems,
238-
// closeDropdown,
239-
// value,
240-
// disabled,
241-
// }: {
242-
// item: SelectItemProps<T>
243-
// setValue: (newValue: T[]) => void
244-
// maxSelectedItems: number
245-
// closeDropdown: () => void
246-
// value: T[]
247-
// disabled: boolean
248-
// }) => {
249-
// const selected = value?.includes(item.value)
250-
// const { colors } = useTheme()
251-
252-
// const onItemSelect = useCallback(() => {
253-
// if (maxSelectedItems === 1) {
254-
// setValue([item.value])
255-
// closeDropdown()
256-
// return
257-
// }
258-
// const newValue = [...value].filter((el) => el)
259-
// if (value?.includes(item.value)) {
260-
// const index = newValue.indexOf(item.value)
261-
// newValue.splice(index, 1)
262-
// setValue(newValue)
263-
// return
264-
// }
265-
// if (value?.length < maxSelectedItems) {
266-
// newValue.push(item.value)
267-
// setValue(newValue)
268-
// }
269-
// }, [closeDropdown, item.value, maxSelectedItems, setValue, value])
270-
271-
// const color = useMemo(
272-
// () => (disabled && !selected ? colors.bg.brand.primary : colors.bg.active),
273-
// [disabled, selected, colors]
274-
// )
275-
276-
// return (
277-
// <TouchableOpacity style={styles.itemWrapper} onPress={onItemSelect}>
278-
// {maxSelectedItems === 1 ? (
279-
// <Row my={2} flex={1} alignItems="center">
280-
// <Text>{item.labelInDropdown ?? item.label}</Text>
281-
// </Row>
282-
// ) : null}
283-
// {maxSelectedItems > 1 ? (
284-
// <Row mb={4}>
285-
// <Box
286-
// borderRadius={5}
287-
// borderColor={disabled && !selected ? 'border.disabled' : 'border.brand'}
288-
// borderWidth={1}
289-
// width={5}
290-
// height={5}
291-
// mr={4}
292-
// justifyContent="center"
293-
// alignItems="center"
294-
// >
295-
// {selected ? <Icon color="icon.fg.brand" name="check-fill" size={18} /> : null}
296-
// </Box>
297-
// <Row flex={1} alignItems="center">
298-
// <Text style={{ color }}>{item.labelInDropdown ?? item.label}</Text>
299-
// </Row>
300-
// </Row>
301-
// ) : null}
302-
// </TouchableOpacity>
303-
// )
304-
// }
305-
306-
// export const Select = <T extends SelectKey>({
307-
// placeholder,
308-
// disabled: dropdownDisabled = false,
309-
// items,
310-
// value,
311-
// setValue,
312-
// maxSelectedItems = 1,
313-
// onOpen,
314-
// isError = false,
315-
// }: SelectProps<T>) => {
316-
// const ref = useRef<BottomSheetModal>(null)
317-
// const { colors } = useTheme()
318-
319-
// const showDropdown = useCallback(() => {
320-
// onOpen && onOpen()
321-
// Keyboard.dismiss()
322-
// ref?.current?.present?.()
323-
// }, [onOpen])
324-
325-
// const closeDropdown = useCallback(() => {
326-
// ref.current?.snapToPosition(-1)
327-
// }, [])
328-
329-
// const disabled = useMemo(
330-
// () => value?.length === maxSelectedItems,
331-
// [maxSelectedItems, value?.length]
332-
// )
333-
334-
// const label = useMemo(() => {
335-
// let retVal = ''
336-
// const selectedItems = items?.filter((item) => value.includes(item.value)) ?? []
337-
// if (selectedItems?.length === 0) {
338-
// return placeholder ?? ''
339-
// }
340-
// for (const item of selectedItems) {
341-
// retVal += `${item.label}, `
342-
// }
343-
// retVal = retVal.slice(0, -2)
344-
// return retVal
345-
// }, [items, placeholder, value])
346-
347-
// const renderItem = useCallback(
348-
// ({ item }: { item: SelectItemProps<T> }) => {
349-
// return (
350-
// <SelectItem
351-
// key={item.label}
352-
// item={item}
353-
// setValue={setValue}
354-
// maxSelectedItems={maxSelectedItems}
355-
// closeDropdown={closeDropdown}
356-
// value={value}
357-
// disabled={disabled}
358-
// />
359-
// )
360-
// },
361-
// [closeDropdown, disabled, maxSelectedItems, setValue, value]
362-
// )
363-
364-
// const keyExtractor = useCallback((item: SelectItemProps<T>) => item.value.toString(), [])
365-
366-
// const inputColor = useMemo(() => {
367-
// return isError ? 'text.error.primary' : dropdownDisabled ? 'utility.gray.500' : 'text.primary'
368-
// }, [dropdownDisabled, isError])
369-
370-
// return (
371-
// <>
372-
// <Touchable disabled={dropdownDisabled} onPress={showDropdown} justifyContent="center">
373-
// <Text
374-
// numberOfLines={1}
375-
// style={[
376-
// styles.textInput,
377-
// isError
378-
// ? { borderColor: colors.text.error.primary }
379-
// : { borderColor: colors.border.primary },
380-
// ]}
381-
// color={inputColor}
382-
// >
383-
// {label}
384-
// </Text>
385-
// <Icon color={inputColor} size={22} name="arrow-down-s-line" style={styles.icon} />
386-
// </Touchable>
387-
// <BottomSheet title={label} bottomSheetRef={ref}>
388-
// <Box
389-
// pb={6}
390-
// px={4}
391-
// style={{
392-
// height: BOTTOM_SHEET_CONTENT_HEIGHT,
393-
// maxWidth: Platform.OS === 'web' ? BOTTOM_SHEET_CONTENT_WIDTH : 'auto',
394-
// }}
395-
// >
396-
// <BottomSheetFlashList
397-
// data={items}
398-
// keyExtractor={keyExtractor}
399-
// renderItem={renderItem}
400-
// estimatedItemSize={51}
401-
// />
402-
// </Box>
403-
// </BottomSheet>
404-
// </>
405-
// )
406-
// }
407-
408-
// const styles = StyleSheet.create({
409-
// icon: {
410-
// position: 'absolute',
411-
// right: 8,
412-
// },
413-
// itemWrapper: {
414-
// paddingVertical: 8,
415-
// },
416-
// textInput: {
417-
// alignItems: 'center',
418-
// borderRadius: 8,
419-
// borderWidth: 1,
420-
// flex: 1,
421-
// fontSize: 16,
422-
// paddingHorizontal: 10,
423-
// paddingRight: 28,
424-
// paddingVertical: 12,
425-
// },
426-
// })

0 commit comments

Comments
 (0)