diff --git a/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeContract.kt b/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeContract.kt index e6d595c8..a35d2040 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeContract.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeContract.kt @@ -1,6 +1,7 @@ package com.susu.feature.envelope import com.susu.core.model.EnvelopeSearch +import com.susu.core.model.Friend import com.susu.core.model.FriendStatistics import com.susu.core.ui.base.SideEffect import com.susu.core.ui.base.UiState @@ -15,6 +16,7 @@ data class SentEnvelopeState( sealed interface SentEnvelopeSideEffect : SideEffect { data class NavigateEnvelopeDetail(val id: Long) : SentEnvelopeSideEffect + data class NavigateEnvelopeAdd(val friend: Friend) : SentEnvelopeSideEffect data object PopBackStack : SentEnvelopeSideEffect data class PopBackStackWithDeleteFriendId(val id: Long) : SentEnvelopeSideEffect } diff --git a/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeScreen.kt b/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeScreen.kt index 51034e9b..9738e823 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeScreen.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeScreen.kt @@ -39,6 +39,7 @@ import com.susu.core.designsystem.component.appbar.icon.BackIcon import com.susu.core.designsystem.component.badge.BadgeColor import com.susu.core.designsystem.component.badge.BadgeStyle import com.susu.core.designsystem.component.badge.SusuBadge +import com.susu.core.designsystem.component.button.SusuFloatingButton import com.susu.core.designsystem.theme.Gray10 import com.susu.core.designsystem.theme.Gray100 import com.susu.core.designsystem.theme.Gray20 @@ -46,6 +47,7 @@ import com.susu.core.designsystem.theme.Gray60 import com.susu.core.designsystem.theme.Gray90 import com.susu.core.designsystem.theme.Orange20 import com.susu.core.designsystem.theme.SusuTheme +import com.susu.core.model.Friend import com.susu.core.ui.extension.OnBottomReached import com.susu.core.ui.extension.collectWithLifecycle import com.susu.core.ui.extension.toMoneyFormat @@ -63,6 +65,7 @@ fun SentEnvelopeRoute( popBackStackWithEditedFriendId: (Long) -> Unit, editedFriendId: Long?, navigateSentEnvelopeDetail: (Long) -> Unit, + navigateSentEnvelopeAdd: (Friend) -> Unit, ) { val uiState = viewModel.uiState.collectAsStateWithLifecycle().value val historyListState = rememberLazyListState() @@ -79,6 +82,7 @@ fun SentEnvelopeRoute( is SentEnvelopeSideEffect.NavigateEnvelopeDetail -> navigateSentEnvelopeDetail(sideEffect.id) is SentEnvelopeSideEffect.PopBackStackWithDeleteFriendId -> popBackStackWithDeleteFriendId(sideEffect.id) + is SentEnvelopeSideEffect.NavigateEnvelopeAdd -> navigateSentEnvelopeAdd(sideEffect.friend) } } @@ -107,6 +111,7 @@ fun SentEnvelopeRoute( refreshState = refreshState, onClickBackIcon = viewModel::popBackStack, onClickEnvelopeDetail = viewModel::navigateSentEnvelopeDetail, + onClickAddEnvelope = viewModel::navigateSentEnvelopeAdd, ) } @@ -119,6 +124,7 @@ fun SentEnvelopeScreen( historyListState: LazyListState = rememberLazyListState(), onClickBackIcon: () -> Unit = {}, onClickEnvelopeDetail: (Long) -> Unit = {}, + onClickAddEnvelope: () -> Unit = {}, ) { val sent = uiState.envelopeInfo.sentAmounts val received = uiState.envelopeInfo.receivedAmounts @@ -234,6 +240,13 @@ fun SentEnvelopeScreen( state = refreshState, containerColor = Gray10, ) + + SusuFloatingButton( + modifier = Modifier + .align(Alignment.BottomEnd) + .padding(SusuTheme.spacing.spacing_l), + onClick = onClickAddEnvelope, + ) } } diff --git a/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeViewModel.kt b/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeViewModel.kt index 22e11f9f..75323f83 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeViewModel.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelope/SentEnvelopeViewModel.kt @@ -58,6 +58,7 @@ class SentEnvelopeViewModel @Inject constructor( } } + fun navigateSentEnvelopeAdd() = postSideEffect(SentEnvelopeSideEffect.NavigateEnvelopeAdd(currentState.envelopeInfo.friend)) fun navigateSentEnvelopeDetail(id: Long) = postSideEffect(SentEnvelopeSideEffect.NavigateEnvelopeDetail(id = id)) fun popBackStack() = postSideEffect(SentEnvelopeSideEffect.PopBackStack) } diff --git a/feature/sent/src/main/java/com/susu/feature/sent/navigation/SentNavigation.kt b/feature/sent/src/main/java/com/susu/feature/sent/navigation/SentNavigation.kt index 06a1de0f..c7d2fc3f 100644 --- a/feature/sent/src/main/java/com/susu/feature/sent/navigation/SentNavigation.kt +++ b/feature/sent/src/main/java/com/susu/feature/sent/navigation/SentNavigation.kt @@ -58,7 +58,7 @@ fun NavGraphBuilder.sentNavGraph( navigateSentEnvelope: (Long) -> Unit, navigateSentEnvelopeDetail: (Long) -> Unit, navigateSentEnvelopeEdit: (EnvelopeDetail) -> Unit, - navigateSentEnvelopeAdd: () -> Unit, + navigateSentEnvelopeAdd: (Friend?) -> Unit, navigateSentEnvelopeSearch: () -> Unit, navigateEnvelopeFilter: (String) -> Unit, onShowSnackbar: (SnackbarToken) -> Unit, @@ -82,7 +82,7 @@ fun NavGraphBuilder.sentNavGraph( editedFriendId = editedFriendId, refresh = refresh, navigateSentEnvelope = navigateSentEnvelope, - navigateSentEnvelopeAdd = navigateSentEnvelopeAdd, + navigateSentEnvelopeAdd = { navigateSentEnvelopeAdd(null) }, navigateSentEnvelopeSearch = navigateSentEnvelopeSearch, navigateEnvelopeFilter = navigateEnvelopeFilter, ) @@ -103,6 +103,7 @@ fun NavGraphBuilder.sentNavGraph( popBackStackWithEditedFriendId = popBackStackWithEditedFriendId, navigateSentEnvelopeDetail = navigateSentEnvelopeDetail, popBackStackWithDeleteFriendId = popBackStackWithDeleteFriendId, + navigateSentEnvelopeAdd = navigateSentEnvelopeAdd, ) }