-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: upgrade example app to add more screens
- Loading branch information
1 parent
6ae9fb5
commit f1ab54c
Showing
26 changed files
with
1,144 additions
and
50 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,42 @@ | ||
import { Tabs } from 'expo-router'; | ||
import React from 'react'; | ||
|
||
import { TabBarIcon } from '@/components/navigation/TabBarIcon'; | ||
import List from 'phosphor-react-native/src/icons/List'; | ||
import { Colors } from '@/constants/Colors'; | ||
import { useColorScheme } from '@/hooks/useColorScheme'; | ||
|
||
export default function TabLayout() { | ||
const colorScheme = useColorScheme(); | ||
|
||
return ( | ||
<Tabs | ||
screenOptions={{ | ||
tabBarActiveTintColor: Colors[colorScheme ?? 'light'].tint, | ||
headerShown: false, | ||
}} | ||
> | ||
<Tabs.Screen | ||
name="index" | ||
options={{ | ||
title: 'All icons', | ||
tabBarIcon: ({ color, focused }) => ( | ||
<List weight={focused ? 'fill' : 'light'} color={color} /> | ||
), | ||
}} | ||
/> | ||
<Tabs.Screen | ||
name="duotone" | ||
options={{ | ||
title: 'Duotone', | ||
tabBarIcon: ({ color, focused }) => ( | ||
<TabBarIcon | ||
name={focused ? 'code-slash' : 'code-slash-outline'} | ||
color={color} | ||
/> | ||
), | ||
}} | ||
/> | ||
</Tabs> | ||
); | ||
} |
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,10 @@ | ||
/* eslint-disable react-native/no-inline-styles */ | ||
import { Text, View } from 'react-native'; | ||
|
||
export default function DuotoneScreen() { | ||
return ( | ||
<View> | ||
<Text>Explore</Text> | ||
</View> | ||
); | ||
} |
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,165 @@ | ||
/* eslint-disable react-native/no-inline-styles */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
import * as React from 'react'; | ||
|
||
import { | ||
StyleSheet, | ||
View, | ||
Text, | ||
SafeAreaView, | ||
FlatList, | ||
StatusBar, | ||
Image, | ||
TouchableOpacity, | ||
} from 'react-native'; | ||
import * as IconPack from 'phosphor-react-native'; | ||
import PhosphorLogo from '@/assets/images/phosphor-mark-tight-yellow.png'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { IconContext, ...Icons } = IconPack; | ||
|
||
const weights = ['thin', 'light', 'regular', 'bold', 'fill', 'duotone']; | ||
|
||
export default function App() { | ||
const [weightIdx, setWeightIdx] = React.useState(2); | ||
const [iconColor, setIconColor] = React.useState(undefined); | ||
const [mirrorActive, setMirrorActive] = React.useState(false); | ||
|
||
const weight: IconPack.IconWeight = React.useMemo( | ||
() => weights[weightIdx] as any, | ||
[weightIdx] | ||
); | ||
|
||
const handleChangeWeight = React.useCallback(() => { | ||
setWeightIdx((weightIdx + 1) % weights.length); | ||
}, [weightIdx]); | ||
|
||
const handleChangeIconColor = React.useCallback(() => { | ||
setIconColor(`#${Math.floor(Math.random() * 16777215).toString(16)}`); | ||
}, []); | ||
|
||
const handleToggleMirror = React.useCallback(() => { | ||
setMirrorActive(!mirrorActive); | ||
}, [mirrorActive]); | ||
|
||
return ( | ||
<View style={styles.rootView}> | ||
<StatusBar barStyle="light-content" /> | ||
|
||
<SafeAreaView style={styles.headerContainer}> | ||
<View style={styles.header}> | ||
<Image source={PhosphorLogo} style={styles.logoImage} /> | ||
<View | ||
style={{ | ||
flex: 1, | ||
alignItems: 'flex-start', | ||
justifyContent: 'center', | ||
paddingStart: 10, | ||
}} | ||
> | ||
<Text style={styles.headerText}>Phosphor React Native</Text> | ||
<Text | ||
style={{ | ||
color: '#fff', | ||
opacity: 0.8, | ||
textTransform: 'capitalize', | ||
}} | ||
> | ||
{weight} | ||
</Text> | ||
</View> | ||
<TouchableOpacity | ||
style={styles.weightSelect} | ||
onPress={handleChangeIconColor} | ||
> | ||
<IconPack.Palette color="#FFF" weight={weight} /> | ||
</TouchableOpacity> | ||
<TouchableOpacity | ||
style={styles.weightSelect} | ||
onPress={handleChangeWeight} | ||
> | ||
<IconPack.PencilLine color="#FFF" weight={weight} /> | ||
</TouchableOpacity> | ||
<TouchableOpacity | ||
style={styles.weightSelect} | ||
onPress={handleToggleMirror} | ||
> | ||
<IconPack.Swap color="#FFF" weight={weight} /> | ||
</TouchableOpacity> | ||
</View> | ||
</SafeAreaView> | ||
<FlatList | ||
style={styles.scrollView} | ||
contentContainerStyle={styles.main} | ||
data={Object.entries(Icons).filter(([, Icon]) => !!Icon) as any[]} | ||
keyExtractor={(item) => item[0]} | ||
numColumns={3} | ||
renderItem={({ item: [name, Icon] }) => ( | ||
<View style={styles.iconItem}> | ||
<Icon | ||
size={48} | ||
weight={weight} | ||
mirrored={mirrorActive} | ||
color={iconColor} | ||
/> | ||
<Text style={styles.iconName}>{name}</Text> | ||
</View> | ||
)} | ||
/> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
rootView: { | ||
flex: 1, | ||
backgroundColor: '#FFF', | ||
}, | ||
headerContainer: { | ||
backgroundColor: '#e76f51', | ||
}, | ||
header: { | ||
backgroundColor: '#e76f51', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
flexDirection: 'row', | ||
paddingBottom: 16, | ||
paddingHorizontal: 16, | ||
}, | ||
logoImage: { | ||
width: 40, | ||
height: 40, | ||
borderRadius: 20, | ||
}, | ||
headerText: { | ||
color: '#FFF', | ||
fontSize: 18, | ||
fontWeight: 'bold', | ||
flex: 1, | ||
textAlign: 'center', | ||
}, | ||
weightSelect: { | ||
width: 35, | ||
}, | ||
scrollView: { | ||
flex: 1, | ||
}, | ||
main: { | ||
backgroundColor: 'white', | ||
paddingHorizontal: 8, | ||
paddingBottom: 16, | ||
}, | ||
iconItem: { | ||
width: '33%', | ||
height: 100, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
padding: 8, | ||
}, | ||
iconName: { | ||
textAlign: 'center', | ||
opacity: 0.8, | ||
marginTop: 4, | ||
}, | ||
}); |
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,42 @@ | ||
import { ScrollViewStyleReset } from 'expo-router/html'; | ||
import { type PropsWithChildren } from 'react'; | ||
|
||
/** | ||
* This file is web-only and used to configure the root HTML for every web page during static rendering. | ||
* The contents of this function only run in Node.js environments and do not have access to the DOM or browser APIs. | ||
*/ | ||
export default function Root({ children }: PropsWithChildren) { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta httpEquiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, shrink-to-fit=no" | ||
/> | ||
|
||
{/* | ||
Disable body scrolling on web. This makes ScrollView components work closer to how they do on native. | ||
However, body scrolling is often nice to have for mobile web. If you want to enable it, remove this line. | ||
*/} | ||
<ScrollViewStyleReset /> | ||
|
||
{/* Using raw CSS styles as an escape-hatch to ensure the background color never flickers in dark-mode. */} | ||
<style dangerouslySetInnerHTML={{ __html: responsiveBackground }} /> | ||
{/* Add any additional <head> elements that you want globally available on web... */} | ||
</head> | ||
<body>{children}</body> | ||
</html> | ||
); | ||
} | ||
|
||
const responsiveBackground = ` | ||
body { | ||
background-color: #fff; | ||
} | ||
@media (prefers-color-scheme: dark) { | ||
body { | ||
background-color: #000; | ||
} | ||
}`; |
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,32 @@ | ||
import { Link, Stack } from 'expo-router'; | ||
import { StyleSheet } from 'react-native'; | ||
|
||
import { ThemedText } from '@/components/ThemedText'; | ||
import { ThemedView } from '@/components/ThemedView'; | ||
|
||
export default function NotFoundScreen() { | ||
return ( | ||
<> | ||
<Stack.Screen options={{ title: 'Oops!' }} /> | ||
<ThemedView style={styles.container}> | ||
<ThemedText type="title">This screen doesn't exist.</ThemedText> | ||
<Link href="/" style={styles.link}> | ||
<ThemedText type="link">Go to home screen!</ThemedText> | ||
</Link> | ||
</ThemedView> | ||
</> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
padding: 20, | ||
}, | ||
link: { | ||
marginTop: 15, | ||
paddingVertical: 15, | ||
}, | ||
}); |
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,31 @@ | ||
import { | ||
DarkTheme, | ||
DefaultTheme, | ||
ThemeProvider, | ||
} from '@react-navigation/native'; | ||
import { Stack } from 'expo-router'; | ||
import * as SplashScreen from 'expo-splash-screen'; | ||
import { useEffect } from 'react'; | ||
import 'react-native-reanimated'; | ||
|
||
import { useColorScheme } from '@/hooks/useColorScheme'; | ||
|
||
// Prevent the splash screen from auto-hiding before asset loading is complete. | ||
SplashScreen.preventAutoHideAsync(); | ||
|
||
export default function RootLayout() { | ||
const colorScheme = useColorScheme(); | ||
|
||
useEffect(() => { | ||
SplashScreen.hideAsync(); | ||
}, []); | ||
|
||
return ( | ||
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}> | ||
<Stack> | ||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} /> | ||
<Stack.Screen name="+not-found" /> | ||
</Stack> | ||
</ThemeProvider> | ||
); | ||
} |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Oops, something went wrong.