|
1 | | -import { View, StyleSheet, ScrollView, SafeAreaView } from 'react-native'; |
| 1 | +import { |
| 2 | + View, |
| 3 | + ScrollView, |
| 4 | + SafeAreaView, |
| 5 | + Text, |
| 6 | + TouchableOpacity, |
| 7 | +} from 'react-native'; |
| 8 | +import { useState } from 'react'; |
2 | 9 | import StripeOTPInput from './examples/stripe'; |
3 | | -import { Title } from './title'; |
4 | 10 | import AppleOTPInput from './examples/apple'; |
5 | 11 | import RevoltOTPInput from './examples/revolt'; |
6 | 12 | import DashedOTPInput from './examples/dashed'; |
7 | 13 | import StripeNativewind from './examples/stripe-nativewind'; |
8 | 14 | import RevoltNativewind from './examples/revolt-nativewind'; |
9 | 15 | import AppleNativewind from './examples/apple-nativewind'; |
10 | 16 | import DashedNativewind from './examples/dashed-nativewind'; |
| 17 | +import AnimatedDashedNativewind from './examples/animated-dashed-nativewind'; |
| 18 | +import AnimatedStripeOTPInput from './examples/animated-stripe-nativewind'; |
| 19 | + |
| 20 | +type TabType = 'regular' | 'nativewind'; |
11 | 21 |
|
12 | 22 | export default function App() { |
| 23 | + const [activeTab, setActiveTab] = useState<TabType>('regular'); |
| 24 | + |
| 25 | + const examples = [ |
| 26 | + { |
| 27 | + title: 'Stripe', |
| 28 | + description: 'Clean, minimal design with subtle borders', |
| 29 | + regular: StripeOTPInput, |
| 30 | + nativewind: StripeNativewind, |
| 31 | + color: '#6772E5', |
| 32 | + }, |
| 33 | + { |
| 34 | + title: 'Apple', |
| 35 | + description: 'iOS-style with rounded corners and shadows', |
| 36 | + regular: AppleOTPInput, |
| 37 | + nativewind: AppleNativewind, |
| 38 | + color: '#007AFF', |
| 39 | + }, |
| 40 | + { |
| 41 | + title: 'Revolt', |
| 42 | + description: 'Modern design with gradient backgrounds', |
| 43 | + regular: RevoltOTPInput, |
| 44 | + nativewind: RevoltNativewind, |
| 45 | + color: '#FF6B6B', |
| 46 | + }, |
| 47 | + { |
| 48 | + title: 'Dashed', |
| 49 | + description: 'Simple dashed border style', |
| 50 | + regular: DashedOTPInput, |
| 51 | + nativewind: DashedNativewind, |
| 52 | + color: '#4ECDC4', |
| 53 | + }, |
| 54 | + { |
| 55 | + title: 'Animated Dashed', |
| 56 | + description: 'Dashed style with slide-in animation', |
| 57 | + regular: AnimatedDashedNativewind, |
| 58 | + nativewind: AnimatedDashedNativewind, |
| 59 | + color: '#8B5CF6', |
| 60 | + }, |
| 61 | + { |
| 62 | + title: 'Animated Stripe', |
| 63 | + description: 'Stripe style with slide-in animation', |
| 64 | + regular: AnimatedStripeOTPInput, |
| 65 | + nativewind: AnimatedStripeOTPInput, |
| 66 | + color: '#8B5CF6', |
| 67 | + }, |
| 68 | + ]; |
| 69 | + |
13 | 70 | return ( |
14 | | - <ScrollView style={styles.container}> |
15 | | - <SafeAreaView> |
16 | | - <View style={styles.exampleContainer}> |
17 | | - <Title>Stripe OTP Input</Title> |
18 | | - <StripeOTPInput /> |
19 | | - <StripeNativewind /> |
20 | | - </View> |
21 | | - <View style={styles.exampleContainer}> |
22 | | - <Title>Apple OTP Input</Title> |
23 | | - <AppleOTPInput /> |
24 | | - <AppleNativewind /> |
25 | | - </View> |
26 | | - <View style={styles.exampleContainer}> |
27 | | - <Title>Revolt OTP Input</Title> |
28 | | - <RevoltOTPInput /> |
29 | | - <RevoltNativewind /> |
30 | | - </View> |
31 | | - <View style={styles.exampleContainer}> |
32 | | - <Title>Dashed OTP Input</Title> |
33 | | - <DashedOTPInput /> |
34 | | - <DashedNativewind /> |
| 71 | + <SafeAreaView className="flex-1 bg-white"> |
| 72 | + <View className="px-5 pt-5 pb-4 bg-white"> |
| 73 | + <Text className="text-3xl font-bold text-slate-800 mb-1"> |
| 74 | + OTP Input Examples |
| 75 | + </Text> |
| 76 | + <Text className="text-base text-slate-500 leading-6"> |
| 77 | + Beautiful, customizable one-time password inputs |
| 78 | + </Text> |
| 79 | + </View> |
| 80 | + |
| 81 | + <View className="flex-row bg-white px-5 pb-4 border-b border-slate-200"> |
| 82 | + <TouchableOpacity |
| 83 | + className={`flex-1 py-3 px-4 mx-1 rounded-lg ${ |
| 84 | + activeTab === 'regular' ? 'bg-blue-500' : 'bg-slate-100' |
| 85 | + }`} |
| 86 | + onPress={() => setActiveTab('regular')} |
| 87 | + > |
| 88 | + <Text |
| 89 | + className={`text-center text-sm font-semibold ${ |
| 90 | + activeTab === 'regular' ? 'text-white' : 'text-slate-500' |
| 91 | + }`} |
| 92 | + > |
| 93 | + StyleSheet |
| 94 | + </Text> |
| 95 | + </TouchableOpacity> |
| 96 | + <TouchableOpacity |
| 97 | + className={`flex-1 py-3 px-4 mx-1 rounded-lg ${ |
| 98 | + activeTab === 'nativewind' ? 'bg-blue-500' : 'bg-slate-100' |
| 99 | + }`} |
| 100 | + onPress={() => setActiveTab('nativewind')} |
| 101 | + > |
| 102 | + <Text |
| 103 | + className={`text-center text-sm font-semibold ${ |
| 104 | + activeTab === 'nativewind' ? 'text-white' : 'text-slate-500' |
| 105 | + }`} |
| 106 | + > |
| 107 | + NativeWind |
| 108 | + </Text> |
| 109 | + </TouchableOpacity> |
| 110 | + </View> |
| 111 | + |
| 112 | + <ScrollView className="flex-1" showsVerticalScrollIndicator={false}> |
| 113 | + {examples.map((example) => ( |
| 114 | + <View |
| 115 | + key={example.title} |
| 116 | + className="mx-5 mt-5 bg-white rounded-2xl shadow-sm" |
| 117 | + > |
| 118 | + <View className="flex-row items-center px-4 py-2 border-b border-slate-200"> |
| 119 | + <View |
| 120 | + className="w-10 h-10 rounded-full items-center justify-center mr-3" |
| 121 | + style={{ backgroundColor: example.color }} |
| 122 | + > |
| 123 | + <Text className="text-white text-lg font-bold"> |
| 124 | + {example.title[0]} |
| 125 | + </Text> |
| 126 | + </View> |
| 127 | + <View className="flex-1"> |
| 128 | + <Text className="text-lg font-semibold text-slate-800 mb-1"> |
| 129 | + {example.title} |
| 130 | + </Text> |
| 131 | + <Text className="text-sm text-slate-500 leading-5"> |
| 132 | + {example.description} |
| 133 | + </Text> |
| 134 | + </View> |
| 135 | + </View> |
| 136 | + |
| 137 | + <View className="bg-slate-50 rounded-b-2xl p-4 items-center h-[120px] justify-center"> |
| 138 | + {activeTab === 'regular' ? ( |
| 139 | + <example.regular /> |
| 140 | + ) : ( |
| 141 | + <example.nativewind /> |
| 142 | + )} |
| 143 | + </View> |
| 144 | + </View> |
| 145 | + ))} |
| 146 | + |
| 147 | + <View className="py-10 items-center"> |
| 148 | + <Text className="text-sm text-slate-400 text-center"> |
| 149 | + Built with ❤️ using input-otp-native |
| 150 | + </Text> |
35 | 151 | </View> |
36 | | - </SafeAreaView> |
37 | | - </ScrollView> |
| 152 | + </ScrollView> |
| 153 | + </SafeAreaView> |
38 | 154 | ); |
39 | 155 | } |
40 | | - |
41 | | -const styles = StyleSheet.create({ |
42 | | - container: { |
43 | | - flex: 1, |
44 | | - // justifyContent: 'center', |
45 | | - }, |
46 | | - exampleContainer: { |
47 | | - paddingVertical: 16, |
48 | | - borderBottomWidth: 1, |
49 | | - borderColor: '#E5E7EB', |
50 | | - borderRadius: 8, |
51 | | - }, |
52 | | -}); |
|
0 commit comments