From 5bdd6da7566ee66dd4c048e929fbc16e25e17763 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Thu, 4 Jun 2020 16:12:51 +0200 Subject: [PATCH 1/7] Switch with Custom Size example --- RNTester/js/examples/Switch/SwitchExample.js | 50 +++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/RNTester/js/examples/Switch/SwitchExample.js b/RNTester/js/examples/Switch/SwitchExample.js index ce825594e1150a..834ee769ae68f1 100644 --- a/RNTester/js/examples/Switch/SwitchExample.js +++ b/RNTester/js/examples/Switch/SwitchExample.js @@ -11,7 +11,7 @@ 'use strict'; const React = require('react'); -const {Switch, Text, View} = require('react-native'); +const {Button, Switch, Text, View} = require('react-native'); type OnOffIndicatorProps = $ReadOnly<{|on: boolean, testID: string|}>; function OnOffIndicator({on, testID}: OnOffIndicatorProps) { @@ -202,6 +202,48 @@ class EventSwitchExample extends React.Component<{...}, $FlowFixMeState> { } } +class CustomSizeSwitchExample extends React.Component< + {||}, + SimpleSwitchExampleState, +> { + state = { + trueSwitchIsOn: true, + falseSwitchIsOn: false, + width: 200, + }; + + render() { + const { width } = this.state; + return ( + <> + + this.setState({falseSwitchIsOn: value})} + trackColor={{ + true: 'yellow', + false: 'purple', + }} + value={this.state.falseSwitchIsOn} + switchMinWidth={width} + style={{width: width}} + /> + +