Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds shared-ui library to expo app #173

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 4 additions & 51 deletions examples/expo/App.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,15 @@
import 'react-native-gesture-handler';

// import { AMAProvider } from '@react-native-ama/core';
import { NavigationContainer } from '@react-navigation/native';
import {
NativeStackNavigationOptions,
createNativeStackNavigator,
} from '@react-navigation/native-stack';
import { AMAProvider } from '@react-native-ama/core';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';

import { HomeScreen } from './src/screens/Home.screen';
import { RootStackParamList } from './src/types';
import { AppNavigator } from './src/AppNavigation';

export default function App() {
return (
<>
<AMAProvider>
<StatusBar style="auto" />
<AppNavigator />
</>
</AMAProvider>
);
}

const AppNavigator = () => {
// const { reactNavigationScreenOptions: amaAnimationScreenOptions } = useAMAContext();

return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
...BaseNavigatorOptions,
// ...amaAnimationScreenOptions,
}}>
<Stack.Screen
name="Home"
component={HomeScreen}
options={
{
// headerTitle: () => <Header title={'AMA Examples'} />, // Add shared header
}
}
/>
</Stack.Navigator>
</NavigationContainer>
);
};

const Stack = createNativeStackNavigator<RootStackParamList>();

const BaseNavigatorOptions: NativeStackNavigationOptions = {
headerTitleAlign: 'center',
headerBackVisible: false,
};

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
204 changes: 204 additions & 0 deletions examples/expo/src/AppNavigation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
import {
BackButton,
BottomSheetScreen,
ExpandablePressableScreen,
FlatListDynamicScreen,
FlatListScreen,
FlatListStaticScreen,
FormScreen,
Header,
HomeScreen,
PressableScreen,
TextScreen,
TouchableOpacityScreen,
TouchableWithoutFeedbackScreen,
UseAMAContextScreen,
UseAnimationScreen,
UseReanimatedTimingScreen,
UseTimedActionScreen,
} from '@examples/shared-ui';
import { useAMAContext } from '@react-native-ama/core';
import { NavigationContainer } from '@react-navigation/native';
import {
NativeStackNavigationOptions,
createNativeStackNavigator,
} from '@react-navigation/native-stack';
import React from 'react';

export const AppNavigator = () => {
const { reactNavigationScreenOptions: amaAnimationScreenOptions } =
useAMAContext();

return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
...BaseNavigatorOptions,
...amaAnimationScreenOptions,
}}>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{
headerTitle: () => <Header title={'AMA Examples'} />,
}}
/>
<Stack.Screen
name="Pressable"
component={PressableScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => <Header title={'Pressable Demo'} autofocus />,
}}
/>
<Stack.Screen
name="TouchableOpacity"
component={TouchableOpacityScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => (
<Header title={'TouchableOpacity Demo'} autofocus />
),
}}
/>
<Stack.Screen
name="TouchableWithoutFeedback"
component={TouchableWithoutFeedbackScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => (
<Header title={'TouchableWithoutFeedback Demo'} autofocus />
),
}}
/>
<Stack.Screen
name="Text"
component={TextScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => <Header title={'Text Demo'} autofocus />,
}}
/>
<Stack.Screen
name="UseAnimation"
component={UseAnimationScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => (
<Header title={'Reduce Motion Demo'} autofocus />
),
}}
/>
<Stack.Screen
name="UseReanimatedTiming"
component={UseReanimatedTimingScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => (
<Header title={'Reanimated Reduce Motion Demo'} autofocus />
),
}}
/>
<Stack.Screen
name="Form"
component={FormScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => <Header title={'Form Demo'} autofocus />,
}}
/>
<Stack.Screen
name="FlatList"
component={FlatListScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => <Header title={'FlatList Demo'} autofocus />,
}}
/>
<Stack.Screen
name="ExpandablePressable"
component={ExpandablePressableScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => (
<Header title={'ExpandablePressable Demo'} autofocus />
),
}}
/>
<Stack.Screen
name="FlatListDynamic"
component={FlatListDynamicScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => (
<Header title={'Dynamic FlatList Demo'} autofocus />
),
}}
/>
<Stack.Screen
name="FlatListStatic"
component={FlatListStaticScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => (
<Header title={'Static FlatList Demo'} autofocus />
),
}}
/>
<Stack.Screen
name="BottomSheet"
component={BottomSheetScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => <Header title={'BottomSheet Demo'} autofocus />,
}}
/>
<Stack.Screen
name="UseTimedAction"
component={UseTimedActionScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => (
<Header title={'useTimedAction Demo'} autofocus />
),
}}
/>
<Stack.Screen
name="UseAMAContext"
component={UseAMAContextScreen}
options={{
headerLeft: () => <BackButton />,
headerTitle: () => (
<Header title={'useAMAContext Demo'} autofocus />
),
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
};

const Stack = createNativeStackNavigator<StackParamList>();

const BaseNavigatorOptions: NativeStackNavigationOptions = {
headerTitleAlign: 'center',
headerBackVisible: false,
};

type StackParamList = {
Home: undefined;
Pressable: undefined;
TouchableOpacity: undefined;
TouchableWithoutFeedback: undefined;
Text: undefined;
UseAnimation: undefined;
UseReanimatedTiming: undefined;
Form: undefined;
FlatList: undefined;
ExpandablePressable: undefined;
FlatListDynamic: undefined;
FlatListStatic: undefined;
BottomSheet: undefined;
UseTimedAction: undefined;
UseAMAContext: undefined;
};
19 changes: 0 additions & 19 deletions examples/expo/src/screens/Home.screen.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions examples/expo/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
export type RootStackParamList = {
Home: undefined;
};
Loading