Skip to content

Commit

Permalink
sdp-tech#14 feat : write detail page with rich editor (sdp-tech#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
youngsikkk authored Feb 9, 2024
1 parent 1b2b94c commit fa05a7e
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 8 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
"react-native-gesture-handler": "^2.14.0",
"react-native-keychain": "^8.1.2",
"react-native-pager-view": "^6.2.3",
"react-native-pell-rich-editor": "^1.9.0",
"react-native-reanimated": "^3.6.2",
"react-native-safe-area-context": "^4.8.2",
"react-native-safearea-height": "^1.0.6",
"react-native-screens": "^3.29.0",
"react-native-snap-carousel": "git+https://github.com/SJ-Kwak/react-native-snap-carousel.git",
"react-native-svg": "^14.1.0",
"react-native-tab-view": "^3.5.2",
"react-native-webview": "^13.7.1",
"styled-components": "^6.1.8",
"yarn": "^1.22.21"
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Home/Market/GoodsRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const GoodsRegistrationPage = ({ navigation, route }: StackScreenProps<HomeStack
</View>
<Body16B style={{margin: 10}}>상품 상세</Body16B>
<FillerSection style={{borderWidth:2,borderColor:"#dcdcdc", backgroundColor:"#FFF"}}>
<UploadButton style={{backgroundColor:"#dcdcdc"}}>
<UploadButton onPress={() => navigation.navigate("WriteDetailPage")}style={{backgroundColor:"#dcdcdc"}}>
<Subtitle16M>작성하기</Subtitle16M>
</UploadButton>
</FillerSection>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Home/Market/ServiceRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const ServiceRegistrationPage = ({ navigation, route }: StackScreenProps<HomeSta
</View>
<Body16B style={{margin: 10}}>서비스 상세</Body16B>
<FillerSection style={{borderWidth:2,borderColor:"#dcdcdc", backgroundColor:"#FFF"}}>
<UploadButton style={{backgroundColor:"#dcdcdc"}}>
<UploadButton onPress={() => navigation.navigate("WriteDetailPage")} style={{backgroundColor:"#dcdcdc"}}>
<Subtitle16B>작성하기</Subtitle16B>
</UploadButton>
</FillerSection>
Expand Down
69 changes: 69 additions & 0 deletions src/components/Home/Market/WriteDetailPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { useCallback, useRef, useState } from 'react';
import { ScrollView, TouchableOpacity, View } from 'react-native';
import { RichEditor, RichToolbar, actions } from 'react-native-pell-rich-editor';
import { Body14M, Body16B } from '../../../styles/GlobalText';
import Arrow from '../../../assets/common/Arrow.svg';
import styled from 'styled-components/native';
import { getStatusBarHeight } from 'react-native-safearea-height';

const statusBarHeight = getStatusBarHeight(true);

const BackButton = styled.TouchableOpacity`
position: absolute;
left: 0px;
padding: 25px;
top: ${statusBarHeight-10}px;
z-index: 1;
`

const WriteDetailPage = ({navigation}:any) => {
const [detail, setDetail] = useState("");
const editor = useRef<RichEditor>(null);
const scrollRef = useRef<ScrollView>(null);

const handleCursorPosition = useCallback((scrollY: number) => {
// Positioning scroll bar
scrollRef.current!.scrollTo({y: scrollY - 30, animated: true});
}, []);

return (
<>
<View style={{flexDirection:"row", marginTop:20, borderBottomWidth:1, borderBlockColor:"#000", padding:15, justifyContent:"center"}}>
<BackButton onPress={() => navigation.goBack()}>
<Arrow color='black' />
</BackButton>
<View>
<Body16B style={{fontSize:18,textAlign:"center"}}>서비스 상세</Body16B>
</View>
</View>
<RichToolbar
editor={editor}
actions={[
actions.insertImage,
actions.setBold,
actions.setItalic,
actions.insertBulletsList,
actions.insertOrderedList,
actions.insertLink,
actions.setStrikethrough,
actions.setUnderline,
]}
// onPressAddImage={pickImage}
/>
<ScrollView>
<RichEditor
ref={editor} // from useRef()
initialContentHTML={detail}
onChange={(html_content) => { setDetail(html_content);
}}
placeholder="내용"
initialHeight={450}
useContainer={true}
onCursorPosition={handleCursorPosition}
/>
</ScrollView>
</>
)
}

export default WriteDetailPage
3 changes: 3 additions & 0 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ServiceDetailPageScreen from '../components/Home/Market/ServiceDetailPage
import GoodsDetailPageScreen from '../components/Home/Market/GoodsDetailPage';
import GoodsRegistrationPage from '../components/Home/Market/GoodsRegistration';
import TempStorageEdit from '../components/Home/Market/TempStorageEdit';
import WriteDetailPage from '../components/Home/Market/WriteDetailPage';

export type HomeStackParams = {
Home: undefined;
Expand All @@ -32,6 +33,7 @@ export type HomeStackParams = {
GoodsRegistrationPage: undefined;
TempStorage: undefined;
TempStorageEdit: undefined;
WriteDetailPage: undefined;
};

const HomeStack = createStackNavigator<HomeStackParams>();
Expand All @@ -54,6 +56,7 @@ const HomeScreen = ({
<HomeStack.Screen name='GoodsRegistrationPage' component={GoodsRegistrationPage} />
<HomeStack.Screen name='TempStorage' component={TempStorage} />
<HomeStack.Screen name='TempStorageEdit' component={TempStorageEdit} />
<HomeStack.Screen name='WriteDetailPage' component={WriteDetailPage} />
</HomeStack.Navigator>
);
};
Expand Down
25 changes: 19 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3594,16 +3594,16 @@ escape-html@~1.0.3:
resolved "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz"
integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==

[email protected], escape-string-regexp@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz"
integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==

escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz"
integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==

escape-string-regexp@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz"
integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==

escape-string-regexp@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz"
Expand Down Expand Up @@ -4440,7 +4440,7 @@ internal-slot@^1.0.5:
hasown "^2.0.0"
side-channel "^1.0.4"

invariant@^2.2.4:
invariant@2.2.4, invariant@^2.2.4:
version "2.2.4"
resolved "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz"
integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==
Expand Down Expand Up @@ -6324,6 +6324,11 @@ react-native-pager-view@^6.2.3:
resolved "https://registry.npmjs.org/react-native-pager-view/-/react-native-pager-view-6.2.3.tgz"
integrity sha512-dqVpXWFtPNfD3D2QQQr8BP+ullS5MhjRJuF8Z/qml4QTILcrWaW8F5iAxKkQR3Jl0ikcEryG/+SQlNcwlo0Ggg==

react-native-pell-rich-editor@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/react-native-pell-rich-editor/-/react-native-pell-rich-editor-1.9.0.tgz#e222b4cd8ead9b5e1de7b6cf2f31a3315c82e570"
integrity sha512-BKzlu++FySzPXrb5bczD8b/ZZJtfzcD4z7FvW7TrH+4OENEQtaIiEMfmb5N09Kv3YVJcfm8fut8Y+GLNAcCQHA==

react-native-reanimated@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-3.6.2.tgz#8a48c37251cbd3b665a659444fa9778f5b510356"
Expand Down Expand Up @@ -6386,6 +6391,14 @@ react-native-tab-view@^3.5.2:
dependencies:
use-latest-callback "^0.1.5"

react-native-webview@^13.7.1:
version "13.7.1"
resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-13.7.1.tgz#d7fe1eb5073e692861457d17b4b998f42846426d"
integrity sha512-tnfTgjIYY3KnBfbN9hRCJf2y/6JZBev3aq2ZacLml0AZn4ufTe4MyCiE1NAZ/l5WHV/1eaqN0srxn45ATL0+Ow==
dependencies:
escape-string-regexp "2.0.0"
invariant "2.2.4"

react-native@*, [email protected]:
version "0.73.2"
resolved "https://registry.npmjs.org/react-native/-/react-native-0.73.2.tgz"
Expand Down

0 comments on commit fa05a7e

Please sign in to comment.