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,27 +232,25 @@ 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
container
258
242
{ ...rest }
259
243
>
260
244
{ shouldAddLeftSpacing ? < View style = { spacingStyle } /> : null }
261
- { ( ! isV3 || isMode ( 'small' ) || isMode ( 'center-aligned' ) ) && (
245
+ { ( isMode ( 'small' ) || isMode ( 'center-aligned' ) ) && (
262
246
< >
263
247
{ /* Render only the back action at first place */ }
264
248
{ renderAppbarContent ( {
265
249
children,
266
250
isDark,
267
251
theme,
268
- isV3,
269
252
renderOnly : [ 'Appbar.BackAction' ] ,
270
- shouldCenterContent : isV3CenterAlignedMode || shouldCenterContent ,
253
+ shouldCenterContent : isCenterAlignedMode || shouldCenterContent ,
271
254
} ) }
272
255
{ /* Render the rest of the content except the back action */ }
273
256
{ renderAppbarContent ( {
@@ -278,9 +261,8 @@ const Appbar = ({
278
261
] ,
279
262
isDark,
280
263
theme,
281
- isV3,
282
264
renderExcept : [ 'Appbar.BackAction' ] ,
283
- shouldCenterContent : isV3CenterAlignedMode || shouldCenterContent ,
265
+ shouldCenterContent : isCenterAlignedMode || shouldCenterContent ,
284
266
} ) }
285
267
</ >
286
268
) }
@@ -297,14 +279,12 @@ const Appbar = ({
297
279
{ renderAppbarContent ( {
298
280
children,
299
281
isDark,
300
- isV3,
301
282
renderOnly : [ 'Appbar.BackAction' ] ,
302
283
mode,
303
284
} ) }
304
285
{ renderAppbarContent ( {
305
286
children : filterAppbarActions ( children , true ) ,
306
287
isDark,
307
- isV3,
308
288
renderOnly : [ 'Appbar.Action' ] ,
309
289
mode,
310
290
} ) }
@@ -313,7 +293,6 @@ const Appbar = ({
313
293
{ renderAppbarContent ( {
314
294
children : filterAppbarActions ( children ) ,
315
295
isDark,
316
- isV3,
317
296
renderExcept : [
318
297
'Appbar' ,
319
298
'Appbar.BackAction' ,
@@ -327,7 +306,6 @@ const Appbar = ({
327
306
{ renderAppbarContent ( {
328
307
children,
329
308
isDark,
330
- isV3,
331
309
renderOnly : [ 'Appbar.Content' ] ,
332
310
mode,
333
311
} ) }
@@ -344,9 +322,6 @@ const styles = StyleSheet.create({
344
322
alignItems : 'center' ,
345
323
paddingHorizontal : 4 ,
346
324
} ,
347
- spacing : {
348
- width : 48 ,
349
- } ,
350
325
v3Spacing : {
351
326
width : 52 ,
352
327
} ,
0 commit comments