index.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import {
  2. useLayoutEffect,
  3. useState,
  4. useRef
  5. } from "react";
  6. import {
  7. View
  8. } from "react-native";
  9. import stylesheet from "./stylesheet";
  10. import {
  11. NCoreUIKitLocalize,
  12. NCoreUIKitTheme,
  13. DateTimeSheet,
  14. PageContainer,
  15. CodeViewer,
  16. Header,
  17. Button,
  18. Text
  19. } from "ncore-ui-kit";
  20. import {
  21. useNavigation
  22. } from "@react-navigation/native";
  23. import type RootStackParamList from "../../../navigation/type";
  24. import type {
  25. NativeStackNavigationProp
  26. } from "@react-navigation/native-stack";
  27. import type {
  28. IBottomSheetRef
  29. } from "ncore-ui-kit";
  30. const DateTimeSheetPage = () => {
  31. const {
  32. localize
  33. } = NCoreUIKitLocalize.useContext();
  34. const {
  35. spaces
  36. } = NCoreUIKitTheme.useContext();
  37. const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
  38. const bottomSheetRef = useRef<IBottomSheetRef>(null);
  39. const [
  40. isActive,
  41. setIsActive
  42. ] = useState<boolean>(false);
  43. useLayoutEffect(() => {
  44. navigation.setOptions({
  45. header: () => <Header
  46. title={localize("components-dateTimeSheet")}
  47. isWrapSafeareaContext={false}
  48. navigation={navigation}
  49. isGoBackEnable={true}
  50. />,
  51. headerShown: true
  52. });
  53. }, []);
  54. return <PageContainer
  55. scrollViewProps={{
  56. contentContainerStyle: stylesheet.scrollContent
  57. }}
  58. isWorkWithHeaderSpace={false}
  59. scrollViewStyle={[
  60. stylesheet.container
  61. ]}
  62. isScrollable={true}
  63. >
  64. <View
  65. style={[
  66. stylesheet.contentContainer
  67. ]}
  68. >
  69. <Text
  70. style={stylesheet.descText}
  71. variant="bodyMediumSize"
  72. color="mid"
  73. >
  74. {localize("dateTimeSheet-desc")}
  75. </Text>
  76. <Text
  77. variant="titleMediumSize"
  78. style={stylesheet.title}
  79. >
  80. {localize("components-dateTimeSheet")}
  81. </Text>
  82. <Button
  83. onPress={() => setIsActive(true)}
  84. title="Open DateTime Sheet"
  85. spreadBehaviour="stretch"
  86. />
  87. <View
  88. style={{
  89. marginVertical: spaces.spacingMd
  90. }}
  91. >
  92. <Text
  93. style={{
  94. marginBottom: spaces.spacingSm
  95. }}
  96. variant="headlineSmallSize"
  97. >
  98. {localize("usage")}
  99. </Text>
  100. <CodeViewer
  101. code={"import {\n DateTimeSheet\n} from \"ncore-ui-kit\";\n\n<DateTimeSheet\n isActive={isActive}\n setIsActive={setIsActive}\n pickerType=\"date\"\n variant=\"single\"\n/>"}
  102. language="tsx"
  103. />
  104. </View>
  105. <DateTimeSheet
  106. cancel={() => setIsActive(false)}
  107. selectMultipleObject={() => {}}
  108. bottomSheetRef={bottomSheetRef}
  109. ok={() => setIsActive(false)}
  110. selectDateRule={() => {}}
  111. isWorkWithRealtime={true}
  112. setIsActive={setIsActive}
  113. dateTimePickerKey="test"
  114. selectObject={() => {}}
  115. isActive={isActive}
  116. pickerType="date"
  117. isLoading={false}
  118. clean={() => {}}
  119. variant="single"
  120. />
  121. </View>
  122. </PageContainer>;
  123. };
  124. export default DateTimeSheetPage;