Skip to content

Commit 778fdbe

Browse files
authored
FloatingButton - change gradient overlay (and change screen) (#1203)
1 parent 8e22e11 commit 778fdbe

File tree

2 files changed

+41
-90
lines changed

2 files changed

+41
-90
lines changed
Lines changed: 41 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,60 @@
11
import React, {Component} from 'react';
22
import {View, StyleSheet, Alert, ScrollView} from 'react-native';
3-
import {
4-
Colors,
5-
Typography,
6-
TouchableOpacity,
7-
Text,
8-
FloatingButton
9-
} from 'react-native-ui-lib';
3+
import {Colors, Text, FloatingButton} from 'react-native-ui-lib';
4+
import {renderBooleanOption} from '../ExampleScreenPresenter';
105

11-
export default class FloatingButtonScreen extends Component {
12-
constructor(props) {
13-
super(props);
14-
15-
this.state = {
16-
showButton: true
17-
};
18-
}
19-
20-
showButton = () => {
21-
this.setState({
22-
showButton: true
23-
});
24-
};
6+
interface State {
7+
showButton: boolean;
8+
showSecondary: boolean;
9+
}
2510

26-
hideButton = () => {
27-
this.setState({
28-
showButton: false
29-
});
11+
export default class FloatingButtonScreen extends Component<{}, State> {
12+
state = {
13+
showButton: true,
14+
showSecondary: true
3015
};
3116

3217
notNow = () => {
3318
Alert.alert('Not Now!');
34-
this.hideButton();
19+
this.setState({showButton: false});
3520
};
3621

3722
close = () => {
3823
Alert.alert('Closed.');
39-
this.hideButton();
24+
this.setState({showButton: false});
4025
};
4126

4227
render() {
28+
const {showSecondary} = this.state;
4329
return (
4430
<View style={styles.container}>
45-
<Text text60 style={{textAlign: 'center'}}>
31+
<Text text60 center marginB-s4>
4632
Trigger Floating Button
4733
</Text>
48-
<View style={styles.buttonsContainer}>
49-
<TouchableOpacity
50-
style={[styles.triggerButton, {marginRight: 10}]}
51-
onPress={this.showButton}
52-
>
53-
<Text style={styles.triggerButtonText}>Show</Text>
54-
</TouchableOpacity>
55-
<TouchableOpacity
56-
style={styles.triggerButton}
57-
onPress={this.hideButton}
58-
>
59-
<Text style={styles.triggerButtonText}>Hide</Text>
60-
</TouchableOpacity>
61-
</View>
34+
{renderBooleanOption.call(this, 'Show Floating Button', 'showButton')}
35+
{renderBooleanOption.call(this, 'Show Secondary Button', 'showSecondary')}
6236

6337
<ScrollView showsVerticalScrollIndicator={false}>
6438
<View paddingT-20>
6539
<Text text70 style={{fontWeight: 'bold'}}>
6640
Scroll behind a FloatingButton
6741
</Text>
6842
<Text text80 marginT-10 style={{lineHeight: 24}}>
69-
Lorem Ipsum is simply dummy text of the printing and typesetting
70-
industry. Lorem Ipsum has been the industry standard dummy text
71-
ever since the 1500s, when an unknown printer took a galley of
72-
type and scrambled it to make a type specimen book. It has
73-
survived not only five centuries, but also the leap into
74-
electronic typesetting, remaining essentially unchanged. It was
75-
popularised in the 1960s with the release of Letraset sheets
76-
containing Lorem Ipsum passages, and more recently with desktop
77-
publishing software like Aldus PageMaker including versions of
78-
Lorem Ipsum. Contrary to popular belief, Lorem Ipsum is not simply
79-
random text. It has roots in a piece of classical Latin literature
80-
from 45 BC, making it over 2000 years old. Lorem Ipsum is simply
81-
dummy text of the printing and typesetting industry. Lorem Ipsum
82-
has been the industry standard dummy text ever since the 1500s,
83-
when an unknown printer took a galley of type and scrambled it to
84-
make a type specimen book. It has survived not only five
85-
centuries, but also the leap into electronic typesetting,
86-
remaining essentially unchanged. It was popularised in the 1960s
87-
with the release of Letraset sheets containing Lorem Ipsum
88-
passages, and more recently with desktop publishing software like
89-
Aldus PageMaker including versions of Lorem Ipsum. Contrary to
90-
popular belief, Lorem Ipsum is not simply random text. It has
91-
roots in a piece of classical Latin literature from 45 BC, making
92-
it over 2000 years old.
43+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
44+
industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and
45+
scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into
46+
electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release
47+
of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software
48+
like Aldus PageMaker including versions of Lorem Ipsum. Contrary to popular belief, Lorem Ipsum is not
49+
simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000
50+
years old. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
51+
the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and
52+
scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into
53+
electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release
54+
of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software
55+
like Aldus PageMaker including versions of Lorem Ipsum. Contrary to popular belief, Lorem Ipsum is not
56+
simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000
57+
years old.
9358
</Text>
9459
</View>
9560
</ScrollView>
@@ -100,11 +65,15 @@ export default class FloatingButtonScreen extends Component {
10065
label: 'Approve',
10166
onPress: this.close
10267
}}
103-
secondaryButton={{
104-
label: 'Not now',
105-
onPress: this.notNow,
106-
color: Colors.red30
107-
}}
68+
secondaryButton={
69+
showSecondary
70+
? {
71+
label: 'Not now',
72+
onPress: this.notNow,
73+
color: Colors.red30
74+
}
75+
: undefined
76+
}
10877
// bottomMargin={80}
10978
// hideBackgroundOverlay
11079
// withoutAnimation
@@ -119,24 +88,6 @@ const styles = StyleSheet.create({
11988
padding: 30,
12089
paddingBottom: 0,
12190
flex: 1,
122-
backgroundColor: Colors.dark80
123-
},
124-
buttonsContainer: {
125-
flexDirection: 'row',
126-
justifyContent: 'center',
127-
margin: 20
128-
},
129-
triggerButton: {
130-
backgroundColor: Colors.dark10,
131-
width: 100,
132-
height: 30,
133-
borderWidth: 1,
134-
borderRadius: 4,
135-
justifyContent: 'center',
136-
alignItems: 'center'
137-
},
138-
triggerButtonText: {
139-
color: Colors.white,
140-
...Typography.text60
91+
backgroundColor: Colors.white
14192
}
14293
});
18 Bytes
Loading

0 commit comments

Comments
 (0)