diff --git a/app/containers/Header/components/HeaderContainer/index.tsx b/app/containers/Header/components/HeaderContainer/index.tsx index bd7cb3ae5b0..ca8fae9c5e9 100644 --- a/app/containers/Header/components/HeaderContainer/index.tsx +++ b/app/containers/Header/components/HeaderContainer/index.tsx @@ -1,5 +1,5 @@ import React, { memo } from 'react'; -import { useWindowDimensions, View, type ViewProps, StyleSheet } from 'react-native'; +import { useWindowDimensions, View, type ViewProps, StyleSheet, Platform } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { useTheme } from '../../../../theme'; @@ -17,6 +17,7 @@ const HeaderContainer = memo( const insets = useSafeAreaInsets(); const { colors } = useTheme(); + const isAndroid = Platform.OS === 'android'; const { height, width } = useWindowDimensions(); const isPortrait = height > width; const paddingTop = isPortrait && !isMasterDetail ? 0 : 4; @@ -27,6 +28,7 @@ const HeaderContainer = memo( return ( ReactNode); + position?: 'left' | 'center' | 'right'; } -const HeaderTitle = memo(({ headerTitle }: IHeaderTitle) => { +type HeaderTitleProps = IHeaderTitle & TextProps; +const HeaderTitle = memo(({ headerTitle, position, ...props }: HeaderTitleProps) => { 'use memo'; const { colors } = useTheme(); @@ -24,8 +26,10 @@ const HeaderTitle = memo(({ headerTitle }: IHeaderTitle) => { numberOfLines={1} style={{ ...styles.androidTitle, - color: colors.fontTitlesLabels - }}> + color: colors.fontTitlesLabels, + alignSelf: position === 'left' ? 'flex-start' : 'center' + }} + {...props}> {headerTitle} ); @@ -36,8 +40,10 @@ const HeaderTitle = memo(({ headerTitle }: IHeaderTitle) => { numberOfLines={1} style={{ ...styles.title, - color: colors.fontTitlesLabels - }}> + color: colors.fontTitlesLabels, + alignSelf: position === 'left' ? 'flex-start' : 'center' + }} + {...props}> {headerTitle} diff --git a/app/containers/Header/components/HeaderTitle/styles.ts b/app/containers/Header/components/HeaderTitle/styles.ts index dd09abc8801..de6504bc1b4 100644 --- a/app/containers/Header/components/HeaderTitle/styles.ts +++ b/app/containers/Header/components/HeaderTitle/styles.ts @@ -10,16 +10,13 @@ export const styles = StyleSheet.create({ }, title: { ...sharedStyles.textBold, - fontSize: 18, - flex: 1, - lineHeight: 24, - paddingVertical: 6 + fontSize: 16, + justifyContent: 'center', + alignItems: 'center' }, androidTitle: { ...sharedStyles.textBold, fontSize: 18, - flex: 1, - lineHeight: 24, - paddingVertical: 10 + flex: 1 } }); diff --git a/app/containers/RoomHeader/RoomHeader.tsx b/app/containers/RoomHeader/RoomHeader.tsx index ec65eb792ea..cf96ae83812 100644 --- a/app/containers/RoomHeader/RoomHeader.tsx +++ b/app/containers/RoomHeader/RoomHeader.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { StyleSheet, Text, useWindowDimensions, View } from 'react-native'; -import { TouchableOpacity } from 'react-native-gesture-handler'; +import { Pressable } from 'react-native-gesture-handler'; -import { useResponsiveLayout } from '../../lib/hooks/useResponsiveLayout/useResponsiveLayout'; +import HeaderTitle from '../Header/components/HeaderTitle'; import I18n from '../../i18n'; import sharedStyles from '../../views/Styles'; import { MarkdownPreview } from '../markdown'; @@ -19,7 +19,6 @@ const HIT_SLOP = { bottom: 5, left: 5 }; -const TITLE_SIZE = 16; const SUBTITLE_SIZE = 12; const getSubTitleSize = (scale: number) => SUBTITLE_SIZE * scale; @@ -33,10 +32,6 @@ const styles = StyleSheet.create({ alignItems: 'center', flexDirection: 'row' }, - title: { - flexShrink: 1, - ...sharedStyles.textSemibold - }, subtitle: { flexShrink: 1, ...sharedStyles.textRegular @@ -53,14 +48,6 @@ type TRoomHeaderSubTitle = { scale: number; }; -type TRoomHeaderHeaderTitle = { - title?: string; - tmid?: string; - prid?: string; - scale: number; - testID?: string; -}; - interface IRoomHeader { title?: string; subtitle?: string; @@ -114,22 +101,6 @@ const SubTitle = React.memo(({ usersTyping, subtitle, renderFunc, scale }: TRoom return null; }); -const HeaderTitle = React.memo(({ title, tmid, prid, scale, testID }: TRoomHeaderHeaderTitle) => { - const { colors } = useTheme(); - const { isLargeFontScale } = useResponsiveLayout(); - - const titleStyle = { fontSize: TITLE_SIZE * scale, color: colors.fontTitlesLabels }; - if (!tmid && !prid) { - return ( - - {title} - - ); - } - - return ; -}); - const Header = React.memo( ({ title, @@ -198,7 +169,7 @@ const Header = React.memo( accessible accessibilityLabel={accessibilityLabel} accessibilityRole='header'> - + {tmid ? null : ( )} - + - + ); } diff --git a/app/containers/RoomHeader/__snapshots__/RoomHeader.test.tsx.snap b/app/containers/RoomHeader/__snapshots__/RoomHeader.test.tsx.snap index f75b0a2470e..ac9afd97058 100644 --- a/app/containers/RoomHeader/__snapshots__/RoomHeader.test.tsx.snap +++ b/app/containers/RoomHeader/__snapshots__/RoomHeader.test.tsx.snap @@ -30,11 +30,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -160,11 +149,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -290,11 +268,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -433,11 +387,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -563,11 +506,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -693,11 +625,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -823,11 +744,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -953,11 +863,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -1083,11 +982,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -1213,11 +1101,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -1343,11 +1220,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -1473,11 +1339,7 @@ exports[`Story Snapshots: Icons should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -1608,11 +1463,7 @@ exports[`Story Snapshots: Themes should match snapshot 1`] = ` > - - +  + + -  - + } + > - title - - - - subtitle - + } + } + > + title + + + + subtitle + , @@ -1771,11 +1615,7 @@ exports[`Story Snapshots: Themes should match snapshot 1`] = ` > - - +  + + -  - + } + > - title - - - - subtitle - + } + } + > + title + + + + subtitle + , @@ -1934,11 +1767,7 @@ exports[`Story Snapshots: Themes should match snapshot 1`] = ` > - - +  + + -  - + } + > - title - - - - subtitle - + } + } + > + title + + + + subtitle + , @@ -2102,11 +1924,7 @@ exports[`Story Snapshots: Thread should match snapshot 1`] = ` > @@ -2143,104 +1955,89 @@ exports[`Story Snapshots: Thread should match snapshot 1`] = ` style={ { "alignItems": "center", - "flexDirection": "row", + "flex": 1, + "justifyContent": "center", } } > title - + - + -  - - - parent title - - + ], + { + "fontFamily": "custom", + "fontStyle": "normal", + "fontWeight": "normal", + }, + {}, + ] + } + > +  + + + parent title + @@ -2277,11 +2074,7 @@ preview > @@ -2318,39 +2105,25 @@ preview style={ { "alignItems": "center", - "flexDirection": "row", + "flex": 1, + "justifyContent": "center", } } > - markdown preview #3 4 5 + markdown +preview +#3 +4 +5 - + - + -  - - - Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries - - + ], + { + "fontFamily": "custom", + "fontStyle": "normal", + "fontWeight": "normal", + }, + {}, + ] + } + > +  + + + Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries + @@ -2457,11 +2234,7 @@ exports[`Story Snapshots: TitleSubtitle should match snapshot 1`] = ` > - - + +  + + -  - + } + > @@ -2587,11 +2353,7 @@ exports[`Story Snapshots: TitleSubtitle should match snapshot 1`] = ` > - - +  + + -  - + } + > @@ -2717,11 +2472,7 @@ exports[`Story Snapshots: TitleSubtitle should match snapshot 1`] = ` > - - +  + + -  - + } + > - title - - - - subtitle - + } + } + > + title + + + + subtitle + , @@ -2880,11 +2624,7 @@ exports[`Story Snapshots: TitleSubtitle should match snapshot 1`] = ` > - - +  + + -  - + } + > - title - - - - Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries - + } + } + > + title + + + + Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries + , @@ -3043,11 +2776,7 @@ exports[`Story Snapshots: TitleSubtitle should match snapshot 1`] = ` > - - -  - + ], + { + "fontFamily": "custom", + "fontStyle": "normal", + "fontWeight": "normal", + }, + {}, + ] + } + > +  + + Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries - - Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries - + + Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries + , @@ -3212,11 +2934,7 @@ exports[`Story Snapshots: Typing should match snapshot 1`] = ` > - - -  - - - title - - - +  + + - user 1 - + title - is typing - ... - + + + + user 1 + + + is typing + ... + , @@ -3375,11 +3086,7 @@ exports[`Story Snapshots: Typing should match snapshot 1`] = ` > - - -  - - - title - - - +  + + - user 1 and user 2 - + title - are typing - ... - + + + + user 1 and user 2 + + + are typing + ... + , @@ -3538,11 +3238,7 @@ exports[`Story Snapshots: Typing should match snapshot 1`] = ` > - - -  - - - title - - - +  + + - user 1, user 2, user 3, user 4, user 5 - + title - are typing - ... - + + + + user 1, user 2, user 3, user 4, user 5 + + + are typing + ... + ,