Skip to content

Commit 2ab1e21

Browse files
authored
Merge pull request #189 from YAPP-Github/feat/#188-mypage-edit-profile
[feat] #188 마이페이지 프로필 편집 기능 추가
2 parents 067476c + 8f907a9 commit 2ab1e21

5 files changed

Lines changed: 123 additions & 158 deletions

File tree

feature/mypage/impl/src/main/java/com/neki/android/feature/mypage/impl/profile/EditProfileScreen.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import com.neki.android.feature.mypage.impl.main.MyPageIntent
3535
import com.neki.android.feature.mypage.impl.main.MyPageState
3636
import com.neki.android.feature.mypage.impl.main.MyPageViewModel
3737
import com.neki.android.feature.mypage.impl.profile.model.EditProfileImageType
38-
import com.neki.android.feature.mypage.impl.profile.component.EditProfileImage
38+
import com.neki.android.feature.mypage.impl.profile.component.ProfileImage
3939
import com.neki.android.feature.mypage.impl.profile.component.ProfileEditTopBar
4040
import com.neki.android.feature.mypage.impl.profile.component.SelectProfileImageDialog
4141
import com.neki.android.feature.mypage.impl.profile.component.ProfileImageOption
@@ -76,7 +76,7 @@ fun EditProfileScreen(
7676
onIntent: (MyPageIntent) -> Unit = {},
7777
) {
7878
var displayProfileImage by remember {
79-
mutableStateOf<Any?>(uiState.userInfo.profileImageUrl)
79+
mutableStateOf<Any>(uiState.userInfo.profileImageUrl)
8080
}
8181

8282
LaunchedEffect(uiState.profileImageState) {
@@ -108,7 +108,7 @@ fun EditProfileScreen(
108108
onIntent(MyPageIntent.ClickEditComplete(nickname = textFieldState.text.toString()))
109109
},
110110
)
111-
EditProfileImage(
111+
ProfileImage(
112112
profileImage = displayProfileImage,
113113
onClickCameraIcon = { onIntent(MyPageIntent.ClickCameraIcon) },
114114
)

feature/mypage/impl/src/main/java/com/neki/android/feature/mypage/impl/profile/ProfileSettingScreen.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import com.neki.android.feature.mypage.impl.main.MyPageEffect
2121
import com.neki.android.feature.mypage.impl.main.MyPageIntent
2222
import com.neki.android.feature.mypage.impl.main.MyPageState
2323
import com.neki.android.feature.mypage.impl.main.MyPageViewModel
24+
import com.neki.android.feature.mypage.impl.profile.component.ProfileImage
2425
import com.neki.android.feature.mypage.impl.profile.component.ProfileSettingTopBar
25-
import com.neki.android.feature.mypage.impl.profile.component.SettingProfileImage
2626
import timber.log.Timber
2727

2828
@Composable
@@ -72,9 +72,10 @@ fun ProfileSettingScreen(
7272
ProfileSettingTopBar(
7373
onBack = { onIntent(MyPageIntent.ClickBackIcon) },
7474
)
75-
SettingProfileImage(
75+
ProfileImage(
76+
profileImage = uiState.userInfo.profileImageUrl.ifEmpty { null },
7677
nickname = uiState.userInfo.nickname,
77-
profileImage = uiState.userInfo.profileImageUrl,
78+
onClickCameraIcon = { onIntent(MyPageIntent.ClickEditIcon) },
7879
onClickEdit = { onIntent(MyPageIntent.ClickEditIcon) },
7980
)
8081
SectionTitleText(text = "서비스 정보 및 지원")

feature/mypage/impl/src/main/java/com/neki/android/feature/mypage/impl/profile/component/EditProfileImage.kt

Lines changed: 0 additions & 73 deletions
This file was deleted.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
package com.neki.android.feature.mypage.impl.profile.component
2+
3+
import androidx.compose.foundation.background
4+
import androidx.compose.foundation.layout.Arrangement
5+
import androidx.compose.foundation.layout.Box
6+
import androidx.compose.foundation.layout.Column
7+
import androidx.compose.foundation.layout.Row
8+
import androidx.compose.foundation.layout.padding
9+
import androidx.compose.foundation.layout.size
10+
import androidx.compose.foundation.shape.CircleShape
11+
import androidx.compose.material3.Icon
12+
import androidx.compose.material3.Text
13+
import androidx.compose.runtime.Composable
14+
import androidx.compose.ui.Alignment
15+
import androidx.compose.ui.Modifier
16+
import androidx.compose.ui.draw.clip
17+
import androidx.compose.ui.graphics.Color
18+
import androidx.compose.ui.graphics.vector.ImageVector
19+
import androidx.compose.ui.layout.ContentScale
20+
import androidx.compose.ui.res.painterResource
21+
import androidx.compose.ui.res.vectorResource
22+
import androidx.compose.ui.unit.dp
23+
import coil3.compose.AsyncImage
24+
import com.neki.android.core.designsystem.ComponentPreview
25+
import com.neki.android.core.designsystem.R
26+
import com.neki.android.core.designsystem.modifier.noRippleClickableSingle
27+
import com.neki.android.core.designsystem.ui.theme.NekiTheme
28+
import com.neki.android.core.ui.compose.VerticalSpacer
29+
30+
@Composable
31+
internal fun ProfileImage(
32+
profileImage: Any? = null,
33+
nickname: String = "",
34+
onClickCameraIcon: () -> Unit,
35+
onClickEdit: () -> Unit = {},
36+
) {
37+
Column(
38+
modifier = Modifier
39+
.padding(
40+
top = 20.dp,
41+
bottom = if (nickname.isNotEmpty()) 34.dp else 28.dp,
42+
),
43+
horizontalAlignment = Alignment.CenterHorizontally,
44+
) {
45+
Box {
46+
AsyncImage(
47+
modifier = Modifier
48+
.size(142.dp)
49+
.clip(CircleShape),
50+
model = profileImage ?: R.drawable.image_profile_empty,
51+
contentDescription = null,
52+
contentScale = ContentScale.Crop,
53+
placeholder = painterResource(R.drawable.image_profile_empty),
54+
error = painterResource(R.drawable.image_profile_empty),
55+
)
56+
Box(
57+
modifier = Modifier
58+
.align(Alignment.BottomEnd)
59+
.background(
60+
color = NekiTheme.colorScheme.gray700,
61+
shape = CircleShape,
62+
)
63+
.noRippleClickableSingle(onClick = onClickCameraIcon)
64+
.padding(8.dp),
65+
contentAlignment = Alignment.Center,
66+
) {
67+
Icon(
68+
imageVector = ImageVector.vectorResource(R.drawable.icon_camera_filled),
69+
contentDescription = null,
70+
tint = Color.Unspecified,
71+
)
72+
}
73+
}
74+
if (nickname.isNotEmpty()) {
75+
VerticalSpacer(16.dp)
76+
Row(
77+
horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),
78+
verticalAlignment = Alignment.CenterVertically,
79+
) {
80+
Text(
81+
text = nickname,
82+
style = NekiTheme.typography.title20Medium,
83+
color = NekiTheme.colorScheme.gray900,
84+
)
85+
Icon(
86+
modifier = Modifier.noRippleClickableSingle(onClick = onClickEdit),
87+
imageVector = ImageVector.vectorResource(R.drawable.icon_edit),
88+
contentDescription = null,
89+
tint = Color.Unspecified,
90+
)
91+
}
92+
}
93+
}
94+
}
95+
96+
@ComponentPreview
97+
@Composable
98+
private fun ProfileImageWithNicknamePreview() {
99+
NekiTheme {
100+
ProfileImage(
101+
nickname = "네키네키",
102+
onClickCameraIcon = {},
103+
onClickEdit = {},
104+
)
105+
}
106+
}
107+
108+
@ComponentPreview
109+
@Composable
110+
private fun ProfileImagePreview() {
111+
NekiTheme {
112+
ProfileImage(
113+
onClickCameraIcon = {},
114+
)
115+
}
116+
}

feature/mypage/impl/src/main/java/com/neki/android/feature/mypage/impl/profile/component/SettingProfileImage.kt

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)