Skip to content

Commit

Permalink
[expo] fix screen header style
Browse files Browse the repository at this point in the history
**Summary**

apply colors from rneui theme.

**Test**

- expo

**Issue**

- N/A
  • Loading branch information
yssk22 committed Oct 20, 2023
1 parent 6eb2291 commit 5b8471e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
23 changes: 18 additions & 5 deletions expo/features/root/protected/stack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ function createStackNavigator<P extends ScreenParams>(
| React.Ref<NavigationContainerRef<ReactNavigation.RootParamList>>
| undefined
): JSX.Element {
const [primary, contrastPrimary] = useColor("primary");
const [secondary, _] = useColor("secondary");
const { screens, onStateChange, initialRouteName, ...navigatorProps } =
props;
const screenMap = screens.reduce((map, s) => {
Expand Down Expand Up @@ -117,13 +119,16 @@ function createStackNavigator<P extends ScreenParams>(
options={{
headerBackTitle: "",
headerBackTitleVisible: false,

headerTintColor: contrastPrimary,
headerStyle: {
backgroundColor: primary,
},
...options,
}}
/>
);
});
}, [screens]);
}, [screens, primary, contrastPrimary]);
return (
<NavigationContainer
ref={ref}
Expand All @@ -132,8 +137,12 @@ function createStackNavigator<P extends ScreenParams>(
theme={{
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: "#ffffff",
primary: primary,
background: contrastPrimary,
card: contrastPrimary,
text: primary,
border: contrastPrimary,
notification: secondary,
},
}}
>
Expand Down Expand Up @@ -197,10 +206,14 @@ const useNavigation = () => {

type Navigation = ReturnType<typeof useNavigation>;

function defineScreen<P>(path: string, component: React.ElementType<P>) {
function defineScreen<P extends ScreenParams>(
path: string,
component: React.ElementType<P>
): Screen<P> {
return {
path,
component,
options: {},
};
}

Expand Down
9 changes: 5 additions & 4 deletions expo/features/settings/theme/ThemeColorSelectorScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { StyleSheet, ScrollView } from "react-native";
import { Icon, ListItem } from "@rneui/themed";
import { defineScreen } from "@hpapp/features/root/protected/stack";
import {
defineScreen,
useScreenTitle,
} from "@hpapp/features/root/protected/stack";
import {
AvailableColors,
ColorScheme,
Expand All @@ -22,13 +25,11 @@ export default defineScreen(
title: string;
scheme: ColorScheme;
}) {
useScreenTitle(title);
const navigation = useNavigation();
const [config, updateConfig] = useLocalUserConfig();
const [_, updateTheme] = useAppTheme();
const [current] = useColor(scheme);
useEffect(() => {
navigation.setOptions({ title: title });
}, [title]);
return (
<ScrollView>
{AvailableColors.map((a) => {
Expand Down

0 comments on commit 5b8471e

Please sign in to comment.