index.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. YearSelector,
  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 YearSelectorPage = () => {
  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-yearSelector")}
  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. scrollViewStyle={[
  53. stylesheet.container
  54. ]}
  55. isWorkWithHeaderSpace={false}
  56. isScrollable={true}
  57. >
  58. <View
  59. style={[
  60. stylesheet.contentContainer
  61. ]}
  62. >
  63. <Text
  64. variant="bodyMediumSize"
  65. color="mid"
  66. style={stylesheet.descText}
  67. >
  68. {localize("yearSelector-desc")}
  69. </Text>
  70. <Text
  71. style={stylesheet.title}
  72. variant="titleMediumSize"
  73. >
  74. {localize("components-yearSelector")}
  75. </Text>
  76. <YearSelector
  77. setIsSheetContentReady={setIsSheetContentReady}
  78. selectMultipleObject={() => {}}
  79. selectObject={() => {}}
  80. variant="single"
  81. />
  82. <View
  83. style={{
  84. marginTop: spaces.spacingMd
  85. }}
  86. >
  87. <Text
  88. variant="headlineSmallSize"
  89. style={{
  90. marginBottom: spaces.spacingSm
  91. }}
  92. >
  93. {localize("usage")}
  94. </Text>
  95. <CodeViewer
  96. code={"import {\n YearSelector\n} from \"ncore-ui-kit\";\n\n<YearSelector\n variant=\"single\"\n selectObject={(item) => console.log(item)}\n/>"}
  97. language="tsx"
  98. />
  99. </View>
  100. </View>
  101. </PageContainer>;
  102. };
  103. export default YearSelectorPage;