1
1
import * as React from 'react' ;
2
2
import {
3
3
Animated ,
4
- Platform ,
5
4
StyleProp ,
6
5
StyleSheet ,
7
6
View ,
8
7
ViewStyle ,
9
8
ColorValue ,
10
9
} from 'react-native' ;
11
10
12
- import color from 'color' ;
13
-
14
11
import AppbarContent from './AppbarContent' ;
15
12
import {
16
13
AppbarModes ,
17
- DEFAULT_APPBAR_HEIGHT ,
18
14
getAppbarBackgroundColor ,
19
15
modeAppbarHeight ,
20
16
renderAppbarContent ,
@@ -165,11 +161,10 @@ const Appbar = ({
165
161
...rest
166
162
} : Props ) => {
167
163
const theme = useInternalTheme ( themeOverrides ) ;
168
- const { isV3 } = theme ;
169
164
const flattenedStyle = StyleSheet . flatten ( style ) ;
170
165
const {
171
166
backgroundColor : customBackground ,
172
- elevation = isV3 ? ( elevated ? 2 : 0 ) : 4 ,
167
+ elevation = elevated ? 2 : 0 ,
173
168
...restStyle
174
169
} = ( flattenedStyle || { } ) as Exclude < typeof flattenedStyle , number > & {
175
170
elevation ?: number ;
@@ -178,34 +173,26 @@ const Appbar = ({
178
173
179
174
const backgroundColor = getAppbarBackgroundColor (
180
175
theme ,
181
- elevation ,
182
176
customBackground ,
183
177
elevated
184
178
) ;
185
179
186
180
const isMode = ( modeToCompare : AppbarModes ) => {
187
- return isV3 && mode === modeToCompare ;
181
+ return mode === modeToCompare ;
188
182
} ;
189
183
190
184
let isDark = false ;
191
185
192
186
if ( typeof dark === 'boolean' ) {
193
187
isDark = dark ;
194
- } else if ( ! isV3 ) {
195
- isDark =
196
- backgroundColor === 'transparent'
197
- ? false
198
- : typeof backgroundColor === 'string'
199
- ? ! color ( backgroundColor ) . isLight ( )
200
- : true ;
201
188
}
202
189
203
- const isV3CenterAlignedMode = isV3 && isMode ( 'center-aligned' ) ;
190
+ const isCenterAlignedMode = isMode ( 'center-aligned' ) ;
204
191
205
192
let shouldCenterContent = false ;
206
193
let shouldAddLeftSpacing = false ;
207
194
let shouldAddRightSpacing = false ;
208
- if ( ( ! isV3 && Platform . OS === 'ios' ) || isV3CenterAlignedMode ) {
195
+ if ( isCenterAlignedMode ) {
209
196
let hasAppbarContent = false ;
210
197
let leftItemsCount = 0 ;
211
198
let rightItemsCount = 0 ;
@@ -225,14 +212,12 @@ const Appbar = ({
225
212
} ) ;
226
213
227
214
shouldCenterContent =
228
- hasAppbarContent &&
229
- leftItemsCount < 2 &&
230
- rightItemsCount < ( isV3 ? 3 : 2 ) ;
215
+ hasAppbarContent && leftItemsCount < 2 && rightItemsCount < 3 ;
231
216
shouldAddLeftSpacing = shouldCenterContent && leftItemsCount === 0 ;
232
217
shouldAddRightSpacing = shouldCenterContent && rightItemsCount === 0 ;
233
218
}
234
219
235
- const spacingStyle = isV3 ? styles . v3Spacing : styles . spacing ;
220
+ const spacingStyle = styles . v3Spacing ;
236
221
237
222
const insets = {
238
223
paddingBottom : safeAreaInsets ?. bottom ,
@@ -247,26 +232,24 @@ const Appbar = ({
247
232
{ backgroundColor } ,
248
233
styles . appbar ,
249
234
{
250
- height : isV3 ? modeAppbarHeight [ mode ] : DEFAULT_APPBAR_HEIGHT ,
235
+ height : modeAppbarHeight [ mode ] ,
251
236
} ,
252
237
insets ,
253
238
restStyle ,
254
- ! theme . isV3 && { elevation } ,
255
239
] }
256
240
elevation = { elevation as MD3Elevation }
257
241
{ ...rest }
258
242
>
259
243
{ shouldAddLeftSpacing ? < View style = { spacingStyle } /> : null }
260
- { ( ! isV3 || isMode ( 'small' ) || isMode ( 'center-aligned' ) ) && (
244
+ { ( isMode ( 'small' ) || isMode ( 'center-aligned' ) ) && (
261
245
< >
262
246
{ /* Render only the back action at first place */ }
263
247
{ renderAppbarContent ( {
264
248
children,
265
249
isDark,
266
250
theme,
267
- isV3,
268
251
renderOnly : [ 'Appbar.BackAction' ] ,
269
- shouldCenterContent : isV3CenterAlignedMode || shouldCenterContent ,
252
+ shouldCenterContent : isCenterAlignedMode || shouldCenterContent ,
270
253
} ) }
271
254
{ /* Render the rest of the content except the back action */ }
272
255
{ renderAppbarContent ( {
@@ -277,9 +260,8 @@ const Appbar = ({
277
260
] ,
278
261
isDark,
279
262
theme,
280
- isV3,
281
263
renderExcept : [ 'Appbar.BackAction' ] ,
282
- shouldCenterContent : isV3CenterAlignedMode || shouldCenterContent ,
264
+ shouldCenterContent : isCenterAlignedMode || shouldCenterContent ,
283
265
} ) }
284
266
</ >
285
267
) }
@@ -296,14 +278,12 @@ const Appbar = ({
296
278
{ renderAppbarContent ( {
297
279
children,
298
280
isDark,
299
- isV3,
300
281
renderOnly : [ 'Appbar.BackAction' ] ,
301
282
mode,
302
283
} ) }
303
284
{ renderAppbarContent ( {
304
285
children : filterAppbarActions ( children , true ) ,
305
286
isDark,
306
- isV3,
307
287
renderOnly : [ 'Appbar.Action' ] ,
308
288
mode,
309
289
} ) }
@@ -312,7 +292,6 @@ const Appbar = ({
312
292
{ renderAppbarContent ( {
313
293
children : filterAppbarActions ( children ) ,
314
294
isDark,
315
- isV3,
316
295
renderExcept : [
317
296
'Appbar' ,
318
297
'Appbar.BackAction' ,
@@ -326,7 +305,6 @@ const Appbar = ({
326
305
{ renderAppbarContent ( {
327
306
children,
328
307
isDark,
329
- isV3,
330
308
renderOnly : [ 'Appbar.Content' ] ,
331
309
mode,
332
310
} ) }
@@ -343,9 +321,6 @@ const styles = StyleSheet.create({
343
321
alignItems : 'center' ,
344
322
paddingHorizontal : 4 ,
345
323
} ,
346
- spacing : {
347
- width : 48 ,
348
- } ,
349
324
v3Spacing : {
350
325
width : 52 ,
351
326
} ,
0 commit comments