| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- import {
- useLayoutEffect,
- useState
- } from "react";
- import {
- View
- } from "react-native";
- import stylesheet from "./stylesheet";
- import {
- NCoreUIKitLocalize,
- NCoreUIKitTheme,
- PageContainer,
- CodeViewer,
- StateCard,
- TextInput,
- 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 {
- Home as HomeIcon
- } from "lucide-react-native";
- const StateCardPage = () => {
- const {
- radiuses,
- borders,
- spaces,
- colors
- } = NCoreUIKitTheme.useContext();
- const {
- localize
- } = NCoreUIKitLocalize.useContext();
- const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
- const [
- title,
- setTitle
- ] = useState<string>("");
- const [
- subTitle,
- setSubTitle
- ] = useState<string>("");
- const [
- value,
- setValue
- ] = useState<string>("");
- useLayoutEffect(() => {
- navigation.setOptions({
- header: () => <Header
- title={localize("stateCard-title")}
- isWrapSafeareaContext={false}
- navigation={navigation}
- isGoBackEnable={true}
- />,
- headerShown: true
- });
- }, []);
- return <PageContainer
- scrollViewProps={{
- contentContainerStyle: stylesheet.scrollContent
- }}
- scrollViewStyle={[
- stylesheet.container
- ]}
- isWorkWithHeaderSpace={false}
- isScrollable={true}
- >
- <View
- style={[
- stylesheet.contentContainer
- ]}
- >
- <Text
- variant="bodyMediumSize"
- color="mid"
- style={stylesheet.descText}
- >
- {localize("stateCard-desc")}
- </Text>
- <View
- style={[
- stylesheet.previewContainer,
- {
- borderColor: colors.content.border.subtle,
- marginBottom: spaces.spacingMd,
- borderRadius: radiuses.form,
- borderWidth: borders.line,
- padding: spaces.spacingMd
- }
- ]}
- >
- <StateCard
- icon={({
- color,
- size
- }) => <HomeIcon
- color={
- colors.content.icon[
- color as keyof typeof colors.content.icon
- ]
- }
- size={size}
- />
- }
- subTitle={
- subTitle ||
- localize("stateCard-exampleSubTitle")
- }
- title={
- title || localize("stateCard-exampleTitle")
- }
- />
- </View>
- <View
- style={{
- marginBottom: spaces.spacingMd
- }}
- >
- <Text
- variant="headlineSmallSize"
- style={{
- marginBottom: spaces.spacingSm
- }}
- >
- {localize("usage")}
- </Text>
- <CodeViewer
- code={"import {\n StateCard\n} from \"ncore-ui-kit\";\n\n<StateCard\n title=\"Title\"\n subTitle=\"Subtitle\"\n/>"}
- language="tsx"
- />
- </View>
- <TextInput
- placeholder={localize("stateCard-enterTitle")}
- title={localize("stateCard-titleLabel")}
- style={{
- marginBottom: spaces.spacingMd
- }}
- spreadBehaviour="stretch"
- onChangeText={setTitle}
- value={title}
- />
- <TextInput
- placeholder={localize("stateCard-enterSubTitle")}
- title={localize("stateCard-subTitleLabel")}
- style={{
- marginBottom: spaces.spacingMd
- }}
- onChangeText={setSubTitle}
- spreadBehaviour="stretch"
- value={subTitle}
- />
- <TextInput
- placeholder={localize("stateCard-enterValue")}
- title={localize("stateCard-valueLabel")}
- style={{
- marginBottom: spaces.spacingMd
- }}
- spreadBehaviour="stretch"
- onChangeText={setValue}
- value={value}
- />
- </View>
- </PageContainer>;
- };
- export default StateCardPage;
|