-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
2,367 additions
and
3,372 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,37 @@ | ||
import React, { ReactNode } from 'react'; | ||
import { ViewStyle, TextStyle, StyleSheet } from 'react-native'; | ||
import { ShowcaseButton, ShowcaseLabel } from '@gorhom/showcase-template'; | ||
|
||
interface ButtonProps { | ||
label: string; | ||
endContent?: string | ReactNode; | ||
style?: ViewStyle; | ||
labelStyle?: TextStyle; | ||
onPress: () => void; | ||
} | ||
|
||
export const Button = ({ | ||
label, | ||
endContent, | ||
style, | ||
labelStyle, | ||
onPress, | ||
}: ButtonProps) => ( | ||
<ShowcaseButton | ||
containerStyle={style} | ||
contentContainerStyle={styles.container} | ||
onPress={onPress} | ||
> | ||
<ShowcaseLabel style={labelStyle}>{label}</ShowcaseLabel> | ||
{endContent && endContent} | ||
</ShowcaseButton> | ||
); | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
}); |
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,82 @@ | ||
import React from 'react'; | ||
import { | ||
GestureResponderEvent, | ||
StyleSheet, | ||
Text, | ||
TouchableOpacity, | ||
TouchableWithoutFeedback, | ||
View, | ||
} from 'react-native'; | ||
|
||
interface SimpleModalProps { | ||
count: number; | ||
onIncrease: () => void; | ||
onPress: (event: GestureResponderEvent) => void; | ||
} | ||
|
||
export const CounterModal = ({ | ||
count, | ||
onIncrease, | ||
onPress, | ||
}: SimpleModalProps) => { | ||
return ( | ||
<TouchableWithoutFeedback onPress={onPress} style={styles.buttonContainer}> | ||
<View style={styles.backdropContainer}> | ||
<View style={styles.modalContainer}> | ||
<Text>Counter Modal</Text> | ||
<View | ||
style={{ | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
marginTop: 12, | ||
}} | ||
> | ||
<Text>{count}</Text> | ||
<View style={{ flexDirection: 'row' }}> | ||
<TouchableOpacity | ||
style={styles.actionButton} | ||
onPress={onIncrease} | ||
> | ||
<Text>+</Text> | ||
</TouchableOpacity> | ||
<TouchableOpacity | ||
style={styles.actionButton} | ||
onPress={onIncrease} | ||
> | ||
<Text>-</Text> | ||
</TouchableOpacity> | ||
</View> | ||
</View> | ||
</View> | ||
</View> | ||
</TouchableWithoutFeedback> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
backdropContainer: { | ||
...StyleSheet.absoluteFillObject, | ||
backgroundColor: 'rgba(0, 0, 0, 0.5)', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
buttonContainer: { | ||
...StyleSheet.absoluteFillObject, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
modalContainer: { | ||
padding: 24, | ||
backgroundColor: 'white', | ||
}, | ||
actionButton: { | ||
width: 25, | ||
height: 25, | ||
borderRadius: 25, | ||
marginHorizontal: 2, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: 'rgba(0, 0, 0, 0.5)', | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
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,89 @@ | ||
import React, { useCallback, useState } from 'react'; | ||
import { Platform, StyleSheet, View } from 'react-native'; | ||
import { Portal } from '@gorhom/portal'; | ||
import { ShowcaseLabel } from '@gorhom/showcase-template'; | ||
import { createNativeStackNavigator } from '@react-navigation/native-stack'; | ||
import { useNavigation } from '@react-navigation/native'; | ||
import { FullWindowOverlay } from 'react-native-screens'; | ||
import { Button } from '../components/Button'; | ||
import { CounterModal } from '../components/CounterModal'; | ||
|
||
const Stack = createNativeStackNavigator(); | ||
|
||
const DummyScreen = () => { | ||
const [showModal, setShowModal] = useState(false); | ||
const [count, setCount] = useState(0); | ||
const { navigate } = useNavigation(); | ||
|
||
const handleModalTogglePress = useCallback(() => { | ||
setShowModal(state => !state); | ||
}, []); | ||
|
||
const handleNavigatePress = useCallback(() => { | ||
navigate({ | ||
// @ts-ignore | ||
name: 'B', | ||
key: `screen-a-${Math.random()}`, | ||
}); | ||
}, [navigate]); | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<ShowcaseLabel children={count} /> | ||
<Button | ||
label={`${showModal ? 'Hide' : 'Show'} Modal`} | ||
onPress={handleModalTogglePress} | ||
/> | ||
|
||
<Button label="Navigate to Native Modal" onPress={handleNavigatePress} /> | ||
|
||
{showModal && ( | ||
<Portal name="modal"> | ||
<FullWindowOverlay style={StyleSheet.absoluteFill}> | ||
<CounterModal | ||
count={count} | ||
onIncrease={() => setCount(count + 1)} | ||
onPress={handleModalTogglePress} | ||
/> | ||
</FullWindowOverlay> | ||
</Portal> | ||
)} | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
alignContent: 'center', | ||
}, | ||
button: { | ||
paddingHorizontal: 24, | ||
paddingVertical: 12, | ||
borderRadius: 24, | ||
backgroundColor: '#333', | ||
}, | ||
text: { | ||
color: 'white', | ||
}, | ||
}); | ||
|
||
export default () => ( | ||
<Stack.Navigator> | ||
<Stack.Screen | ||
name="A" | ||
component={DummyScreen} | ||
options={{ headerShown: false }} | ||
/> | ||
<Stack.Screen | ||
name="B" | ||
component={DummyScreen} | ||
options={{ | ||
presentation: 'formSheet', | ||
headerShown: Platform.OS === 'ios', | ||
}} | ||
/> | ||
</Stack.Navigator> | ||
); |
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.