-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
437 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
feature/signin/src/main/java/tht/feature/signin/signup/blockcontact/BlockContactsFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
feature/signin/src/main/java/tht/feature/signin/signup/blockcontact/BlockContactsUiState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ure/signin/src/main/java/tht/feature/signin/signup/blockcontact/BlockContactsViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...in/src/main/java/tht/feature/signin/signup/blockcontact/composable/BlockContactsScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...e/signin/src/main/java/tht/feature/signin/signup/signupcomplete/SignupCompleteActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.