-
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
4 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
...ain/java/com/hankki/feature/storedetail/editbottomsheet/edit/delete/DeleteSuccessRoute.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,135 @@ | ||
package com.hankki.feature.storedetail.editbottomsheet.edit.delete | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.navigationBarsPadding | ||
import androidx.compose.foundation.layout.offset | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.statusBarsPadding | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.unit.dp | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
import com.hankki.core.common.extension.noRippleClickable | ||
import com.hankki.core.designsystem.component.button.HankkiMediumButton | ||
import com.hankki.core.designsystem.component.topappbar.HankkiTopBar | ||
import com.hankki.core.designsystem.theme.Gray700 | ||
import com.hankki.core.designsystem.theme.Gray850 | ||
import com.hankki.core.designsystem.theme.HankkiTheme | ||
import com.hankki.core.designsystem.theme.Red500 | ||
import com.hankki.core.designsystem.theme.White | ||
import com.hankki.feature.storedetail.R | ||
|
||
@Composable | ||
fun DeleteSuccessRoute( | ||
viewModel: DeleteSuccessViewModel = hiltViewModel(), | ||
onNavigateToEditMenu: () -> Unit, | ||
onNavigateToStoreDetailRoute: () -> Unit, | ||
onNavigateUp: () -> Unit | ||
) { | ||
val uiState by viewModel.uiState.collectAsStateWithLifecycle() | ||
val sideEffectFlow = viewModel.sideEffect | ||
|
||
LaunchedEffect(Unit) { | ||
sideEffectFlow.collect { sideEffect -> | ||
when (sideEffect) { | ||
DeleteSuccessSideEffect.NavigateToEditMenu -> onNavigateToEditMenu() | ||
DeleteSuccessSideEffect.NavigateToStoreDetail -> onNavigateToStoreDetailRoute() | ||
DeleteSuccessSideEffect.NavigateUp -> onNavigateUp() | ||
} | ||
} | ||
} | ||
|
||
DeleteSuccessScreen( | ||
nickname = uiState.nickname, | ||
onNavigateToEditMenu = { viewModel.navigateToEditMenu() }, | ||
onNavigateToStoreDetailRoute = { viewModel.navigateToStoreDetail() }, | ||
onNavigateUp = { viewModel.navigateUp() }, | ||
) | ||
} | ||
|
||
@Composable | ||
fun DeleteSuccessScreen( | ||
nickname: String, | ||
onNavigateToEditMenu: () -> Unit, | ||
onNavigateToStoreDetailRoute: () -> Unit, | ||
onNavigateUp: () -> Unit | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
) { | ||
Spacer(modifier = Modifier.statusBarsPadding()) | ||
HankkiTopBar( | ||
leadingIcon = { | ||
Icon( | ||
painter = painterResource(com.hankki.core.designsystem.R.drawable.ic_arrow_left), | ||
contentDescription = "뒤로가기", | ||
modifier = Modifier | ||
.offset(x = 6.dp, y = 2.dp) | ||
.noRippleClickable(onClick = onNavigateUp), | ||
tint = Gray700 | ||
) | ||
} | ||
) | ||
|
||
Spacer(modifier = Modifier.height(18.dp)) | ||
Text( | ||
text = "${nickname}님이 말씀해주신대로\n메뉴를 삭제했어요!", | ||
style = HankkiTheme.typography.suitH2, | ||
color = Gray850, | ||
modifier = Modifier.padding(start = 22.dp) | ||
) | ||
|
||
Box { | ||
Image( | ||
painter = painterResource(id = R.drawable.img_deleted_complete), | ||
contentDescription = "delete_complete", | ||
modifier = Modifier.fillMaxSize() | ||
) | ||
|
||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(16.dp) | ||
) { | ||
Spacer(modifier = Modifier.weight(1f)) | ||
|
||
HankkiMediumButton( | ||
modifier = Modifier.fillMaxWidth(), | ||
text = "다른 메뉴도 삭제하기", | ||
onClick = onNavigateToEditMenu, | ||
enabled = true, | ||
backgroundColor = White, | ||
textStyle = HankkiTheme.typography.sub3, | ||
textColor = Red500, | ||
borderColor = Red500 | ||
) | ||
Spacer(modifier = Modifier.height(16.dp)) | ||
HankkiMediumButton( | ||
modifier = Modifier.fillMaxWidth(), | ||
text = "완료", | ||
onClick = onNavigateToStoreDetailRoute, | ||
enabled = true, | ||
textStyle = HankkiTheme.typography.sub3 | ||
) | ||
Spacer( | ||
modifier = Modifier | ||
.navigationBarsPadding() | ||
.padding(bottom = 15.dp) | ||
) | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...ava/com/hankki/feature/storedetail/editbottomsheet/edit/delete/DeleteSuccessSideEffect.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,7 @@ | ||
package com.hankki.feature.storedetail.editbottomsheet.edit.delete | ||
|
||
sealed interface DeleteSuccessSideEffect { | ||
data object NavigateToEditMenu : DeleteSuccessSideEffect | ||
data object NavigateToStoreDetail : DeleteSuccessSideEffect | ||
data object NavigateUp : DeleteSuccessSideEffect | ||
} |
5 changes: 5 additions & 0 deletions
5
...ain/java/com/hankki/feature/storedetail/editbottomsheet/edit/delete/DeleteSuccessState.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,5 @@ | ||
package com.hankki.feature.storedetail.editbottomsheet.edit.delete | ||
|
||
data class DeleteSuccessState( | ||
val nickname: String = "" | ||
) |
59 changes: 59 additions & 0 deletions
59
...java/com/hankki/feature/storedetail/editbottomsheet/edit/delete/DeleteSuccessViewModel.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,59 @@ | ||
package com.hankki.feature.storedetail.editbottomsheet.edit.delete | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.hankki.domain.storedetail.repository.StoreDetailRepository | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.channels.Channel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.receiveAsFlow | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class DeleteSuccessViewModel @Inject constructor( | ||
private val storeDetailRepository: StoreDetailRepository | ||
) : ViewModel() { | ||
|
||
private val _uiState = MutableStateFlow(DeleteSuccessState()) | ||
val uiState: StateFlow<DeleteSuccessState> = _uiState | ||
|
||
private val _sideEffect = Channel<DeleteSuccessSideEffect>() | ||
val sideEffect = _sideEffect.receiveAsFlow() | ||
|
||
init { | ||
fetchNickname() | ||
} | ||
|
||
|
||
private fun fetchNickname() { | ||
viewModelScope.launch { | ||
storeDetailRepository.getStoreDetailNickname() | ||
.onSuccess { nickname -> | ||
_uiState.value = DeleteSuccessState(nickname = nickname.nickname) | ||
} | ||
.onFailure { | ||
// 처리 | ||
} | ||
} | ||
} | ||
|
||
fun navigateToEditMenu() { | ||
viewModelScope.launch { | ||
_sideEffect.send(DeleteSuccessSideEffect.NavigateToEditMenu) | ||
} | ||
} | ||
|
||
fun navigateToStoreDetail() { | ||
viewModelScope.launch { | ||
_sideEffect.send(DeleteSuccessSideEffect.NavigateToStoreDetail) | ||
} | ||
} | ||
|
||
fun navigateUp() { | ||
viewModelScope.launch { | ||
_sideEffect.send(DeleteSuccessSideEffect.NavigateUp) | ||
} | ||
} | ||
} |