Skip to content

Commit 9e3e6c7

Browse files
Merge pull request #40 from naveenvignesh5/typescript
Typescript
2 parents 28ffef6 + 2cae0c4 commit 9e3e6c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+6676
-6898
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@ typings/
5959

6060
# next.js build output
6161
.next
62+
63+
# lock files
64+
package-lock.json
65+
66+
# generated files
67+
dist

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
ScreenShots/*
2-
Example
2+
Example/*

Example/.buckconfig

Lines changed: 0 additions & 6 deletions
This file was deleted.

Example/.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

Example/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
root: true,
3-
extends: '@react-native-community',
3+
extends: '@react-native',
44
};

Example/.flowconfig

Lines changed: 0 additions & 65 deletions
This file was deleted.

Example/.gitignore

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23+
ios/.xcode.env.local
2324

2425
# Android/IntelliJ
2526
#
@@ -29,32 +30,37 @@ build/
2930
local.properties
3031
*.iml
3132
*.hprof
33+
.cxx/
34+
*.keystore
35+
!debug.keystore
3236

3337
# node.js
3438
#
3539
node_modules/
3640
npm-debug.log
3741
yarn-error.log
3842

39-
# BUCK
40-
buck-out/
41-
\.buckd/
42-
*.keystore
43-
!debug.keystore
44-
4543
# fastlane
4644
#
4745
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
4846
# screenshots whenever they are needed.
4947
# For more information about the recommended setup visit:
5048
# https://docs.fastlane.tools/best-practices/source-control/
5149

52-
*/fastlane/report.xml
53-
*/fastlane/Preview.html
54-
*/fastlane/screenshots
50+
**/fastlane/report.xml
51+
**/fastlane/Preview.html
52+
**/fastlane/screenshots
53+
**/fastlane/test_output
5554

5655
# Bundle artifact
5756
*.jsbundle
5857

59-
# CocoaPods
58+
# Ruby / CocoaPods
6059
/ios/Pods/
60+
/vendor/bundle/
61+
62+
# Temporary files created by Metro to check the health of the file watcher
63+
.metro-health-check*
64+
65+
# testing
66+
/coverage

Example/.prettierrc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2-
bracketSpacing: false,
3-
jsxBracketSameLine: true,
2+
arrowParens: 'avoid',
3+
bracketSameLine: true,
4+
bracketSpacing: true,
45
singleQuote: true,
56
trailingComma: 'all',
6-
arrowParens: 'avoid',
77
};

Example/.watchmanconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{}
Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1-
import React, {Component} from 'react';
2-
import {StyleSheet, Text, View, Button, Alert, TextInput} from 'react-native';
1+
import React, { useRef, useState } from 'react';
2+
import {
3+
StyleSheet,
4+
Text,
5+
View,
6+
Button,
7+
Alert,
8+
TextInput,
9+
SafeAreaView,
10+
ScrollView,
11+
} from 'react-native';
312

413
import OTPTextView from 'react-native-otp-textinput';
514

