-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: use the headerTitle in the Header/components folder for RoomHeader
#6805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
a058a55
62e0172
367718c
7d95908
8dba0f5
f70ab25
299853b
87827d4
d5222b7
8fdf16e
8c70b54
1e77337
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -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; | ||||||||||||||
|
|
@@ -115,22 +102,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 ( | ||||||||||||||
| <Text style={[styles.title, titleStyle]} numberOfLines={isLargeFontScale ? 2 : 1} testID={testID}> | ||||||||||||||
| {title} | ||||||||||||||
| </Text> | ||||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| return <MarkdownPreview msg={title} style={[styles.title, titleStyle]} testID={testID} />; | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| const Header = React.memo( | ||||||||||||||
| ({ | ||||||||||||||
| title, | ||||||||||||||
|
|
@@ -201,7 +172,7 @@ const Header = React.memo( | |||||||||||||
| accessible | ||||||||||||||
| accessibilityLabel={accessibilityLabel} | ||||||||||||||
| accessibilityRole='header'> | ||||||||||||||
| <TouchableOpacity testID='room-header' onPress={handleOnPress} disabled={disabled} hitSlop={HIT_SLOP}> | ||||||||||||||
| <Pressable testID='room-header' onPress={handleOnPress} disabled={disabled} hitSlop={HIT_SLOP}> | ||||||||||||||
| <View style={styles.titleContainer}> | ||||||||||||||
| {tmid ? null : ( | ||||||||||||||
| <RoomTypeIcon | ||||||||||||||
|
|
@@ -214,10 +185,10 @@ const Header = React.memo( | |||||||||||||
| abacAttributes={abacAttributes} | ||||||||||||||
| /> | ||||||||||||||
| )} | ||||||||||||||
| <HeaderTitle title={title} tmid={tmid} prid={prid} scale={scale} testID={testID} /> | ||||||||||||||
| <HeaderTitle headerTitle={title ?? ''} testID={testID} position='left' /> | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hard-coded The PR description states "On Android the headerTitle is left-aligned; on iOS it is centered," but the 📱 Proposed fix for platform-specific alignment+import { Platform } from 'react-native';
+
// ... inside the component
- <HeaderTitle headerTitle={title ?? ''} testID={testID} position='left' />
+ <HeaderTitle headerTitle={title ?? ''} testID={testID} position={Platform.OS === 'ios' ? 'center' : 'left'} />📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| </View> | ||||||||||||||
| <SubTitle usersTyping={tmid ? [] : usersTyping} subtitle={subtitle} renderFunc={renderFunc} scale={scale} /> | ||||||||||||||
| </TouchableOpacity> | ||||||||||||||
| </Pressable> | ||||||||||||||
| </View> | ||||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle all position values explicitly.
The current implementation only distinguishes between
'left'and everything else (defaulting to'center'). The'right'position value is accepted by the type but would incorrectly render as centered. Consider implementing all three position values explicitly.Apply this diff to handle all position values:
And similarly for the non-Android branch:
Also applies to: 44-44
🤖 Prompt for AI Agents