-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* design: 마이페이지에 닉네임 변경 뷰로 가는 이미지 추가 * design: 내 프로필 변경(닉네임 변경) 뷰 생성 * feat: 마이페이지에서 프로필 변경 뷰로 이동하는 기능 구현 * feat: profile 작업을 위한 profile 서비스, profile 레포지토리 생성 * feat: hilt 적용 * feat: 닉네임 변경 기능 구현 * feat: 마이페이지에서 내 이름을 가져올 때 랭킹이 아닌 프로필 레포지토리를 사용해 가져오도록 변경 * refactor: 오류 문구 수정 * refactor: 인자 타입 변경 * refactor: 데이터 바이딩 변수 할당 * feat: 닉네임 변경 후 마이페이지로 돌아왔을 때 바뀐 닉네임으로 보이도록 변경 * design: 닉네임 뷰 배경 이미지 추가 * fix: 닉네임 변경 안되는 오류 수정 * design: 공백 추가 * refactor: 버튼 round 처리 * refactor: edittext 색상 변경 * refactor: edittext 색상 변경
- Loading branch information
1 parent
44b4acc
commit ce5d6a3
Showing
18 changed files
with
394 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
android/app/src/main/java/com/now/naaga/data/remote/dto/NicknameDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.now.naaga.data.remote.dto | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class NicknameDto( | ||
@SerialName("nickname") | ||
val nickname: String, | ||
) |
18 changes: 18 additions & 0 deletions
18
android/app/src/main/java/com/now/naaga/data/remote/retrofit/service/ProfileService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.now.naaga.data.remote.retrofit.service | ||
|
||
import com.now.naaga.data.remote.dto.NicknameDto | ||
import com.now.naaga.data.remote.dto.PlayerDto | ||
import retrofit2.Response | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.PATCH | ||
|
||
interface ProfileService { | ||
@GET("/profiles/my") | ||
suspend fun getProfile(): Response<PlayerDto> | ||
|
||
@PATCH("/profiles/my") | ||
suspend fun modifyNickname( | ||
@Body nicknameDto: NicknameDto, | ||
): Response<NicknameDto> | ||
} |
23 changes: 23 additions & 0 deletions
23
android/app/src/main/java/com/now/naaga/data/repository/DefaultProfileRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.now.naaga.data.repository | ||
|
||
import com.now.domain.model.Player | ||
import com.now.domain.repository.ProfileRepository | ||
import com.now.naaga.data.mapper.toDomain | ||
import com.now.naaga.data.remote.dto.NicknameDto | ||
import com.now.naaga.data.remote.retrofit.service.ProfileService | ||
import com.now.naaga.util.extension.getValueOrThrow | ||
|
||
class DefaultProfileRepository( | ||
private val profileService: ProfileService, | ||
) : ProfileRepository { | ||
override suspend fun fetchProfile(): Player { | ||
val response = profileService.getProfile().getValueOrThrow() | ||
return response.toDomain() | ||
} | ||
|
||
override suspend fun modifyNickname(nickname: String): String { | ||
val nicknameDto = NicknameDto(nickname) | ||
val response = profileService.modifyNickname(nicknameDto).getValueOrThrow() | ||
return response.nickname | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
android/app/src/main/java/com/now/naaga/presentation/profile/ProfileActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.now.naaga.presentation.profile | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.now.naaga.R | ||
import com.now.naaga.databinding.ActivityProfileBinding | ||
import com.now.naaga.presentation.mypage.MyPageActivity | ||
import com.now.naaga.util.extension.showToast | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class ProfileActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivityProfileBinding | ||
private val viewModel: ProfileViewModel by viewModels() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityProfileBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
binding.lifecycleOwner = this | ||
binding.viewModel = viewModel | ||
subscribe() | ||
setClickListeners() | ||
} | ||
|
||
private fun subscribe() { | ||
viewModel.modifyStatus.observe(this) { status -> | ||
if (status) { | ||
showToast(getString(R.string.profile_modify_success_message)) | ||
setResult(RESULT_OK, MyPageActivity.getIntent(this, viewModel.nickname.value.toString())) | ||
finish() | ||
} | ||
} | ||
viewModel.throwable.observe(this) { | ||
showToast(getString(R.string.profile_modify_fail_message)) | ||
} | ||
} | ||
|
||
private fun setClickListeners() { | ||
binding.ivProfileBack.setOnClickListener { | ||
finish() | ||
} | ||
binding.btnProfileNicknameModify.setOnClickListener { | ||
if (viewModel.isFormValid()) { | ||
viewModel.modifyNickname() | ||
} else { | ||
showToast(getString(R.string.profile_no_content_message)) | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
fun getIntent(context: Context): Intent { | ||
return Intent(context, ProfileActivity::class.java) | ||
} | ||
} | ||
} |
Oops, something went wrong.