From b1de5164ca3d7791257dff90020f145f774feedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atakan=20Ya=C5=9Far?= Date: Mon, 16 Dec 2024 20:49:13 +0300 Subject: [PATCH] feat(mobile): add posting guide and preview --- mobile/app/question/[questionId]/answer.tsx | 20 ++----- mobile/app/question/new.tsx | 61 +++++++++++++++++---- mobile/components/PostingGuide.tsx | 55 +++++++++++++++++++ 3 files changed, 110 insertions(+), 26 deletions(-) create mode 100644 mobile/components/PostingGuide.tsx diff --git a/mobile/app/question/[questionId]/answer.tsx b/mobile/app/question/[questionId]/answer.tsx index 7afe6c5..6841809 100644 --- a/mobile/app/question/[questionId]/answer.tsx +++ b/mobile/app/question/[questionId]/answer.tsx @@ -18,14 +18,10 @@ import { Popover, PopoverBackdrop, PopoverContent, - PopoverArrow, - PopoverHeader, - PopoverCloseButton, - PopoverBody, - PopoverFooter, } from "@/components/ui"; import { X, InfoIcon } from "lucide-react-native"; import { ContentWithSnippets } from "@/components/ContentWithSnippets"; +import { PostingGuide } from "@/components/PostingGuide"; export default function NewAnswerPage() { const { questionId } = useLocalSearchParams<{ questionId: string }>(); @@ -88,17 +84,10 @@ export default function NewAnswerPage() { ) }} - onOpen={() => console.log("Popover opened")} > - - - - - - - - + + @@ -106,6 +95,9 @@ export default function NewAnswerPage() { + {preview ? ( diff --git a/mobile/app/question/new.tsx b/mobile/app/question/new.tsx index 72fd442..ea86572 100644 --- a/mobile/app/question/new.tsx +++ b/mobile/app/question/new.tsx @@ -1,10 +1,15 @@ +import { ContentWithSnippets } from "@/components/ContentWithSnippets"; import ErrorAlert from "@/components/ErrorAlert"; import { FullscreenLoading } from "@/components/FullscreenLoading"; +import { PostingGuide } from "@/components/PostingGuide"; import { Button, ButtonText, HStack, Icon, + Popover, + PopoverBackdrop, + PopoverContent, ScrollView, Text, Textarea, @@ -23,7 +28,7 @@ import { } from "@/services/api/programmingForumSchemas"; import useAuthStore from "@/services/auth"; import { useLocalSearchParams, useRouter } from "expo-router"; -import { X } from "lucide-react-native"; +import { InfoIcon, X } from "lucide-react-native"; import { useState } from "react"; export default function NewQuestionPage() { @@ -33,6 +38,7 @@ export default function NewQuestionPage() { const [title, setTitle] = useState(""); const [content, setContent] = useState(""); + const [preview, setPreview] = useState(false); const contentLength = content.length; const [searchQuery, setSearchQuery] = useState(""); const [selectedTags, setSelectedTags] = useState([]); @@ -145,18 +151,49 @@ export default function NewQuestionPage() { {/* Content Input */} - Content - + onOpen={() => console.log("Popover opened")} + > + + + + + + + + + + + + { preview ? ( + + ) : ( + + )} + {contentLength} characters diff --git a/mobile/components/PostingGuide.tsx b/mobile/components/PostingGuide.tsx new file mode 100644 index 0000000..3017808 --- /dev/null +++ b/mobile/components/PostingGuide.tsx @@ -0,0 +1,55 @@ +import { + Text, + View, + ScrollView, +} from "@/components/ui"; +import { openURL } from "expo-linking"; + +export const PostingGuide = () => { + return ( + + + {/* Writing Answers Section */} + Writing Answers + + We use Markdown for formatting answers. You can use standard Markdown + syntax for headers, lists, links, etc. For a basic reference, you can + check{" "} + openURL("https://commonmark.org/help/")} + > + CommonMark + + . + + + {/* Code Execution Section */} + Code Execution + + To create executable code blocks, use triple backticks with + language-exec: + + + + {`\`\`\`javascript-exec\nconsole.log("Hello, world!, This is executable!");\`\`\``} + + + + {/* Linking Section */} + Linking + + Link to tags using:{" "} + + [tag name](#tag-123) + + {"\n"} + Link to questions using:{" "} + + [question title](#q-456) + + + + + ); +};