Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] HistoryDetail 내역 보기 & 수정 구현 #57

Merged
merged 10 commits into from
Feb 6, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package ac.dnd.bookkeeping.android.presentation.common.util.expansion

import android.graphics.BlurMaskFilter
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Paint
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

fun Modifier.customOuterShadow(
color: Color,
offsetX: Dp = 0.dp,
offsetY: Dp = 0.dp,
blurRadius: Float,
) = then(
drawBehind {
drawIntoCanvas { canvas ->
val paint = Paint()
val frameworkPaint = paint.asFrameworkPaint()
if (blurRadius != 0f) {
frameworkPaint.maskFilter = (BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.NORMAL))
}
frameworkPaint.color = color.toArgb()

val leftPixel = offsetX.toPx()
val topPixel = offsetY.toPx()
val rightPixel = size.width + topPixel
val bottomPixel = size.height + leftPixel

canvas.drawRect(
left = leftPixel,
top = topPixel,
right = rightPixel,
bottom = bottomPixel,
paint = paint,
)
}
}
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package ac.dnd.bookkeeping.android.presentation.common.view

import ac.dnd.bookkeeping.android.presentation.common.theme.Gray000
import ac.dnd.bookkeeping.android.presentation.common.util.expansion.customOuterShadow
import ac.dnd.bookkeeping.android.presentation.common.view.confirm.ConfirmButton
import ac.dnd.bookkeeping.android.presentation.common.view.confirm.ConfirmButtonProperties
import ac.dnd.bookkeeping.android.presentation.common.view.confirm.ConfirmButtonSize
import ac.dnd.bookkeeping.android.presentation.common.view.confirm.ConfirmButtonType
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -20,6 +23,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -33,30 +37,40 @@ fun BottomSheetScreen(
properties: BottomSheetDialogProperties = BottomSheetDialogProperties(),
content: @Composable () -> Unit
) {

BottomSheetDialog(
onDismissRequest = onDismissRequest,
properties = properties
properties = properties,
) {
Surface(
color = Gray000,
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight(),
color = Color.White,
shape = RoundedCornerShape(
topStart = 12.dp,
topEnd = 12.dp
)
.clip(
RoundedCornerShape(
topStart = 12.dp,
topEnd = 12.dp
)
)
.padding(top = 0.68.dp)
.padding(horizontal = 0.68.dp)
.customOuterShadow(
color = Color(0x4D888888),
offsetX = 0.68.dp,
offsetY = 0.68.dp,
blurRadius = 6.8f
)
.wrapContentHeight()
) {
content()
}
}
}

