11import * as React from 'react' ;
22import {
33 Animated ,
4- Platform ,
54 StyleProp ,
65 StyleSheet ,
76 View ,
87 ViewStyle ,
98 ColorValue ,
109} from 'react-native' ;
1110
12- import color from 'color' ;
13-
1411import AppbarContent from './AppbarContent' ;
1512import {
1613 AppbarModes ,
17- DEFAULT_APPBAR_HEIGHT ,
1814 getAppbarBackgroundColor ,
1915 modeAppbarHeight ,
2016 renderAppbarContent ,
@@ -165,11 +161,10 @@ const Appbar = ({
165161 ...rest
166162} : Props ) => {
167163 const theme = useInternalTheme ( themeOverrides ) ;
168- const { isV3 } = theme ;
169164 const flattenedStyle = StyleSheet . flatten ( style ) ;
170165 const {
171166 backgroundColor : customBackground ,
172- elevation = isV3 ? ( elevated ? 2 : 0 ) : 4 ,
167+ elevation = elevated ? 2 : 0 ,
173168 ...restStyle
174169 } = ( flattenedStyle || { } ) as Exclude < typeof flattenedStyle , number > & {
175170 elevation ?: number ;
@@ -178,34 +173,26 @@ const Appbar = ({
178173
179174 const backgroundColor = getAppbarBackgroundColor (
180175 theme ,
181- elevation ,
182176 customBackground ,
183177 elevated
184178 ) ;
185179
186180 const isMode = ( modeToCompare : AppbarModes ) => {
187- return isV3 && mode === modeToCompare ;
181+ return mode === modeToCompare ;
188182 } ;
189183
190184 let isDark = false ;
191185
192186 if ( typeof dark === 'boolean' ) {
193187 isDark = dark ;
194- } else if ( ! isV3 ) {
195- isDark =
196- backgroundColor === 'transparent'
197- ? false
198- : typeof backgroundColor === 'string'
199- ? ! color ( backgroundColor ) . isLight ( )
200- : true ;
201188 }
202189
203- const isV3CenterAlignedMode = isV3 && isMode ( 'center-aligned' ) ;
190+ const isCenterAlignedMode = isMode ( 'center-aligned' ) ;
204191
205192 let shouldCenterContent = false ;
206193 let shouldAddLeftSpacing = false ;
207194 let shouldAddRightSpacing = false ;
208- if ( ( ! isV3 && Platform . OS === 'ios' ) || isV3CenterAlignedMode ) {
195+ if ( isCenterAlignedMode ) {
209196 let hasAppbarContent = false ;
210197 let leftItemsCount = 0 ;
211198 let rightItemsCount = 0 ;
@@ -225,14 +212,12 @@ const Appbar = ({
225212 } ) ;
226213
227214 shouldCenterContent =
228- hasAppbarContent &&
229- leftItemsCount < 2 &&
230- rightItemsCount < ( isV3 ? 3 : 2 ) ;
215+ hasAppbarContent && leftItemsCount < 2 && rightItemsCount < 3 ;
231216 shouldAddLeftSpacing = shouldCenterContent && leftItemsCount === 0 ;
232217 shouldAddRightSpacing = shouldCenterContent && rightItemsCount === 0 ;
233218 }
234219
235- const spacingStyle = isV3 ? styles . v3Spacing : styles . spacing ;
220+ const spacingStyle = styles . v3Spacing ;
236221
237222 const insets = {
238223 paddingBottom : safeAreaInsets ?. bottom ,
@@ -247,26 +232,24 @@ const Appbar = ({
247232 { backgroundColor } ,
248233 styles . appbar ,
249234 {
250- height : isV3 ? modeAppbarHeight [ mode ] : DEFAULT_APPBAR_HEIGHT ,
235+ height : modeAppbarHeight [ mode ] ,
251236 } ,
252237 insets ,
253238 restStyle ,
254- ! theme . isV3 && { elevation } ,
255239 ] }
256240 elevation = { elevation as MD3Elevation }
257241 { ...rest }
258242 >
259243 { shouldAddLeftSpacing ? < View style = { spacingStyle } /> : null }
260- { ( ! isV3 || isMode ( 'small' ) || isMode ( 'center-aligned' ) ) && (
244+ { ( isMode ( 'small' ) || isMode ( 'center-aligned' ) ) && (
261245 < >
262246 { /* Render only the back action at first place */ }
263247 { renderAppbarContent ( {
264248 children,
265249 isDark,
266250 theme,
267- isV3,
268251 renderOnly : [ 'Appbar.BackAction' ] ,
269- shouldCenterContent : isV3CenterAlignedMode || shouldCenterContent ,
252+ shouldCenterContent : isCenterAlignedMode || shouldCenterContent ,
270253 } ) }
271254 { /* Render the rest of the content except the back action */ }
272255 { renderAppbarContent ( {
@@ -277,9 +260,8 @@ const Appbar = ({
277260 ] ,
278261 isDark,
279262 theme,
280- isV3,
281263 renderExcept : [ 'Appbar.BackAction' ] ,
282- shouldCenterContent : isV3CenterAlignedMode || shouldCenterContent ,
264+ shouldCenterContent : isCenterAlignedMode || shouldCenterContent ,
283265 } ) }
284266 </ >
285267 ) }
@@ -296,14 +278,12 @@ const Appbar = ({
296278 { renderAppbarContent ( {
297279 children,
298280 isDark,
299- isV3,
300281 renderOnly : [ 'Appbar.BackAction' ] ,
301282 mode,
302283 } ) }
303284 { renderAppbarContent ( {
304285 children : filterAppbarActions ( children , true ) ,
305286 isDark,
306- isV3,
307287 renderOnly : [ 'Appbar.Action' ] ,
308288 mode,
309289 } ) }
@@ -312,7 +292,6 @@ const Appbar = ({
312292 { renderAppbarContent ( {
313293 children : filterAppbarActions ( children ) ,
314294 isDark,
315- isV3,
316295 renderExcept : [
317296 'Appbar' ,
318297 'Appbar.BackAction' ,
@@ -326,7 +305,6 @@ const Appbar = ({
326305 { renderAppbarContent ( {
327306 children,
328307 isDark,
329- isV3,
330308 renderOnly : [ 'Appbar.Content' ] ,
331309 mode,
332310 } ) }
@@ -343,9 +321,6 @@ const styles = StyleSheet.create({
343321 alignItems : 'center' ,
344322 paddingHorizontal : 4 ,
345323 } ,
346- spacing : {
347- width : 48 ,
348- } ,
349324 v3Spacing : {
350325 width : 52 ,
351326 } ,
0 commit comments