Skip to content

Commit

Permalink
Merge branch 'android_develop' into #91/feature/jsp/app_enhancement3
Browse files Browse the repository at this point in the history
  • Loading branch information
pknujsp authored Jun 8, 2023
2 parents 7a89aaa + ea878c5 commit 5db9032
Show file tree
Hide file tree
Showing 11 changed files with 337 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ interface AppDataStore {
suspend fun saveMyAccountInfo(userEmail: String, nickName: String, myAccountId: Long)
suspend fun saveNickName(nickName: String)
suspend fun saveSkipIntro(skipIntro: Boolean)
suspend fun clearMyAccountInfo()
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,14 @@ class AppDataStoreImpl @Inject constructor(
override suspend fun saveSkipIntro(skipIntro: Boolean) {
context.dataStore.edit { it[KEY_SKIP_INTRO] = skipIntro }
}


override suspend fun clearMyAccountInfo() {
context.dataStore.edit {
it[KEY_USER_EMAIL] = ""
it[KEY_NICK_NAME] = ""
it[KEY_MY_ACCOUNT_ID] = 0
it[KEY_SKIP_INTRO] = false
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class TokenDataSourceImpl @Inject constructor(
tokenDataStore.updateData {
it.toBuilder().clear().build()
}
updateTokenState()
}

private fun updateTokenState() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.android.mediproject.core.datastore

import android.util.Log
import com.android.mediproject.core.model.remote.token.NewTokensFromAws
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.MutableSharedFlow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.android.mediproject.core.domain.user

import android.util.Log
import com.android.mediproject.core.data.remote.sign.SignRepository
import com.android.mediproject.core.data.remote.user.UserInfoRepository
import com.android.mediproject.core.data.remote.user.UserRepository
import com.android.mediproject.core.datastore.AppDataStore
import com.android.mediproject.core.domain.GetTokenUseCase
import com.android.mediproject.core.model.requestparameters.ChangeNicknameParameter
import com.android.mediproject.core.model.requestparameters.ChangePasswordParamter
import com.android.mediproject.core.model.user.AccountState
Expand All @@ -18,35 +20,45 @@ import javax.inject.Inject
class UserUseCase @Inject constructor(
private val appDataStore: AppDataStore,
private val userRepository: UserRepository,
private val getUserInfoRepository: UserInfoRepository
private val getUserInfoRepository: UserInfoRepository,
private val signRepository: SignRepository
) {
suspend operator fun invoke(): Flow<UserDto> = channelFlow {
appDataStore.nickName.collect { nickName ->
Log.d("wap", nickName)
trySend(UserDto(nickName = nickName))
}
}

suspend fun changeNickname(changeNicknameParameter: ChangeNicknameParameter) = channelFlow {
userRepository.changeNickname(changeNicknameParameter).map {
it.fold(onSuccess = { Result.success(it) }, onFailure = { Result.failure(it) })
it.fold(onSuccess = {
appDataStore.saveNickName(changeNicknameParameter.newNickname)
Result.success(it)
}, onFailure = { Result.failure(it) })
}.collectLatest { trySend(it) }
}

suspend fun changePassword(changePasswordParamter: ChangePasswordParamter) = channelFlow {
val email = (getUserInfoRepository.myAccountInfo.value as AccountState.SignedIn).email.toCharArray()
val email =
(getUserInfoRepository.myAccountInfo.value as AccountState.SignedIn).email.toCharArray()
userRepository.changePassword(changePasswordParamter.apply {
this.email = email
}).map {
it.fold(onSuccess = { Result.success(it) }, onFailure = { Result.failure(it) })
it.fold(onSuccess = {
Result.success(it)
}, onFailure = { Result.failure(it) })
}.collectLatest { trySend(it) }
}

suspend fun withdrawal() = channelFlow {
Log.d("wap", "UserUseCase : withdrawal()")
userRepository.withdrawal().map {
Log.d("wap", "UserUseCase : withdrawal()" + it.toString())
it.fold(onSuccess = { Result.success(it) }, onFailure = { Result.failure(it) })
it.fold(onSuccess = {
signRepository.signOut()
appDataStore.clearMyAccountInfo()
Result.success(it)
}, onFailure = { Result.failure(it) })
}.collectLatest { trySend(it) }
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
package com.android.mediproject.feature.comments.mycommentslist

import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.android.mediproject.core.common.uiutil.SystemBarStyler
import com.android.mediproject.core.model.comments.MyCommentDto
import com.android.mediproject.core.ui.base.BaseFragment
import com.android.mediproject.feature.comments.databinding.FragmentMyCommnetsListBinding
import dagger.hilt.android.AndroidEntryPoint
import repeatOnStarted
import javax.inject.Inject


@AndroidEntryPoint
class MyCommentsListFragment : BaseFragment<FragmentMyCommnetsListBinding, MyCommentsListViewModel>(
FragmentMyCommnetsListBinding::inflate
) {
override val fragmentViewModel: MyCommentsListViewModel by viewModels()
private val myCommentsListAdapter: MyCommentsListAdapter by lazy { MyCommentsListAdapter() }

@Inject
lateinit var systemBarStyler: SystemBarStyler

override fun onAttach(context: Context) {
super.onAttach(context)
systemBarStyler.setStyle(
SystemBarStyler.StatusBarColor.BLACK,
SystemBarStyler.NavigationBarColor.BLACK
)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setBarStyle()

binding.apply {
viewModel = fragmentViewModel.apply {
Expand All @@ -43,16 +59,28 @@ class MyCommentsListFragment : BaseFragment<FragmentMyCommnetsListBinding, MyCom
"2023-03-30 22:48",
2,
{ comment ->
log(comment.medicineName + "을 누르셨습니다.") })
,
log(comment.medicineName + "을 누르셨습니다.")
}),
MyCommentDto(
12346,
"코메키나",
"저 같은 비염환자들한테 딱 입니다. 시험칠 때 필수...!!",
"2023-03-30 22:48",
3,
{ comment ->
log(comment.medicineName + "을 누르셨습니다.") })
log(comment.medicineName + "을 누르셨습니다.")
})
)
)
}

private fun setBarStyle() = binding.apply {
systemBarStyler.changeMode(
topViews = listOf(
SystemBarStyler.ChangeView(
myCommentsListBar,
SystemBarStyler.SpacingType.PADDING
)
)
)
}
Expand Down
Loading

0 comments on commit 5db9032

Please sign in to comment.