615
const styles = StyleSheet.create({
7-
container: {
16+
safeAreaView: {
817
flex: 1,
18+
},
19+
container: {
920
justifyContent: 'center',
1021
alignItems: 'center',
1122
backgroundColor: '#F5FCFF',
1223
padding: 5,
24+
paddingVertical: 20,
1325
},
1426
welcome: {
1527
fontSize: 20,
1628
textAlign: 'center',
1729
margin: 10,
1830
},
1931
instructions: {
20-
fontSize: 22,
32+
fontSize: 18,
2133
fontWeight: '500',
2234
textAlign: 'center',
2335
color: '#333333',
24-
marginBottom: 20,
36+
marginBottom: 10,
2537
},
2638
textInputContainer: {
2739
marginBottom: 20,
@@ -35,6 +47,7 @@ const styles = StyleSheet.create({
3547
justifyContent: 'space-around',
3648
marginBottom: 20,
3749
width: '60%',
50+
gap: 20,
3851
},
3952
textInput: {
4053
height: 40,
@@ -47,94 +60,80 @@ const styles = StyleSheet.create({
4760
marginBottom: 10,
4861
textAlign: 'center',
4962
},
50-
buttonStyle: {
51-
marginHorizontal: 20,
52-
},
5363
});
5464

55-
export default class App extends Component {
56-
state = {
57-
otpInput: '',
58-
inputText: '',
59-
};
65+
const App: React.FC = () => {
66+
const [otpInput, setOtpInput] = useState<string>("");
6067

61-
alertText = () => {
62-
const {otpInput = ''} = this.state;
63-
if (otpInput) {
64-
Alert.alert(otpInput);
65-
}
66-
};
68+
const input = useRef<OTPTextView>(null);
6769

68-
clear = () => {
69-
this.input1.clear();
70-
};
70+
const clear = () => input.current?.clear();
7171

72-
updateOtpText = () => {
73-
// will automatically trigger handleOnTextChange callback passed
74-
this.input1.setValue(this.state.inputText);
75-
};
72+
const updateOtpText = () => input.current?.setValue(otpInput);
7673

77-
render() {
78-
return (
79-
<View style={styles.container}>
80-
<Text style={styles.instructions}>react-native-otp-textinput</Text>
74+
const showTextAlert = () => otpInput && Alert.alert(otpInput);
75+
76+
return (
77+
<SafeAreaView style={styles.safeAreaView}>
78+
<ScrollView contentContainerStyle={styles.container}>
8179
<OTPTextView
82-
ref={e => (this.input1 = e)}
80+
ref={input}
8381
containerStyle={styles.textInputContainer}
84-
handleTextChange={text => this.setState({otpInput: text})}
82+
handleTextChange={setOtpInput}
8583
inputCount={4}
8684
keyboardType="numeric"
8785
/>
8886
<TextInput
8987
maxLength={4}
90-
onChangeText={e => this.setState({inputText: e})}
88+
onChangeText={setOtpInput}
9189
style={styles.textInput}
9290
/>
9391
<View style={styles.buttonWrapper}>
94-
<Button title="Clear" onPress={this.clear} />
92+
<Button title="Clear" onPress={clear} />
9593
<Button
96-
style={styles.buttonStyle}
9794
title="Update"
98-
onPress={this.updateOtpText}
95+
onPress={updateOtpText}
9996
/>
10097
<Button
101-
style={styles.buttonStyle}
10298
title="Submit"
103-
onPress={this.alertText}
99+
onPress={showTextAlert}
104100
/>
105101
</View>
106102
<Text style={styles.instructions}>Customizations</Text>
107103
<OTPTextView
108-
handleTextChange={e => {}}
104+
handleTextChange={() => { }}
109105
containerStyle={styles.textInputContainer}
110106
textInputStyle={styles.roundedTextInput}
111107
inputCount={5}
112108
inputCellLength={2}
113109
/>
114110
<OTPTextView
115-
handleTextChange={e => {}}
111+
handleTextChange={() => { }}
116112
containerStyle={styles.textInputContainer}
117113
textInputStyle={styles.roundedTextInput}
118114
defaultValue="1234"
119115
/>
120116
<OTPTextView
121-
handleTextChange={e => {}}
117+
handleTextChange={() => { }}
122118
containerStyle={styles.textInputContainer}
123-
textInputStyle={[styles.roundedTextInput, {borderRadius: 100}]}
119+
// textInputStyle={[styles.roundedTextInput, { borderRadius: 100 }]}
124120
tintColor="#000"
125121
/>
122+
<TextInput />
126123
<OTPTextView
127-
handleTextChange={e => {}}
124+
handleTextChange={() => { }}
128125
containerStyle={styles.textInputContainer}
129126
tintColor={['#FF0000', '#FFFF00', '#00FF00', '#0000FF']}
130127
/>
131128
<OTPTextView
132-
handleTextChange={e => {}}
129+
handleTextChange={() => { }}
133130
containerStyle={styles.textInputContainer}
134131
tintColor="#000"
135132
offTintColor={['#FF0000', '#FFFF00', '#00FF00', '#0000FF']}
136133
/>
137-
</View>
138-
);
139-
}
134+
</ScrollView>
135+
</SafeAreaView>
136+
)
140137
}
138+
139+
export default App;

0 commit comments

Comments
 (0)