diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/HomeScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/HomeScreen.kt index 0afc3318..4bb8f6ec 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/HomeScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/HomeScreen.kt @@ -3,7 +3,7 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.home import ac.dnd.bookkeeping.android.presentation.common.util.ErrorObserver import ac.dnd.bookkeeping.android.presentation.common.view.CustomSnackBarHost import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState -import ac.dnd.bookkeeping.android.presentation.ui.main.home.bookkeeping.BookkeepingScreen +import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.HistoryScreen import ac.dnd.bookkeeping.android.presentation.ui.main.home.setting.SettingScreen import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.fillMaxSize @@ -67,7 +67,7 @@ fun HomeScreen( ) { page -> when (page) { 0 -> { - BookkeepingScreen( + HistoryScreen( appState = appState ) } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/bookkeeping/BookkeepingScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/bookkeeping/BookkeepingScreen.kt deleted file mode 100644 index d93a3316..00000000 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/bookkeeping/BookkeepingScreen.kt +++ /dev/null @@ -1,46 +0,0 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.bookkeeping - -import ac.dnd.bookkeeping.android.presentation.common.util.ErrorObserver -import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.Text -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.unit.sp -import androidx.hilt.navigation.compose.hiltViewModel - -@Composable -fun BookkeepingScreen( - appState: ApplicationState, - viewModel: BookkeepingViewModel = hiltViewModel() -) { - Observer( - appState = appState, - viewModel = viewModel - ) - - Box( - modifier = Modifier - .fillMaxSize() - .background(color = Color.White), - contentAlignment = Alignment.Center - ) { - Text( - text = "Bookkeeping", - fontSize = 20.sp, - color = Color.Black - ) - } -} - -@Composable -private fun Observer( - appState: ApplicationState, - viewModel: BookkeepingViewModel -) { - ErrorObserver(viewModel) -} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/bookkeeping/BookkeepingViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/bookkeeping/BookkeepingViewModel.kt deleted file mode 100644 index d88768a3..00000000 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/bookkeeping/BookkeepingViewModel.kt +++ /dev/null @@ -1,11 +0,0 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.bookkeeping - -import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel -import androidx.lifecycle.SavedStateHandle -import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject - -@HiltViewModel -class BookkeepingViewModel @Inject constructor( - private val savedStateHandle: SavedStateHandle -) : BaseViewModel() diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupEvent.kt similarity index 61% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupEvent.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupEvent.kt index 32755f6d..1f988671 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupEvent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupEvent.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.group +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add sealed interface AddGroupEvent { sealed interface AddGroup : AddGroupEvent { diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupIntent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupIntent.kt similarity index 54% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupIntent.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupIntent.kt index 4b712988..7c81a08a 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupIntent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupIntent.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.group +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add sealed interface AddGroupIntent { data class OnConfirm(val name: String) : AddGroupIntent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupModel.kt similarity index 58% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupModel.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupModel.kt index 8e439be6..6e42b34b 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupModel.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.group +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add import androidx.compose.runtime.Immutable diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupScreen.kt similarity index 98% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupScreen.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupScreen.kt index 65b4b302..2506d020 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupScreen.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.group +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add import ac.dnd.bookkeeping.android.presentation.R import ac.dnd.bookkeeping.android.presentation.common.theme.Gray200 diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupState.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupState.kt similarity index 58% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupState.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupState.kt index 1c8d3251..91b5310d 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupState.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupState.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.group +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add sealed interface AddGroupState { data object Init : AddGroupState diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupViewModel.kt similarity index 96% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupViewModel.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupViewModel.kt index a1a28ff3..dedd0d41 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/group/AddGroupViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/add/AddGroupViewModel.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.group +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add import ac.dnd.bookkeeping.android.domain.model.error.ServerException import ac.dnd.bookkeeping.android.domain.usecase.feature.group.AddGroupUseCase diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationConstant.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationConstant.kt new file mode 100644 index 00000000..484bd3fb --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationConstant.kt @@ -0,0 +1,5 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.get + +object GetRelationConstant { + const val ROUTE: String = "searchName" +} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationEvent.kt new file mode 100644 index 00000000..10b521ca --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationEvent.kt @@ -0,0 +1,3 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.get + +sealed interface GetRelationEvent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationIntent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationIntent.kt new file mode 100644 index 00000000..20093705 --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationIntent.kt @@ -0,0 +1,3 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.get + +sealed interface GetRelationIntent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationModel.kt similarity index 53% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationModel.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationModel.kt index 59d411cb..aa925f7c 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationModel.kt @@ -1,10 +1,10 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.relation +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.get import ac.dnd.bookkeeping.android.domain.model.feature.group.GroupWithRelation import androidx.compose.runtime.Immutable @Immutable -data class SearchRelationModel( - val state: SearchRelationState, +data class GetRelationModel( + val state: GetRelationState, val groups: List ) diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationScreen.kt similarity index 96% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationScreen.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationScreen.kt index 6cdb081f..c52400c9 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationScreen.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.relation +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.get import ac.dnd.bookkeeping.android.domain.model.feature.group.GroupWithRelation import ac.dnd.bookkeeping.android.domain.model.feature.relation.RelationSimple @@ -69,13 +69,13 @@ fun SearchRelationScreen( appState: ApplicationState, onDismissRequest: () -> Unit, onResult: (RelationSimple) -> Unit, - viewModel: SearchRelationViewModel = hiltViewModel() + viewModel: GetRelationViewModel = hiltViewModel() ) { - val model: SearchRelationModel = Unit.let { + val model: GetRelationModel = Unit.let { val state by viewModel.state.collectAsStateWithLifecycle() val groups by viewModel.groups.collectAsStateWithLifecycle() - SearchRelationModel( + GetRelationModel( state = state, groups = groups ) @@ -97,9 +97,9 @@ fun SearchRelationScreen( @OptIn(ExperimentalMaterialApi::class) private fun SearchRelationScreen( appState: ApplicationState, - model: SearchRelationModel, - event: EventFlow, - intent: (SearchRelationIntent) -> Unit, + model: GetRelationModel, + event: EventFlow, + intent: (GetRelationIntent) -> Unit, handler: CoroutineExceptionHandler, onDismissRequest: () -> Unit, onResult: (RelationSimple) -> Unit, @@ -356,7 +356,7 @@ private fun SearchRelationRelation( fun SearchRelationScreenPreview() { SearchRelationScreen( appState = rememberApplicationState(), - model = SearchRelationModel(state = SearchRelationState.Init, groups = listOf()), + model = GetRelationModel(state = GetRelationState.Init, groups = listOf()), event = MutableEventFlow(), intent = {}, handler = CoroutineExceptionHandler { _, _ -> }, diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationState.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationState.kt new file mode 100644 index 00000000..40dfa0b8 --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationState.kt @@ -0,0 +1,6 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.get + +sealed interface GetRelationState { + data object Init : GetRelationState + data object Loading : GetRelationState +} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationViewModel.kt similarity index 76% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationViewModel.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationViewModel.kt index 0080df7b..d855cd10 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/relation/get/GetRelationViewModel.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.relation +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.get import ac.dnd.bookkeeping.android.domain.model.error.ServerException import ac.dnd.bookkeeping.android.domain.model.feature.group.GroupWithRelation @@ -16,24 +16,24 @@ import kotlinx.coroutines.flow.asStateFlow import javax.inject.Inject @HiltViewModel -class SearchRelationViewModel @Inject constructor( +class GetRelationViewModel @Inject constructor( private val savedStateHandle: SavedStateHandle, private val getGroupListWithRelationUseCase: GetGroupListWithRelationUseCase ) : BaseViewModel() { - private val _state: MutableStateFlow = - MutableStateFlow(SearchRelationState.Init) - val state: StateFlow = _state.asStateFlow() + private val _state: MutableStateFlow = + MutableStateFlow(GetRelationState.Init) + val state: StateFlow = _state.asStateFlow() - private val _event: MutableEventFlow = MutableEventFlow() - val event: EventFlow = _event.asEventFlow() + private val _event: MutableEventFlow = MutableEventFlow() + val event: EventFlow = _event.asEventFlow() private val _groups: MutableStateFlow> = MutableStateFlow(emptyList()) val groups: StateFlow> = _groups.asStateFlow() init { launch { - _state.value = SearchRelationState.Loading + _state.value = GetRelationState.Loading getGroupListWithRelationUseCase() .onSuccess { _groups.value = it @@ -51,7 +51,7 @@ class SearchRelationViewModel @Inject constructor( } } - fun onIntent(intent: SearchRelationIntent) { + fun onIntent(intent: GetRelationIntent) { } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationConstant.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationConstant.kt deleted file mode 100644 index c87703d5..00000000 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationConstant.kt +++ /dev/null @@ -1,5 +0,0 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.relation - -object SearchRelationConstant { - const val ROUTE: String = "searchName" -} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationEvent.kt deleted file mode 100644 index 65a5480b..00000000 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationEvent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.relation - -sealed interface SearchRelationEvent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationIntent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationIntent.kt deleted file mode 100644 index 11ee7661..00000000 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationIntent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.relation - -sealed interface SearchRelationIntent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationState.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationState.kt deleted file mode 100644 index e9bee9e9..00000000 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/event/common/relation/SearchRelationState.kt +++ /dev/null @@ -1,6 +0,0 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.relation - -sealed interface SearchRelationState { - data object Init : SearchRelationState - data object Loading : SearchRelationState -} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryConstant.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryConstant.kt index dce54412..cfcbb3ba 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryConstant.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryConstant.kt @@ -1,5 +1,5 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.home.history object HistoryConstant { - const val ROUTE = "/history" + const val ROUTE: String = "/history" } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryEvent.kt similarity index 59% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainEvent.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryEvent.kt index 0f7f90f3..18bbd9c1 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainEvent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryEvent.kt @@ -1,3 +1,3 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history -sealed interface HistoryMainEvent +sealed interface HistoryEvent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainIntent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryIntent.kt similarity index 59% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainIntent.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryIntent.kt index e41a8723..8391f3e9 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainIntent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryIntent.kt @@ -1,3 +1,3 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history -sealed interface HistoryMainIntent +sealed interface HistoryIntent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryModel.kt similarity index 76% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainModel.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryModel.kt index 4c14e509..412a516b 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryModel.kt @@ -1,10 +1,10 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history import ac.dnd.bookkeeping.android.domain.model.legacy.HistoryInfoLegacy import androidx.compose.runtime.Immutable @Immutable -data class HistoryMainModel( - val state: HistoryMainState, +data class HistoryModel( + val state: HistoryState, val historyInfo: HistoryInfoLegacy ) diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryScreen.kt index 2bd46264..9c91f50f 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryScreen.kt @@ -1,32 +1,72 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.home.history +import ac.dnd.bookkeeping.android.domain.model.legacy.HistoryInfoLegacy +import ac.dnd.bookkeeping.android.presentation.R +import ac.dnd.bookkeeping.android.presentation.common.theme.Gray000 +import ac.dnd.bookkeeping.android.presentation.common.theme.Gray100 +import ac.dnd.bookkeeping.android.presentation.common.theme.Gray400 +import ac.dnd.bookkeeping.android.presentation.common.theme.Gray700 +import ac.dnd.bookkeeping.android.presentation.common.theme.Headline0 +import ac.dnd.bookkeeping.android.presentation.common.theme.Headline3 import ac.dnd.bookkeeping.android.presentation.common.util.ErrorObserver +import ac.dnd.bookkeeping.android.presentation.common.util.LaunchedEffectWithLifecycle +import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow +import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow +import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.eventObserve +import ac.dnd.bookkeeping.android.presentation.common.util.expansion.addFocusCleaner import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.HistoryMainModel -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.HistoryMainScreen -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.HistoryMainViewModel +import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item.HistoryDetailScreen +import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item.type.HistoryViewType +import ac.dnd.bookkeeping.android.presentation.ui.main.rememberApplicationState +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.pager.HorizontalPager +import androidx.compose.foundation.pager.rememberPagerState +import androidx.compose.material.Tab +import androidx.compose.material.TabRow +import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.painter.Painter +import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import kotlinx.coroutines.CoroutineExceptionHandler +import kotlinx.coroutines.launch @Composable fun HistoryScreen( appState: ApplicationState, - viewModel: HistoryMainViewModel = hiltViewModel() + viewModel: HistoryViewModel = hiltViewModel() ) { - val model: HistoryMainModel = Unit.let { + val model: HistoryModel = Unit.let { val state by viewModel.state.collectAsStateWithLifecycle() val historyInfo by viewModel.historyInfo.collectAsStateWithLifecycle() - HistoryMainModel( + HistoryModel( state = state, historyInfo = historyInfo ) } ErrorObserver(viewModel) - HistoryMainScreen( + HistoryScreen( appState = appState, model = model, event = viewModel.event, @@ -34,3 +74,159 @@ fun HistoryScreen( handler = viewModel.handler ) } + +@OptIn(ExperimentalFoundationApi::class) +@Composable +private fun HistoryScreen( + appState: ApplicationState, + model: HistoryModel, + event: EventFlow, + intent: (HistoryIntent) -> Unit, + handler: CoroutineExceptionHandler +) { + val focusManager = LocalFocusManager.current + val scope = rememberCoroutineScope() + val pages = listOf("전체", "받은 마음", "보낸 마음") + val pagerState = rememberPagerState( + pageCount = { 3 } + ) + + Column( + modifier = Modifier + .fillMaxSize() + .addFocusCleaner(focusManager) + .background(Gray100) + ) { + Box( + modifier = Modifier + .height(56.dp) + .fillMaxWidth() + .background(Gray000) + .padding(horizontal = 20.dp) + ) { + Text( + text = "MUR", + style = Headline0.merge( + color = Gray700, + fontWeight = FontWeight.SemiBold + ), + modifier = Modifier.align(Alignment.CenterStart) + ) + Image( + painter = getAlarmImage(model.historyInfo.unReadAlarm), + contentDescription = null, + modifier = Modifier + .align(Alignment.CenterEnd) + .clickable { + //TODO go alarm view + } + ) + } + Box( + modifier = Modifier + .fillMaxWidth() + .background(Gray000) + ) { + Box( + modifier = Modifier + .align(Alignment.BottomCenter) + .height(1.dp) + .fillMaxWidth() + .background(Gray400) + ) + TabRow( + selectedTabIndex = pagerState.currentPage, + backgroundColor = Color.Transparent, + modifier = Modifier + .background(Color.Transparent) + .padding(horizontal = 20.dp), + divider = { + Box( + modifier = Modifier + .height(1.dp) + .fillMaxWidth() + .background(Gray400) + ) + } + ) { + pages.forEachIndexed { index, pageText -> + Tab( + selected = index == pagerState.currentPage, + onClick = { + scope.launch { + pagerState.animateScrollToPage(index) + } + }, + text = { + Text( + text = pageText, + style = Headline3.merge( + color = if (index == pagerState.currentPage) Gray700 else Gray400, + fontWeight = FontWeight.SemiBold + ) + ) + } + ) + } + } + } + + HorizontalPager( + state = pagerState, + userScrollEnabled = false + ) { pageIndex -> + when (pageIndex) { + 0 -> { + HistoryDetailScreen( + viewType = HistoryViewType.TOTAL, + mainModel = model + ) + } + + 1 -> { + HistoryDetailScreen( + viewType = HistoryViewType.TAKE, + mainModel = model + ) + } + + 2 -> { + HistoryDetailScreen( + viewType = HistoryViewType.GIVE, + mainModel = model + ) + } + } + } + } + + LaunchedEffectWithLifecycle(event, handler) { + event.eventObserve { event -> + + } + } +} + +@Composable +private fun getAlarmImage(alarmOnState: Boolean): Painter { + return painterResource(if (alarmOnState) R.drawable.ic_notification_on else R.drawable.ic_notification) +} + +@Composable +@Preview +private fun HistoryScreenPreview() { + HistoryScreen( + appState = rememberApplicationState(), + model = HistoryModel( + state = HistoryState.Init, + historyInfo = HistoryInfoLegacy( + unReadAlarm = true, + totalHeartCount = 30, + unWrittenCount = 5 + ) + ), + event = MutableEventFlow(), + intent = {}, + handler = CoroutineExceptionHandler { _, _ -> } + ) +} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryState.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryState.kt new file mode 100644 index 00000000..c4cc8bcf --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryState.kt @@ -0,0 +1,6 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history + +sealed interface HistoryState { + data object Init : HistoryState + data object Loading : HistoryState +} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryViewModel.kt similarity index 78% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainViewModel.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryViewModel.kt index 660fdb58..2d7ffbac 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/HistoryViewModel.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history import ac.dnd.bookkeeping.android.domain.model.error.ServerException import ac.dnd.bookkeeping.android.domain.model.legacy.HistoryInfoLegacy @@ -16,16 +16,16 @@ import kotlinx.coroutines.flow.asStateFlow import javax.inject.Inject @HiltViewModel -class HistoryMainViewModel @Inject constructor( +class HistoryViewModel @Inject constructor( private val savedStateHandle: SavedStateHandle, private val getHistoryInfoUseCase: GetHistoryInfoUseCase ) : BaseViewModel() { - private val _state: MutableStateFlow = MutableStateFlow(HistoryMainState.Init) - val state: StateFlow = _state.asStateFlow() + private val _state: MutableStateFlow = MutableStateFlow(HistoryState.Init) + val state: StateFlow = _state.asStateFlow() - private val _event: MutableEventFlow = MutableEventFlow() - val event: EventFlow = _event.asEventFlow() + private val _event: MutableEventFlow = MutableEventFlow() + val event: EventFlow = _event.asEventFlow() private val _historyInfo: MutableStateFlow = MutableStateFlow(HistoryInfoLegacy(0, 0, false)) @@ -33,7 +33,7 @@ class HistoryMainViewModel @Inject constructor( init { launch { - _state.value = HistoryMainState.Loading + _state.value = HistoryState.Loading getHistoryInfoUseCase() .onSuccess { _historyInfo.value = it @@ -49,11 +49,11 @@ class HistoryMainViewModel @Inject constructor( } } } - _state.value = HistoryMainState.Init + _state.value = HistoryState.Init } } - fun onIntent(intent: HistoryMainIntent) { + fun onIntent(intent: HistoryIntent) { } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailEvent.kt similarity index 85% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailEvent.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailEvent.kt index 11909fce..fa0fc0fd 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailEvent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailEvent.kt @@ -1,3 +1,3 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item sealed interface HistoryDetailEvent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailIntent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailIntent.kt similarity index 85% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailIntent.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailIntent.kt index 0cb904ac..98136766 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailIntent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailIntent.kt @@ -1,3 +1,3 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item sealed interface HistoryDetailIntent diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailModel.kt similarity index 87% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailModel.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailModel.kt index 96b01363..2ee38edc 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailModel.kt @@ -1,7 +1,7 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item import ac.dnd.bookkeeping.android.domain.model.legacy.GroupLegacy -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail.type.HistoryViewType +import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item.type.HistoryViewType import androidx.compose.runtime.Immutable @Immutable diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailScreen.kt similarity index 98% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailScreen.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailScreen.kt index 35c1cb77..a4db6d25 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailScreen.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item import ac.dnd.bookkeeping.android.domain.model.legacy.HistoryInfoLegacy import ac.dnd.bookkeeping.android.presentation.R @@ -25,11 +25,11 @@ import ac.dnd.bookkeeping.android.presentation.common.view.chip.ChipType import ac.dnd.bookkeeping.android.presentation.common.view.chip.GroupChipListComponent import ac.dnd.bookkeeping.android.presentation.common.view.textfield.TypingTextField import ac.dnd.bookkeeping.android.presentation.common.view.textfield.TypingTextFieldType -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.HistoryMainModel -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.HistoryMainState -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail.item.HistoryRelationItem -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail.type.HistorySortedType -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail.type.HistoryViewType +import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.HistoryModel +import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.HistoryState +import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item.item.HistoryRelationItem +import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item.type.HistorySortedType +import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item.type.HistoryViewType import android.annotation.SuppressLint import androidx.compose.foundation.Image import androidx.compose.foundation.background @@ -81,7 +81,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle @Composable fun HistoryDetailScreen( viewType: HistoryViewType, - mainModel: HistoryMainModel, + mainModel: HistoryModel, viewModel: HistoryDetailViewModel = hiltViewModel() ) { val model: HistoryDetailModel = Unit.let { @@ -402,8 +402,8 @@ fun EmptyRelationView() { fun HistoryDetailPreview() { HistoryDetailScreen( HistoryViewType.TOTAL, - mainModel = HistoryMainModel( - state = HistoryMainState.Init, + mainModel = HistoryModel( + state = HistoryState.Init, historyInfo = HistoryInfoLegacy( unReadAlarm = true, totalHeartCount = 30, diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailState.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailState.kt similarity index 91% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailState.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailState.kt index e0a26eda..44e1e27f 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailState.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailState.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item sealed interface HistoryDetailState { data object Init : HistoryDetailState diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailViewModel.kt similarity index 98% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailViewModel.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailViewModel.kt index 9c3897e0..547531f3 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/HistoryDetailViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/HistoryDetailViewModel.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item import ac.dnd.bookkeeping.android.domain.model.error.ServerException import ac.dnd.bookkeeping.android.domain.model.legacy.GroupLegacy @@ -8,7 +8,7 @@ import ac.dnd.bookkeeping.android.presentation.common.base.ErrorEvent import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.asEventFlow -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail.type.HistoryViewType +import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item.type.HistoryViewType import androidx.lifecycle.SavedStateHandle import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/item/HistoryRelationItem.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/item/HistoryRelationItem.kt similarity index 99% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/item/HistoryRelationItem.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/item/HistoryRelationItem.kt index c7b9feea..1aa1c57e 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/item/HistoryRelationItem.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/item/HistoryRelationItem.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail.item +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item.item import ac.dnd.bookkeeping.android.domain.model.legacy.RelationLegacy import ac.dnd.bookkeeping.android.domain.model.legacy.RelationGroupLegacy diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/type/HistorySortedType.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/type/HistorySortedType.kt similarity index 89% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/type/HistorySortedType.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/type/HistorySortedType.kt index e96ce59d..f5f8065c 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/type/HistorySortedType.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/type/HistorySortedType.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail.type +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item.type enum class HistorySortedType( val typeName: String diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/type/HistoryViewType.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/type/HistoryViewType.kt similarity index 89% rename from presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/type/HistoryViewType.kt rename to presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/type/HistoryViewType.kt index 437bb418..c3d12816 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/detail/type/HistoryViewType.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/item/type/HistoryViewType.kt @@ -1,4 +1,4 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail.type +package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.item.type enum class HistoryViewType( val typeName: String diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainConstant.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainConstant.kt deleted file mode 100644 index bec4bd8a..00000000 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainConstant.kt +++ /dev/null @@ -1,7 +0,0 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main - -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.HistoryConstant - -object HistoryMainConstant { - const val ROUTE: String = "${HistoryConstant.ROUTE}/main" -} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainScreen.kt deleted file mode 100644 index dc15421b..00000000 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainScreen.kt +++ /dev/null @@ -1,203 +0,0 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main - -import ac.dnd.bookkeeping.android.domain.model.legacy.HistoryInfoLegacy -import ac.dnd.bookkeeping.android.presentation.R -import ac.dnd.bookkeeping.android.presentation.common.theme.Gray000 -import ac.dnd.bookkeeping.android.presentation.common.theme.Gray100 -import ac.dnd.bookkeeping.android.presentation.common.theme.Gray400 -import ac.dnd.bookkeeping.android.presentation.common.theme.Gray700 -import ac.dnd.bookkeeping.android.presentation.common.theme.Headline0 -import ac.dnd.bookkeeping.android.presentation.common.theme.Headline3 -import ac.dnd.bookkeeping.android.presentation.common.util.LaunchedEffectWithLifecycle -import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow -import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.MutableEventFlow -import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.eventObserve -import ac.dnd.bookkeeping.android.presentation.common.util.expansion.addFocusCleaner -import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail.HistoryDetailScreen -import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main.detail.type.HistoryViewType -import ac.dnd.bookkeeping.android.presentation.ui.main.rememberApplicationState -import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.Image -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.pager.HorizontalPager -import androidx.compose.foundation.pager.rememberPagerState -import androidx.compose.material.Tab -import androidx.compose.material.TabRow -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.platform.LocalFocusManager -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import kotlinx.coroutines.CoroutineExceptionHandler -import kotlinx.coroutines.launch - -@OptIn(ExperimentalFoundationApi::class) -@Composable -fun HistoryMainScreen( - appState: ApplicationState, - model: HistoryMainModel, - event: EventFlow, - intent: (HistoryMainIntent) -> Unit, - handler: CoroutineExceptionHandler -) { - val focusManager = LocalFocusManager.current - val scope = rememberCoroutineScope() - val pages = listOf("전체", "받은 마음", "보낸 마음") - val pagerState = rememberPagerState( - pageCount = { 3 } - ) - - Column( - modifier = Modifier - .fillMaxSize() - .addFocusCleaner(focusManager) - .background(Gray100) - ) { - Box( - modifier = Modifier - .height(56.dp) - .fillMaxWidth() - .background(Gray000) - .padding(horizontal = 20.dp) - ) { - Text( - text = "MUR", - style = Headline0.merge( - color = Gray700, - fontWeight = FontWeight.SemiBold - ), - modifier = Modifier.align(Alignment.CenterStart) - ) - Image( - painter = getAlarmImage(model.historyInfo.unReadAlarm), - contentDescription = null, - modifier = Modifier - .align(Alignment.CenterEnd) - .clickable { - //TODO go alarm view - } - ) - } - Box( - modifier = Modifier - .fillMaxWidth() - .background(Gray000) - ) { - Box( - modifier = Modifier - .align(Alignment.BottomCenter) - .height(1.dp) - .fillMaxWidth() - .background(Gray400) - ) - TabRow( - selectedTabIndex = pagerState.currentPage, - backgroundColor = Color.Transparent, - modifier = Modifier - .background(Color.Transparent) - .padding(horizontal = 20.dp), - divider = { - Box( - modifier = Modifier - .height(1.dp) - .fillMaxWidth() - .background(Gray400) - ) - } - ) { - pages.forEachIndexed { index, pageText -> - Tab( - selected = index == pagerState.currentPage, - onClick = { - scope.launch { - pagerState.animateScrollToPage(index) - } - }, - text = { - Text( - text = pageText, - style = Headline3.merge( - color = if (index == pagerState.currentPage) Gray700 else Gray400, - fontWeight = FontWeight.SemiBold - ) - ) - } - ) - } - } - } - - HorizontalPager( - state = pagerState, - userScrollEnabled = false - ) { pageIndex -> - when (pageIndex) { - 0 -> { - HistoryDetailScreen( - viewType = HistoryViewType.TOTAL, - mainModel = model - ) - } - - 1 -> { - HistoryDetailScreen( - viewType = HistoryViewType.TAKE, - mainModel = model - ) - } - - 2 -> { - HistoryDetailScreen( - viewType = HistoryViewType.GIVE, - mainModel = model - ) - } - } - } - } - - LaunchedEffectWithLifecycle(event, handler) { - event.eventObserve { event -> - - } - } -} - -@Composable -fun getAlarmImage(alarmOnState: Boolean): Painter { - return painterResource(if (alarmOnState) R.drawable.ic_notification_on else R.drawable.ic_notification) -} - -@Composable -@Preview -fun HistoryScreenPreview() { - HistoryMainScreen( - appState = rememberApplicationState(), - model = HistoryMainModel( - state = HistoryMainState.Init, - historyInfo = HistoryInfoLegacy( - unReadAlarm = true, - totalHeartCount = 30, - unWrittenCount = 5 - ) - ), - event = MutableEventFlow(), - intent = {}, - handler = CoroutineExceptionHandler { _, _ -> } - ) -} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainState.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainState.kt deleted file mode 100644 index 75d9189a..00000000 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/main/HistoryMainState.kt +++ /dev/null @@ -1,6 +0,0 @@ -package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.main - -sealed interface HistoryMainState { - data object Init : HistoryMainState - data object Loading : HistoryMainState -} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/registration/HistoryRegistrationScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/registration/HistoryRegistrationScreen.kt index e0ee90e1..a6059ece 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/registration/HistoryRegistrationScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/history/registration/HistoryRegistrationScreen.kt @@ -33,7 +33,7 @@ import ac.dnd.bookkeeping.android.presentation.common.view.textfield.TypingPrice import ac.dnd.bookkeeping.android.presentation.common.view.textfield.TypingTextField import ac.dnd.bookkeeping.android.presentation.common.view.textfield.TypingTextFieldType import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState -import ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.relation.SearchRelationScreen +import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.get.SearchRelationScreen import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.registration.calendar.HistoryCalendarScreen import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.registration.type.HistoryRegistrationEventType import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.registration.type.HistoryRegistrationTagType diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/setting/SettingScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/setting/SettingScreen.kt index 21474780..240c0d62 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/setting/SettingScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/setting/SettingScreen.kt @@ -15,8 +15,8 @@ import ac.dnd.bookkeeping.android.presentation.common.view.confirm.ConfirmButton import ac.dnd.bookkeeping.android.presentation.common.view.textfield.TypingTextField import ac.dnd.bookkeeping.android.presentation.common.view.textfield.TypingTextFieldType import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState -import ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.group.AddGroupScreen -import ac.dnd.bookkeeping.android.presentation.ui.main.home.event.common.relation.SearchRelationScreen +import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add.AddGroupScreen +import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.get.SearchRelationScreen import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement