Skip to content

Commit

Permalink
#86 refactor : Merge Complete
Browse files Browse the repository at this point in the history
  • Loading branch information
yy0ung committed Nov 21, 2023
1 parent a937870 commit f69a210
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
1 change: 0 additions & 1 deletion Aos/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/Theme.Nibobnebob"
android:usesCleartextTraffic="true"
tools:targetApi="31">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import androidx.navigation.NavController
import androidx.navigation.Navigation
import androidx.navigation.fragment.findNavController
import com.avengers.nibobnebob.R
import com.avengers.nibobnebob.databinding.FragmentMyPageBinding
import com.avengers.nibobnebob.presentation.base.BaseFragment
Expand All @@ -17,7 +18,6 @@ import kotlinx.coroutines.flow.collectLatest

@AndroidEntryPoint
class MyPageFragment : BaseFragment<FragmentMyPageBinding>(R.layout.fragment_my_page) {
private lateinit var navController: NavController
private val viewModel: MyPageViewModel by viewModels()
private val sharedViewModel: MyPageSharedViewModel by viewModels()
override val parentViewModel: MainViewModel by activityViewModels()
Expand All @@ -31,15 +31,13 @@ class MyPageFragment : BaseFragment<FragmentMyPageBinding>(R.layout.fragment_my_
private fun initView(view: View) {
binding.svm = sharedViewModel
binding.vm = viewModel
navController = Navigation.findNavController(view)


viewLifecycleOwner.repeatOnStarted {
sharedViewModel.uiEvent.collect { event ->
when (event) {
is MyPageSharedUiEvent.NavigateToEditProfile -> navController.toEditProfile()
is MyPageSharedUiEvent.NavigateToMyList -> navController.toMyList()
is MyPageSharedUiEvent.NavigateToWishList -> navController.toWishList()
is MyPageSharedUiEvent.NavigateToEditProfile -> findNavController().toEditProfile()
is MyPageSharedUiEvent.NavigateToMyList -> findNavController().toMyList()
is MyPageSharedUiEvent.NavigateToWishList -> findNavController().toWishList()
else -> Unit
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MyPageViewModel @Inject constructor(
}

private fun getUserInfo() {
myPageRepository.getMyPageInfo().onEach {
myPageRepository.getMyInfo().onEach {
when (it) {
is ApiState.Success -> {
it.data.toUiMyPageInfoData().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.avengers.nibobnebob.data.model.ApiState
import com.avengers.nibobnebob.data.model.request.MyPageEditInfoRequest
import com.avengers.nibobnebob.data.repository.MyPageEditRepository
import com.avengers.nibobnebob.data.model.request.EditMyInfoRequest
import com.avengers.nibobnebob.data.repository.MyPageRepository
import com.avengers.nibobnebob.data.repository.ValidationRepository
import com.avengers.nibobnebob.presentation.ui.main.mypage.Validation
import com.avengers.nibobnebob.presentation.ui.main.mypage.mapper.toUiMyPageEditInfoData
import com.avengers.nibobnebob.presentation.util.LocationArray
Expand Down Expand Up @@ -44,7 +45,8 @@ sealed class EditProfileUiEvent {

@HiltViewModel
class EditProfileViewModel @Inject constructor(
private val myPageEditRepository: MyPageEditRepository
private val myPageRepository: MyPageRepository,
private val validationRepository: ValidationRepository
) : ViewModel() {
private val _uiState = MutableStateFlow(EditProfileUiState())
val uiState: StateFlow<EditProfileUiState> = _uiState.asStateFlow()
Expand Down Expand Up @@ -74,7 +76,7 @@ class EditProfileViewModel @Inject constructor(
}

private fun getOriginalData() {
myPageEditRepository.getMyPageEditInfo().onEach {
myPageRepository.getMyDefaultInfo().onEach {

when (it) {
is ApiState.Success -> {
Expand Down Expand Up @@ -123,10 +125,10 @@ class EditProfileViewModel @Inject constructor(
}

fun checkNickValidation() {
myPageEditRepository.getCheckNickname(nickState.value).onEach {
validationRepository.nickValidation(nickState.value).onEach {
when (it) {
is ApiState.Success -> {
if (it.data.data.isExist) {
if (it.data.isExist) {

_uiState.value = uiState.value.copy(
nickName = InputState(
Expand Down Expand Up @@ -196,8 +198,8 @@ class EditProfileViewModel @Inject constructor(

fun doneEditProfile() {

myPageEditRepository.putMyPageEditInfo(
MyPageEditInfoRequest(
myPageRepository.editMyInfo(
EditMyInfoRequest(
nickName = nickState.value,
email = uiState.value.email,
provider = uiState.value.provider,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.avengers.nibobnebob.presentation.ui.main.mypage.mapper

import com.avengers.nibobnebob.data.model.response.MyPageInfoResponse
import com.avengers.nibobnebob.data.model.response.MyInfoResponse
import com.avengers.nibobnebob.presentation.ui.main.mypage.model.UiMyPageInfoData

internal fun MyPageInfoResponse.toUiMyPageInfoData() = UiMyPageInfoData(
nickName = data.userInfo.nickName,
age = data.userInfo.birthdate,
location = data.userInfo.region,
gender = if(data.userInfo.isMale) "" else ""
internal fun MyInfoResponse.toUiMyPageInfoData() = UiMyPageInfoData(
nickName = userInfo.nickName,
age = userInfo.birthdate,
location = userInfo.region,
gender = if(userInfo.isMale) "" else ""
)
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.avengers.nibobnebob.presentation.ui.main.mypage.mapper

import com.avengers.nibobnebob.data.model.response.MyPageEditInfoResponse
import com.avengers.nibobnebob.data.model.response.MyDefaultInfoResponse
import com.avengers.nibobnebob.data.model.response.MyInfoResponse
import com.avengers.nibobnebob.presentation.ui.main.mypage.model.UiMyPageEditInfoData
import com.avengers.nibobnebob.presentation.util.LocationArray
import com.avengers.nibobnebob.presentation.util.LoginType

fun MyPageEditInfoResponse.toUiMyPageEditInfoData() = UiMyPageEditInfoData(
nickName = data.userInfo.nickName,
email = data.userInfo.email,
provider = data.userInfo.provider,
birth = data.userInfo.birthdate,
location = data.userInfo.region,
gender = data.userInfo.isMale
fun MyDefaultInfoResponse.toUiMyPageEditInfoData() = UiMyPageEditInfoData(
nickName = userInfo.nickName,
email = userInfo.email,
provider = userInfo.provider,
birth = userInfo.birthdate,
location = userInfo.region,
gender = userInfo.isMale
)

0 comments on commit f69a210

Please sign in to comment.