aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/moments/MomentPost.tsx42
-rw-r--r--src/routes/main/MainStackScreen.tsx27
2 files changed, 38 insertions, 31 deletions
diff --git a/src/components/moments/MomentPost.tsx b/src/components/moments/MomentPost.tsx
index eae95fe2..d95d6f3a 100644
--- a/src/components/moments/MomentPost.tsx
+++ b/src/components/moments/MomentPost.tsx
@@ -25,7 +25,7 @@ import Video from 'react-native-video';
import {useDispatch, useSelector, useStore} from 'react-redux';
import {TaggedUsersDrawer} from '.';
import PauseIcon from '../../assets/icons/pause-icon.svg';
-import {headerBarOptions} from '../../routes';
+import {headerBarOptions, multilineHeaderTitle} from '../../routes';
import {MomentContext} from '../../screens/profile/IndividualMoment';
import {deleteMomentTag, loadMomentTags} from '../../services';
import {loadUserMoments} from '../../store/actions';
@@ -129,28 +129,18 @@ const MomentPost: React.FC<MomentPostProps> = ({
}
};
- useEffect(
- () =>
+ useEffect(() => {
+ if (moment.moment_category.length > 20) {
navigation.setOptions({
...headerBarOptions('white', ''),
- headerTitle: () => (
- <Text
- numberOfLines={3}
- style={[
- styles.multilineHeaderTitle,
- {
- fontSize:
- moment.moment_category.length > 18
- ? normalize(14)
- : normalize(16),
- },
- ]}>
- {moment.moment_category}
- </Text>
- ),
- }),
- [moment.moment_id],
- );
+ ...multilineHeaderTitle(moment.moment_category),
+ });
+ } else {
+ navigation.setOptions({
+ ...headerBarOptions('white', moment.moment_category),
+ });
+ }
+ }, [moment.moment_id]);
/*
* Determines if an image is 9:16 to set aspect ratio of current image and
@@ -506,16 +496,6 @@ const styles = StyleSheet.create({
profilePreviewContainer: {
paddingHorizontal: '3%',
},
- multilineHeaderTitle: {
- width: SCREEN_WIDTH * 0.7,
- height: normalize(70),
- marginTop: normalize(90) / 2,
- textAlign: 'center',
- lineHeight: normalize(21.48),
- letterSpacing: normalize(1.3),
- fontWeight: '700',
- color: 'white',
- },
});
export default MomentPost;
diff --git a/src/routes/main/MainStackScreen.tsx b/src/routes/main/MainStackScreen.tsx
index 35e1f8e0..64060554 100644
--- a/src/routes/main/MainStackScreen.tsx
+++ b/src/routes/main/MainStackScreen.tsx
@@ -393,6 +393,23 @@ export const headerBarOptions: (
),
});
+export const multilineHeaderTitle: (title: string) => StackNavigationOptions = (
+ title,
+) => ({
+ headerTitle: () => (
+ <Text
+ numberOfLines={3}
+ style={[
+ styles.multilineHeaderTitle,
+ {
+ fontSize: title.length > 18 ? normalize(14) : normalize(16),
+ },
+ ]}>
+ {title}
+ </Text>
+ ),
+});
+
export const modalStyle: StackNavigationOptions = {
cardStyle: {backgroundColor: 'rgba(80,80,80,0.6)'},
gestureDirection: 'vertical',
@@ -424,6 +441,16 @@ const styles = StyleSheet.create({
letterSpacing: normalize(1.3),
fontWeight: '700',
},
+ multilineHeaderTitle: {
+ width: SCREEN_WIDTH * 0.7,
+ height: normalize(70),
+ marginTop: normalize(90) / 2,
+ textAlign: 'center',
+ lineHeight: normalize(21.48),
+ letterSpacing: normalize(1.3),
+ fontWeight: '700',
+ color: 'white',
+ },
});
export default MainStackScreen;