Skip to content

Commit

Permalink
[Feat]: History 구체화 & 디자인 검수 (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinuemong authored Feb 19, 2024
1 parent cce3c29 commit 271d905
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fun HistoryBackgroundComponent(
model: HistoryModel,
searchText: String,
isTextFieldFocused: Boolean,
isViewUnrecordedState: Boolean,
onFocusChange: (Boolean) -> Unit,
alarmState: Boolean = true,
onClickUnrecorded: () -> Unit,
Expand Down Expand Up @@ -168,7 +169,7 @@ fun HistoryBackgroundComponent(
)
}
Spacer(modifier = Modifier.height(32.dp))
if (model.unrecordedSchedule.isNotEmpty()) {
if (model.unrecordedSchedule.isNotEmpty() && isViewUnrecordedState) {
Card(shape = RoundedCornerShape(16.dp)) {
Box(
modifier = Modifier
Expand Down Expand Up @@ -304,6 +305,7 @@ private fun HistoryBackgroundComponent1Preview() {
onClickUnrecorded = {},
onDeleteUnrecorded = {},
isTextFieldFocused = true,
isViewUnrecordedState = true,
onFocusChange = {},
)
}
Expand Down Expand Up @@ -356,6 +358,7 @@ private fun HistoryBackgroundComponent2Preview() {
onClickUnrecorded = {},
onDeleteUnrecorded = {},
isTextFieldFocused = true,
isViewUnrecordedState = true,
onFocusChange = {},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState
import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.detail.growth.historyDetailGrowthDestination
import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.detail.historyDetailDestination
import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.registration.historyRegistrationDestination
import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.unrecorded.historyUnrecordedDestination
import androidx.navigation.NavGraphBuilder

fun NavGraphBuilder.historyDestination(
Expand All @@ -12,4 +13,5 @@ fun NavGraphBuilder.historyDestination(
historyDetailDestination(appState)
historyRegistrationDestination(appState)
historyDetailGrowthDestination(appState)
historyUnrecordedDestination(appState)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import ac.dnd.bookkeeping.android.presentation.model.history.HistoryViewType
import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState
import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.RelationConstant
import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.registration.HistoryRegistrationConstant
import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.unrecorded.HistoryUnrecordedConstant
import ac.dnd.bookkeeping.android.presentation.ui.main.rememberApplicationState
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateDpAsState
Expand Down Expand Up @@ -94,6 +95,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.Velocity
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.PopupProperties
import androidx.constraintlayout.compose.ConstraintSet
import androidx.constraintlayout.compose.Dimension
import androidx.constraintlayout.compose.ExperimentalMotionApi
Expand Down Expand Up @@ -146,7 +148,9 @@ private fun HistoryScreen(
handler: CoroutineExceptionHandler
) {
val focusManager = LocalFocusManager.current
val contentHeight = (if (model.unrecordedSchedule.isEmpty()) 257.dp else 343.dp)
var isViewUnrecordedState by remember { mutableStateOf(true) }
val contentHeight =
(if (model.unrecordedSchedule.isNotEmpty() && isViewUnrecordedState) 343.dp else 257.dp)
val swipeState = rememberSwipeableState(initialValue = HistoryViewSwipingType.COLLAPSED)
val nestedScrollConnection = remember {
object : NestedScrollConnection {
Expand Down Expand Up @@ -203,6 +207,19 @@ private fun HistoryScreen(
var searchText by remember { mutableStateOf("") }
var isTextFieldFocused by remember { mutableStateOf(false) }


fun navigateToUnrecorded() {
appState.navController.navigate(HistoryUnrecordedConstant.ROUTE)
}

fun navigateToAddRelation() {
appState.navController.navigate(RelationConstant.ROUTE)
}

fun navigateToAddHeart() {
appState.navController.navigate(HistoryRegistrationConstant.ROUTE)
}

BoxWithConstraints(
modifier = Modifier
.fillMaxSize()
Expand Down Expand Up @@ -233,6 +250,7 @@ private fun HistoryScreen(

},
isTextFieldFocused = isTextFieldFocused,
isViewUnrecordedState = isViewUnrecordedState,
onFocusChange = {
isTextFieldFocused = it
},
Expand All @@ -241,10 +259,11 @@ private fun HistoryScreen(
searchText = it
},
onClickUnrecorded = {
//TODO go Unrecorded
navigateToUnrecorded()
},
onDeleteUnrecorded = {
//TODO delete Unrecorded
isViewUnrecordedState = false
//TODO delete Unrecorded (api)
}
)
MotionLayout(
Expand Down Expand Up @@ -493,7 +512,7 @@ private fun HistoryScreen(
onClick = {
if (isNotEmptyRelation) {
isDropDownMenuExpanded = false
appState.navController.navigate(HistoryRegistrationConstant.ROUTE)
navigateToAddHeart()
}
},
modifier = Modifier.height(48.dp)
Expand Down Expand Up @@ -528,27 +547,28 @@ private fun HistoryScreen(
.border(
width = 1.dp,
shape = RoundedCornerShape(100.dp),
color = if (isNotEmptyRelation) Gray300 else Gray500
color = Gray300
)
.background(
color = if (isNotEmptyRelation) Gray000 else Gray500,
color = Gray000,
shape = RoundedCornerShape(100.dp)
)
.width(120.dp)
.height(48.dp),
onDismissRequest = {
isDropDownMenuExpanded = false
},
properties = PopupProperties(
dismissOnClickOutside = false
),
offset = DpOffset(y = 16.dp, x = 0.dp),
expanded = isDropDownMenuExpanded
) {
DropdownMenuItem(
contentPadding = PaddingValues(bottom = 12.dp),
onClick = {
if (isNotEmptyRelation) {
isDropDownMenuExpanded = false
appState.navController.navigate(RelationConstant.ROUTE)
}
isDropDownMenuExpanded = false
navigateToAddRelation()
},
modifier = Modifier.height(48.dp)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class HistoryViewModel @Inject constructor(
_state.value = HistoryState.Loading
zip(
{ getGroupHeartHistoryUseCase() },
{ getUnrecordedScheduleListUseCase("") } //TODO name param ?
{ getUnrecordedScheduleListUseCase("") }
).onSuccess { (groups, unrecordedSchedule) ->
_state.value = HistoryState.Init
_groups.value = groups
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.detail
import ac.dnd.bookkeeping.android.domain.model.feature.heart.RelatedHeart
import ac.dnd.bookkeeping.android.domain.model.feature.relation.RelationDetailGroup
import ac.dnd.bookkeeping.android.domain.model.feature.relation.RelationDetailWithUserInfo
import ac.dnd.bookkeeping.android.presentation.R
import ac.dnd.bookkeeping.android.presentation.common.theme.Gray000
import ac.dnd.bookkeeping.android.presentation.common.theme.Gray200
import ac.dnd.bookkeeping.android.presentation.common.theme.Gray500
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.Headline3
import ac.dnd.bookkeeping.android.presentation.common.util.LaunchedEffectWithLifecycle
import ac.dnd.bookkeeping.android.presentation.common.util.coroutine.event.EventFlow
Expand All @@ -23,6 +25,7 @@ import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState
import ac.dnd.bookkeeping.android.presentation.ui.main.home.common.relation.RelationConstant
import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.detail.growth.HistoryDetailGrowthConstant
import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.detail.information.HistoryDetailInformationScreen
import ac.dnd.bookkeeping.android.presentation.ui.main.home.history.registration.HistoryRegistrationConstant
import ac.dnd.bookkeeping.android.presentation.ui.main.rememberApplicationState
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
Expand All @@ -34,11 +37,14 @@ 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.layout.size
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.FloatingActionButton
import androidx.compose.material.FractionalThreshold
import androidx.compose.material.Icon
import androidx.compose.material.Tab
import androidx.compose.material.TabRow
import androidx.compose.material.Text
Expand All @@ -51,6 +57,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
Expand All @@ -59,6 +66,7 @@ import androidx.compose.ui.input.nestedscroll.NestedScrollSource
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.layout.layoutId
import androidx.compose.ui.platform.LocalDensity
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.Velocity
Expand Down Expand Up @@ -146,6 +154,10 @@ fun HistoryDetailScreen(
appState.navController.navigate(route)
}

fun navigateToAddHeart() {
appState.navController.navigate(HistoryRegistrationConstant.ROUTE)
}

BoxWithConstraints(
modifier = Modifier
.fillMaxSize()
Expand Down Expand Up @@ -305,6 +317,24 @@ fun HistoryDetailScreen(
}
}
}

FloatingActionButton(
modifier = Modifier
.padding(bottom = 24.dp, end = 20.dp)
.size(52.dp)
.align(Alignment.BottomEnd),
backgroundColor = Gray800,
onClick = {
navigateToAddHeart()
}
) {
Icon(
modifier = Modifier.size(32.dp),
painter = painterResource(id = R.drawable.ic_plus),
contentDescription = null,
tint = Gray000
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import ac.dnd.bookkeeping.android.presentation.ui.main.ApplicationState
import ac.dnd.bookkeeping.android.presentation.ui.main.common.event.EventTypeScreen
import ac.dnd.bookkeeping.android.presentation.ui.main.rememberApplicationState
import android.annotation.SuppressLint
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
Expand Down Expand Up @@ -146,6 +147,7 @@ private fun HistoryDetailEditScreen(
val tagIdList =
remember { HistoryTagType.getTagIdList(model.relatedHeart.tags).toMutableStateList() }

var isEditMode by remember { mutableStateOf(false) }
var isEventSelected by remember { mutableStateOf(false) }
var isEventFocused by remember { mutableStateOf(false) }
var isEventTyping by remember { mutableStateOf(false) }
Expand All @@ -155,6 +157,17 @@ private fun HistoryDetailEditScreen(
var isShowingDeleteDialog by remember { mutableStateOf(false) }
var isShowingSuccessEditSnackBar by remember { mutableStateOf(false) }

BackHandler(
enabled = true,
onBack = {
if (isEditMode) {
isShowingOutPageDialog = true
} else {
onDismissRequest()
}
}
)

fun delete(event: HistoryDetailEditEvent.DeleteRelatedHeart) {
when (event) {
is HistoryDetailEditEvent.DeleteRelatedHeart.Success -> {
Expand Down Expand Up @@ -212,7 +225,11 @@ private fun HistoryDetailEditScreen(
modifier = Modifier
.align(Alignment.CenterEnd)
.clickable {
isShowingOutPageDialog = true
if (isEditMode) {
isShowingOutPageDialog = true
} else {
onDismissRequest()
}
}
)
}
Expand All @@ -229,6 +246,7 @@ private fun HistoryDetailEditScreen(
textValue = moneyText,
onValueChange = {
moneyText = it
isEditMode = true
},
isAddFiledEnabled = false,
)
Expand All @@ -241,6 +259,7 @@ private fun HistoryDetailEditScreen(
text = listOf(selectedYear, selectedMonth, selectedDay).joinToString(" / "),
onClick = {
isCalendarSelected = true
isEditMode = true
}
)
Spacer(modifier = Modifier.height(Space24))
Expand All @@ -251,6 +270,7 @@ private fun HistoryDetailEditScreen(
text = eventText,
onValueChange = {
eventText = it
isEditMode = true
},
textType = TypingTextFieldType.Basic,
onTextFieldFocusChange = {
Expand Down Expand Up @@ -295,6 +315,7 @@ private fun HistoryDetailEditScreen(
text = memoText,
onValueChange = {
memoText = it
isEditMode = true
},
contentPadding = PaddingValues(
vertical = 15.dp,
Expand Down Expand Up @@ -344,6 +365,7 @@ private fun HistoryDetailEditScreen(
currentSelectedId = tagIdList.toSet(),
chipId = type.id,
onSelectChip = { selectId ->
isEditMode = true
if (tagIdList.contains(selectId)) {
tagIdList.remove(selectId)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,20 @@ private fun HistoryDetailInformationScreen(
.size(80.dp)
.background(color = Gray200)
) {
AsyncImage(
model = model.relationDetail.imageUrl,
contentDescription = null,
contentScale = ContentScale.Crop
)
if (model.relationDetail.imageUrl.isEmpty()) {
Image(
painter = painterResource(R.drawable.ic_default_user_image),
modifier = Modifier.size(80.dp),
contentDescription = null
)
} else {
AsyncImage(
model = model.relationDetail.imageUrl,
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.size(80.dp),
)
}
}
Spacer(modifier = Modifier.height(7.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable


fun NavGraphBuilder.historyRegistrationDestination(
appState: ApplicationState
) {
Expand Down
Loading

0 comments on commit 271d905

Please sign in to comment.