1- /* eslint-disable react-native/no-inline-styles */
21import {
32 MultiswitchController ,
43 type ControllerVariant ,
54} from 'react-native-multiswitch-controller' ;
65import ExampleWrapper from './ExampleWrapper' ;
6+ import { StyleSheet } from 'react-native' ;
77
88type AlignProps = {
99 variant : ControllerVariant ;
@@ -19,14 +19,18 @@ export default function Align({ variant }: AlignProps) {
1919 ] }
2020 defaultOption = "First"
2121 variant = { variant }
22- styleProps = { {
23- align : 'left' ,
24- inactiveBackgroundColor : 'rgb(21, 87, 21)' ,
25- activeBackgroundColor : 'rgb(60, 180, 20)' ,
26- inactiveTextColor : 'rgb(208, 249, 205)' ,
27- containerHeight : 52 ,
28- itemHeight : 46 ,
29- } }
22+ align = "left"
23+ containerHeight = { 52 }
24+ optionHeight = { 46 }
25+ containerPadding = { variant === 'tabs' ? 10 : undefined }
26+ containerStyle = { styles . containerStyle1 }
27+ activeOptionContainerStyle = { styles . activeOptionContainerStyle1 }
28+ inactiveTextStyle = { styles . inactiveCustomTextStyle1 }
29+ activeTextStyle = {
30+ variant === 'tabs'
31+ ? styles . activeTextStyleTabs1
32+ : styles . activeTextStyleSegmentedControl1
33+ }
3034 />
3135 < MultiswitchController < 'First' | 'Second' >
3236 options = { [
@@ -35,28 +39,18 @@ export default function Align({ variant }: AlignProps) {
3539 ] }
3640 defaultOption = "Second"
3741 variant = { variant }
38- styleProps = { {
39- align : 'center' ,
40- inactiveBackgroundColor : 'rgba(220, 38, 38, 0.08)' ,
41- activeBackgroundColor : 'rgb(185, 28, 28)' ,
42- inactiveTextColor : 'rgb(185, 28, 28)' ,
43- containerHeight : 28 ,
44- itemHeight : 24 ,
45- customTextStyle : {
46- fontSize : 10 ,
47- } ,
48- customItemStyle : {
49- paddingHorizontal : 8 ,
50- paddingVertical : 2 ,
51- borderRadius : 0 ,
52- } ,
53- customActiveOptionStyle : {
54- borderRadius : 0 ,
55- } ,
56- customContainerStyle : {
57- borderRadius : 0 ,
58- } ,
59- } }
42+ align = "center"
43+ containerHeight = { 28 }
44+ optionHeight = { 24 }
45+ containerStyle = { styles . containerStyle2 }
46+ inactiveOptionContainerStyle = { styles . inactiveOptionContainerStyle2 }
47+ activeOptionContainerStyle = { styles . activeOptionContainerStyle2 }
48+ inactiveTextStyle = { styles . inactiveCustomTextStyle2 }
49+ activeTextStyle = {
50+ variant === 'tabs'
51+ ? styles . activeTextStyleTabs2
52+ : styles . activeTextStyleSegmentedControl2
53+ }
6054 />
6155 < MultiswitchController < 'First' | 'Second' | 'Third' >
6256 options = { [
@@ -66,22 +60,85 @@ export default function Align({ variant }: AlignProps) {
6660 ] }
6761 defaultOption = "First"
6862 variant = { variant }
69- styleProps = { {
70- align : 'right' ,
71- inactiveBackgroundColor : 'rgba(205, 197, 40, 0.08)' ,
72- activeBackgroundColor : 'rgb(180, 170, 20)' ,
73- inactiveTextColor : 'rgb(180, 170, 20)' ,
74- containerHeight : 28 ,
75- itemHeight : 24 ,
76- customTextStyle : {
77- fontSize : 10 ,
78- } ,
79- customItemStyle : {
80- paddingHorizontal : 8 ,
81- paddingVertical : 2 ,
82- } ,
83- } }
63+ align = "right"
64+ containerHeight = { 44 }
65+ optionHeight = { 24 }
66+ containerStyle = { styles . containerStyle3 }
67+ inactiveTextStyle = { styles . inactiveCustomTextStyle3 }
68+ inactiveOptionContainerStyle = { styles . inactiveOptionContainerStyle3 }
69+ activeOptionContainerStyle = { styles . activeOptionContainerStyle3 }
70+ activeTextStyle = {
71+ variant === 'tabs'
72+ ? styles . activeTextStyleTabs3
73+ : styles . activeTextStyleSegmentedControl3
74+ }
8475 />
8576 </ ExampleWrapper >
8677 ) ;
8778}
79+
80+ const styles = StyleSheet . create ( {
81+ // 1st example
82+ containerStyle1 : {
83+ backgroundColor : 'rgb(21, 87, 21)' ,
84+ } ,
85+ activeOptionContainerStyle1 : {
86+ backgroundColor : 'rgb(60, 180, 20)' ,
87+ } ,
88+ inactiveCustomTextStyle1 : {
89+ color : 'rgb(208, 249, 205)' ,
90+ } ,
91+ activeTextStyleTabs1 : {
92+ color : 'rgb(60, 180, 20)' ,
93+ } ,
94+ activeTextStyleSegmentedControl1 : {
95+ color : '#fff' ,
96+ } ,
97+
98+ // 2nd example
99+ containerStyle2 : {
100+ borderRadius : 0 ,
101+ backgroundColor : 'rgba(220, 38, 38, 0.08)' ,
102+ } ,
103+ inactiveCustomTextStyle2 : {
104+ color : 'rgba(185, 28, 28, 0.6)' ,
105+ fontSize : 10 ,
106+ } ,
107+ inactiveOptionContainerStyle2 : {
108+ paddingHorizontal : 8 ,
109+ paddingVertical : 2 ,
110+ borderRadius : 0 ,
111+ } ,
112+ activeOptionContainerStyle2 : {
113+ borderRadius : 0 ,
114+ backgroundColor : 'rgb(185, 28, 28)' ,
115+ } ,
116+ activeTextStyleTabs2 : {
117+ color : 'rgb(185, 28, 28)' ,
118+ } ,
119+ activeTextStyleSegmentedControl2 : {
120+ color : '#fff' ,
121+ } ,
122+
123+ // 3rd example
124+ containerStyle3 : {
125+ backgroundColor : 'rgba(205, 197, 40, 0.4)' ,
126+ } ,
127+ inactiveCustomTextStyle3 : {
128+ color : 'rgb(180, 170, 20)' ,
129+ fontSize : 10 ,
130+ } ,
131+ inactiveOptionContainerStyle3 : {
132+ paddingHorizontal : 8 ,
133+ paddingVertical : 2 ,
134+ } ,
135+ activeOptionContainerStyle3 : {
136+ backgroundColor : 'rgb(180, 170, 20)' ,
137+ } ,
138+ activeTextStyleTabs3 : {
139+ color : 'rgb(180, 170, 20)' ,
140+ } ,
141+ activeTextStyleSegmentedControl3 : {
142+ color : '#fff' ,
143+ } ,
144+ } ) ;
0 commit comments