-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from intergalacticspacehighway/v1
release 0.1.0 🚀
- Loading branch information
Showing
12 changed files
with
10,584 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,122 @@ | ||
# Native android bottomsheet (WIP) | ||
# React Native Android Bottomsheet (alpha) | ||
|
||
## Why? | ||
|
||
This library uses native Bottomsheet. Biggest wins are on accessibility. Styling can also be customised. | ||
|
||
## Installation | ||
|
||
``` | ||
yarn add react-native-android-bottomsheet | ||
``` | ||
|
||
## API | ||
|
||
### Simple usage | ||
|
||
```jsx | ||
import { BottomSheet } from 'react-native-android-bottomsheet'; | ||
|
||
<BottomSheet | ||
peekHeight={400} | ||
visible={visible} | ||
onDismiss={() => { | ||
setVisible(false); | ||
}} | ||
> | ||
<View | ||
style={{ | ||
flex: 1, | ||
backgroundColor: 'white', | ||
}} | ||
> | ||
<Text>Hello from bottomsheet</Text> | ||
</View> | ||
</BottomSheet>; | ||
``` | ||
|
||
- BottomSheet has no background by default. So, setting `backgroundColor` on view is important. | ||
|
||
### BottomSheet with ScrollView | ||
|
||
```jsx | ||
import { ScrollView } from 'react-native'; | ||
import { BottomSheet } from 'react-native-android-bottomsheet'; | ||
|
||
<BottomSheet | ||
visible={visible} | ||
onDismiss={() => { | ||
setVisible(false); | ||
}} | ||
> | ||
<ScrollView style={{ backgroundColor: 'white' }} nestedScrollEnabled> | ||
<Boxes /> | ||
</ScrollView> | ||
</BottomSheet>; | ||
``` | ||
|
||
- For drag-to-close/expand gesture to work, make sure to add `nestedScrollEnabled` to the ScrollView | ||
|
||
### BottomSheet with ScrollView and pull to refresh | ||
|
||
```jsx | ||
import { ScrollView, RefreshControl } from 'react-native'; | ||
import { BottomSheet } from 'react-native-android-bottomsheet'; | ||
|
||
<BottomSheet | ||
visible={visible} | ||
onDismiss={() => { | ||
setVisible(false); | ||
}} | ||
> | ||
<ScrollView | ||
style={{ backgroundColor: 'white' }} | ||
refreshControl={ | ||
<RefreshControl | ||
onRefresh={() => { | ||
setRefreshing(true); | ||
setTimeout(() => { | ||
setRefreshing(false); | ||
}, 2000); | ||
}} | ||
refreshing={refreshing} | ||
/> | ||
} | ||
> | ||
<Boxes /> | ||
</ScrollView> | ||
</BottomSheet>; | ||
``` | ||
|
||
## Props | ||
|
||
```ts | ||
type AndroidBottomsheetProps = { | ||
// To show/hide bottomsheet | ||
'visible': boolean; | ||
|
||
// gets called when bottomsheet is dismissed. Use this to reset visible state | ||
'onDismiss'?: () => void; | ||
|
||
// Collapsed bottomsheet height | ||
'peekHeight'?: number; | ||
|
||
// Expanded bottomsheet height | ||
'maxHeight'?: number; | ||
|
||
// Gets announced when bottomsheet is opened with TalkBack | ||
'aria-label'?: string; | ||
|
||
// To set backdrop dim ammount. Accepts value 0 to 1. 0 would make the backdrop transparent. | ||
'backdropDimAmount'?: number; | ||
|
||
// Determines whether bottomsheet can be cancelled by swiping or back button | ||
'cancelable'?: boolean; | ||
}; | ||
``` | ||
|
||
## To run examples | ||
|
||
## To run example | ||
- Clone the repo | ||
- Go to example/ | ||
- yarn && yarn android | ||
- yarn && yarn android |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.