-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change themes dynamically on the example project
- Loading branch information
Showing
9 changed files
with
275 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { useContext } from 'react'; | ||
import { createStackNavigator } from '@react-navigation/stack'; | ||
import { AppBar, ThemeProvider as React95Provider } from 'react95-native'; | ||
|
||
import { LocalThemeContext } from './util/LocalThemeContext'; | ||
import ExamplesScreen from './ExamplesScreen'; | ||
import examples from './examples'; | ||
|
||
const flattenedExamples = examples.map(section => section.items).flat(); | ||
|
||
type RootStackParamList = { | ||
Home: undefined; | ||
ButtonExample: undefined; | ||
TextInputExample: undefined; | ||
}; | ||
|
||
const Stack = createStackNavigator<RootStackParamList>(); | ||
|
||
const MainNavigation = () => { | ||
const { theme } = useContext(LocalThemeContext); | ||
|
||
return ( | ||
<React95Provider theme={theme}> | ||
<Stack.Navigator | ||
headerMode='screen' | ||
screenOptions={{ | ||
header: ({ navigation, scene, previous }) => ( | ||
<AppBar> | ||
{previous && ( | ||
<AppBar.BackAction onPress={() => navigation.goBack()} /> | ||
)} | ||
<AppBar.Content title={scene.descriptor.options.title} /> | ||
</AppBar> | ||
), | ||
}} | ||
> | ||
<Stack.Screen | ||
name='Home' | ||
component={ExamplesScreen} | ||
options={{ title: 'Examples' }} | ||
/> | ||
{flattenedExamples.map(({ name, title, component }) => ( | ||
<Stack.Screen | ||
key={name} | ||
name={name} | ||
component={component} | ||
options={{ title }} | ||
/> | ||
))} | ||
</Stack.Navigator> | ||
</React95Provider> | ||
); | ||
}; | ||
|
||
export default MainNavigation; |
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,7 @@ | ||
import { original, counterStrike, vaporTeal } from 'react95-native'; | ||
|
||
export default [ | ||
{ id: original.name, theme: original }, | ||
{ id: counterStrike.name, theme: counterStrike }, | ||
{ id: vaporTeal.name, theme: vaporTeal }, | ||
]; |
Oops, something went wrong.