1
1
import React , { Component } from 'react' ;
2
2
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' ;
10
5
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
+ }
25
10
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
30
15
} ;
31
16
32
17
notNow = ( ) => {
33
18
Alert . alert ( 'Not Now!' ) ;
34
- this . hideButton ( ) ;
19
+ this . setState ( { showButton : false } ) ;
35
20
} ;
36
21
37
22
close = ( ) => {
38
23
Alert . alert ( 'Closed.' ) ;
39
- this . hideButton ( ) ;
24
+ this . setState ( { showButton : false } ) ;
40
25
} ;
41
26
42
27
render ( ) {
28
+ const { showSecondary} = this . state ;
43
29
return (
44
30
< View style = { styles . container } >
45
- < Text text60 style = { { textAlign : ' center' } } >
31
+ < Text text60 center marginB-s4 >
46
32
Trigger Floating Button
47
33
</ 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' ) }
62
36
63
37
< ScrollView showsVerticalScrollIndicator = { false } >
64
38
< View paddingT-20 >
65
39
< Text text70 style = { { fontWeight : 'bold' } } >
66
40
Scroll behind a FloatingButton
67
41
</ Text >
68
42
< 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.
93
58
</ Text >
94
59
</ View >
95
60
</ ScrollView >
@@ -100,11 +65,15 @@ export default class FloatingButtonScreen extends Component {
100
65
label : 'Approve' ,
101
66
onPress : this . close
102
67
} }
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
+ }
108
77
// bottomMargin={80}
109
78
// hideBackgroundOverlay
110
79
// withoutAnimation
@@ -119,24 +88,6 @@ const styles = StyleSheet.create({
119
88
padding : 30 ,
120
89
paddingBottom : 0 ,
121
90
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
141
92
}
142
93
} ) ;
0 commit comments