import {SafeAreaView, View, Text} from 'react-native';
import React from 'react';
import ProfileBody from '../components/ProfileBody';
const Profile = () => {
return (
<SafeAreaView style={{width: '100%', backgroundColor: 'white'}}>
<View style={{width: '100%', padding: 10}}>
<ProfileBody
name="Johnny"
accountName="johnny"
profileImage={require('../../assets/images/userProfile.jpeg')}
followers="300"
following="35"
post="458"
/>
</View>
</SafeAreaView>
);
};
export default Profile;
<ProfileBody
name="Johnny"
accountName="johnny"
profileImage={require('../../assets/images/userProfile.jpeg')}
followers="300"
following="35"
post="458"
/>
/// 추가
<ProfileButton
id={0}
name="Johnny"
accountName="johnny"
profileImage={require('../../assets/images/userProfile.jpeg')}
/>
id === 0 번일때 보여주는 코드를 추가한다
import {StyleSheet, Text, View, TouchableOpacity} from 'react-native';
import React, {useState} from 'react';
import Feather from 'react-native-vector-icons/Feather';
import {useNavigation} from '@react-navigation/native';
const ProfileButton = ({id, name, accountName, profileImage}) => {
const navigation = useNavigation();
const [follow, setFollow] = useState(follow);
return (
<>
{id === 0 ? (
<View
style={{
width: '100%',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-evenly',
paddingVertical: 5,
}}>
<TouchableOpacity
onPress={() =>
navigation.push('EditProfile', {
name: name,
accountName: accountName,
profileImage: profileImage,
})
}
style={{
width: '100%',
}}>
<View
style={{
width: '100%',
height: 35,
borderRadius: 5,
borderColor: '#DEDEDE',
borderWidth: 1,
justifyContent: 'center',
alignItems: 'center',
}}>
<Text
style={{
fontWeight: 'bold',
fontSize: 14,
letterSpacing: 1,
opacity: 0.8,
}}>
프로필 수정
</Text>
</View>
</TouchableOpacity>
</View>
) : (
<View
style={{
width: '100%',
flexDirection: 'row',
justifyContent: 'space-evenly',
alignItems: 'center',
}}>
<TouchableOpacity
onPress={() => setFollow(!follow)}
style={{width: '42%'}}>
<View
style={{
width: '100%',
height: 35,
borderRadius: 5,
backgroundColor: follow ? null : '#3493D9',
borderWidth: follow ? 1 : 0,
borderColor: '#DEDEDE',
justifyContent: 'center',
alignItems: 'center',
}}>
<Text style={{color: follow ? 'black' : 'white'}}>
{follow ? '팔로잉' : '팔로우'}
</Text>
</View>
</TouchableOpacity>
<View
style={{
width: '42%',
height: 35,
borderWidth: 1,
borderColor: '#DEDEDE',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 5,
}}>
<Text>메시지</Text>
</View>
<View
style={{
width: '10%',
height: 35,
borderWidth: 1,
borderColor: '#DEDEDE',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 5,
}}>
<Feather
name="chevron-down"
style={{fontSize: 20, color: 'black'}}
/>
</View>
</View>
)}
</>
);
};
export default ProfileButton;
const styles = StyleSheet.create({});
const Profile = () => {
let circles = [];
let numberOfCircles = 10;
for (let index = 0; index < numberOfCircles; index++) {
circles.push(
<View key={index}>
{index === 0 ? (
<View
style={{
width: 60,
height: 60,
borderRadius: 100,
borderWidth: 1,
opacity: 0.7,
marginHorizontal: 5,
justifyContent: 'center',
alignItems: 'center',
}}>
<Entypo name="plus" style={{fontSize: 40, color: 'black'}} />
</View>
) : (
<View
style={{
width: 60,
height: 60,
borderRadius: 100,
backgroundColor: 'black',
opacity: 0.1,
marginHorizontal: 5,
}}></View>
)}
</View>,
);
}
return (
...
<View>
<ScrollView
horizontal={true}
showsHorizontalScrollIndicator={false}
style={{
paddingVertical: 5,
paddingHorizontal: 10,
}}>
{circles}
</ScrollView>
</View>
</SafeAreaView>
import {
View,
Text,
SafeAreaView,
TouchableOpacity,
Image,
TextInput,
} from 'react-native';
import React from 'react';
const EditProfile = ({route, navigation}) => {
const {name, accountName, profileImage} = route.params;
return (
<SafeAreaView
style={{
width: '100%',
backgroundColor: 'white',
}}>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
padding: 10,
}}>
<TouchableOpacity onPress={() => navigation.goBack()}>
<Text>취소</Text>
</TouchableOpacity>
<Text style={{fontSize: 16, fontWeight: 'bold'}}>프로필 수정</Text>
<TouchableOpacity
onPress={() => {
navigation.goBack();
}}>
<Text style={{color: '#3493D9'}}>완료</Text>
</TouchableOpacity>
</View>
<View style={{padding: 20, alignItems: 'center'}}>
<Image
source={profileImage}
style={{width: 80, height: 80, borderRadius: 100}}
/>
<Text
style={{
color: '#3493D9',
marginTop: 10,
}}>
프로필 사진 바꾸기
</Text>
</View>
<View style={{padding: 10}}>
<View>
<Text
style={{
opacity: 0.5,
}}>
이름
</Text>
<TextInput
placeholder="이름"
defaultValue={name}
style={{
fontSize: 16,
borderBottomWidth: 1,
borderColor: '#CDCDCD',
}}
/>
</View>
<View style={{paddingVertical: 10}}>
<Text
style={{
opacity: 0.5,
}}>
사용자 이름
</Text>
<TextInput
placeholder="사용자 이름"
defaultValue={accountName}
style={{
fontSize: 16,
borderBottomWidth: 1,
borderColor: '#CDCDCD',
}}
/>
</View>
<View style={{paddingVertical: 10}}>
<Text
style={{
opacity: 0.5,
}}>
웹사이트
</Text>
<TextInput
placeholder="웹사이트"
style={{
fontSize: 16,
borderBottomWidth: 1,
borderColor: '#CDCDCD',
}}
/>
</View>
<View style={{paddingVertical: 10}}>
<Text
style={{
opacity: 0.5,
}}>
소개
</Text>
<TextInput
placeholder="소개"
style={{
fontSize: 16,
borderBottomWidth: 1,
borderColor: '#CDCDCD',
}}
/>
</View>
</View>
<View>
<Text
style={{
marginVertical: 5,
padding: 10,
color: '#3493D9',
}}>
프로페셔널 계정으로 전환
</Text>
<Text
style={{
marginVertical: 5,
padding: 10,
color: '#3493D9',
}}>
개인정보 설정
</Text>
</View>
</SafeAreaView>
);
};
export default EditProfile;