-
Notifications
You must be signed in to change notification settings - Fork 41
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 #793 from grahammendick/action-bar
- Loading branch information
Showing
39 changed files
with
1,105 additions
and
128 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React, { useState } from 'react'; | ||
import { requireNativeComponent, StyleSheet, Platform } from 'react-native'; | ||
import BackButton from './BackButton'; | ||
|
||
const Drawer = ({view, open, fromRight = false, onChangeOpen, onOpen, onClose, children}) => { | ||
const [show, setShow] = useState(false); | ||
const [mostRecentEventCount, setMostRecentEventCount] = useState(0); | ||
if (open != null && show !== open) setShow(open); | ||
const onChangeShow = ({nativeEvent}) => { | ||
const {eventCount: mostRecentEventCount, open: newOpen} = nativeEvent; | ||
if (show !== newOpen) { | ||
if (open == null) | ||
setShow(newOpen); | ||
if (!!onChangeOpen) | ||
onChangeOpen(newOpen); | ||
} | ||
if (newOpen) onOpen?.(); | ||
else onClose?.(); | ||
setMostRecentEventCount(mostRecentEventCount); | ||
} | ||
if (Platform.OS === 'ios') return children; | ||
return ( | ||
<> | ||
<BackButton onPress={() => { | ||
if (show) { | ||
if (open == null) | ||
setShow(false); | ||
if (!!onChangeOpen) | ||
onChangeOpen(false); | ||
return true; | ||
} | ||
return false; | ||
}} /> | ||
<NVDrawerLayout | ||
open={show} | ||
fromRight={fromRight} | ||
mostRecentEventCount={mostRecentEventCount} | ||
onChangeOpen={onChangeShow} | ||
style={styles.drawer}> | ||
{children} | ||
<NVDrawer fromRight={fromRight} style={[styles.view]}> | ||
{view} | ||
</NVDrawer> | ||
</NVDrawerLayout> | ||
</> | ||
); | ||
}; | ||
|
||
const NVDrawerLayout = global.nativeFabricUIManager ? require('./DrawerLayoutNativeComponent').default : requireNativeComponent('NVDrawerLayout'); | ||
const NVDrawer = global.nativeFabricUIManager ? require('./DrawerNativeComponent').default : requireNativeComponent('NVDrawer'); | ||
|
||
const styles = StyleSheet.create({ | ||
drawer: { | ||
flex: 1, | ||
}, | ||
view: { | ||
position: 'absolute', | ||
top: 0, | ||
bottom: 0, | ||
left: 0, | ||
right: 64, | ||
elevation: 5, | ||
backgroundColor: 'transparent', | ||
} | ||
}); | ||
|
||
export default Drawer; |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @flow strict-local | ||
|
||
import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; | ||
import type {HostComponent} from 'react-native'; | ||
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; | ||
|
||
type NativeProps = $ReadOnly<{| | ||
...ViewProps, | ||
open: boolean, | ||
fromRight: boolean, | ||
mostRecentEventCount: Int32, | ||
onChangeOpen: DirectEventHandler<$ReadOnly<{| | ||
open: boolean, | ||
eventCount: Int32, | ||
|}>>, | ||
|}>; | ||
|
||
export default (codegenNativeComponent<NativeProps>( | ||
'NVDrawerLayout', | ||
): HostComponent<NativeProps>); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// @flow strict-local | ||
|
||
import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; | ||
import type {HostComponent} from 'react-native'; | ||
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; | ||
|
||
type NativeProps = $ReadOnly<{| | ||
...ViewProps, | ||
fromRight: boolean, | ||
|}>; | ||
|
||
export default (codegenNativeComponent<NativeProps>( | ||
'NVDrawer', | ||
): HostComponent<NativeProps>); |
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
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.