index.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import {
  2. useLayoutEffect,
  3. useState
  4. } from "react";
  5. import {
  6. View
  7. } from "react-native";
  8. import stylesheet from "./stylesheet";
  9. import {
  10. NCoreUIKitLocalize,
  11. NCoreUIKitTheme,
  12. PageContainer,
  13. TimeSelector,
  14. CodeViewer,
  15. Header,
  16. Text
  17. } from "ncore-ui-kit";
  18. import {
  19. useNavigation
  20. } from "@react-navigation/native";
  21. import type RootStackParamList from "../../../navigation/type";
  22. import type {
  23. NativeStackNavigationProp
  24. } from "@react-navigation/native-stack";
  25. const TimeSelectorPage = () => {
  26. const {
  27. localize
  28. } = NCoreUIKitLocalize.useContext();
  29. const {
  30. spaces
  31. } = NCoreUIKitTheme.useContext();
  32. const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
  33. const [
  34. ,
  35. setIsSheetContentReady
  36. ] = useState<boolean>(false);
  37. useLayoutEffect(() => {
  38. navigation.setOptions({
  39. header: () => <Header
  40. title={localize("components-timeSelector")}
  41. isWrapSafeareaContext={false}
  42. navigation={navigation}
  43. isGoBackEnable={true}
  44. />,
  45. headerShown: true
  46. });
  47. }, []);
  48. return <PageContainer
  49. scrollViewProps={{
  50. contentContainerStyle: stylesheet.scrollContent
  51. }}
  52. isWorkWithHeaderSpace={false}
  53. scrollViewStyle={[
  54. stylesheet.container
  55. ]}
  56. isScrollable={true}
  57. >
  58. <View
  59. style={[
  60. stylesheet.contentContainer
  61. ]}
  62. >
  63. <Text
  64. style={stylesheet.descText}
  65. variant="bodyMediumSize"
  66. color="mid"
  67. >
  68. {localize("timeSelector-desc")}
  69. </Text>
  70. <Text
  71. variant="titleMediumSize"
  72. style={stylesheet.title}
  73. >
  74. {localize("components-timeSelector")}
  75. </Text>
  76. <TimeSelector
  77. setIsSheetContentReady={setIsSheetContentReady}
  78. selectMultipleObject={() => {}}
  79. selectObject={() => {}}
  80. pickerType="time"
  81. variant="single"
  82. />
  83. <View
  84. style={{
  85. marginTop: spaces.spacingMd
  86. }}
  87. >
  88. <Text
  89. style={{
  90. marginBottom: spaces.spacingSm
  91. }}
  92. variant="headlineSmallSize"
  93. >
  94. {localize("usage")}
  95. </Text>
  96. <CodeViewer
  97. code={"import {\n TimeSelector\n} from \"ncore-ui-kit\";\n\n<TimeSelector\n variant=\"single\"\n pickerType=\"time\"\n selectObject={(item) => console.log(item)}\n/>"}
  98. language="tsx"
  99. />
  100. </View>
  101. </View>
  102. </PageContainer>;
  103. };
  104. export default TimeSelectorPage;