| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- import {
- useLayoutEffect,
- useState
- } from "react";
- import {
- View
- } from "react-native";
- import stylesheet from "./stylesheet";
- import {
- NCoreUIKitLocalize,
- NCoreUIKitTheme,
- PageContainer,
- CodeViewer,
- TextInput,
- Header,
- Switch,
- 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";
- const HeaderPage = () => {
- const {
- radiuses,
- borders,
- spaces,
- colors
- } = NCoreUIKitTheme.useContext();
- const {
- localize
- } = NCoreUIKitLocalize.useContext();
- const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
- const [
- title,
- setTitle
- ] = useState<string>("Header Example");
- const [
- isGoBackEnable,
- setIsGoBackEnable
- ] = useState<boolean>(true);
- useLayoutEffect(() => {
- navigation.setOptions({
- header: () => <Header
- title={localize("header-title")}
- isWrapSafeareaContext={false}
- navigation={navigation}
- isGoBackEnable={true}
- />,
- headerShown: true
- });
- }, []);
- return <PageContainer
- scrollViewProps={{
- contentContainerStyle: stylesheet.scrollContent
- }}
- isWorkWithHeaderSpace={false}
- scrollViewStyle={[
- stylesheet.container
- ]}
- isScrollable={true}
- >
- <View
- style={[
- stylesheet.contentContainer
- ]}
- >
- <Text
- style={stylesheet.marginContainer}
- variant="bodyMediumSize"
- color="mid"
- >
- {localize("header-desc")}
- </Text>
- <View
- style={[
- stylesheet.paddedMarginContainer,
- {
- borderColor: colors.content.border.subtle,
- marginBottom: spaces.spacingMd,
- borderRadius: radiuses.form,
- borderWidth: borders.line,
- padding: spaces.spacingMd
- }
- ]}
- >
- <Header
- isGoBackEnable={isGoBackEnable}
- isWrapSafeareaContext={false}
- navigation={navigation}
- title={title}
- />
- </View>
- <View
- style={{
- marginBottom: spaces.spacingMd
- }}
- >
- <Text
- style={{
- marginBottom: spaces.spacingSm
- }}
- variant="headlineSmallSize"
- >
- {localize("usage")}
- </Text>
- <CodeViewer
- code={"import {\n Header\n} from \"ncore-ui-kit\";\n\n<Header\n title=\"Header Example\"\n isGoBackEnable={true}\n/>"}
- language="tsx"
- />
- </View>
- <TextInput
- placeholder={localize("header-enterTitle")}
- title={localize("header-titleLabel")}
- style={{
- marginBottom: spaces.spacingMd
- }}
- spreadBehaviour="stretch"
- onChangeText={setTitle}
- value={title}
- />
- <View
- style={stylesheet.rowSpaceBetween}
- >
- <Switch
- onPress={() => setIsGoBackEnable(!isGoBackEnable)}
- title={localize("header-toggleGoBack")}
- isActive={isGoBackEnable}
- spreadBehaviour="free"
- />
- </View>
- </View>
- </PageContainer>;
- };
- export default HeaderPage;
|