Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text Box Icon #4

Merged
merged 11 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 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,8 @@ const App = () => {
onPress={() => Keyboard.dismiss()}>
<FloatingTextInput
label="Test sinte"
error="Invalid klhfdg"
error="Invalid Input"
icon={<Icon name="clock" size={30} 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: 9 additions & 0 deletions 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 @@ -93,12 +94,20 @@ const FloatingTextInput = ({
<Text
style={{
...styles.label,
...styles.animatedStyle, left: icon ? 30 : 15,
Dagic-zewdu marked this conversation as resolved.
Show resolved Hide resolved
...labelStyle,
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
6 changes: 6 additions & 0 deletions 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 Down Expand Up @@ -40,6 +41,11 @@ const styles = StyleSheet.create({
alignSelf: 'center',
paddingHorizontal: 10,
},
iconContainer: {
position: "absolute",
top: 11,
left: 5,
}
});

export default styles;
Loading