Skip to content

Commit

Permalink
๐Ÿš€ :: (#421) ์›น๋ทฐ ์„ค์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
parkuiery authored Nov 7, 2024
2 parents 68ca1ef + 3d4effa commit d2f086b
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ enum class Department(val value: String) {
EMBEDDED_SOFTWARE("์ž„๋ฒ ๋””๋“œ์†Œํ”„ํŠธ์›จ์–ด๊ณผ"),
INFORMATION_SECURITY("์ •๋ณด๋ณด์•ˆ๊ณผ"),
AI_SOFTWARE("์ธ๊ณต์ง€๋Šฅ์†Œํ”„ํŠธ์›จ์–ด๊ณผ"),
COMMON("๊ณตํ†ต๊ต์œก๊ณผ์ •"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ object JobisIcon {
val SnowMan = R.drawable.ic_snow_man
val Notification = R.drawable.ic_notification
val Empty = R.drawable.ic_empty
val Person = R.drawable.ic_person
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PostSignUpUseCase @Inject constructor(
gender: Gender,
classRoom: Long,
number: Long,
profileImageUrl: String,
profileImageUrl: String?,
deviceToken: String,
) = runCatching {
studentRepository.postSignUp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class PostSignUpRequest(
@Json(name = "gender") val gender: Gender,
@Json(name = "class_room") val classRoom: Long,
@Json(name = "number") val number: Long,
@Json(name = "profile_image_url") val profileImageUrl: String,
@Json(name = "profile_image_url") val profileImageUrl: String?,
@Json(name = "platform_type") val platformType: PlatformType,
@Json(name = "device_token") val deviceToken: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private fun MyPageScreen(
with(state.studentInformation) {
StudentInfo(
modifier = Modifier.padding(vertical = 12.dp),
profileImageUrl = state.studentInformation.profileImageUrl,
profileImageUrl = profileImageUrl,
number = studentGcn,
name = studentName,
department = department.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ internal class MyPageViewModel @Inject constructor(

private fun fetchStudentInformation() {
viewModelScope.launch(Dispatchers.IO) {
fetchStudentInformationUseCase().onSuccess {
val profileImageUrl = ResourceKeys.IMAGE_URL + it.profileImageUrl
setState { state.value.copy(studentInformation = it.copy(profileImageUrl = profileImageUrl)) }
}
fetchStudentInformationUseCase()
.onSuccess {
val profileImageUrl = ResourceKeys.IMAGE_URL + it.profileImageUrl
setState { state.value.copy(studentInformation = it.copy(profileImageUrl = profileImageUrl)) }
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class SignUpData(
val gender: Gender? = null,
val classRoom: String = "",
val number: String = "",
val profileImageUrl: String = "",
val profileImageUrl: String? = null,
)

internal fun SignUpData.toJsonString() = Json.encodeToString(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import coil.compose.AsyncImage
import team.retum.jobisdesignsystemv2.appbar.JobisLargeTopAppBar
import team.retum.jobisdesignsystemv2.button.ButtonColor
import team.retum.jobisdesignsystemv2.button.JobisButton
import team.retum.jobisdesignsystemv2.foundation.JobisIcon
import team.retum.jobisdesignsystemv2.foundation.JobisTheme
import team.retum.jobisdesignsystemv2.foundation.JobisTypography
import team.retum.jobisdesignsystemv2.text.JobisText
Expand Down Expand Up @@ -82,6 +83,7 @@ internal fun SetProfile(
SetProfileScreen(
onBackPressed = onBackPressed,
onNextClick = setProfileViewModel::onNextClick,
onImgChangeClick = setProfileViewModel::onImgChangeClick,
activityResultLauncher = activityResultLauncher,
state = state,
)
Expand All @@ -91,6 +93,7 @@ internal fun SetProfile(
private fun SetProfileScreen(
onBackPressed: () -> Unit,
onNextClick: () -> Unit,
onImgChangeClick: () -> Unit,
activityResultLauncher: ManagedActivityResultLauncher<PickVisualMediaRequest, Uri?>,
state: SetProfileState,
) {
Expand All @@ -104,26 +107,26 @@ private fun SetProfileScreen(
onBackPressed = onBackPressed,
)
SetImage(
uri = state.uri.toString(),
uri = state.uri,
onClick = {
val mediaType = ActivityResultContracts.PickVisualMedia.ImageOnly
val request = PickVisualMediaRequest(mediaType)
activityResultLauncher.launch(request)
onImgChangeClick()
},
)
Spacer(modifier = Modifier.weight(1f))
JobisButton(
text = stringResource(id = R.string.next),
text = stringResource(id = if (state.uri == null) R.string.skip else R.string.next),
onClick = onNextClick,
color = ButtonColor.Primary,
enabled = state.buttonEnabled,
)
}
}

@Composable
private fun SetImage(
uri: String?,
uri: Uri?,
onClick: () -> Unit,
) {
Column(
Expand All @@ -137,7 +140,7 @@ private fun SetImage(
modifier = Modifier
.size(80.dp)
.clip(CircleShape),
model = uri ?: team.retum.common.R.drawable.ic_person,
model = uri ?: JobisIcon.Person,
contentDescription = "user profile",
contentScale = ContentScale.Crop,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ internal class SetProfileViewModel @Inject constructor(
}

internal fun onNextClick() {
val profileImageUrl = state.value.profileImageUrl
postSideEffect(SetProfileSideEffect.MoveToNext(profileImageUrl = profileImageUrl))
}

internal fun onImgChangeClick() {
viewModelScope.launch(Dispatchers.IO) {
createPresignedUrlUseCase(files = listOf(state.value.image?.name ?: "")).onSuccess {
val response = it.urls.first()
Expand All @@ -60,7 +65,7 @@ internal class SetProfileViewModel @Inject constructor(
file = state.value.image!!,
).onSuccess {
val encodedImageUrl = URLEncoder.encode(fileUrl, "UTF8")
postSideEffect(SetProfileSideEffect.MoveToNext(profileImageUrl = encodedImageUrl))
setState { state.value.copy(profileImageUrl = encodedImageUrl) }
}
}
}
Expand All @@ -70,18 +75,20 @@ internal data class SetProfileState(
val image: File?,
val imageUrl: String,
val uri: Uri?,
val profileImageUrl: String?,
val buttonEnabled: Boolean,
) {
companion object {
fun getInitialState() = SetProfileState(
image = null,
imageUrl = "",
uri = null,
profileImageUrl = null,
buttonEnabled = false,
)
}
}

internal sealed interface SetProfileSideEffect {
data class MoveToNext(val profileImageUrl: String) : SetProfileSideEffect
data class MoveToNext(val profileImageUrl: String?) : SetProfileSideEffect
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ internal class TermsViewModel @Inject constructor(
internal fun onCompleteClick(signUpData: SignUpData) {
with(signUpData) {
val decodedPassword = URLDecoder.decode(password, "UTF8")
val decodedImageUrl = URLDecoder.decode(profileImageUrl, "UTF8")
val decodedImageUrl = if (profileImageUrl.isNullOrEmpty()) {
null
} else {
URLDecoder.decode(
profileImageUrl,
"UTF8",
)
}
viewModelScope.launch(Dispatchers.IO) {
postSignUpUseCase(
email = email,
Expand Down
1 change: 1 addition & 0 deletions feature/signup/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<string name="name">์ด๋ฆ„</string>
<string name="student_number">ํ•™๋ฒˆ</string>
<string name="next">๋‹ค์Œ</string>
<string name="skip">๊ฑด๋„ˆ๋›ฐ๊ธฐ</string>


<string name="select_gender">์„ฑ๋ณ„์„ ์„ ํƒํ•ด์ฃผ์„ธ์š”</string>
Expand Down

0 comments on commit d2f086b

Please sign in to comment.