mancala/apps/mobile/src/screens/HomeScreen.tsx

45 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-03-24 14:23:08 +03:00
import * as React from 'react';
2024-03-31 16:39:39 +03:00
import { View, Button, Pressable, Text } from 'react-native';
2024-03-24 14:23:08 +03:00
import { useTranslation } from 'react-i18next';
import { HomeScreenProps } from '../types';
2024-03-31 16:39:39 +03:00
import CircularPanel from '../components/CircularPanel';
import { SvgXml } from 'react-native-svg';
import helpSvg from '../svg/help';
import { getColorByBrightness } from "@mancala/core";
2024-03-24 14:23:08 +03:00
export function HomeScreen({ navigation, route }: HomeScreenProps) {
const { context } = route.params;
2024-03-24 14:23:08 +03:00
const { t } = useTranslation();
const textColorOnAppBar = getColorByBrightness(
context.themeManager.theme.appBarBgColor,
context.themeManager.theme.textColor,
context.themeManager.theme.textLightColor
);
const updateHeaderButton = () => {
navigation.setOptions({
headerRight: () => (
<Pressable onPress={() => {
navigation.push("Help", { context })
}}>
<SvgXml xml={helpSvg.replaceAll("customColor", textColorOnAppBar)} width="24" height="24" />
</Pressable>
),
});
}
React.useEffect(() => {
updateHeaderButton();
}, []);
2024-03-24 14:23:08 +03:00
return (
2024-03-31 16:39:39 +03:00
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: context.themeManager.theme?.background }}>
<Pressable onPress={() => navigation.replace('Loby', { context })}>
<CircularPanel color={context.themeManager.theme?.boardColor} children={<Text style={{ color: context.themeManager.theme.textColor }}>{t('NewGame')}</Text>} />
2024-03-31 16:39:39 +03:00
</Pressable>
2024-03-24 14:23:08 +03:00
</View>
);
}