UI changes

This commit is contained in:
Sadaqat Ali 2022-01-12 20:04:05 +05:00
parent 1960c5dfa5
commit 6ad3b0b8e2
2 changed files with 56 additions and 62 deletions

View File

@ -9,30 +9,15 @@ export default EStyleSheet.create({
right: 0, right: 0,
zIndex: 999, zIndex: 999,
}, },
container:{
modalContainer: {
padding: 12,
},
intialView: {
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
},
userAvatar: {
width: 50,
height: 50,
borderRadius: 50,
},
addCommentBtn: {
backgroundColor: '$primaryLightBackground',
flex:1, flex:1,
height: 50,
marginLeft: 8,
borderRadius: 8,
justifyContent: 'center',
paddingLeft: 12,
}, },
modalContainer: {
paddingVertical: 16,
},
modalHeader: {}, modalHeader: {},
titleBtnTxt: { titleBtnTxt: {
fontSize: 18, fontSize: 18,
@ -40,7 +25,7 @@ export default EStyleSheet.create({
color: '$primaryBlack', color: '$primaryBlack',
}, },
inputContainer: { inputContainer: {
paddingVertical: 16, padding: 16,
}, },
textInput: { textInput: {
color: '$iconColor', color: '$iconColor',
@ -53,6 +38,7 @@ export default EStyleSheet.create({
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'flex-end', justifyContent: 'flex-end',
alignItems: 'center', alignItems: 'center',
paddingHorizontal:16,
}, },
commentBtn: { commentBtn: {
width: 100, width: 100,
@ -60,4 +46,30 @@ export default EStyleSheet.create({
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
}, },
replySection: {
paddingTop: 10,
paddingBottom: 0,
},
accountTile: {
height: 60,
flexDirection: 'row',
paddingHorizontal: 16,
alignItems: 'center',
justifyContent: 'space-between',
},
avatarAndNameContainer: {
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal:16,
paddingTop:12,
},
nameContainer: {
marginLeft: 2,
},
name: {
marginLeft: 4,
color: '$primaryDarkGray',
},
}); });

View File

@ -5,8 +5,9 @@ import styles from './quickReplyModalStyles';
import { forwardRef } from 'react'; import { forwardRef } from 'react';
import { View, Text } from 'react-native'; import { View, Text } from 'react-native';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { MainButton, TextButton, TextInput, UserAvatar } from '..'; import { MainButton, SummaryArea, TextInput, UserAvatar } from '..';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
export interface QuickReplyModalProps {} export interface QuickReplyModalProps {}
@ -16,13 +17,12 @@ const QuickReplyModal = ({}: QuickReplyModalProps, ref) => {
const [selectedPost, setSelectedPost] = useState(null); const [selectedPost, setSelectedPost] = useState(null);
const [commentValue, setCommentValue] = useState(''); const [commentValue, setCommentValue] = useState('');
const [expand, setExpand] = useState(false);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const sheetModalRef = useRef<ActionSheet>(); const sheetModalRef = useRef<ActionSheet>();
const inputRef = useRef<TextInput>(null);
// reset the state when post changes // reset the state when post changes
useEffect(() => { useEffect(() => {
setExpand(false);
setCommentValue(''); setCommentValue('');
}, [selectedPost]); }, [selectedPost]);
@ -32,43 +32,31 @@ const QuickReplyModal = ({}: QuickReplyModalProps, ref) => {
console.log('Showing action modal'); console.log('Showing action modal');
setSelectedPost(post); setSelectedPost(post);
sheetModalRef.current?.setModalVisible(true); sheetModalRef.current?.setModalVisible(true);
// wait for modal to open and then show the keyboard
setTimeout(() => {
inputRef.current?.focus();
}, 1000);
}, },
})); }));
//VIEW_RENDERERS //VIEW_RENDERERS
const _renderInitialView = () => { const _renderContent = () => {
return ( return (
<View style={styles.intialView}> <View style={styles.modalContainer}>
<UserAvatar username={currentAccount.name} disableSize style={styles.userAvatar} /> <SummaryArea summary={selectedPost.summary} />
<TextButton <View style={styles.avatarAndNameContainer}>
text={intl.formatMessage({ <UserAvatar noAction username={currentAccount.username} />
id: 'quick_reply.placeholder', <View style={styles.nameContainer}>
})} <Text style={styles.name}>{`@${currentAccount.username}`}</Text>
onPress={() => setExpand(true)}
style={styles.addCommentBtn}
textStyle={styles.btnText}
/>
</View> </View>
);
};
const _renderFullView = () => {
return (
<View style={styles.fullView}>
<View style={styles.modalHeader}>
<TextButton
text={selectedPost.title}
onPress={() => console.log('title pressed!')}
style={styles.titleBtn}
textStyle={styles.titleBtnTxt}
/>
</View> </View>
<View style={styles.inputContainer}> <View style={styles.inputContainer}>
<TextInput <TextInput
innerRef={inputRef}
onChangeText={setCommentValue} onChangeText={setCommentValue}
value={commentValue} value={commentValue}
autoFocus // autoFocus
placeholder={intl.formatMessage({ placeholder={intl.formatMessage({
id: 'quick_reply.placeholder', id: 'quick_reply.placeholder',
})} })}
@ -77,6 +65,7 @@ const QuickReplyModal = ({}: QuickReplyModalProps, ref) => {
style={styles.textInput} style={styles.textInput}
multiline={true} multiline={true}
numberOfLines={5} numberOfLines={5}
textAlignVertical="top"
/> />
</View> </View>
<View style={styles.footer}> <View style={styles.footer}>
@ -92,24 +81,17 @@ const QuickReplyModal = ({}: QuickReplyModalProps, ref) => {
</View> </View>
); );
}; };
const _renderContent = () => {
return (
<View style={styles.modalContainer}>
{!expand && _renderInitialView()}
{expand && _renderFullView()}
</View>
);
};
return ( return (
<ActionSheet <ActionSheet
ref={sheetModalRef} ref={sheetModalRef}
gestureEnabled={false} gestureEnabled={true}
hideUnderlay
containerStyle={styles.sheetContent} containerStyle={styles.sheetContent}
indicatorColor={EStyleSheet.value('$primaryWhiteLightBackground')} indicatorColor={EStyleSheet.value('$primaryWhiteLightBackground')}
> >
<KeyboardAwareScrollView enableOnAndroid={true}>
{selectedPost && _renderContent()} {selectedPost && _renderContent()}
</KeyboardAwareScrollView>
</ActionSheet> </ActionSheet>
); );
}; };