Skip to content

Commit

Permalink
feat:TOP-96 지인차단, 회원가입 완료 화면 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
cwj-c committed May 12, 2024
1 parent f6a778b commit c462439
Show file tree
Hide file tree
Showing 17 changed files with 437 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.ui.graphics.Shadow
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.TextUnit
import com.example.compose_ui.component.font.rememberPretendardFontStyle
import com.example.compose_ui.extensions.dpTextUnit

Expand Down Expand Up @@ -81,14 +82,16 @@ fun ThtHeadline3(
fontWeight: FontWeight,
color: Color,
textAlign: TextAlign = TextAlign.Center,
lineHeight: TextUnit = TextUnit.Unspecified
) {
Text(
modifier = modifier,
textAlign = textAlign,
text = text,
style = rememberPretendardFontStyle(
fontWeight = fontWeight,
fontSize = 24.dpTextUnit
fontSize = 24.dpTextUnit,
lineHeight = lineHeight
),
color = color,
)
Expand Down
2 changes: 0 additions & 2 deletions data/src/main/java/com/tht/tht/data/di/UseCaseModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,10 @@ object UseCaseModule {
fun provideRequestSignupUseCase(
repository: SignupRepository,
tokenRepository: TokenRepository,
removeSignupUserUseCase: RemoveSignupUserUseCase,
@DefaultDispatcher dispatcher: CoroutineDispatcher
): RequestSignupUseCase = RequestSignupUseCase(
repository,
tokenRepository,
removeSignupUserUseCase,
dispatcher
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RemoveSignupUserUseCase(
private val dispatcher: CoroutineDispatcher
) {

internal suspend operator fun invoke(phone: String): Boolean {
suspend operator fun invoke(phone: String): Boolean {
return withContext(dispatcher) {
repository.removeSignupUser(phone)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import kotlinx.coroutines.withContext
class RequestSignupUseCase(
private val signupRepository: SignupRepository,
private val tokenRepository: TokenRepository,
private val removeSignupUserUseCase: RemoveSignupUserUseCase,
private val dispatcher: CoroutineDispatcher
) {
suspend operator fun invoke(phone: String): Result<Boolean> {
Expand Down Expand Up @@ -59,7 +58,6 @@ class RequestSignupUseCase(
signupRepository.requestSignup(
user.copy(fcmToken = fcmToken)
).let {
removeSignupUserUseCase(phone)
tokenRepository.updateThtToken(it.accessToken, it.accessTokenExpiresIn, phone)
it.accessToken.isNotBlank()
}
Expand Down
5 changes: 4 additions & 1 deletion feature/signin/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
<meta-data
android:name="android.app.lib_name"
android:value="" />

</activity>
<activity
android:name=".signup.signupcomplete.SignupCompleteActivity"
android:exported="false"
android:screenOrientation="portrait" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import tht.core.ui.extension.repeatOnStarted
import tht.core.ui.extension.showToast
import tht.feature.signin.R
import tht.feature.signin.databinding.ActivitySignupRootBinding
import tht.feature.signin.signup.signupcomplete.SignupCompleteActivity
import javax.inject.Inject

@AndroidEntryPoint
Expand All @@ -25,9 +26,6 @@ class SignupRootActivity : AppCompatActivity() {
private val viewModel: SignupRootViewModel by viewModels()
private val binding: ActivitySignupRootBinding by viewBinding(ActivitySignupRootBinding::inflate)

@Inject
lateinit var homeNavigation: HomeNavigation

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initNavGraph()
Expand Down Expand Up @@ -105,13 +103,22 @@ class SignupRootActivity : AppCompatActivity() {
navController.navigate(R.id.action_introductionFragment_to_locationFragment)
}
SignupRootViewModel.Step.LOCATION -> {
// 위치 입력 후 회원가입 요청 시도. 회원가입 이후 지인 차단 진행
viewModel.signUpEvent()
}
SignupRootViewModel.Step.BlockContacts -> {
startActivity(
SignupCompleteActivity.getIntent(
this@SignupRootActivity,
viewModel.phone.value
)
)
}
}
}
is SignupRootViewModel.SignupRootSideEffect.FinishSignup -> {
homeNavigation.navigateHome(this@SignupRootActivity)
finish()
SignupRootViewModel.SignupRootSideEffect.SuccessSignup -> {
// 회원 가입 이후 지인 차단 기능
findNavController(binding.fcNavHost.id).navigate(R.id.action_locationFragment_to_blockContactsFragment)
}
is SignupRootViewModel.SignupRootSideEffect.ShowToast -> {
showToast(it.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SignupRootViewModel @Inject constructor(
viewModelScope.launch {
_dataLoading.value = true
requestSignupUseCase(phone.value).onSuccess {
_sideEffectFlow.emit(SignupRootSideEffect.FinishSignup)
_sideEffectFlow.emit(SignupRootSideEffect.SuccessSignup)
}.onFailure {
it.printStackTrace()
_sideEffectFlow.emit(
Expand All @@ -65,7 +65,7 @@ class SignupRootViewModel @Inject constructor(

sealed class SignupRootSideEffect : SideEffect {
object Back : SignupRootSideEffect()
object FinishSignup : SignupRootSideEffect()
object SuccessSignup : SignupRootSideEffect()
data class ShowToast(val message: String) : SignupRootSideEffect()
data class NavigateNextView(val step: Step) : SignupRootSideEffect()
}
Expand All @@ -82,7 +82,8 @@ class SignupRootViewModel @Inject constructor(
INTEREST,
IDEAL_TYPE,
INTRODUCTION,
LOCATION
LOCATION,
BlockContacts
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package tht.feature.signin.signup.blockcontact

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.fragment.app.viewModels
import dagger.hilt.android.AndroidEntryPoint
import tht.core.ui.extension.showToast
import tht.feature.signin.signup.SignupBaseComposeFragment
import tht.feature.signin.signup.SignupRootViewModel
import tht.feature.signin.signup.blockcontact.composable.BlockContactsScreen

@AndroidEntryPoint
class BlockContactsFragment : SignupBaseComposeFragment<BlockContactsViewModel>() {

override val viewModel: BlockContactsViewModel by viewModels()

@Composable
override fun ComposeContent() {
LaunchedEffect(Unit) {
viewModel.sideEffectFlow.collect {
when (it) {
is BlockContactsViewModel.BlockContactsSideEffect.ShowToast -> {
requireContext().showToast(it.message)
}
BlockContactsViewModel.BlockContactsSideEffect.NavigateNextScreen -> {
rootViewModel.nextEvent(SignupRootViewModel.Step.BlockContacts)
}
}
}
}

val state by viewModel.uiStateFlow.collectAsState()
BlockContactsScreen(
loading = state.loading,
btnEnable = !state.loading,
onBlockContactsClick = viewModel::onBlockContactsEvent,
onLaterClick = viewModel::onLaterEvent
)
}

override fun setProgress() {
rootViewModel.progressEvent(SignupRootViewModel.Step.BlockContacts)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package tht.feature.signin.signup.blockcontact

import tht.core.ui.base.UiState

data class BlockContactsUiState(
val loading: Boolean
) : UiState {
companion object {
val default: BlockContactsUiState get() = BlockContactsUiState(
loading = false
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package tht.feature.signin.signup.blockcontact

import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import tht.core.ui.base.BaseStateViewModel
import tht.core.ui.base.SideEffect
import javax.inject.Inject

@HiltViewModel
class BlockContactsViewModel @Inject constructor(

) : BaseStateViewModel<BlockContactsUiState, BlockContactsViewModel.BlockContactsSideEffect>() {

sealed interface BlockContactsSideEffect : SideEffect {
object NavigateNextScreen : BlockContactsSideEffect

data class ShowToast(
val message: String
) : BlockContactsSideEffect
}

override val _uiStateFlow: MutableStateFlow<BlockContactsUiState> = MutableStateFlow(BlockContactsUiState.default)

fun onBlockContactsEvent() {
viewModelScope.launch {
_uiStateFlow.update { it.copy(loading = true) }
delay(1500L) // 기능 구현 전 delay
postSideEffect(BlockContactsSideEffect.ShowToast("저장된 연락처를 모두 차단했습니다"))
postSideEffect(BlockContactsSideEffect.NavigateNextScreen)
_uiStateFlow.update { it.copy(loading = true) }
}
}

fun onLaterEvent() {
postSideEffect(BlockContactsSideEffect.NavigateNextScreen)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package tht.feature.signin.signup.blockcontact.composable

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.ButtonDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.compose_ui.component.progress.ThtCircularProgress
import com.example.compose_ui.component.text.headline.ThtHeadline3
import com.example.compose_ui.component.text.subtitle.ThtSubtitle1
import tht.core.ui.R
import tht.feature.signin.ui.SignupLargeButton

@Composable
internal fun BlockContactsScreen(
loading: Boolean,
btnEnable: Boolean,
onBlockContactsClick: () -> Unit,
onLaterClick: () -> Unit,
modifier: Modifier = Modifier
) {
Box {
Column(
modifier = modifier
.background(colorResource(id = R.color.black_161616))
.padding(horizontal = 22.dp)
) {
Spacer(modifier = Modifier.height(90.dp))
ThtHeadline3(
modifier = Modifier.padding(horizontal = 16.dp),
text = stringResource(id = tht.feature.signin.R.string.title_block_contacts),
fontWeight = FontWeight.Bold,
color = colorResource(id = R.color.white_f9fafa),
lineHeight = 32.64.sp,
textAlign = TextAlign.Start
)
Spacer(modifier = Modifier.height(20.dp))
ThtSubtitle1(
modifier = Modifier.padding(horizontal = 16.dp),
text = stringResource(id = tht.feature.signin.R.string.description_block_contacts),
fontWeight = FontWeight.Normal,
color = colorResource(id = R.color.gray_8d8d8d),
lineHeight = 22.4.sp,
textAlign = TextAlign.Start
)
Spacer(modifier = Modifier.weight(1f))
SignupLargeButton(
onClick = onBlockContactsClick,
text = stringResource(id = tht.feature.signin.R.string.block_contacts),
enable = btnEnable
)
Spacer(modifier = Modifier.height(8.dp))
SignupLargeButton(
onClick = onLaterClick,
text = stringResource(id = tht.feature.signin.R.string.later),
enable = btnEnable,
colors = ButtonDefaults.buttonColors(
backgroundColor = colorResource(id = R.color.black_222222),
contentColor = Color.Transparent,
disabledBackgroundColor = colorResource(id = R.color.black_222222),
disabledContentColor = Color.Transparent
),
textColor = colorResource(id = R.color.gray_666666)
)
Spacer(modifier = Modifier.height(22.dp))
}
ThtCircularProgress(
modifier = Modifier.align(Alignment.Center),
color = colorResource(id = R.color.yellow_f9cc2e),
visible = loading
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package tht.feature.signin.signup.signupcomplete

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import dagger.hilt.android.AndroidEntryPoint
import tht.core.navigation.HomeNavigation
import tht.feature.signin.signup.signupcomplete.composable.SignupCompleteScreen
import javax.inject.Inject

@AndroidEntryPoint
class SignupCompleteActivity : AppCompatActivity() {

private val viewModel: SignupCompleteViewModel by viewModels()

@Inject
lateinit var homeNavigation: HomeNavigation

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
LaunchedEffect(Unit) {
viewModel.sideEffectFlow.collect {
when (it) {
SignupCompleteViewModel.SignupSideEffect.NavigateMain -> {
homeNavigation.navigateHome(this@SignupCompleteActivity)
finish()
}
}
}
}
val state by viewModel.uiStateFlow.collectAsState()
SignupCompleteScreen(
loading = state.loading,
btnEnable = !state.profileImage.isNullOrBlank() && state.error != null && !state.loading,
profileImage = state.profileImage,
onComplete = viewModel::onCompleteEvent
)
}
}


companion object {
fun getIntent(context: Context, phone: String): Intent {
return Intent(context, SignupCompleteActivity::class.java).apply {
putExtra(SignupCompleteViewModel.EXTRA_KEY_PHONE, phone)
}
}
}
}
Loading

0 comments on commit c462439

Please sign in to comment.