@Preview
@Preview(apiLevel = 33)
@Composable
fun BottomSheetScreenPreview1() {
var isShowing by remember { mutableStateOf(true) }

if (isShowing) {
BottomSheetScreen(
onDismissRequest = { isShowing = false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ac.dnd.bookkeeping.android.presentation.common.theme.Primary4
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.Space40
import ac.dnd.bookkeeping.android.presentation.common.theme.Space48
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
Expand All @@ -25,6 +26,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

Expand Down Expand Up @@ -61,7 +63,10 @@ fun FieldSelectComponent(
color = Gray800,
fontWeight = FontWeight.Normal
),
modifier = Modifier.align(Alignment.CenterStart)
modifier = Modifier
.align(Alignment.CenterStart)
.padding(end = Space40),
overflow = TextOverflow.Ellipsis
)

Image(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ fun TypingPriceField(
hintText: String = "지출하신 금액을 입력해주세요",
isError: Boolean = false,
isEnabled: Boolean = true,
isAddFiledEnabled : Boolean = true ,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format

innerPadding: PaddingValues = PaddingValues(0.dp),
textFieldHeight: Dp = 35.dp,
keyboardOptions: KeyboardOptions = KeyboardOptions(keyboardType = KeyboardType.NumberPassword),
Expand Down Expand Up @@ -140,21 +141,24 @@ fun TypingPriceField(
contentPadding = innerPadding
)
}
Spacer(modifier = Modifier.height(12.dp))
Divider(
modifier = Modifier
.fillMaxWidth()
.height(1.dp),
color = currentColorState.value
)
Spacer(modifier = Modifier.height(6.dp))
PriceChipComponent(
scope = scope,
onClickChip = { addPrice ->
val newText = addPriceFormat(addPrice)
onValueChange(newText)
}
)
errorMessageContent()
if (isAddFiledEnabled || isTextFieldFocused) {
Spacer(modifier = Modifier.height(6.dp))
PriceChipComponent(
scope = scope,
onClickChip = { addPrice ->
val newText = addPriceFormat(addPrice)
onValueChange(newText)
}
)
errorMessageContent()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ac.dnd.bookkeeping.android.presentation.model.history

enum class HistoryRegistrationEventType(
enum class HistoryEventType(
val id: Long,
val eventName: String
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ac.dnd.bookkeeping.android.presentation.model.history

enum class HistoryRegistrationTagType(
enum class HistoryTagType(
val id: Long,
val tagName: String
) {
Expand All @@ -20,5 +20,13 @@ enum class HistoryRegistrationTagType(
it.tagName
}
}

fun getTagIdList(nameList: List<String>): List<Long>{
return entries.filter {
it.tagName in nameList
}.map {
it.id
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.common.calendar

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.Gray200
import ac.dnd.bookkeeping.android.presentation.common.theme.Gray600
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.theme.Primary1
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.model.history.HistoryEventType
import androidx.compose.animation.animateColorAsState
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.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableLongStateOf
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.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import com.holix.android.bottomsheetdialog.compose.BottomSheetBehaviorProperties
import com.holix.android.bottomsheetdialog.compose.BottomSheetDialog
import com.holix.android.bottomsheetdialog.compose.BottomSheetDialogProperties
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@Composable
fun EventTypeScreen(
onDismissRequest: () -> Unit,
onConfirm: (String) -> Unit
) {
var selectedEventId by remember { mutableLongStateOf(-1) }
val scope = rememberCoroutineScope()
BottomSheetDialog(
onDismissRequest = onDismissRequest,
properties = BottomSheetDialogProperties(
behaviorProperties = BottomSheetBehaviorProperties(
state = BottomSheetBehaviorProperties.State.Expanded,
skipCollapsed = true
)
)
) {
Column(
modifier = Modifier
.background(Gray000)
.fillMaxWidth()
.wrapContentHeight()
) {
Box(
modifier = Modifier
.background(Gray200)
.fillMaxWidth()
.padding(
horizontal = Space20,
vertical = Space12
)
) {
Text(
text = "경사 종류",
style = Headline3.merge(
color = Gray800,
fontWeight = FontWeight.SemiBold
),
modifier = Modifier.align(Alignment.CenterStart)
)
Text(
text = "완료",
style = Headline3.merge(
color = Gray600,
fontWeight = FontWeight.Normal
),
modifier = Modifier
.align(Alignment.CenterEnd)
.clickable {
if (selectedEventId!= -1L){
onConfirm(
HistoryEventType.getEventName(selectedEventId)
)
}
}
)
}
LazyColumn {
items(HistoryEventType.entries) { type ->
var clickState by remember { mutableStateOf(false) }
val backgroundColor = animateColorAsState(
targetValue =
if (clickState) Gray150 else if (selectedEventId == type.id) Primary1 else Gray000,
label = ""
)
Box(
modifier = Modifier
.background(backgroundColor.value)
.fillMaxWidth()
.clickable {
selectedEventId =
if (selectedEventId == type.id) -1 else type.id

scope.launch {
clickState = true
delay(100L)
clickState = false
}

}
.padding(
horizontal = Space20,
vertical = Space16
)
){
Text(
text = type.eventName,
style = Headline3.merge(
color = Gray800,
fontWeight = FontWeight.SemiBold
)
)
}
}

//TODO 직접 입력 케이스 추가
}
}
}
}

@Preview
@Composable
fun EventTypeScreenPreview(){
EventTypeScreen(
onDismissRequest = {

},
onConfirm = {

}
)
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
package ac.dnd.bookkeeping.android.presentation.ui.main.home.history.detail.edit

sealed interface HistoryDetailEditEvent
import ac.dnd.bookkeeping.android.domain.model.feature.heart.RelatedHeart

sealed interface HistoryDetailEditEvent {
sealed interface EditRelatedHeart : HistoryDetailEditEvent {
data class Success(val relatedHeart: RelatedHeart) : EditRelatedHeart
}

sealed interface DeleteRelatedHeart : HistoryDetailEditEvent {
data object Success : DeleteRelatedHeart
}
}
Loading
Loading