From 68016de3850d46dd375b83ee5bc434546183a45f Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Tue, 28 Jan 2020 21:19:19 +0100 Subject: [PATCH] chore: add example for transparent card --- example/src/Screens/AuthFlow.tsx | 21 ++- example/src/Screens/StackTransparent.tsx | 160 +++++++++++++++++++++++ example/src/index.tsx | 5 + 3 files changed, 182 insertions(+), 4 deletions(-) create mode 100644 example/src/Screens/StackTransparent.tsx diff --git a/example/src/Screens/AuthFlow.tsx b/example/src/Screens/AuthFlow.tsx index a27625b1..b1272b61 100644 --- a/example/src/Screens/AuthFlow.tsx +++ b/example/src/Screens/AuthFlow.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { View, TextInput, ActivityIndicator, StyleSheet } from 'react-native'; import { Title, Button } from 'react-native-paper'; -import { ParamListBase } from '@react-navigation/native'; +import { useTheme, ParamListBase } from '@react-navigation/native'; import { createStackNavigator, HeaderBackButton, @@ -40,11 +40,25 @@ const SplashScreen = () => { const SignInScreen = () => { const { signIn } = React.useContext(AuthContext); + const { colors } = useTheme(); return ( - - + + @@ -178,7 +192,6 @@ const styles = StyleSheet.create({ input: { margin: 8, padding: 10, - backgroundColor: 'white', borderRadius: 3, borderWidth: StyleSheet.hairlineWidth, borderColor: 'rgba(0, 0, 0, 0.08)', diff --git a/example/src/Screens/StackTransparent.tsx b/example/src/Screens/StackTransparent.tsx new file mode 100644 index 00000000..dc15045e --- /dev/null +++ b/example/src/Screens/StackTransparent.tsx @@ -0,0 +1,160 @@ +import * as React from 'react'; +import { View, StyleSheet, ScrollView } from 'react-native'; +import { Button, Paragraph } from 'react-native-paper'; +import { RouteProp, ParamListBase, useTheme } from '@react-navigation/native'; +import { + createStackNavigator, + StackNavigationProp, +} from '@react-navigation/stack'; +import Article from '../Shared/Article'; + +type SimpleStackParams = { + Article: { author: string }; + Dialog: undefined; +}; + +type SimpleStackNavigation = StackNavigationProp; + +const ArticleScreen = ({ + navigation, + route, +}: { + navigation: SimpleStackNavigation; + route: RouteProp; +}) => { + return ( + + + + + +
+ + ); +}; + +const DialogScreen = ({ + navigation, +}: { + navigation: SimpleStackNavigation; +}) => { + const { colors } = useTheme(); + + return ( + + + + Mise en place is a French term that literally means “put in place.” It + also refers to a way cooks in professional kitchens and restaurants + set up their work stations—first by gathering all ingredients for a + recipes, partially preparing them (like measuring out and chopping), + and setting them all near each other. Setting up mise en place before + cooking is another top tip for home cooks, as it seriously helps with + organization. It’ll pretty much guarantee you never forget to add an + ingredient and save you time from running back and forth from the + pantry ten times. + + + + + ); +}; + +const SimpleStack = createStackNavigator(); + +type Props = Partial> & { + navigation: StackNavigationProp; +}; + +export default function SimpleStackScreen({ navigation, ...rest }: Props) { + navigation.setOptions({ + headerShown: false, + }); + + return ( + + + ({ + cardStyle: { + opacity: progress.interpolate({ + inputRange: [0, 0.5, 0.9, 1], + outputRange: [0, 0.25, 0.7, 1], + }), + transform: [ + { + scale: progress.interpolate({ + inputRange: [0, 1], + outputRange: [0.9, 1], + extrapolate: 'clamp', + }), + }, + ], + }, + overlayStyle: { + opacity: progress.interpolate({ + inputRange: [0, 1], + outputRange: [0, 0.5], + extrapolate: 'clamp', + }), + }, + }), + }} + /> + + ); +} + +const styles = StyleSheet.create({ + buttons: { + flexDirection: 'row', + padding: 8, + }, + button: { + margin: 8, + }, + container: { + flex: 1, + alignItems: 'center', + justifyContent: 'center', + }, + dialog: { + padding: 16, + width: '90%', + borderRadius: 3, + elevation: 6, + shadowColor: 'black', + shadowOpacity: 0.15, + shadowOffset: { width: 0, height: 2 }, + shadowRadius: 10, + }, + close: { + alignSelf: 'flex-end', + }, +}); diff --git a/example/src/index.tsx b/example/src/index.tsx index 03e3ccf1..e94be64c 100644 --- a/example/src/index.tsx +++ b/example/src/index.tsx @@ -41,6 +41,7 @@ import LinkingPrefixes from './LinkingPrefixes'; import SimpleStack from './Screens/SimpleStack'; import NativeStack from './Screens/NativeStack'; import ModalPresentationStack from './Screens/ModalPresentationStack'; +import StackTransparent from './Screens/StackTransparent'; import StackHeaderCustomization from './Screens/StackHeaderCustomization'; import BottomTabs from './Screens/BottomTabs'; import MaterialTopTabsScreen from './Screens/MaterialTopTabs'; @@ -71,6 +72,10 @@ const SCREENS = { title: 'Modal Presentation Stack', component: ModalPresentationStack, }, + StackTransparent: { + title: 'Transparent Stack', + component: StackTransparent, + }, StackHeaderCustomization: { title: 'Header Customization in Stack', component: StackHeaderCustomization,