-
Notifications
You must be signed in to change notification settings - Fork 0
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
Input component 86937xxay #2
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { useState } from 'react'; | ||
import { StyleSheet, Text, TextInput, View } from 'react-native'; | ||
|
||
interface CustomInputProps { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. każdy wie, że ten typ jest napisany do propsów komponentu poniżej, więc nie ma potrzeby pisać There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dobrą techniką tutaj byłoby przyjęcie przez propsów dokładnie takich samych typów jak komponent |
||
label: string; | ||
secureTextEntry?: boolean; | ||
onSubmit: (text: string) => void; | ||
} | ||
|
||
const CustomInput: React.FC<CustomInputProps> = ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ogólnie są dwie opcje typowania komponentu. W zasadzie obie są okej pod warunkiem, że stosuje je każdy w aplikacji spójnie.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nazwa zamiast |
||
label, | ||
secureTextEntry, | ||
onSubmit, | ||
}) => { | ||
const [text, setText] = useState(''); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. jeśli już byś chciał użyć |
||
|
||
const handleSubmit = () => { | ||
onSubmit(text); | ||
}; | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<Text style={styles.label}>{label}</Text> | ||
<TextInput | ||
style={styles.input} | ||
value={text} | ||
secureTextEntry={secureTextEntry} | ||
onChangeText={setText} | ||
onSubmitEditing={handleSubmit} | ||
Comment on lines
+24
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. brakuje propsa |
||
/> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
marginBottom: 10, | ||
}, | ||
label: { | ||
fontSize: 16, | ||
marginBottom: 5, | ||
fontFamily: '', | ||
}, | ||
input: { | ||
borderWidth: 1, | ||
borderColor: '#c7c4d6', | ||
borderRadius: 10, | ||
width: 300, | ||
height: 40, | ||
padding: 10, | ||
fontSize: 16, | ||
}, | ||
}); | ||
Comment on lines
+35
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. w projekcie można już korzystać ze stylowania zgodnie z dokumentacją. Docelowo chcemy tworzyć wersję w motywie jasnym i ciemnym i takie też inputy potrzebujemy w tym zadaniu |
||
|
||
export default CustomInput; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zamiast
interface
stosujmytype