| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import {
- useLayoutEffect,
- useState
- } from "react";
- import {
- View
- } from "react-native";
- import stylesheet from "./stylesheet";
- import {
- NCoreUIKitLocalize,
- NCoreUIKitTheme,
- PageContainer,
- CodeViewer,
- Header,
- Button,
- Modal,
- 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 ModalPage = () => {
- const {
- localize
- } = NCoreUIKitLocalize.useContext();
- const {
- spaces
- } = NCoreUIKitTheme.useContext();
- const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
- const [
- isActive,
- setIsActive
- ] = useState<boolean>(false);
- useLayoutEffect(() => {
- navigation.setOptions({
- header: () => <Header
- title={localize("components-modal")}
- 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.descText}
- variant="bodyMediumSize"
- color="mid"
- >
- {localize("modal-desc")}
- </Text>
- <Text
- variant="titleMediumSize"
- style={stylesheet.title}
- >
- {localize("components-modal")}
- </Text>
- <Button
- onPress={() => setIsActive(true)}
- spreadBehaviour="stretch"
- title="Open Modal"
- />
- <View
- style={{
- marginVertical: spaces.spacingMd
- }}
- >
- <Text
- style={{
- marginBottom: spaces.spacingSm
- }}
- variant="headlineSmallSize"
- >
- {localize("usage")}
- </Text>
- <CodeViewer
- code={"import {\n Modal\n} from \"ncore-ui-kit\";\n\n<Modal\n isActive={isActive}\n onOverlayPress={() => setIsActive(false)}\n>\n <View>\n <Text>Modal Content</Text>\n </View>\n</Modal>"}
- language="tsx"
- />
- </View>
- <Modal
- onOverlayPress={() => setIsActive(false)}
- isActive={isActive}
- id="example-modal"
- >
- <View
- style={stylesheet.modalContent}
- >
- <Text>
- This is an example modal content.
- </Text>
- <Button
- onPress={() => setIsActive(false)}
- spreadBehaviour="stretch"
- title="Close Modal"
- type="primary"
- />
- </View>
- </Modal>
- </View>
- </PageContainer>;
- };
- export default ModalPage;
|