index.tsx 2.5 KB

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