Skip to content

Commit

Permalink
Merge pull request #4 from Dagic-zewdu/feature
Browse files Browse the repository at this point in the history
Text Box Icon
  • Loading branch information
Dagic-zewdu authored Nov 15, 2022
2 parents 3898e3a + a80566f commit 1048742
Show file tree
Hide file tree
Showing 6 changed files with 1,170 additions and 1,121 deletions.
4 changes: 3 additions & 1 deletion App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {View, TouchableWithoutFeedback, Keyboard} from 'react-native';
import React from 'react';
import FloatingTextInput from './src/floatingTextInput';
// @ts-ignore
import Icon from 'react-native-vector-icons/EvilIcons';

const App = () => {
return (
Expand All @@ -10,7 +12,7 @@ const App = () => {
onPress={() => Keyboard.dismiss()}>
<FloatingTextInput
label="Test sinte"
error="Invalid klhfdg"
icon={<Icon name="clock" size={28} color="#900" />}
onChangeText={text => console.log(text)}
/>
</TouchableWithoutFeedback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.floatinginputs.newarchitecture.MainApplicationReactNativeHost;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import com.oblador.vectoricons.VectorIconsPackage;

public class MainApplication extends Application implements ReactApplication {

Expand All @@ -29,7 +28,6 @@ protected List<ReactPackage> getPackages() {
// Packages that cannot be autolinked yet can be added manually here, for
// example:
// packages.add(new MyReactNativePackage());
packages.add(new VectorIconsPackage());
return packages;
}

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@react-native-community/cli-platform-android": "^9.3.1",
"react": "18.1.0",
"react-native": "0.70.4",
"react-native": "^0.70.5",
"react-native-vector-icons": "^9.2.0"
},
"devDependencies": {
Expand All @@ -21,6 +22,7 @@
"@types/jest": "^26.0.23",
"@types/react": "^18.0.21",
"@types/react-native": "^0.70.6",
"@types/react-native-vector-icons": "^6.4.12",
"@types/react-test-renderer": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
Expand Down
9 changes: 8 additions & 1 deletion src/floatingTextInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const FloatingTextInput = ({
labelColor = '#111',
labelStyle = {},
inputStyle = {},
icon,
...props
}: Props) => {
const [val, setValue] = useState(props.value ? props.value : '');
Expand Down Expand Up @@ -70,7 +71,7 @@ const FloatingTextInput = ({

const yVal = moveText.interpolate({
inputRange: [0, 1],
outputRange: [4, -18],
outputRange: [4, -20],
});

const animStyle = {
Expand All @@ -94,11 +95,17 @@ const FloatingTextInput = ({
style={{
...styles.label,
...labelStyle,
left: icon ? 20 : 15,
color: error ? 'red' : labelColor,
}}>
{label}
</Text>
</Animated.View>
{icon ? (
<View style={styles.iconContainer}>{icon}</View>
) : (
<React.Fragment></React.Fragment>
)}
<TextInput
style={{...styles.input, ...inputStyle}}
value={val}
Expand Down
10 changes: 9 additions & 1 deletion src/floatingTextInput/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const styles = StyleSheet.create({
borderWidth: 1,
borderColor: '#bdbdbd',
borderRadius: 2,
paddingLeft: 35,
},
icon: {
width: 40,
Expand All @@ -22,13 +23,15 @@ const styles = StyleSheet.create({
fontSize: 13,
height: 45,
color: '#000',
justifyContent: 'center',
marginTop: 2,
},
label: {
fontSize: 13,
backgroundColor: '#fff',
},
animatedStyle: {
top: 11,
top: 13,
left: 15,
position: 'absolute',
borderRadius: 90,
Expand All @@ -40,6 +43,11 @@ const styles = StyleSheet.create({
alignSelf: 'center',
paddingHorizontal: 10,
},
iconContainer: {
position: 'absolute',
top: 11,
left: 5,
},
});

export default styles;
Loading

0 comments on commit 1048742

Please sign in to comment.