|
| 1 | +import React from "react"; |
| 2 | +import { View, Text } from "react-native"; |
| 3 | +import { |
| 4 | + AudioPlayer, |
| 5 | + CircularProgress, |
| 6 | + CustomPinInputCell, |
| 7 | + CustomPinInputText, |
| 8 | + DeckSwiper, |
| 9 | + DeckSwiperCard, |
| 10 | + LinearProgress, |
| 11 | + LoadingIndicator, |
| 12 | + LottieAnimation, |
| 13 | + Markdown, |
| 14 | + PinInput, |
| 15 | + Swiper, |
| 16 | + SwiperItem, |
| 17 | + Timer, |
| 18 | + VideoPlayer, |
| 19 | + WebView, |
| 20 | +} from "@draftbit/ui"; |
| 21 | +import { LoadingIndicatorType } from "@draftbit/core/lib/typescript/src/components/LoadingIndicator"; |
| 22 | +import Section, { Container } from "./Section"; |
| 23 | + |
| 24 | +const PROGRESS_VALUE = 65; |
| 25 | + |
| 26 | +const NativeWindExample: React.FC<{ theme?: any }> = () => { |
| 27 | + const [pinValue, setPinValue] = React.useState(""); |
| 28 | + const timerRef = React.useRef<any>(null); |
| 29 | + |
| 30 | + return ( |
| 31 | + <Container style={{}}> |
| 32 | + <Section title="AudioPlayer" style={{}}> |
| 33 | + <AudioPlayer |
| 34 | + className="rounded-2xl bg-gray-100 h-12 border-0 w-100" |
| 35 | + source={{ |
| 36 | + uri: "https://static.draftbit.com/audio/intro-to-draftbit-audio.mp3", |
| 37 | + }} |
| 38 | + /> |
| 39 | + </Section> |
| 40 | + |
| 41 | + <Section title="CircularProgress" style={{}}> |
| 42 | + <View className="items-center flex-row"> |
| 43 | + <CircularProgress className="w-60" value={PROGRESS_VALUE} /> |
| 44 | + <CircularProgress |
| 45 | + className="w-40 ml-20" |
| 46 | + color="rgb(99,102,241)" |
| 47 | + trackColor="rgb(224,231,255)" |
| 48 | + value={PROGRESS_VALUE} |
| 49 | + /> |
| 50 | + </View> |
| 51 | + </Section> |
| 52 | + |
| 53 | + <Section |
| 54 | + title="DeckSwiper + DeckSwiperCard" |
| 55 | + style={{ paddingBottom: 30 }} |
| 56 | + > |
| 57 | + <DeckSwiper className="w-100" visibleCardCount={2}> |
| 58 | + <DeckSwiperCard className="bg-red-100 p-10 items-center justify-center rounded-xl"> |
| 59 | + <Text className="text-base font-semibold text-red-700">Card 1</Text> |
| 60 | + </DeckSwiperCard> |
| 61 | + <DeckSwiperCard className="bg-blue-100 p-10 items-center justify-center rounded-xl"> |
| 62 | + <Text className="text-base font-semibold text-blue-700"> |
| 63 | + Card 2 |
| 64 | + </Text> |
| 65 | + </DeckSwiperCard> |
| 66 | + <DeckSwiperCard className="bg-green-100 p-10 items-center justify-center rounded-xl"> |
| 67 | + <Text className="text-base font-semibold text-green-700"> |
| 68 | + Card 3 |
| 69 | + </Text> |
| 70 | + </DeckSwiperCard> |
| 71 | + </DeckSwiper> |
| 72 | + </Section> |
| 73 | + |
| 74 | + <Section title="LinearProgress" style={{}}> |
| 75 | + <LinearProgress className="w-100" value={PROGRESS_VALUE} /> |
| 76 | + <LinearProgress |
| 77 | + className="w-100 mt-3" |
| 78 | + color="rgb(99,102,241)" |
| 79 | + trackColor="rgb(224,231,255)" |
| 80 | + thickness={12} |
| 81 | + value={PROGRESS_VALUE} |
| 82 | + /> |
| 83 | + <LinearProgress |
| 84 | + className="w-150 mt-10" |
| 85 | + thickness={8} |
| 86 | + trackThickness={8} |
| 87 | + dashWidth={12} |
| 88 | + dashGap={8} |
| 89 | + value={PROGRESS_VALUE} |
| 90 | + /> |
| 91 | + </Section> |
| 92 | + |
| 93 | + <Section title="LoadingIndicator" style={{}}> |
| 94 | + <View className="flex-row"> |
| 95 | + <LoadingIndicator |
| 96 | + className="m-2 border-2 p-4" |
| 97 | + type={LoadingIndicatorType.circle} |
| 98 | + /> |
| 99 | + <LoadingIndicator className="m-2" type={LoadingIndicatorType.wave} /> |
| 100 | + |
| 101 | + <LoadingIndicator |
| 102 | + className="m-2" |
| 103 | + type={LoadingIndicatorType.bounce} |
| 104 | + /> |
| 105 | + |
| 106 | + <LoadingIndicator className="m-2" type={LoadingIndicatorType.pulse} /> |
| 107 | + </View> |
| 108 | + </Section> |
| 109 | + |
| 110 | + <Section title="LottieAnimation" style={{}}> |
| 111 | + <LottieAnimation |
| 112 | + className="w-48 h-48 border-2" |
| 113 | + source={require("./assets/lottie_animation_example.json")} |
| 114 | + /> |
| 115 | + </Section> |
| 116 | + |
| 117 | + <Section title="Markdown" style={{}}> |
| 118 | + <Markdown className="w-200"> |
| 119 | + { |
| 120 | + "## NativeWind\n\nThis is **bold** and _italic_ text styled via `className`.\n\n- Item one\n- Item two\n- Item three" |
| 121 | + } |
| 122 | + </Markdown> |
| 123 | + </Section> |
| 124 | + |
| 125 | + <Section title="PinInput (default)" style={{}}> |
| 126 | + <PinInput |
| 127 | + className="border-2 w-100" |
| 128 | + value={pinValue} |
| 129 | + onChangeText={setPinValue} |
| 130 | + /> |
| 131 | + </Section> |
| 132 | + |
| 133 | + <Section |
| 134 | + title="PinInput (CustomPinInputCell + CustomPinInputText)" |
| 135 | + style={{}} |
| 136 | + > |
| 137 | + <PinInput |
| 138 | + value={pinValue} |
| 139 | + onChangeText={setPinValue} |
| 140 | + className="w-100" |
| 141 | + renderItem={({ cellValue, isFocused }) => ( |
| 142 | + <CustomPinInputCell |
| 143 | + className={`w-14 h-14 mx-1.5 rounded-xl bg-white items-center justify-center ${ |
| 144 | + isFocused ? "border-2 border-red-500" : "border border-gray-300" |
| 145 | + }`} |
| 146 | + > |
| 147 | + <CustomPinInputText |
| 148 | + className={`text-xl font-bold ${ |
| 149 | + isFocused ? "text-indigo-500" : "text-gray-800" |
| 150 | + }`} |
| 151 | + isFocused={isFocused} |
| 152 | + > |
| 153 | + {cellValue} |
| 154 | + </CustomPinInputText> |
| 155 | + </CustomPinInputCell> |
| 156 | + )} |
| 157 | + /> |
| 158 | + </Section> |
| 159 | + |
| 160 | + <Section title="Swiper + SwiperItem" style={{}}> |
| 161 | + <Swiper |
| 162 | + keyExtractor={(key) => key} |
| 163 | + className="w-100 h-48" |
| 164 | + vertical={false} |
| 165 | + loop |
| 166 | + > |
| 167 | + <SwiperItem className="items-center justify-center bg-red-100"> |
| 168 | + <Text className="text-lg font-semibold text-red-700">Slide 1</Text> |
| 169 | + </SwiperItem> |
| 170 | + <SwiperItem className="items-center justify-center bg-indigo-100"> |
| 171 | + <Text className="text-lg font-semibold text-indigo-700"> |
| 172 | + Slide 2 |
| 173 | + </Text> |
| 174 | + </SwiperItem> |
| 175 | + <SwiperItem className="items-center justify-center bg-green-100"> |
| 176 | + <Text className="text-lg font-semibold text-green-700"> |
| 177 | + Slide 3 |
| 178 | + </Text> |
| 179 | + </SwiperItem> |
| 180 | + </Swiper> |
| 181 | + </Section> |
| 182 | + |
| 183 | + <Section title="Timer" style={{}}> |
| 184 | + <Timer |
| 185 | + ref={timerRef} |
| 186 | + className="text-5xl text-red-800" |
| 187 | + initialTime={0} |
| 188 | + format="mm:ss" |
| 189 | + countDirection="up" |
| 190 | + /> |
| 191 | + </Section> |
| 192 | + |
| 193 | + <Section title="VideoPlayer" style={{}}> |
| 194 | + <VideoPlayer |
| 195 | + className="w-100 h-56 rounded-xl overflow-hidden" |
| 196 | + source={{ |
| 197 | + uri: "http://static.draftbit.com/videos/intro-to-draftbit.mp4", |
| 198 | + }} |
| 199 | + useNativeControls |
| 200 | + resizeMode="cover" |
| 201 | + /> |
| 202 | + </Section> |
| 203 | + |
| 204 | + <Section title="WebView" style={{}}> |
| 205 | + <WebView |
| 206 | + className="w-200 h-100 rounded-xl overflow-hidden" |
| 207 | + source={{ uri: "https://docs.expo.io/" }} |
| 208 | + /> |
| 209 | + </Section> |
| 210 | + </Container> |
| 211 | + ); |
| 212 | +}; |
| 213 | + |
| 214 | +export default NativeWindExample; |
0 commit comments