Skip to content

Commit 130f9a5

Browse files
committed
FloatingButton - revert 3864 and apply zIndex to iOS (#3914)
1 parent 1cc0ec9 commit 130f9a5

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

demo/src/screens/componentScreens/FloatingButtonScreen.tsx

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React, {Component} from 'react';
22
import {View, StyleSheet, Alert, ScrollView} from 'react-native';
3-
import {Colors, Text, FloatingButton, FloatingButtonLayouts} from 'react-native-ui-lib';
3+
import {Colors, Text, FloatingButton, FloatingButtonLayouts, Keyboard} from 'react-native-ui-lib';
44
import {renderBooleanOption} from '../ExampleScreenPresenter';
55

66
interface State {
77
showButton: boolean;
88
showPrimary: boolean;
99
showSecondary: boolean;
1010
showVertical: boolean;
11+
withTrackingView: boolean;
1112
}
1213

1314
export default class FloatingButtonScreen extends Component<{}, State> {
@@ -16,7 +17,8 @@ export default class FloatingButtonScreen extends Component<{}, State> {
1617
showPrimary: true,
1718
showSecondary: true,
1819
showVertical: true,
19-
fullWidth: false
20+
fullWidth: false,
21+
withTrackingView: false
2022
};
2123

2224
notNow = () => {
@@ -30,7 +32,8 @@ export default class FloatingButtonScreen extends Component<{}, State> {
3032
};
3133

3234
render() {
33-
const {showSecondary, showVertical} = this.state;
35+
const {showSecondary, showVertical, withTrackingView} = this.state;
36+
const Container = withTrackingView ? Keyboard.KeyboardTrackingView : React.Fragment;
3437
return (
3538
<View style={styles.container}>
3639
<Text text60 center $textDefault marginB-s4>
@@ -41,6 +44,7 @@ export default class FloatingButtonScreen extends Component<{}, State> {
4144
{renderBooleanOption.call(this, 'Show Primary Button', 'showPrimary')}
4245
{renderBooleanOption.call(this, 'Show Secondary Button', 'showSecondary')}
4346
{renderBooleanOption.call(this, 'Button Layout Vertical', 'showVertical')}
47+
{renderBooleanOption.call(this, 'With tracking view', 'withTrackingView')}
4448

4549
<ScrollView showsVerticalScrollIndicator={false}>
4650
<View paddingT-20>
@@ -67,30 +71,32 @@ export default class FloatingButtonScreen extends Component<{}, State> {
6771
</View>
6872
</ScrollView>
6973

70-
<FloatingButton
71-
visible={this.state.showButton}
72-
fullWidth={this.state.fullWidth}
73-
button={
74-
this.state.showPrimary
75-
? {
76-
label: 'Approve',
77-
onPress: this.close
78-
}
79-
: undefined
80-
}
81-
secondaryButton={
82-
showSecondary
83-
? {
84-
label: 'Not now',
85-
onPress: this.notNow
86-
}
87-
: undefined
88-
}
89-
buttonLayout={showVertical ? FloatingButtonLayouts.VERTICAL : FloatingButtonLayouts.HORIZONTAL}
90-
// bottomMargin={80}
91-
// hideBackgroundOverlay
92-
// withoutAnimation
93-
/>
74+
<Container>
75+
<FloatingButton
76+
visible={this.state.showButton}
77+
fullWidth={this.state.fullWidth}
78+
button={
79+
this.state.showPrimary
80+
? {
81+
label: 'Approve',
82+
onPress: this.close
83+
}
84+
: undefined
85+
}
86+
secondaryButton={
87+
showSecondary
88+
? {
89+
label: 'Not now',
90+
onPress: this.notNow
91+
}
92+
: undefined
93+
}
94+
buttonLayout={showVertical ? FloatingButtonLayouts.VERTICAL : FloatingButtonLayouts.HORIZONTAL}
95+
// bottomMargin={80}
96+
// hideBackgroundOverlay
97+
// withoutAnimation
98+
/>
99+
</Container>
94100
</View>
95101
);
96102
}

packages/react-native-ui-lib/src/components/floatingButton/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
254254

255255
const styles = StyleSheet.create({
256256
container: {
257-
...StyleSheet.absoluteFillObject,
257+
// ...StyleSheet.absoluteFillObject, // TODO: this is breaking scenarios where the FloatingButton is inside a KeyboardTrackingView
258258
top: undefined,
259-
zIndex: Constants.isAndroid ? 99 : undefined
259+
zIndex: 99
260260
},
261261
image: {
262262
...StyleSheet.absoluteFillObject,

0 commit comments

Comments
 (0)