Skip to content

Commit

Permalink
#6 mypage_fragment/설정 화면 : 4 계정 관리 화면
Browse files Browse the repository at this point in the history
 - 서비스 이용약관과 회원탈퇴가 있는 계정 관리 화면
  • Loading branch information
likppi10 committed Aug 23, 2022
1 parent bfa6049 commit ebf862b
Show file tree
Hide file tree
Showing 11 changed files with 462 additions and 64 deletions.
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
android:usesCleartextTraffic="true"
tools:targetApi="31"
>

<activity
android:name=".ui.manageaccount.ManageAccountActivity"
android:exported="false"
/>
<activity
android:name=".ui.writtenreview.WrittenReviewsActivity"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.ftw.hometerview.dispatcher.Dispatcher
import com.ftw.hometerview.ui.buildingreview.BuildingReviewViewModel
import com.ftw.hometerview.ui.main.MainViewModel
import com.ftw.hometerview.ui.main.home.review.LocationReviewListViewModel
import com.ftw.hometerview.ui.manageaccount.ManageAccountViewModel
import com.ftw.hometerview.ui.searchaddressbuilding.SearchAddressBuildingViewModel
import com.ftw.hometerview.ui.searchcompanyresult.SearchCompanyResultViewModel
import com.ftw.hometerview.ui.splash.SplashViewModel
Expand All @@ -19,6 +20,7 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.scopes.ActivityScoped
import dagger.hilt.android.scopes.FragmentScoped
import javax.inject.Named

@Module
Expand Down Expand Up @@ -106,4 +108,10 @@ class ActivityViewModelModule {
getWrittenReviewsUseCase
)
}

@Provides
@ActivityScoped
fun provideManageAccountViewModel(): ManageAccountViewModel {
return ManageAccountViewModel()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.ftw.hometerview.R
import com.ftw.hometerview.databinding.FragmentMyPageBinding
import com.ftw.hometerview.ui.manageaccount.ManageAccountActivity
import com.ftw.hometerview.ui.updatenickname.UpdateNicknameActivity
import com.ftw.hometerview.ui.writtenreview.WrittenReviewsActivity
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -73,12 +74,9 @@ class MyPageFragment : Fragment() {
viewModel.event.collect { event ->
when (event) {
MyPageViewModel.Event.None -> {}
is MyPageViewModel.Event.onClickUpdateNickname -> {
updateNicknameActivity(event.nickname)
}
MyPageViewModel.Event.onClickWrittenReview -> {
writtenReviewActivity()
}
is MyPageViewModel.Event.onClickUpdateNickname -> updateNicknameActivity(event.nickname)
MyPageViewModel.Event.onClickWrittenReview -> writtenReviewActivity()
MyPageViewModel.Event.onClickManageAccount -> manageAccountActivity()
}
}
}
Expand Down Expand Up @@ -138,6 +136,10 @@ class MyPageFragment : Fragment() {
startActivity(WrittenReviewsActivity.newIntent(requireContext()))
}

private fun manageAccountActivity() {
startActivity(ManageAccountActivity.newIntent(requireContext()))
}

private fun setLauncher() {
updateNicknameLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class MyPageViewModel (
object None : Event()
class onClickUpdateNickname(val nickname: String) : Event()
object onClickWrittenReview : Event()
object onClickManageAccount : Event()
}

private val _user: MutableStateFlow<User> = MutableStateFlow(User.NONE)
Expand Down Expand Up @@ -48,4 +49,9 @@ class MyPageViewModel (
_event.value = Event.onClickWrittenReview
_event.value = Event.None
}

fun onClickManageAccount() {
_event.value = Event.onClickManageAccount
_event.value = Event.None
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.ftw.hometerview.ui.manageaccount

import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.ftw.hometerview.R
import com.ftw.hometerview.databinding.ActivityManageAccountBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import javax.inject.Inject

@AndroidEntryPoint
class ManageAccountActivity : AppCompatActivity() {

companion object {
fun newIntent(context: Context): Intent {
return Intent(context, ManageAccountActivity::class.java)
}
}

@Inject
lateinit var viewModel: ManageAccountViewModel

private lateinit var binding: ActivityManageAccountBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView<ActivityManageAccountBinding>(
this,
R.layout.activity_manage_account
).apply {
viewModel = this@ManageAccountActivity.viewModel
}
observe()
}


private fun observe() {
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.event.collect { event ->
when (event) {
ManageAccountViewModel.Event.None -> {}
ManageAccountViewModel.Event.onClickServiceUseTerms -> onClickServiceUseTerms()
ManageAccountViewModel.Event.onClickUseUserInfo -> onClickUseUserInfo()
ManageAccountViewModel.Event.onClickLocationForService -> onClickLocationForService()
ManageAccountViewModel.Event.onClickOpenSourceLibrary -> onClickOpenSourceLibrary()
ManageAccountViewModel.Event.onClickWithdrawal -> onClickWithdrawal()
}
}
}
}
}

private fun onClickServiceUseTerms() { }
private fun onClickUseUserInfo() { }
private fun onClickLocationForService() { }
private fun onClickOpenSourceLibrary() { }
private fun onClickWithdrawal() { }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.ftw.hometerview.ui.manageaccount

import kotlinx.coroutines.flow.*

class ManageAccountViewModel() {

sealed class Event {
object None : Event()
object onClickServiceUseTerms : Event()
object onClickUseUserInfo : Event()
object onClickLocationForService : Event()
object onClickOpenSourceLibrary : Event()
object onClickWithdrawal : Event()
}

private val _event: MutableStateFlow<Event> = MutableStateFlow(Event.None)
val event: StateFlow<Event> = _event.asStateFlow()

fun onClickServiceUseTerms() {
_event.value = Event.onClickServiceUseTerms
_event.value = Event.None
}
fun onClickUseUserInfo() {
_event.value = Event.onClickUseUserInfo
_event.value = Event.None
}
fun onClickLocationForService() {
_event.value = Event.onClickLocationForService
_event.value = Event.None
}
fun onClickOpenSourceLibrary() {
_event.value = Event.onClickOpenSourceLibrary
_event.value = Event.None
}
fun onClickWithdrawal() {
_event.value = Event.onClickWithdrawal
_event.value = Event.None
}
}
Loading

0 comments on commit ebf862b

Please sign in to comment.