|
1 | 1 | import * as React from 'react'; |
2 | 2 | import { |
3 | 3 | Animated, |
| 4 | + ColorValue, |
4 | 5 | EasingFunction, |
5 | 6 | Platform, |
6 | 7 | StyleProp, |
@@ -255,7 +256,7 @@ export type Props = { |
255 | 256 | * barStyle={{ backgroundColor: '#694fad' }} |
256 | 257 | * ``` |
257 | 258 | */ |
258 | | - barStyle?: StyleProp<ViewStyle>; |
| 259 | + barStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>; |
259 | 260 | /** |
260 | 261 | * Specifies the largest possible scale a label font can reach. |
261 | 262 | */ |
@@ -620,8 +621,11 @@ const BottomNavigation = ({ |
620 | 621 | const { routes } = navigationState; |
621 | 622 | const { colors, dark: isDarkTheme, mode, isV3 } = theme; |
622 | 623 |
|
623 | | - const { backgroundColor: customBackground, elevation = 4 }: ViewStyle = |
624 | | - StyleSheet.flatten(barStyle) || {}; |
| 624 | + const { backgroundColor: customBackground, elevation = 4 } = |
| 625 | + (StyleSheet.flatten(barStyle) || {}) as { |
| 626 | + elevation?: number; |
| 627 | + backgroundColor?: ColorValue; |
| 628 | + }; |
625 | 629 |
|
626 | 630 | const approxBackgroundColor = customBackground |
627 | 631 | ? customBackground |
@@ -758,29 +762,28 @@ const BottomNavigation = ({ |
758 | 762 | </View> |
759 | 763 | <Surface |
760 | 764 | {...(theme.isV3 && { elevation: 0 })} |
761 | | - style={ |
762 | | - [ |
763 | | - !theme.isV3 && { elevation: 4 }, |
764 | | - styles.bar, |
765 | | - keyboardHidesNavigationBar |
766 | | - ? { |
767 | | - // When the keyboard is shown, slide down the navigation bar |
768 | | - transform: [ |
769 | | - { |
770 | | - translateY: visibleAnim.interpolate({ |
771 | | - inputRange: [0, 1], |
772 | | - outputRange: [layout.height, 0], |
773 | | - }), |
774 | | - }, |
775 | | - ], |
776 | | - // Absolutely position the navigation bar so that the content is below it |
777 | | - // This is needed to avoid gap at bottom when the navigation bar is hidden |
778 | | - position: keyboardVisible ? 'absolute' : null, |
779 | | - } |
780 | | - : null, |
781 | | - barStyle, |
782 | | - ] as StyleProp<ViewStyle> |
783 | | - } |
| 765 | + testID={`${testID}-surface`} |
| 766 | + style={[ |
| 767 | + !theme.isV3 && styles.elevation, |
| 768 | + styles.bar, |
| 769 | + keyboardHidesNavigationBar // eslint-disable-next-line react-native/no-inline-styles |
| 770 | + ? { |
| 771 | + // When the keyboard is shown, slide down the navigation bar |
| 772 | + transform: [ |
| 773 | + { |
| 774 | + translateY: visibleAnim.interpolate({ |
| 775 | + inputRange: [0, 1], |
| 776 | + outputRange: [layout.height, 0], |
| 777 | + }), |
| 778 | + }, |
| 779 | + ], |
| 780 | + // Absolutely position the navigation bar so that the content is below it |
| 781 | + // This is needed to avoid gap at bottom when the navigation bar is hidden |
| 782 | + position: keyboardVisible ? 'absolute' : undefined, |
| 783 | + } |
| 784 | + : null, |
| 785 | + barStyle, |
| 786 | + ]} |
784 | 787 | pointerEvents={ |
785 | 788 | layout.measured |
786 | 789 | ? keyboardHidesNavigationBar && keyboardVisible |
@@ -1233,4 +1236,7 @@ const styles = StyleSheet.create({ |
1233 | 1236 | borderRadius: OUTLINE_WIDTH / 4, |
1234 | 1237 | alignSelf: 'center', |
1235 | 1238 | }, |
| 1239 | + elevation: { |
| 1240 | + elevation: 4, |
| 1241 | + }, |
1236 | 1242 | }); |
0 commit comments