index.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. MarkdownEditor,
  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 MarkdownEditorPage = () => {
  25. const {
  26. spaces
  27. } = NCoreUIKitTheme.useContext();
  28. const {
  29. localize
  30. } = NCoreUIKitLocalize.useContext();
  31. const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
  32. useLayoutEffect(() => {
  33. navigation.setOptions({
  34. header: () => <Header
  35. title={localize("markdownEditor-title")}
  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. isWorkWithHeaderSpace={false}
  48. scrollViewStyle={[
  49. stylesheet.container
  50. ]}
  51. isScrollable={true}
  52. >
  53. <View
  54. style={[
  55. stylesheet.contentContainer
  56. ]}
  57. >
  58. <Text
  59. style={stylesheet.marginContainer}
  60. variant="bodyMediumSize"
  61. color="mid"
  62. >
  63. {localize("markdownEditor-desc")}
  64. </Text>
  65. <View
  66. style={{
  67. marginBottom: spaces.spacingMd
  68. }}
  69. >
  70. <Text
  71. style={{
  72. marginBottom: spaces.spacingSm
  73. }}
  74. variant="headlineSmallSize"
  75. >
  76. {localize("usage") || "Usage"}
  77. </Text>
  78. <CodeViewer
  79. code={"import {\n MarkdownEditor\n} from \"ncore-ui-kit\";\n\n<MarkdownEditor\n initialValue=\"# Hello\"\n/>"}
  80. language="tsx"
  81. />
  82. </View>
  83. <MarkdownEditor
  84. initialValue="# Markdown Editor\n\nThis is a **MarkdownEditor** component from *NCore UI Kit*.\n\n- Write your markdown here."
  85. style={stylesheet.editor}
  86. />
  87. </View>
  88. </PageContainer>;
  89. };
  90. export default MarkdownEditorPage;