Skip to content

Commit

Permalink
bottomDrawer 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonzalo Lopez committed Oct 17, 2023
1 parent f10782f commit 628e479
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 48 deletions.
29 changes: 25 additions & 4 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
import React from 'react';
import {View, Text} from 'react-native';
import {Text} from 'react-native';
import {GestureHandlerRootView} from 'react-native-gesture-handler'

Check failure on line 3 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Insert `;`

Check warning on line 3 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Missing semicolon
import BottomDrawer from './src/components/BottomDrawer';
import RadioButton from './src/components/RadioButton'

Check failure on line 5 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Insert `;`

Check warning on line 5 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Missing semicolon

const dataItem = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]

Check failure on line 7 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Replace `↹const·dataItem·=·[1,2,3,4,5,6,7,8,9,10,11,12,13,14]` with `const·dataItem·=·[1,·2,·3,·4,·5,·6,·7,·8,·9,·10,·11,·12,·13,·14];`

Check warning on line 7 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Missing semicolon

const renderItem = ({item,index}) => {

Check failure on line 9 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Replace `↹const·renderItem·=·({item,` with `const·renderItem·=·({item,·`
return (

Check failure on line 10 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Delete `↹`
<RadioButton checkSize='md' checkPosition='left' key={index}>

Check failure on line 11 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Replace `↹↹↹<RadioButton·checkSize='md'·checkPosition='left'` with `↹↹<RadioButton·checkSize="md"·checkPosition="left"`

Check warning on line 11 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Unexpected usage of singlequote

Check warning on line 11 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Unexpected usage of singlequote
<Text>{item}</Text>

Check failure on line 12 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Delete `↹`
</RadioButton>

Check failure on line 13 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Delete `↹`
)

Check failure on line 14 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Replace `↹)` with `);`

Check warning on line 14 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Missing semicolon
}

Check failure on line 15 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Replace `↹}` with `};`

Check warning on line 15 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Missing semicolon

const App = () => (
<View>
<Text>UI native</Text>
</View>
<GestureHandlerRootView style={{ flex: 1 }}>

Check warning on line 18 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Inline style: { flex: 1 }
<BottomDrawer

Check warning on line 19 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Trailing spaces not allowed
typeList='flatList'

Check warning on line 20 in App.tsx

View workflow job for this annotation

GitHub Actions / Build

Unexpected usage of singlequote
snapPoints={['25%', '50%','75%']}
index={0}
data={dataItem}
renderItem={renderItem}
children={null}
containerStyle={{backgroundColor:'rgba(0,0,0,0.5)'}}
/>
</GestureHandlerRootView>
);

export default App;
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import App from './App';
import {name as appName} from './app.json';
import Storybook from './storybook';

const Component = __DEV__ ? Storybook : App;
const Component = App;
AppRegistry.registerComponent(appName, () => Component);
31 changes: 22 additions & 9 deletions src/components/BottomDrawer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import React, { ReactElement } from 'react'
import BottomSheet, {BottomSheetProps} from '@gorhom/bottom-sheet'
import { ViewStyle, StyleSheet } from 'react-native';
import {BottomDrawerFlatList} from './listComponents'
import BottomSheet, {BottomSheetFlatList, BottomSheetProps, BottomSheetScrollView, BottomSheetView} from '@gorhom/bottom-sheet'
import { FlatListProps } from 'react-native'


type typeList = 'none' | 'flatList' | 'scrollView'


export interface BottomDrawerProps extends BottomSheetProps {
children: ReactElement | null
typeList?: typeList
data: any[],
renderItem: any
}

const BottomDrawer = ({
Expand All @@ -14,25 +19,33 @@ const BottomDrawer = ({
index = 0,
style,
onChange,
typeList = 'none',
containerStyle,
data,
renderItem,
...props} : BottomDrawerProps) => {

if(!children) return null;
if(!snapPoints || !snapPoints ) return null;

const wrapper = {
flatList: () => <BottomSheetFlatList data={data} renderItem={renderItem}/>,
scrollView: () => <BottomSheetScrollView>{children}</BottomSheetScrollView>,
none: () => <BottomSheetView>{children}</BottomSheetView>
}

const BottomContent = wrapper[typeList]

return (
<BottomSheet
snapPoints={snapPoints}
index={index}
onChange={onChange}
style={style}
containerStyle={containerStyle}
{...props}>
{children}
{BottomContent}
</BottomSheet>
)
}

export {
BottomDrawer,
BottomDrawerFlatList
};
export default BottomDrawer

This file was deleted.

5 changes: 0 additions & 5 deletions src/components/BottomDrawer/listComponents/index.tsx

This file was deleted.

5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Input from './components/Input';
import LoadingFullScreen from './components/LoadingFullScreen';
import {palette} from './theme/palette';
import RadioButton from './components/RadioButton';
import {BottomDrawer,BottomDrawerFlatList} from './components/BottomDrawer';
import BottomDrawer from './components/BottomDrawer';

export {
Text,
Expand All @@ -23,6 +23,5 @@ export {
palette,
LoadingFullScreen,
RadioButton,
BottomDrawer,
BottomDrawerFlatList
BottomDrawer
};

0 comments on commit 628e479

Please sign in to comment.