added body in text input and bodyDiff in renderPostBody

This commit is contained in:
Sadaqat Ali 2022-05-05 21:34:40 +05:00
parent 3aab1e5a7c
commit 29891cb238
2 changed files with 21 additions and 15 deletions

View File

@ -11,7 +11,7 @@ import {
TouchableOpacity, TouchableOpacity,
View, View,
} from 'react-native'; } from 'react-native';
import { BasicHeader, Icon, PostBody } from '../../components'; import { BasicHeader, Icon, PostBody, TextInput } from '../../components';
import { diff_match_patch } from 'diff-match-patch'; import { diff_match_patch } from 'diff-match-patch';
// styles // styles
@ -145,35 +145,34 @@ const EditHistoryScreen = ({ navigation }) => {
); );
const _renderDiff = (item: CommentHistoryListItemDiff) => { const _renderDiff = (item: CommentHistoryListItemDiff) => {
const previewTitle = renderPostBody(item.titleDiff, true, Platform.OS === 'ios' ? false : true);
const previewTags = renderPostBody(item.tagsDiff, true, Platform.OS === 'ios' ? false : true);
const previewBody = renderPostBody(item.bodyDiff, true, Platform.OS === 'ios' ? false : true);
return ( return (
<View style={styles.diffContainer}> <View style={styles.diffContainer}>
<Text style={styles.titleDiff}>{item.titleDiff}</Text> <PostBody body={previewTitle} />
<View style={styles.tagsContainer}> <View style={styles.tagsContainer}>
<Icon style={styles.tagIcon} iconType="AntDesign" name={'tag'} /> <Icon style={styles.tagIcon} iconType="AntDesign" name={'tag'} />
<Text style={styles.tags}>{item.tagsDiff}</Text> <PostBody body={previewTags} width={screenWidth - 50} />
</View> </View>
<Text style={styles.bodyDiff}>{item.bodyDiff}</Text>
<PostBody body={previewBody} />
</View> </View>
); );
}; };
const _renderPreview = (selectedItem: CommentHistoryListItemDiff) => { const _renderPlainBody = (selectedItem: CommentHistoryListItemDiff) => {
const previewBody = renderPostBody(
selectedItem.body,
true,
Platform.OS === 'ios' ? false : true,
);
return ( return (
<> <>
<View style={styles.postHeaderContainer}> <View style={styles.postHeaderContainer}>
<Text style={styles.postHeaderTitle}>{selectedItem.title}</Text> <TextInput value={selectedItem.title} style={styles.postHeaderTitle} multiline={true} />
<View style={styles.tagsContainer}> <View style={styles.tagsContainer}>
<Icon style={styles.tagIcon} iconType="AntDesign" name={'tag'} /> <Icon style={styles.tagIcon} iconType="AntDesign" name={'tag'} />
<Text style={styles.tags}>{selectedItem.tags}</Text> <Text style={styles.tags}>{selectedItem.tags}</Text>
</View> </View>
</View> </View>
<View style={styles.bodyContainer}> <View style={styles.bodyContainer}>
<PostBody body={previewBody} onLoadEnd={() => setIsLoading(false)} width={screenWidth} /> <TextInput value={selectedItem.body} style={styles.postBodyText} multiline={true} />
</View> </View>
</> </>
); );
@ -189,7 +188,7 @@ const EditHistoryScreen = ({ navigation }) => {
style={[styles.previewScroll]} style={[styles.previewScroll]}
contentContainerStyle={styles.previewScrollContentContainer} contentContainerStyle={styles.previewScrollContentContainer}
> >
{showDiff ? _renderDiff(selectedItem) : _renderPreview(selectedItem)} {showDiff ? _renderDiff(selectedItem) : _renderPlainBody(selectedItem)}
</ScrollView> </ScrollView>
); );
}; };

View File

@ -44,6 +44,13 @@ export default EStyleSheet.create({
fontFamily: '$primaryFont', fontFamily: '$primaryFont',
marginBottom: 11, marginBottom: 11,
}, },
postBodyText:{
fontSize: 16,
color: '$primaryBlack',
fontWeight: 'bold',
fontFamily: '$primaryFont',
marginBottom: 12,
},
tagsContainer: { tagsContainer: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
@ -52,10 +59,10 @@ export default EStyleSheet.create({
fontSize: 14, fontSize: 14,
color: '$primaryBlack', color: '$primaryBlack',
fontFamily: '$primaryFont', fontFamily: '$primaryFont',
marginLeft: 12,
}, },
tagIcon: { tagIcon: {
color: '$primaryDarkGray' color: '$primaryDarkGray',
marginRight: 12,
}, },
rightIcon: { rightIcon: {
backgroundColor: '$primaryDarkGray', backgroundColor: '$primaryDarkGray',