@@ -35,7 +35,18 @@ https://github.com/dooboolab/react-native-switch-toggle
3535| backgroundColorOff| | string | 'rgb(215,215,215)' |
3636| circleColorOn| | string | 'white' |
3737| circleColorOff| | string | 'rgb(102,134,205)' |
38- |duration| | number | 300
38+ | duration| | number | 300 |
39+ | type| | number| 0 - Normal switch, 1 - Switch with a text|
40+ | buttonText| | string| Text on-top of the button|
41+ | backTextRight| | string| Text to appear in right side when button toggled to left|
42+ | backTextLeft| | string| Text to appear in left side when button toggled to right|
43+ | buttonTextStyle| | styles| Styles for text on the button|
44+ | textRightStyle| | styles| Styles for text in right|
45+ | textLeftStyle| | styles| Styles for text in left|
46+ | buttonStyle| | styles| Styles for the button|
47+ | buttonContainerStyle| | styles| Styles for button container|
48+ | rightContainerStyle| | styles| Styles for right text container|
49+ | leftContainerStyle| | styles| Styles for left text container|
3950
4051## Getting started
4152` $ npm install react-native-switch-toggle --save `
@@ -57,8 +68,21 @@ export default class App extends Component<{}> {
5768 this .state = {
5869 switchOn1: false ,
5970 switchOn2: false ,
71+ switchOn4: false
6072 };
6173 }
74+
75+ getButtonText () {
76+ return this .state .switchOn4 ? ' Hour' : ' Day' ;
77+ }
78+
79+ getRightText () {
80+ return this .state .switchOn4 ? ' ' : ' Hour' ;
81+ }
82+
83+ getLeftText () {
84+ return this .state .switchOn4 ? ' Day' : ' ' ;
85+ }
6286
6387 render () {
6488 return (
@@ -110,6 +134,46 @@ export default class App extends Component<{}> {
110134 circleColorOn= ' green'
111135 duration= {500 }
112136 / >
137+ < SwitchToggle
138+ buttonText= {this .getButtonText ()}
139+ backTextRight= {this .getRightText ()}
140+ backTextLeft= {this .getLeftText ()}
141+
142+ type= {1 }
143+ buttonStyle= {{
144+ alignItems: ' center' ,
145+ justifyContent: ' center' ,
146+ position: ' absolute'
147+ }}
148+
149+ rightContainerStyle= {{flex: 1 , alignItems: ' center' , justifyContent: ' center' }}
150+ leftContainerStyle= {{flex: 1 , alignItems: ' center' , justifyContent: ' flex-start' }}
151+
152+ buttonTextStyle= {{fontSize: 20 }}
153+ textRightStyle= {{fontSize: 20 }}
154+ textLeftStyle= {{fontSize: 20 }}
155+
156+ containerStyle= {{
157+ marginTop: 16 ,
158+ width: 160 ,
159+ height: 65 ,
160+ borderRadius: 30 ,
161+ padding: 5 ,
162+ }}
163+ backgroundColorOn= ' #fff'
164+ backgroundColorOff= ' #fff'
165+ circleStyle= {{
166+ width: 80 ,
167+ height: 55 ,
168+ borderRadius: 27.5 ,
169+ backgroundColor: ' blue' , // rgb(102,134,205)
170+ }}
171+ switchOn= {this .state .switchOn4 }
172+ onPress= {this .onPress4 }
173+ circleColorOff= ' #e5e1e0'
174+ circleColorOn= ' #e5e1e0'
175+ duration= {500 }
176+ / >
113177 < / View>
114178 );
115179 }
@@ -122,6 +186,9 @@ export default class App extends Component<{}> {
122186 onPress3 = () => {
123187 this .setState ({ switchOn3: ! this .state .switchOn3 });
124188 }
189+ onPress4 = () => {
190+ this .setState ({switchOn4: ! this .state .switchOn4 });
191+ };
125192}
126193
127194const styles = StyleSheet .create ({
0 commit comments