@@ -6,12 +6,17 @@ import {
66 Platform ,
77 StyleSheet ,
88 LayoutChangeEvent ,
9- MaskedViewIOS ,
9+ UIManager ,
1010} from 'react-native' ;
1111import Animated from 'react-native-reanimated' ;
12+ import MaskedView from '@react-native-community/masked-view' ;
1213import TouchableItem from '../TouchableItem' ;
1314import { HeaderBackButtonProps } from '../../types' ;
1415
16+ const isMaskedViewAvailable =
17+ // @ts -ignore
18+ UIManager . getViewManagerConfig ( 'RNCMaskedView' ) != null ;
19+
1520type Props = HeaderBackButtonProps & {
1621 tintColor : string ;
1722} ;
@@ -95,33 +100,43 @@ class HeaderBackButton extends React.Component<Props, State> {
95100 }
96101
97102 const labelElement = (
98- < Animated . Text
99- accessible = { false }
100- onLayout = {
101- // This measurement is used to determine if we should truncate the label when it doesn't fit
102- // Only measure it when label is not truncated because we want the measurement of full label
103- leftLabelText === label ? this . handleLabelLayout : undefined
103+ < View
104+ style = {
105+ screenLayout
106+ ? // We make the button extend till the middle of the screen
107+ // Otherwise it appears to cut off when translating
108+ [ styles . labelWrapper , { minWidth : screenLayout . width / 2 - 27 } ]
109+ : null
104110 }
105- style = { [
106- styles . label ,
107- tintColor ? { color : tintColor } : null ,
108- labelStyle ,
109- ] }
110- numberOfLines = { 1 }
111- allowFontScaling = { ! ! allowFontScaling }
112111 >
113- { leftLabelText }
114- </ Animated . Text >
112+ < Animated . Text
113+ accessible = { false }
114+ onLayout = {
115+ // This measurement is used to determine if we should truncate the label when it doesn't fit
116+ // Only measure it when label is not truncated because we want the measurement of full label
117+ leftLabelText === label ? this . handleLabelLayout : undefined
118+ }
119+ style = { [
120+ styles . label ,
121+ tintColor ? { color : tintColor } : null ,
122+ labelStyle ,
123+ ] }
124+ numberOfLines = { 1 }
125+ allowFontScaling = { ! ! allowFontScaling }
126+ >
127+ { leftLabelText }
128+ </ Animated . Text >
129+ </ View >
115130 ) ;
116131
117- if ( backImage || Platform . OS !== 'ios' ) {
132+ if ( ! isMaskedViewAvailable || backImage || Platform . OS !== 'ios' ) {
118133 // When a custom backimage is specified, we can't mask the label
119134 // Otherwise there might be weird effect due to our mask not being the same as the image
120135 return labelElement ;
121136 }
122137
123138 return (
124- < MaskedViewIOS
139+ < MaskedView
125140 maskElement = {
126141 < View style = { styles . iconMaskContainer } >
127142 < Image
@@ -132,18 +147,8 @@ class HeaderBackButton extends React.Component<Props, State> {
132147 </ View >
133148 }
134149 >
135- < View
136- style = {
137- screenLayout
138- ? // We make the button extend till the middle of the screen
139- // Otherwise it appears to cut off when translating
140- [ styles . labelWrapper , { minWidth : screenLayout . width / 2 - 27 } ]
141- : null
142- }
143- >
144- { labelElement }
145- </ View >
146- </ MaskedViewIOS >
150+ { labelElement }
151+ </ MaskedView >
147152 ) ;
148153 }
149154
0 commit comments