11import React from 'react' ;
2- import { View , Text } from 'react-native' ;
2+ import { View , Text , StyleSheet } from 'react-native' ;
33import { NavigationComponent , NavigationProps , Navigation as Nav } from 'react-native-navigation' ;
44import Button from '../components/Button' ;
55import Root from '../components/Root' ;
@@ -11,6 +11,8 @@ const {
1111 TOPBAR_TITLE_AVATAR ,
1212 SET_TOPBAR_WITH_SUBTITLE_BTN ,
1313 SET_TOPBAR_WITHOUT_SUBTITLE_BTN ,
14+ SET_TOPBAR_CENTER_WITH_BUTTONS_BTN ,
15+ SET_TOPBAR_FILL_WITH_BUTTONS_BTN ,
1416} = testIDs ;
1517
1618// TopBar title component WITH subtitle
@@ -53,8 +55,37 @@ function TopBarWithoutSubtitle() {
5355 ) ;
5456}
5557
58+ // Mimics an inbox conversation header: avatar + long name + status line.
59+ // With center alignment + right buttons, ellipsizeMode won't fire because
60+ // TitleBarReactView measures with UNSPECIFIED — the text renders at full
61+ // natural width and gets clipped behind the buttons.
62+ function InboxConversationHeader ( ) {
63+ return (
64+ < View style = { inboxStyles . row } >
65+ < View style = { inboxStyles . avatar } />
66+ < View style = { inboxStyles . textContainer } >
67+ < Text numberOfLines = { 1 } ellipsizeMode = "tail" style = { inboxStyles . name } >
68+ John Jacob Jingleheimer Schmidt-Wolfeschlegelsteinhausen
69+ </ Text >
70+ < Text numberOfLines = { 1 } ellipsizeMode = "tail" style = { inboxStyles . status } >
71+ Online - Last message received 2 minutes ago via mobile
72+ </ Text >
73+ </ View >
74+ </ View >
75+ ) ;
76+ }
77+
78+ const inboxStyles = StyleSheet . create ( {
79+ row : { flexDirection : 'row' , alignItems : 'center' , flex : 1 } ,
80+ avatar : { width : 32 , height : 32 , borderRadius : 16 , backgroundColor : '#4A90D9' , marginRight : 8 } ,
81+ textContainer : { flex : 1 , justifyContent : 'center' } ,
82+ name : { fontSize : 16 , fontWeight : '600' , color : '#000' } ,
83+ status : { fontSize : 12 , color : '#888' } ,
84+ } ) ;
85+
5686Nav . registerComponent ( 'TopBarWithSubtitle' , ( ) => TopBarWithSubtitle ) ;
5787Nav . registerComponent ( 'TopBarWithoutSubtitle' , ( ) => TopBarWithoutSubtitle ) ;
88+ Nav . registerComponent ( 'InboxConversationHeader' , ( ) => InboxConversationHeader ) ;
5889
5990interface Props extends NavigationProps { }
6091
@@ -90,6 +121,16 @@ export default class TopBarTitleTestScreen extends NavigationComponent<Props> {
90121 testID = { SET_TOPBAR_WITHOUT_SUBTITLE_BTN }
91122 onPress = { this . setTopBarWithoutSubtitle }
92123 />
124+ < Button
125+ label = "Center + Right Buttons (Cut-off Bug)"
126+ testID = { SET_TOPBAR_CENTER_WITH_BUTTONS_BTN }
127+ onPress = { this . setCenterWithRightButtons }
128+ />
129+ < Button
130+ label = "Fill + Right Buttons (Working)"
131+ testID = { SET_TOPBAR_FILL_WITH_BUTTONS_BTN }
132+ onPress = { this . setFillWithRightButtons }
133+ />
93134 </ Root >
94135 ) ;
95136 }
@@ -117,5 +158,37 @@ export default class TopBarTitleTestScreen extends NavigationComponent<Props> {
117158 } ,
118159 } ,
119160 } ) ;
161+
162+ setCenterWithRightButtons = ( ) =>
163+ Navigation . mergeOptions ( this , {
164+ topBar : {
165+ rightButtons : [
166+ { id : 'SEARCH' , icon : require ( '../../img/clear.png' ) } ,
167+ { id : 'MORE' , icon : require ( '../../img/star.png' ) } ,
168+ ] ,
169+ title : {
170+ component : {
171+ name : 'InboxConversationHeader' ,
172+ alignment : 'center' ,
173+ } ,
174+ } ,
175+ } ,
176+ } ) ;
177+
178+ setFillWithRightButtons = ( ) =>
179+ Navigation . mergeOptions ( this , {
180+ topBar : {
181+ rightButtons : [
182+ { id : 'SEARCH' , icon : require ( '../../img/clear.png' ) } ,
183+ { id : 'MORE' , icon : require ( '../../img/star.png' ) } ,
184+ ] ,
185+ title : {
186+ component : {
187+ name : 'InboxConversationHeader' ,
188+ alignment : 'fill' ,
189+ } ,
190+ } ,
191+ } ,
192+ } ) ;
120193}
121194
0 commit comments