| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- import {
- useLayoutEffect
- } from "react";
- import {
- View
- } from "react-native";
- import stylesheet from "./stylesheet";
- import {
- NCoreUIKitLocalize,
- NCoreUIKitTheme,
- LocaleSwitcher,
- PageContainer,
- Button,
- Header,
- Text
- } from "ncore-ui-kit";
- import {
- useNavigation
- } from "@react-navigation/native";
- import type RootStackParamList from "../../../navigation/type";
- import type {
- NativeStackNavigationProp
- } from "@react-navigation/native-stack";
- import {
- ChevronRightIcon,
- ChevronLeftIcon
- } from "lucide-react-native";
- const LocaleExamples = () => {
- const {
- colors,
- spaces
- } = NCoreUIKitTheme.useContext();
- const {
- activeLocale,
- localize
- } = NCoreUIKitLocalize.useContext();
- const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
- useLayoutEffect(() => {
- navigation.setOptions({
- header: () => <Header
- navigation={navigation as unknown as NCoreUIKit.Navigation}
- title={localize("localeExamples-title")}
- isWrapSafeareaContext={false}
- isGoBackEnable={true}
- />,
- headerShown: true
- });
- }, [
- navigation,
- localize
- ]);
- return <PageContainer
- isWorkWithHeaderSpace={false}
- isScrollable={true}
- >
- <Text
- variant="headlineSmallSize"
- color="high"
- >
- {localize("localeExamples-title")}
- </Text>
- <Text
- color="mid"
- >
- {localize("localeExamples-desc")}
- </Text>
- <Text
- style={{
- marginBottom: spaces.spacingLg,
- marginTop: spaces.spacingXl
- }}
- variant="titleMediumSize"
- color="high"
- >
- {localize("localeExamples-languageSwitcher")}
- </Text>
- <View
- style={[
- stylesheet.rowContainer,
- {
- gap: spaces.spacingMd
- }
- ]}
- >
- <LocaleSwitcher/>
- </View>
- <View
- style={[
- stylesheet.borderedCard,
- {
- backgroundColor: colors.content.container.subtle,
- marginTop: spaces.spacingLg,
- padding: spaces.spacingLg
- }
- ]}
- >
- <Text
- style={{
- marginBottom: spaces.spacingMd
- }}
- variant="titleMediumSize"
- color="high"
- >
- {localize("localeExamples-localizedTexts")}
- </Text>
- <Text
- style={{
- marginBottom: spaces.spacingSm
- }}
- color="mid"
- >
- {localize("localeExamples-currentLanguage")}<Text
- variant="labelLargeSize"
- color="high"
- >
- {activeLocale}
- </Text>
- </Text>
- <View
- style={[
- stylesheet.borderedCard2,
- {
- backgroundColor: colors.content.container.default,
- padding: spaces.spacingMd,
- gap: spaces.spacingMd
- }
- ]}
- >
- <View>
- <Text
- variant="labelMediumSize"
- color="mid"
- >
- "hello-world" key
- </Text>
- <Text
- variant="bodyLargeSize"
- color="high"
- >
- {localize("hello-world")}
- </Text>
- </View>
- <View>
- <Text
- variant="labelMediumSize"
- color="mid"
- >
- "menu" key
- </Text>
- <Text
- variant="bodyLargeSize"
- color="high"
- >
- {localize("menu")}
- </Text>
- </View>
- <View>
- <Text
- variant="labelMediumSize"
- color="mid"
- >
- "installation" key
- </Text>
- <Text
- variant="bodyLargeSize"
- color="high"
- >
- {localize("installation")}
- </Text>
- </View>
- </View>
- </View>
- <View
- style={[
- stylesheet.rowSpaceBetween,
- {
- marginTop: spaces.spacingXl
- }
- ]}
- >
- <Button
- icon={({
- color,
- size
- }) => {
- return <ChevronLeftIcon
- color={colors.content.icon[color]}
- size={size + 3}
- />;
- }}
- onPress={() => {
- navigation.navigate("CoreFeatures", {
- screen: "ThemeExamples"
- });
- }}
- title={localize("themeExamples-title")}
- />
- <Button
- icon={({
- color,
- size
- }) => {
- return <ChevronRightIcon
- color={colors.content.icon[color]}
- size={size + 3}
- />;
- }}
- onPress={() => {
- navigation.navigate("CoreFeatures", {
- screen: "TypesOverride"
- });
- }}
- title={localize("typesOverride-title")}
- iconDirection="right"
- />
- </View>
- </PageContainer>;
- };
- export default LocaleExamples;
|