@@ -70,6 +70,7 @@ const StackAggregator = (props: StackAggregatorProps) => {
70
70
collapsed = true ,
71
71
disablePresses = false ,
72
72
onItemPress,
73
+ backgroundColor,
73
74
contentContainerStyle,
74
75
itemBorderRadius = 0 ,
75
76
onCollapseWillChange,
@@ -83,11 +84,11 @@ const StackAggregator = (props: StackAggregatorProps) => {
83
84
setIsCollapsed ( collapsed ) ;
84
85
} , [ collapsed ] ) ;
85
86
86
- useDidUpdate ( ( ) => {
87
+ useDidUpdate ( async ( ) => {
87
88
onCollapseWillChange ?.( isCollapsed ) ;
88
- animate ( ) ;
89
+ await animate ( ) ;
89
90
onCollapseChanged ?.( isCollapsed ) ;
90
- } , [ isCollapsed , onCollapseWillChange , onCollapseChanged ] ) ;
91
+ } , [ isCollapsed , itemsCount ] ) ;
91
92
92
93
/** Animations */
93
94
@@ -100,10 +101,11 @@ const StackAggregator = (props: StackAggregatorProps) => {
100
101
101
102
const getItemScale = useCallback ( ( index : number ) => {
102
103
if ( isCollapsed ) {
103
- if ( index === itemsCount - 2 ) {
104
+ if ( index === 1 ) {
104
105
return 0.95 ;
105
106
}
106
- if ( index === itemsCount - 1 ) {
107
+
108
+ if ( index === 2 ) {
107
109
return 0.9 ;
108
110
}
109
111
}
@@ -185,10 +187,11 @@ const StackAggregator = (props: StackAggregatorProps) => {
185
187
const getTop = ( index : number ) => {
186
188
let start = 0 ;
187
189
188
- if ( index === itemsCount - 2 ) {
190
+ if ( index === 1 ) {
189
191
start += PEEP ;
190
192
}
191
- if ( index === itemsCount - 1 ) {
193
+
194
+ if ( index === 2 ) {
192
195
start += PEEP * 2 ;
193
196
}
194
197
@@ -218,6 +221,10 @@ const StackAggregator = (props: StackAggregatorProps) => {
218
221
] ;
219
222
} , [ firstItemHeight , itemsCount ] ) ;
220
223
224
+ const cardStyle = useMemo ( ( ) => {
225
+ return backgroundColor ? [ styles . card , { backgroundColor} ] : styles . card ;
226
+ } , [ backgroundColor ] ) ;
227
+
221
228
/** Events */
222
229
223
230
const _onItemPress = ( index : number ) => {
@@ -241,7 +248,7 @@ const StackAggregator = (props: StackAggregatorProps) => {
241
248
< Animated . View
242
249
onLayout = { index === 0 ? onLayout : undefined }
243
250
style = { [
244
- Constants . isIOS && styles . containerShadow ,
251
+ Constants . isIOS && ( index === 0 || index === 1 || index === 2 || ! isCollapsed ) && styles . containerShadow ,
245
252
contentContainerStyle ,
246
253
//@ts -expect-error 'position' doesn't match AnimatedInterpolation type
247
254
getItemStyle ( index ) ,
@@ -256,7 +263,7 @@ const StackAggregator = (props: StackAggregatorProps) => {
256
263
] }
257
264
collapsable = { false }
258
265
>
259
- < Card style = { styles . card } onPress = { ( ) => _onItemPress ( index ) } borderRadius = { itemBorderRadius } elevation = { 5 } >
266
+ < Card style = { cardStyle } onPress = { ( ) => _onItemPress ( index ) } borderRadius = { itemBorderRadius } elevation = { 5 } >
260
267
< Animated . View style = { index !== 0 ? { opacity : animatedContentOpacity } : undefined } collapsable = { false } >
261
268
{ item }
262
269
</ Animated . View >
@@ -319,8 +326,7 @@ const styles = StyleSheet.create({
319
326
} ,
320
327
card : {
321
328
overflow : 'hidden' ,
322
- flexShrink : 1 ,
323
- backgroundColor : 'transparent'
329
+ flexShrink : 1
324
330
} ,
325
331
button : {
326
332
zIndex : 100
0 commit comments