-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: sarthakpranesh <[email protected]>
- Loading branch information
sarthakpranesh
committed
Feb 24, 2021
1 parent
22f0370
commit dfc59df
Showing
12 changed files
with
125 additions
and
85 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
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,72 @@ | ||
import React, { useState } from 'react' | ||
import { Dimensions } from 'react-native' | ||
import LinearGradient from 'react-native-linear-gradient' | ||
import { NavigationContainer } from '@react-navigation/native' | ||
import { createDrawerNavigator } from '@react-navigation/drawer' | ||
import Animated from 'react-native-reanimated' | ||
|
||
import { DrawerContent, Screens } from './Drawer' | ||
|
||
import Layout from '../../Layout' | ||
const Drawer = createDrawerNavigator() | ||
|
||
export type RootNavigatorProps = { | ||
country: string, | ||
} | ||
|
||
const RootNavigator = (props: RootNavigatorProps) => { | ||
const [isLargeDevice, setIsLargeDevice] = useState<boolean>(Layout.isLargeDevice) | ||
const [progress, setProgress] = useState<Animated.Node<number>>( | ||
new Animated.Value(0) | ||
) | ||
const scale = Animated.interpolate(progress, { | ||
inputRange: [0, 1], | ||
outputRange: [1, 0.8] | ||
}) | ||
const borderRadius = Animated.interpolate(progress, { | ||
inputRange: [0, 1], | ||
outputRange: [0, 16] | ||
}) | ||
|
||
const animatedStyle = { borderRadius, transform: [{ scale }] } | ||
|
||
Dimensions.addEventListener('change', ({ window }) => { | ||
if (isLargeDevice !== (window.width > Layout.largeScreenBreak)) { | ||
setIsLargeDevice(window.width > Layout.largeScreenBreak) | ||
} | ||
}) | ||
|
||
return ( | ||
<NavigationContainer> | ||
<LinearGradient | ||
colors={['#DEF7FF', '#B1ECFF']} | ||
style={{ flex: 1, backgroundColor: '#B1ECFF' }}> | ||
<Drawer.Navigator | ||
edgeWidth={100} | ||
initialRouteName="Screens" | ||
drawerType={isLargeDevice ? 'permanent' : 'slide'} | ||
overlayColor="transparent" | ||
drawerStyle={{ | ||
width: isLargeDevice ? '20%' : '50%', | ||
backgroundColor: 'transparent' | ||
}} | ||
sceneContainerStyle={{ backgroundColor: 'transparent' }} | ||
drawerContent={(p) => { | ||
setProgress(p.progress) | ||
return <DrawerContent {...p} country={props.country} /> | ||
}}> | ||
<Drawer.Screen name="Screens"> | ||
{(p) => <Screens | ||
{...p} | ||
style={animatedStyle} | ||
country={props.country} | ||
isLargeDevice={isLargeDevice} | ||
/>} | ||
</Drawer.Screen> | ||
</Drawer.Navigator> | ||
</LinearGradient> | ||
</NavigationContainer> | ||
) | ||
} | ||
|
||
export default RootNavigator |
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