Skip to content

Commit

Permalink
fixes after code review
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Ro-Man committed Oct 22, 2021
1 parent e09e159 commit 5d75938
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/components/input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Input = ({
const [isError, setIsError] = useState(false);

const _onChangeText = (value: string) => {
onChangeText && onChangeText(value);
onChangeText(value);
setIsError(!rule.test(value));
};

Expand Down
25 changes: 12 additions & 13 deletions src/features/profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,30 @@ export const ProfileScreen = () => {

useEffect(() => {
(async () => {
if (Platform.OS !== 'web') {
const { status } =
await ImagePicker.requestMediaLibraryPermissionsAsync();
if (status !== 'granted') {
alert('Sorry, we need camera roll permissions to make this work!');
}
const { status } =
await ImagePicker.requestMediaLibraryPermissionsAsync();
if (status !== 'granted') {
alert('Sorry, we need camera roll permissions to make this work!');
}
})();
}, []);

const pickImage = async () => {
let permission = await ImagePicker.getMediaLibraryPermissionsAsync();
console.log('permission: ', permission);
if (permission.status !== 'denied') {
if (permission.granted) {
let result = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true,
aspect: [1, 1],
quality: 1,
limited: true,
accessPrivileges: 'limited',
});
console.log(result);

if (!result.cancelled) {
setImage(result.uri);
}
} else {
alert('Sorry, we need camera roll permissions to make this work!');
alert('Sorry, we need library permissions to make this work!');
}
};

Expand All @@ -79,9 +75,7 @@ export const ProfileScreen = () => {
<View style={styles.header}>
<Text style={styles.title}>Profile</Text>
</View>
<View
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}
>
<View style={styles.avatarContainer}>
<Pressable onPress={pickImage} style={styles.avatarButton}>
<Image
source={image ? { uri: image } : defaultUserImage}
Expand Down Expand Up @@ -183,6 +177,11 @@ const styles = StyleSheet.create({
fontSize: 20,
fontWeight: 'bold',
},
avatarContainer: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
avatarButton: {
width: 210,
height: 210,
Expand Down

0 comments on commit 5d75938

Please sign in to comment.