| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- import {
- useLayoutEffect,
- useState
- } from "react";
- import {
- View
- } from "react-native";
- import stylesheet from "./stylesheet";
- import {
- NCoreUIKitLocalize,
- NCoreUIKitTheme,
- PageContainer,
- BottomSheet,
- CodeViewer,
- Button,
- 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 BottomSheetPage = () => {
- const {
- radiuses,
- borders,
- spaces,
- colors
- } = NCoreUIKitTheme.useContext();
- const {
- localize
- } = NCoreUIKitLocalize.useContext();
- const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
- const [
- isWorkWithPortal,
- setIsWorkWithPortal
- ] = useState<boolean>(true);
- const [
- isSwipeClose,
- setIsSwipeClose
- ] = useState<boolean>(true);
- const [
- isShowHandle,
- setIsShowHandle
- ] = useState<boolean>(true);
- const [
- isActive,
- setIsActive
- ] = useState<boolean>(false);
- useLayoutEffect(() => {
- navigation.setOptions({
- header: () => <Header
- title={localize("bottomSheet-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("bottomSheet-desc")}
- </Text>
- <View
- style={[
- stylesheet.paddedMarginContainer,
- {
- borderColor: colors.content.border.subtle,
- marginBottom: spaces.spacingMd,
- borderRadius: radiuses.form,
- borderWidth: borders.line,
- padding: spaces.spacingMd
- }
- ]}
- >
- <Button
- title={localize("bottomSheet-openSheet")}
- onPress={() => setIsActive(true)}
- />
- </View>
- <View
- style={{
- marginBottom: spaces.spacingMd
- }}
- >
- <Text
- style={{
- marginBottom: spaces.spacingSm
- }}
- variant="headlineSmallSize"
- >
- {localize("usage")}
- </Text>
- <CodeViewer
- code={"import {\n BottomSheet\n} from \"ncore-ui-kit\";\n\n<BottomSheet\n isActive={isActive}\n onClose={() => setIsActive(false)}\n>\n <Text>BottomSheet Content</Text>\n</BottomSheet>"}
- language="tsx"
- />
- </View>
- <View
- style={[
- stylesheet.rowSpaceBetween,
- {
- gap: spaces.spacingMd
- }
- ]}
- >
- <View
- style={stylesheet.rowSpaceBetween2}
- >
- <Switch
- title={localize(
- "bottomSheet-toggleSwipeClose",
- )}
- onPress={() => {
- setIsSwipeClose(!isSwipeClose);
- }}
- isActive={isSwipeClose}
- spreadBehaviour="free"
- />
- <Switch
- title={localize(
- "bottomSheet-toggleShowHandle",
- )}
- onPress={() => {
- setIsShowHandle(!isShowHandle);
- }}
- isActive={isShowHandle}
- spreadBehaviour="free"
- />
- <Switch
- title={localize("bottomSheet-togglePortal")}
- onPress={() => {
- setIsWorkWithPortal(!isWorkWithPortal);
- }}
- isActive={isWorkWithPortal}
- spreadBehaviour="free"
- />
- </View>
- </View>
- </View>
- <BottomSheet
- isWorkWithPortal={isWorkWithPortal}
- onClose={() => setIsActive(false)}
- isSwipeClose={isSwipeClose}
- isShowHandle={isShowHandle}
- isActive={isActive}
- >
- <View
- style={{
- padding: spaces.spacingMd
- }}
- >
- <Text
- style={[
- stylesheet.centeredText,
- {
- marginBottom: spaces.spacingMd
- }
- ]}
- >
- {localize("bottomSheet-content")}
- </Text>
- <Button
- title={localize("bottomSheet-close")}
- onPress={() => setIsActive(false)}
- spreadBehaviour="stretch"
- type="danger"
- />
- </View>
- </BottomSheet>
- </PageContainer>;
- };
- export default BottomSheetPage;
|