|
1 | | -import React from "react"; |
2 | | -import { Box, Switch, useTheme } from "@adaptui/react-native-tailwind"; |
| 1 | +import React, { useState } from "react"; |
| 2 | +import { |
| 3 | + Box, |
| 4 | + Radio, |
| 5 | + RadioGroup, |
| 6 | + Switch, |
| 7 | + SwitchSize, |
| 8 | + SwitchTheme, |
| 9 | + useTheme, |
| 10 | +} from "@adaptui/react-native-tailwind"; |
3 | 11 |
|
4 | 12 | export const SwitchComponentScreen = () => { |
5 | 13 | const tailwind = useTheme(); |
| 14 | + |
| 15 | + const [selectedSize, setSelectedSize] = useState<SwitchSize>("md"); |
| 16 | + const [selectedTheme, setSelectedTheme] = useState<SwitchTheme>("base"); |
| 17 | + |
| 18 | + const [hasLabel, setHasLabel] = useState(false); |
| 19 | + const [hasDesc, setHasDesc] = useState(false); |
| 20 | + |
| 21 | + const [isSwitchDisabled, setIsSwitchDisabled] = useState<boolean>(false); |
| 22 | + |
6 | 23 | return ( |
7 | | - <Box style={tailwind.style("flex-1 justify-center bg-white-900")}> |
8 | | - <Box style={tailwind.style("my-2 items-center")}> |
9 | | - <Switch /> |
10 | | - </Box> |
11 | | - <Box style={tailwind.style("my-2")}> |
12 | | - <Switch style={tailwind.style("mx-2 justify-between")} label="Wifi" /> |
13 | | - </Box> |
14 | | - <Box style={tailwind.style("my-2 items-center")}> |
15 | | - <Switch disabled label="Disabled-Off" /> |
16 | | - </Box> |
17 | | - <Box style={tailwind.style("my-2 items-center")}> |
18 | | - <Switch defaultState={true} disabled label="Disabled-On" /> |
19 | | - </Box> |
20 | | - <Box style={tailwind.style("my-2 mx-4")}> |
| 24 | + <Box style={tailwind.style("flex-1 items-center bg-white-900")}> |
| 25 | + <Box style={tailwind.style("flex-1 px-2 justify-center")}> |
21 | 26 | <Switch |
22 | | - label="Isolation" |
23 | | - description="Utilities for controlling whether an element should explicitly create a new stacking context." |
| 27 | + size={selectedSize} |
| 28 | + themeColor={selectedTheme} |
| 29 | + label={hasLabel ? "Isolation" : null} |
| 30 | + description={ |
| 31 | + hasLabel && hasDesc |
| 32 | + ? "Utilities for controlling whether an element should explicitly create a new stacking context." |
| 33 | + : null |
| 34 | + } |
| 35 | + disabled={isSwitchDisabled} |
24 | 36 | /> |
25 | 37 | </Box> |
26 | | - <Box style={tailwind.style("my-2 items-center")}> |
27 | | - <Switch themeColor="primary" /> |
28 | | - </Box> |
29 | | - <Box style={tailwind.style("my-2 items-center")}> |
30 | | - <Switch themeColor="primary" label="Wifi" /> |
31 | | - </Box> |
32 | | - <Box style={tailwind.style("my-2 items-center")}> |
33 | | - <Switch themeColor="primary" disabled label="Disabled-Off" /> |
34 | | - </Box> |
35 | | - <Box style={tailwind.style("my-2 items-center")}> |
36 | | - <Switch |
37 | | - themeColor="primary" |
38 | | - defaultState={true} |
39 | | - disabled |
40 | | - label="Disabled-On" |
41 | | - /> |
42 | | - </Box> |
43 | | - <Box style={tailwind.style("my-2 mx-4")}> |
44 | | - <Switch |
45 | | - themeColor="primary" |
46 | | - label="Isolation" |
47 | | - description="Utilities for controlling whether an element should explicitly create a new stacking context." |
48 | | - /> |
| 38 | + <Box |
| 39 | + style={tailwind.style( |
| 40 | + "w-full py-2 rounded-t-lg shadow-lg bg-gray-100 justify-end items-center", |
| 41 | + )} |
| 42 | + > |
| 43 | + <RadioGroup |
| 44 | + value={selectedSize} |
| 45 | + onChange={value => setSelectedSize(value as SwitchSize)} |
| 46 | + orientation="horizontal" |
| 47 | + > |
| 48 | + <Radio value="sm" label="sm" /> |
| 49 | + <Radio value="md" label="md" /> |
| 50 | + <Radio value="lg" label="lg" /> |
| 51 | + <Radio value="xl" label="xl" /> |
| 52 | + </RadioGroup> |
| 53 | + <RadioGroup |
| 54 | + value={selectedTheme} |
| 55 | + onChange={value => setSelectedTheme(value as SwitchTheme)} |
| 56 | + orientation="horizontal" |
| 57 | + > |
| 58 | + <Radio value="base" label="base" /> |
| 59 | + <Radio value="primary" label="primary" /> |
| 60 | + </RadioGroup> |
| 61 | + <Box |
| 62 | + style={tailwind.style( |
| 63 | + "flex flex-row justify-center flex-wrap w-full", |
| 64 | + )} |
| 65 | + > |
| 66 | + <Switch |
| 67 | + state={hasLabel} |
| 68 | + size="md" |
| 69 | + onStateChange={value => setHasLabel(value)} |
| 70 | + style={tailwind.style("ml-1 mt-1")} |
| 71 | + label="Has Label" |
| 72 | + /> |
| 73 | + <Switch |
| 74 | + state={hasDesc} |
| 75 | + size="md" |
| 76 | + onStateChange={value => setHasDesc(value)} |
| 77 | + style={tailwind.style("ml-1 mt-1")} |
| 78 | + label="Has Description" |
| 79 | + /> |
| 80 | + <Switch |
| 81 | + state={isSwitchDisabled} |
| 82 | + onStateChange={value => setIsSwitchDisabled(value)} |
| 83 | + size="md" |
| 84 | + style={tailwind.style("ml-1 mt-1")} |
| 85 | + label="Disabled" |
| 86 | + /> |
| 87 | + </Box> |
49 | 88 | </Box> |
50 | 89 | </Box> |
51 | 90 | ); |
|
0 commit comments