From 4eda2ca12b174bb2d35fdda481cd43f0bb843c1e Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Sun, 8 Aug 2021 19:42:42 +0500 Subject: [PATCH 1/2] updated post description time and reputation placement --- .../basicUIElements/view/tag/tagContainer.js | 2 + .../basicUIElements/view/tag/tagView.js | 3 +- src/components/comment/view/commentView.js | 3 +- .../view/postHeaderDescription.js | 64 +++++++++++-------- .../view/postHeaderDescriptionStyles.js | 17 ++++- .../postView/view/postDisplayView.js | 3 +- .../container/applicationContainer.js | 4 +- src/utils/time.js | 22 +++++++ 8 files changed, 84 insertions(+), 34 deletions(-) diff --git a/src/components/basicUIElements/view/tag/tagContainer.js b/src/components/basicUIElements/view/tag/tagContainer.js index 6624cf730..4f520a61c 100644 --- a/src/components/basicUIElements/view/tag/tagContainer.js +++ b/src/components/basicUIElements/view/tag/tagContainer.js @@ -30,6 +30,7 @@ const TagContainer = ({ disabled, communityTitle, prefix, + suffix, }) => { const [label, setLabel] = useState(value); const [isCommunity, setIsCommunity] = useState(false); @@ -94,6 +95,7 @@ const TagContainer = ({ textStyle={textStyle} disabled={disabled} prefix={prefix} + suffix={suffix} /> ); }; diff --git a/src/components/basicUIElements/view/tag/tagView.js b/src/components/basicUIElements/view/tag/tagView.js index d3ab91ce1..bef3f5f81 100644 --- a/src/components/basicUIElements/view/tag/tagView.js +++ b/src/components/basicUIElements/view/tag/tagView.js @@ -13,6 +13,7 @@ const Tag = ({ textStyle, disabled, prefix, + suffix, }) => ( - {`${prefix ? prefix : ''} ${label} `} + {`${prefix ? prefix : ''} ${label}${suffix ? suffix : ''}`} diff --git a/src/components/comment/view/commentView.js b/src/components/comment/view/commentView.js index de85ac6f5..a716f8dab 100644 --- a/src/components/comment/view/commentView.js +++ b/src/components/comment/view/commentView.js @@ -69,10 +69,11 @@ const CommentView = ({ date={getTimeFromNow(comment.created)} name={comment.author} reputation={comment.author_reputation} - size={avatarSize || 36} + size={avatarSize || 40} currentAccountUsername={currentAccountUsername} isShowOwnerIndicator={mainAuthor === comment.author} isHideImage={isHideImage} + inlineTime={true} /> @@ -97,13 +97,18 @@ class PostHeaderDescription extends PureComponent { onPress={() => this._handleOnUserPress(name)} > {!isHideImage && ( - + <> + + + {reputation} + + )} @@ -113,41 +118,46 @@ class PostHeaderDescription extends PureComponent { onPress={() => this._handleOnUserPress(name)} > {name} - {_reputationText} + + {inlineTime && ( + + {isPromoted ? intl.formatMessage({ id: 'post.sponsored' }) : date} + + )} + {isShowOwnerIndicator && ( )} + {content && ( this._handleOnTagPress(content)}> - - - - {isPromoted ? intl.formatMessage({ id: 'post.sponsored' }) : date} - - + )} + {!!tag && ( (tagOnPress && tagOnPress()) || this._handleOnTagPress(tag)} > - - - - {isPromoted ? intl.formatMessage({ id: 'post.sponsored' }) : date} - - + )} + + {!inlineTime && ( + + {isPromoted ? intl.formatMessage({ id: 'post.sponsored' }) : date} + + )} diff --git a/src/components/postElements/headerDescription/view/postHeaderDescriptionStyles.js b/src/components/postElements/headerDescription/view/postHeaderDescriptionStyles.js index 525be9696..8b00de1c5 100644 --- a/src/components/postElements/headerDescription/view/postHeaderDescriptionStyles.js +++ b/src/components/postElements/headerDescription/view/postHeaderDescriptionStyles.js @@ -10,13 +10,16 @@ export default EStyleSheet.create({ }, primaryDetails: { flexDirection: 'row', + alignItems: 'center', }, secondaryDetails: { flexDirection: 'row', + alignItems: 'center', marginHorizontal: 3, }, tagDetails: { flexDirection: 'row', + alignItems: 'center', }, rightContainer: { flexDirection: 'column', @@ -37,21 +40,29 @@ export default EStyleSheet.create({ fontWeight: 'bold', alignSelf: 'center', }, + reputationWrapper: { + position: 'absolute', + bottom: -2, + left: -2, + backgroundColor: '$iconColor', + borderRadius: 20, + }, reputation: { - fontSize: 12, + fontSize: 10, color: '$primaryDarkGray', - marginRight: 8, alignSelf: 'center', + fontWeight: 'bold', + padding: 4, }, date: { fontSize: 14, fontWeight: '300', - marginVertical: 5, color: '$primaryDarkGray', }, topic: { marginVertical: 3, marginRight: 0, + paddingRight: 0, marginLeft: 0, paddingLeft: 0, borderRadius: 0, diff --git a/src/components/postView/view/postDisplayView.js b/src/components/postView/view/postDisplayView.js index ae3441143..9e81df1ae 100644 --- a/src/components/postView/view/postDisplayView.js +++ b/src/components/postView/view/postDisplayView.js @@ -221,7 +221,8 @@ const PostDisplayView = ({ name={author || post.author} currentAccountUsername={name} reputation={post.author_reputation} - size={36} + size={40} + inlineTime={true} /> {!postBodyLoading && ( diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js index 1979d028a..f5ab230bd 100644 --- a/src/screens/application/container/applicationContainer.js +++ b/src/screens/application/container/applicationContainer.js @@ -106,7 +106,7 @@ import darkTheme from '../../../themes/darkTheme'; import lightTheme from '../../../themes/lightTheme'; import persistAccountGenerator from '../../../utils/persistAccountGenerator'; import parseVersionNumber from '../../../utils/parseVersionNumber'; -import { getTimeFromNow } from '../../../utils/time'; +import { getTimeFromNow, setMomentLocale } from '../../../utils/time'; // Workaround let previousAppState = 'background'; @@ -180,6 +180,8 @@ class ApplicationContainer extends Component { } }); + setMomentLocale(); + ReceiveSharingIntent.getReceivedFiles( () => { navigate({ diff --git a/src/utils/time.js b/src/utils/time.js index b50e3820d..44eb797f6 100644 --- a/src/utils/time.js +++ b/src/utils/time.js @@ -52,6 +52,28 @@ export const getTimeFromNowNative = (d) => { } return { unit: 'day', value: future ? Math.round(diff / DAY) : -Math.round(diff / DAY) }; }; + +export const setMomentLocale = () => { + moment.locale('en', { + relativeTime: { + future: 'in %s', + past: '%s', + s: '1s', + ss: '%ss', + m: '1m', + mm: '%dm', + h: '1h', + hh: '%dh', + d: '1d', + dd: '%dd', + M: '1M', + MM: '%dM', + y: '1Y', + yy: '%dY', + }, + }); +}; + export const getTimeFromNow = (value, isWithoutUtc) => { if (!value) { return null; From 537abd674085da97783ebe1a57774f0cdebb24b4 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Sun, 8 Aug 2021 19:51:40 +0500 Subject: [PATCH 2/2] updated reputation badge style --- .../headerDescription/view/postHeaderDescriptionStyles.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/postElements/headerDescription/view/postHeaderDescriptionStyles.js b/src/components/postElements/headerDescription/view/postHeaderDescriptionStyles.js index 8b00de1c5..6cc432331 100644 --- a/src/components/postElements/headerDescription/view/postHeaderDescriptionStyles.js +++ b/src/components/postElements/headerDescription/view/postHeaderDescriptionStyles.js @@ -44,8 +44,10 @@ export default EStyleSheet.create({ position: 'absolute', bottom: -2, left: -2, - backgroundColor: '$iconColor', + backgroundColor: '$white', borderRadius: 20, + borderWidth: EStyleSheet.hairlineWidth, + borderColor: '$primaryDarkGray', }, reputation: { fontSize: 10,