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,27 +232,25 @@ 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 container
258242 { ...rest }
259243 >
260244 { shouldAddLeftSpacing ? < View style = { spacingStyle } /> : null }
261- { ( ! isV3 || isMode ( 'small' ) || isMode ( 'center-aligned' ) ) && (
245+ { ( isMode ( 'small' ) || isMode ( 'center-aligned' ) ) && (
262246 < >
263247 { /* Render only the back action at first place */ }
264248 { renderAppbarContent ( {
265249 children,
266250 isDark,
267251 theme,
268- isV3,
269252 renderOnly : [ 'Appbar.BackAction' ] ,
270- shouldCenterContent : isV3CenterAlignedMode || shouldCenterContent ,
253+ shouldCenterContent : isCenterAlignedMode || shouldCenterContent ,
271254 } ) }
272255 { /* Render the rest of the content except the back action */ }
273256 { renderAppbarContent ( {
@@ -278,9 +261,8 @@ const Appbar = ({
278261 ] ,
279262 isDark,
280263 theme,
281- isV3,
282264 renderExcept : [ 'Appbar.BackAction' ] ,
283- shouldCenterContent : isV3CenterAlignedMode || shouldCenterContent ,
265+ shouldCenterContent : isCenterAlignedMode || shouldCenterContent ,
284266 } ) }
285267 </ >
286268 ) }
@@ -297,14 +279,12 @@ const Appbar = ({
297279 { renderAppbarContent ( {
298280 children,
299281 isDark,
300- isV3,
301282 renderOnly : [ 'Appbar.BackAction' ] ,
302283 mode,
303284 } ) }
304285 { renderAppbarContent ( {
305286 children : filterAppbarActions ( children , true ) ,
306287 isDark,
307- isV3,
308288 renderOnly : [ 'Appbar.Action' ] ,
309289 mode,
310290 } ) }
@@ -313,7 +293,6 @@ const Appbar = ({
313293 { renderAppbarContent ( {
314294 children : filterAppbarActions ( children ) ,
315295 isDark,
316- isV3,
317296 renderExcept : [
318297 'Appbar' ,
319298 'Appbar.BackAction' ,
@@ -327,7 +306,6 @@ const Appbar = ({
327306 { renderAppbarContent ( {
328307 children,
329308 isDark,
330- isV3,
331309 renderOnly : [ 'Appbar.Content' ] ,
332310 mode,
333311 } ) }
@@ -344,9 +322,6 @@ const styles = StyleSheet.create({
344322 alignItems : 'center' ,
345323 paddingHorizontal : 4 ,
346324 } ,
347- spacing : {
348- width : 48 ,
349- } ,
350325 v3Spacing : {
351326 width : 52 ,
352327 } ,
0 commit comments