-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#74 [feat] 회원 탈퇴 서버통신 #78
Changes from 5 commits
3f424ab
7380af1
acaa571
34af493
7e40ab8
b25da6f
b3796b0
c8664ec
b653161
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.sopetit.softie.data.repositoryImpl | ||
|
||
import com.sopetit.softie.data.source.AuthDataSource | ||
import com.sopetit.softie.domain.repository.AuthRepository | ||
import javax.inject.Inject | ||
|
||
class AuthRepositoryImpl @Inject constructor( | ||
private val authDataSource: AuthDataSource | ||
) : AuthRepository { | ||
|
||
override suspend fun deleteAuth(): Result<Unit> = runCatching { authDataSource.deleteAuth() } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.sopetit.softie.data.service | ||
|
||
import com.sopetit.softie.data.entity.BaseResponse | ||
import retrofit2.http.DELETE | ||
|
||
interface AuthService { | ||
|
||
@DELETE("/api/v1/auth") | ||
suspend fun deleteAuth(): BaseResponse<Unit> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.sopetit.softie.data.source | ||
|
||
import com.sopetit.softie.data.entity.BaseResponse | ||
import com.sopetit.softie.data.service.AuthService | ||
import javax.inject.Inject | ||
|
||
class AuthDataSource @Inject constructor( | ||
private val authService: AuthService | ||
) { | ||
|
||
suspend fun deleteAuth(): BaseResponse<Unit> = authService.deleteAuth() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
package com.sopetit.softie.domain.repository | ||
|
||
interface AuthRepository | ||
interface AuthRepository { | ||
|
||
suspend fun deleteAuth(): Result<Unit> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.sopetit.softie.domain.usecase.auth | ||
|
||
import com.sopetit.softie.domain.repository.AuthRepository | ||
import javax.inject.Inject | ||
|
||
class DeleteAuthUseCase @Inject constructor( | ||
private val authRepository: AuthRepository | ||
) { | ||
|
||
suspend operator fun invoke() = authRepository.deleteAuth() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,47 @@ | ||
package com.sopetit.softie.ui.setting | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.SharedPreferences | ||
import android.os.Bundle | ||
import android.text.SpannableStringBuilder | ||
import android.text.Spanned | ||
import android.text.style.ForegroundColorSpan | ||
import android.view.View | ||
import androidx.core.content.ContextCompat | ||
import androidx.lifecycle.ViewModelProvider | ||
import com.sopetit.softie.R | ||
import com.sopetit.softie.databinding.FragmentSettingUserExitBinding | ||
import com.sopetit.softie.ui.main.LoginActivity | ||
import com.sopetit.softie.ui.onboarding.OnboardingViewModel.Companion.BROWN | ||
import com.sopetit.softie.ui.onboarding.OnboardingViewModel.Companion.GRAY | ||
import com.sopetit.softie.ui.onboarding.OnboardingViewModel.Companion.RED | ||
import com.sopetit.softie.ui.onboarding.OnboardingViewModel.Companion.WHITE | ||
import com.sopetit.softie.util.binding.BindingFragment | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import timber.log.Timber | ||
|
||
@AndroidEntryPoint | ||
class SettingUserExitFragment : | ||
BindingFragment<FragmentSettingUserExitBinding>(R.layout.fragment_setting_user_exit) { | ||
|
||
private lateinit var viewModel: SettingViewModel | ||
private lateinit var sharedPreferences: SharedPreferences | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
viewModel = ViewModelProvider(requireActivity()).get(SettingViewModel::class.java) | ||
binding.viewModel = viewModel | ||
|
||
sharedPreferences = | ||
this.requireActivity().getSharedPreferences("user", Context.MODE_PRIVATE) | ||
val bearType = sharedPreferences.getString("bearType", BROWN) | ||
|
||
initSetBear(bearType) | ||
initSetSpeechText() | ||
initSetClickBackBtn() | ||
initSetClickExitBtn() | ||
} | ||
|
||
private fun initSetSpeechText() { | ||
|
@@ -37,8 +61,17 @@ class SettingUserExitFragment : | |
} | ||
} | ||
|
||
private fun initSetBear() { | ||
// TODO bear type 받아서 bear 이미지 띄우기 | ||
private fun initSetBear(bearType: String?) { | ||
when (bearType) { | ||
BROWN -> setBearImage(R.drawable.ic_bear_brown_crying) | ||
GRAY -> setBearImage(R.drawable.ic_bear_gray_crying) | ||
RED -> setBearImage(R.drawable.ic_bear_red_crying) | ||
WHITE -> setBearImage(R.drawable.ic_bear_panda_crying) | ||
} | ||
} | ||
|
||
private fun setBearImage(image: Int) { | ||
binding.ivUserExitBear.setImageResource(image) | ||
} | ||
|
||
private fun initSetClickBackBtn() { | ||
|
@@ -49,7 +82,19 @@ class SettingUserExitFragment : | |
|
||
private fun initSetClickExitBtn() { | ||
binding.btnUserExitExit.setOnClickListener { | ||
// TODO 회원탈퇴 로직 추가 | ||
viewModel.setDeleteAuth() | ||
|
||
deleteAuth() | ||
} | ||
} | ||
|
||
private fun deleteAuth() { | ||
val intent = Intent(requireActivity(), LoginActivity::class.java) | ||
viewModel.isDeleteAuthResponse.observe(viewLifecycleOwner) { deleteSuccess -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. viewLifecycleOwner.. 아직 쓰면서도 정확히 어떤 기능을 하는지 잘 모르겠네요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저두요ㅣ..ㅠ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fragment에서 livedata를 옵저빙할 때 |
||
if (deleteSuccess) { | ||
Timber.d("setting -> 멤버 탈퇴 성공") | ||
startActivity(intent) | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 다음 pr때 관련 UseCase 만들어 두겠습니다~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네엡