@@ -3,8 +3,8 @@ import {StyleSheet, Animated} from 'react-native';
3
3
import { Constants , asBaseComponent } from '../../commons/new' ;
4
4
import { Colors , Spacings } from '../../style' ;
5
5
import View from '../view' ;
6
- import Button , { ButtonProps } from '../button' ;
7
6
import Image from '../image' ;
7
+ import Button , { ButtonProps } from '../button' ;
8
8
9
9
export enum FloatingButtonLayouts {
10
10
VERTICAL = 'Vertical' ,
@@ -27,6 +27,14 @@ export interface FloatingButtonProps {
27
27
* The bottom margin of the button, or secondary button if passed
28
28
*/
29
29
bottomMargin ?: number ;
30
+ /**
31
+ * Whether the buttons get the container's full with (vertical layout only)
32
+ */
33
+ fullWidth ?: boolean ;
34
+ /**
35
+ * Button layout direction: vertical or horizontal
36
+ */
37
+ buttonLayout ?: FloatingButtonLayouts | `${FloatingButtonLayouts } `;
30
38
/**
31
39
* The duration of the button's animations (show/hide)
32
40
*/
@@ -46,10 +54,6 @@ export interface FloatingButtonProps {
46
54
* <TestID>.secondaryButton - the floatingButton secondaryButton
47
55
*/
48
56
testID ?: string ;
49
- /**
50
- * Button layout direction: vertical or horizontal
51
- */
52
- buttonLayout ?: FloatingButtonLayouts | `${FloatingButtonLayouts } `;
53
57
}
54
58
55
59
const gradientImage = ( ) => require ( './gradient.png' ) ;
@@ -156,35 +160,26 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
156
160
const { secondaryButton, bottomMargin, testID, buttonLayout} = this . props ;
157
161
158
162
const bgColor = secondaryButton ?. backgroundColor || Colors . $backgroundDefault ;
159
-
160
- if ( buttonLayout === FloatingButtonLayouts . HORIZONTAL ) {
161
- return (
162
- < Button
163
- outline
164
- flex
165
- size = { Button . sizes . large }
166
- testID = { `${ testID } .secondaryButton` }
167
- { ...secondaryButton }
168
- style = { [ styles . shadow , styles . secondaryMargin , { backgroundColor : bgColor } ] }
169
- enableShadow = { false }
170
- />
171
- ) ;
172
- }
173
-
163
+ const isHorizontal = buttonLayout === FloatingButtonLayouts . HORIZONTAL ;
164
+ const buttonStyle = isHorizontal ?
165
+ [ styles . shadow , styles . secondaryMargin , { backgroundColor : bgColor } ] : { marginBottom : bottomMargin || Spacings . s7 } ;
166
+
174
167
return (
175
168
< Button
176
- link
169
+ outline = { isHorizontal }
170
+ flex = { isHorizontal }
171
+ link = { ! isHorizontal }
177
172
size = { Button . sizes . large }
178
173
testID = { `${ testID } .secondaryButton` }
179
174
{ ...secondaryButton }
180
- style = { { marginBottom : bottomMargin || Spacings . s7 } }
175
+ style = { buttonStyle }
181
176
enableShadow = { false }
182
177
/>
183
178
) ;
184
179
}
185
180
186
181
render ( ) {
187
- const { withoutAnimation, visible, testID} = this . props ;
182
+ const { withoutAnimation, visible, fullWidth , testID} = this . props ;
188
183
// NOTE: keep this.firstLoad as true as long as the visibility changed to true
189
184
this . firstLoad && ! visible ? ( this . firstLoad = true ) : ( this . firstLoad = false ) ;
190
185
@@ -199,7 +194,8 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
199
194
return (
200
195
< View
201
196
row = { ! ! this . isSecondaryHorizontal }
202
- center = { ! ! this . isSecondaryHorizontal }
197
+ center = { ! ! this . isSecondaryHorizontal || ! fullWidth }
198
+ paddingH-16 = { ! this . isSecondaryHorizontal && fullWidth }
203
199
pointerEvents = "box-none"
204
200
animated
205
201
style = { [ styles . container , this . getAnimatedStyle ( ) ] }
@@ -218,7 +214,6 @@ const styles = StyleSheet.create({
218
214
container : {
219
215
...StyleSheet . absoluteFillObject ,
220
216
top : undefined ,
221
- alignItems : 'center' ,
222
217
zIndex : Constants . isAndroid ? 99 : undefined
223
218
} ,
224
219
image : {
0 commit comments