From 746c35a66a858873eaae9a83e555ba4e72ed8a62 Mon Sep 17 00:00:00 2001 From: jinuemong Date: Mon, 5 Feb 2024 18:45:13 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[Feat]:=20get=20=EA=B7=B8=EB=A3=B9=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/common/group/get/GetGroupEvent.kt | 7 + .../home/common/group/get/GetGroupIntent.kt | 5 + .../home/common/group/get/GetGroupModel.kt | 10 + .../home/common/group/get/GetGroupScreen.kt | 303 ++++++++++++++++++ .../home/common/group/get/GetGroupState.kt | 6 + .../common/group/get/GetGroupViewModel.kt | 67 ++++ .../common/group/get/type/DefaultGroupType.kt | 16 + .../src/main/res/drawable/ic_circle_plus.xml | 25 ++ .../src/main/res/drawable/ic_edit.xml | 20 ++ .../src/main/res/drawable/ic_trash.xml | 34 ++ 10 files changed, 493 insertions(+) create mode 100644 presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupEvent.kt create mode 100644 presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupIntent.kt create mode 100644 presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupModel.kt create mode 100644 presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt create mode 100644 presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupState.kt create mode 100644 presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupViewModel.kt create mode 100644 presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/type/DefaultGroupType.kt create mode 100644 presentation/src/main/res/drawable/ic_circle_plus.xml create mode 100644 presentation/src/main/res/drawable/ic_edit.xml create mode 100644 presentation/src/main/res/drawable/ic_trash.xml diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupEvent.kt new file mode 100644 index 00000000..4f89476c --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupEvent.kt @@ -0,0 +1,7 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get + +sealed interface GetGroupEvent { + sealed interface DeleteGroup : GetGroupEvent{ + data object Success : DeleteGroup + } +} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupIntent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupIntent.kt new file mode 100644 index 00000000..e025a07f --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupIntent.kt @@ -0,0 +1,5 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get + +sealed interface GetGroupIntent { + data class OnDelete(val id: Long) : GetGroupIntent +} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupModel.kt new file mode 100644 index 00000000..4867c0b8 --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupModel.kt @@ -0,0 +1,10 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get + +import ac.dnd.bookkeeping.android.domain.model.feature.group.Group +import androidx.compose.runtime.Immutable + +@Immutable +data class GetGroupModel( + val state: GetGroupState, + val groups : List +) diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt new file mode 100644 index 00000000..eea6bc21 --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt @@ -0,0 +1,303 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get + +import ac.dnd.bookkeeping.android.domain.model.feature.group.Group +import ac.dnd.bookkeeping.android.presentation.R +import ac.dnd.bookkeeping.android.presentation.common.theme.Body0 +import ac.dnd.bookkeeping.android.presentation.common.theme.Gray000 +import ac.dnd.bookkeeping.android.presentation.common.theme.Gray150 +import ac.dnd.bookkeeping.android.presentation.common.theme.Gray500 +import ac.dnd.bookkeeping.android.presentation.common.theme.Gray600 +import ac.dnd.bookkeeping.android.presentation.common.theme.Gray700 +import ac.dnd.bookkeeping.android.presentation.common.theme.Gray800 +import ac.dnd.bookkeeping.android.presentation.common.theme.Headline2 +import ac.dnd.bookkeeping.android.presentation.common.theme.Headline3 +import ac.dnd.bookkeeping.android.presentation.common.theme.Shapes +import ac.dnd.bookkeeping.android.presentation.common.theme.Space12 +import ac.dnd.bookkeeping.android.presentation.common.theme.Space16 +import ac.dnd.bookkeeping.android.presentation.common.theme.Space20 +import ac.dnd.bookkeeping.android.presentation.common.theme.Space8 +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.view.BottomSheetScreen +import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add.AddGroupEvent +import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get.type.DefaultGroupType +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.material.DropdownMenu +import androidx.compose.material.DropdownMenuItem +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.ColorFilter +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 com.holix.android.bottomsheetdialog.compose.BottomSheetBehaviorProperties +import com.holix.android.bottomsheetdialog.compose.BottomSheetDialogProperties +import kotlinx.coroutines.CoroutineExceptionHandler + +@Composable +fun GetGroupScreen( + onDismissRequest: () -> Unit, + onResult: (Group) -> Unit, + model: GetGroupModel, + handler: CoroutineExceptionHandler, + intent : (GetGroupIntent) -> Unit, + event : EventFlow +) { + + BottomSheetScreen( + onDismissRequest = onDismissRequest, + properties = BottomSheetDialogProperties( + behaviorProperties = BottomSheetBehaviorProperties( + state = BottomSheetBehaviorProperties.State.Expanded, + skipCollapsed = true + ) + ) + ) { + Column( + modifier = Modifier + .wrapContentHeight() + .background(Gray150) + .padding(horizontal = Space20) + ) { + Spacer(modifier = Modifier.height(Space20)) + Box( + modifier = Modifier + .padding(Space8) + .fillMaxWidth() + ) { + Image( + painter = painterResource(R.drawable.ic_close), + contentDescription = null, + modifier = Modifier.align(Alignment.CenterEnd) + ) + } + Text( + text = "전체 그룹 ${model.groups.size}", + style = Headline2.merge( + color = Gray800, + fontWeight = FontWeight.SemiBold + ), + modifier = Modifier.padding(vertical = Space8) + ) + Spacer(modifier = Modifier.height(Space20)) + LazyColumn(verticalArrangement = Arrangement.spacedBy(Space12)) { + items(model.groups) { group -> + var isDropDownMenuExpanded by remember { mutableStateOf(false) } + Box( + contentAlignment = Alignment.CenterStart, + modifier = Modifier + .fillMaxWidth() + .clickable { + onResult(group) + } + .padding( + start = Space16, + end = Space12, + top = Space16, + bottom = Space16 + ) + ) { + Text( + text = group.name, + style = Headline3.merge( + color = Gray700, + fontWeight = FontWeight.SemiBold + ), + modifier = Modifier.align(Alignment.CenterStart) + ) + if (DefaultGroupType.checkEditable(group.name)) { + Image( + painter = painterResource(R.drawable.ic_more_vertical), + contentDescription = null, + colorFilter = ColorFilter.tint(Gray500), + modifier = Modifier + .align(Alignment.CenterEnd) + .clickable { + isDropDownMenuExpanded = true + } + ) + DropdownMenu( + modifier = Modifier + .wrapContentSize() + .background( + color = Gray000, + shape = Shapes.medium + ), + expanded = isDropDownMenuExpanded, + onDismissRequest = { isDropDownMenuExpanded = false } + ){ + Column(verticalArrangement = Arrangement.Center){ + DropdownMenuItem( + onClick = { + // TODO 수정 + isDropDownMenuExpanded = false + }, + contentPadding = PaddingValues(0.dp), + modifier = Modifier + .width(100.dp) + .height(40.dp) + ){ + Box( + modifier = Modifier + .padding( + vertical = Space8, + horizontal = Space12 + ) + .fillMaxWidth() + ){ + Text( + text = "수정", + style = Body0.merge( + color = Gray700, + fontWeight = FontWeight.Normal + ), + modifier = Modifier.align(Alignment.CenterStart) + ) + Image( + painter = painterResource(R.drawable.ic_edit), + contentDescription = null, + modifier = Modifier.align(Alignment.CenterStart) + ) + } + } + DropdownMenuItem( + onClick = { + // TODO 삭제 + isDropDownMenuExpanded = false + }, + contentPadding = PaddingValues(0.dp), + modifier = Modifier + .width(100.dp) + .height(40.dp) + ){ + Box( + modifier = Modifier + .padding( + vertical = Space8, + horizontal = Space12 + ) + ){ + Text( + text = "삭제", + style = Body0.merge( + color = Gray700, + fontWeight = FontWeight.Normal + ), + modifier = Modifier.align(Alignment.CenterStart) + ) + Image( + painter = painterResource(R.drawable.ic_trash), + contentDescription = null, + modifier = Modifier.align(Alignment.CenterStart) + ) + } + } + } + } + } + } + } + } + Spacer(modifier = Modifier.height(Space16)) + Row( + modifier = Modifier + .clickable { + // TODO open add group + } + .padding( + vertical = Space16, + horizontal = 2.dp + ), + verticalAlignment = Alignment.CenterVertically + ) { + Image( + painter = painterResource(R.drawable.ic_circle_plus), + contentDescription = null + ) + Spacer(modifier = Modifier.width(6.dp)) + Text( + text = "그룹 등록하기", + style = Headline3.merge( + color = Gray600, + fontWeight = FontWeight.SemiBold + ) + ) + } + Spacer(modifier = Modifier.height(Space12)) + } + } + + LaunchedEffectWithLifecycle(event, handler) { + event.eventObserve { event -> + when (event) { + is GetGroupEvent.DeleteGroup -> { + + } + } + } + } +} + +@Preview(apiLevel = 33) +@Composable +fun GetGroupScreenPreivew() { + GetGroupScreen( + onDismissRequest = {}, + event = MutableEventFlow(), + intent = {}, + handler = CoroutineExceptionHandler { _, _ -> }, + onResult = { + + }, + model = GetGroupModel( + state = GetGroupState.Init, + groups = listOf( + Group( + id = 0, + name = "친구" + ), + Group( + id = 0, + name = "가족" + ), + Group( + id = 0, + name = "지인" + ), + Group( + id = 0, + name = "직장" + ), + Group( + id = 0, + name = "label" + ) + ) + ) + ) +} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupState.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupState.kt new file mode 100644 index 00000000..2f410c40 --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupState.kt @@ -0,0 +1,6 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get + +sealed interface GetGroupState { + data object Init : GetGroupState + data object Loading : GetGroupState +} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupViewModel.kt new file mode 100644 index 00000000..7f298acc --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupViewModel.kt @@ -0,0 +1,67 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get + +import ac.dnd.bookkeeping.android.domain.model.error.ServerException +import ac.dnd.bookkeeping.android.domain.usecase.feature.group.AddGroupUseCase +import ac.dnd.bookkeeping.android.domain.usecase.feature.group.DeleteGroupUseCase +import ac.dnd.bookkeeping.android.domain.usecase.feature.group.EditGroupUseCase +import ac.dnd.bookkeeping.android.domain.usecase.feature.group.GetGroupListUseCase +import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel +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.common.group.add.AddGroupEvent +import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add.AddGroupIntent +import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add.AddGroupState +import androidx.lifecycle.SavedStateHandle +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import javax.inject.Inject + +@HiltViewModel +class GetGroupViewModel @Inject constructor( + private val savedStateHandle: SavedStateHandle, + private val deleteGroupUseCase: DeleteGroupUseCase, +) : BaseViewModel() { + private val _state: MutableStateFlow = + MutableStateFlow(GetGroupState.Init) + val state: StateFlow = _state.asStateFlow() + + private val _event: MutableEventFlow = MutableEventFlow() + val event: EventFlow = _event.asEventFlow() + + fun onIntent(intent: GetGroupIntent) { + when (intent) { + is GetGroupIntent.OnDelete -> deleteGroup(intent.id) + } + } + + private fun deleteGroup( + id : Long + ){ + launch { + _state.value = GetGroupState.Loading + deleteGroupUseCase( + id = id + ) + .onSuccess { + _state.value = GetGroupState.Init + _event.emit(GetGroupEvent.DeleteGroup.Success) + } + .onFailure { exception -> + _state.value = GetGroupState.Init + when (exception) { + is ServerException -> { + _errorEvent.emit(ErrorEvent.InvalidRequest(exception)) + } + + else -> { + _errorEvent.emit(ErrorEvent.UnavailableServer(exception)) + } + } + } + } + } +} diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/type/DefaultGroupType.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/type/DefaultGroupType.kt new file mode 100644 index 00000000..19399ea4 --- /dev/null +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/type/DefaultGroupType.kt @@ -0,0 +1,16 @@ +package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get.type + +enum class DefaultGroupType( + private val typeName: String +) { + FRIEND("친구"), + FAMILY("가족"), + ACQUAINTANCE("지인"), + RECTAL("직장"); + + companion object { + fun checkEditable(name: String): Boolean { + return entries.find { it.typeName == name } == null + } + } +} diff --git a/presentation/src/main/res/drawable/ic_circle_plus.xml b/presentation/src/main/res/drawable/ic_circle_plus.xml new file mode 100644 index 00000000..dd81c1d3 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_circle_plus.xml @@ -0,0 +1,25 @@ + + + + + diff --git a/presentation/src/main/res/drawable/ic_edit.xml b/presentation/src/main/res/drawable/ic_edit.xml new file mode 100644 index 00000000..c7ed30d6 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_edit.xml @@ -0,0 +1,20 @@ + + + + diff --git a/presentation/src/main/res/drawable/ic_trash.xml b/presentation/src/main/res/drawable/ic_trash.xml new file mode 100644 index 00000000..11179c0c --- /dev/null +++ b/presentation/src/main/res/drawable/ic_trash.xml @@ -0,0 +1,34 @@ + + + + + + From 6d4049ce7e832201b06609ff3b955753173a7371 Mon Sep 17 00:00:00 2001 From: jinuemong Date: Mon, 5 Feb 2024 18:45:43 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[Chore]:=20=EC=BD=94=EB=93=9C=20=ED=8F=AC?= =?UTF-8?q?=EB=A7=B7=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/home/common/group/get/GetGroupEvent.kt | 2 +- .../main/home/common/group/get/GetGroupModel.kt | 2 +- .../home/common/group/get/GetGroupScreen.kt | 17 ++++++++--------- .../home/common/group/get/GetGroupViewModel.kt | 10 ++-------- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupEvent.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupEvent.kt index 4f89476c..de8ba71e 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupEvent.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupEvent.kt @@ -1,7 +1,7 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get sealed interface GetGroupEvent { - sealed interface DeleteGroup : GetGroupEvent{ + sealed interface DeleteGroup : GetGroupEvent { data object Success : DeleteGroup } } diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupModel.kt index 4867c0b8..bb35d9fd 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupModel.kt @@ -6,5 +6,5 @@ import androidx.compose.runtime.Immutable @Immutable data class GetGroupModel( val state: GetGroupState, - val groups : List + val groups: List ) diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt index eea6bc21..dcb236e3 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt @@ -21,7 +21,6 @@ import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.Event 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.view.BottomSheetScreen -import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add.AddGroupEvent import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get.type.DefaultGroupType import androidx.compose.foundation.Image import androidx.compose.foundation.background @@ -65,8 +64,8 @@ fun GetGroupScreen( onResult: (Group) -> Unit, model: GetGroupModel, handler: CoroutineExceptionHandler, - intent : (GetGroupIntent) -> Unit, - event : EventFlow + intent: (GetGroupIntent) -> Unit, + event: EventFlow ) { BottomSheetScreen( @@ -150,8 +149,8 @@ fun GetGroupScreen( ), expanded = isDropDownMenuExpanded, onDismissRequest = { isDropDownMenuExpanded = false } - ){ - Column(verticalArrangement = Arrangement.Center){ + ) { + Column(verticalArrangement = Arrangement.Center) { DropdownMenuItem( onClick = { // TODO 수정 @@ -161,7 +160,7 @@ fun GetGroupScreen( modifier = Modifier .width(100.dp) .height(40.dp) - ){ + ) { Box( modifier = Modifier .padding( @@ -169,7 +168,7 @@ fun GetGroupScreen( horizontal = Space12 ) .fillMaxWidth() - ){ + ) { Text( text = "수정", style = Body0.merge( @@ -194,14 +193,14 @@ fun GetGroupScreen( modifier = Modifier .width(100.dp) .height(40.dp) - ){ + ) { Box( modifier = Modifier .padding( vertical = Space8, horizontal = Space12 ) - ){ + ) { Text( text = "삭제", style = Body0.merge( diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupViewModel.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupViewModel.kt index 7f298acc..b250767f 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupViewModel.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupViewModel.kt @@ -1,18 +1,12 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get import ac.dnd.bookkeeping.android.domain.model.error.ServerException -import ac.dnd.bookkeeping.android.domain.usecase.feature.group.AddGroupUseCase import ac.dnd.bookkeeping.android.domain.usecase.feature.group.DeleteGroupUseCase -import ac.dnd.bookkeeping.android.domain.usecase.feature.group.EditGroupUseCase -import ac.dnd.bookkeeping.android.domain.usecase.feature.group.GetGroupListUseCase import ac.dnd.bookkeeping.android.presentation.common.base.BaseViewModel 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.common.group.add.AddGroupEvent -import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add.AddGroupIntent -import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.add.AddGroupState import androidx.lifecycle.SavedStateHandle import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow @@ -39,8 +33,8 @@ class GetGroupViewModel @Inject constructor( } private fun deleteGroup( - id : Long - ){ + id: Long + ) { launch { _state.value = GetGroupState.Loading deleteGroupUseCase( From 2739369ffa895d34838dad522dcb8567df2859cd Mon Sep 17 00:00:00 2001 From: jinuemong Date: Tue, 6 Feb 2024 00:46:37 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[Feat]:=201=EC=B0=A8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/common/group/get/GetGroupScreen.kt | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt index dcb236e3..f19c98a5 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/common/group/get/GetGroupScreen.kt @@ -16,12 +16,15 @@ import ac.dnd.bookkeeping.android.presentation.common.theme.Space12 import ac.dnd.bookkeeping.android.presentation.common.theme.Space16 import ac.dnd.bookkeeping.android.presentation.common.theme.Space20 import ac.dnd.bookkeeping.android.presentation.common.theme.Space8 +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.view.BottomSheetScreen +import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.group.get.type.DefaultGroupType +import ac.dnd.bookkeeping.android.presentation.ui.main.rememberApplicationState import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -54,18 +57,50 @@ 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 com.holix.android.bottomsheetdialog.compose.BottomSheetBehaviorProperties import com.holix.android.bottomsheetdialog.compose.BottomSheetDialogProperties import kotlinx.coroutines.CoroutineExceptionHandler @Composable fun GetGroupScreen( + appState: ApplicationState, + groups: List, + onDismissRequest: () -> Unit, + onResult: (Group) -> Unit, + viewModel: GetGroupViewModel = hiltViewModel() +){ + val model : GetGroupModel = Unit.let { + val state by viewModel.state.collectAsStateWithLifecycle() + + GetGroupModel( + state = state, + groups = groups + ) + } + ErrorObserver(viewModel) + + GetGroupScreen( + appState = appState, + onDismissRequest = onDismissRequest, + onResult = onResult, + model = model, + intent = viewModel::onIntent, + event = viewModel.event, + handler = viewModel.handler, + ) +} + +@Composable +private fun GetGroupScreen( + appState: ApplicationState, onDismissRequest: () -> Unit, onResult: (Group) -> Unit, model: GetGroupModel, - handler: CoroutineExceptionHandler, intent: (GetGroupIntent) -> Unit, - event: EventFlow + event: EventFlow, + handler: CoroutineExceptionHandler ) { BottomSheetScreen( @@ -264,8 +299,10 @@ fun GetGroupScreen( @Preview(apiLevel = 33) @Composable -fun GetGroupScreenPreivew() { +private fun GetGroupScreenPreivew() { GetGroupScreen( + appState = rememberApplicationState(), + onDismissRequest = {}, event = MutableEventFlow(), intent = {},