Skip to content

Commit

Permalink
#67 feat : daily 존재에 따른 달력 ui 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
koreatlwls committed Feb 24, 2024
1 parent 6716021 commit abeb0cc
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ data class HomeUiState(

data class DailyUiState(
val currentDate: LocalDate = LocalDate.now(),
val hasDaily: List<LocalDate> = emptyList(),
val hasDailies: List<LocalDate> = emptyList(),
val dailyGraphData: DailyGraphData = DailyGraphData(),
)

Expand All @@ -101,7 +101,7 @@ data class DailyGraphData(

data class WeekUiState(
val currentDate: LocalDate = LocalDate.now(),
val hasDaily: List<LocalDate> = emptyList(),
val hasDailies: List<LocalDate> = emptyList(),
val weekGraphData: WeekGraphData = WeekGraphData(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ fun DailyScreen(
currentDate: LocalDate,
totalTime: String,
maxTime: String,
hasDailies: List<LocalDate>,
taskData: List<TdsTaskData>,
tdsColors: List<TdsColor>,
timeLines: List<Long>,
Expand All @@ -93,6 +94,7 @@ fun DailyScreen(
modifier = Modifier.fillMaxWidth(),
themeColor = tdsColors.first(),
currentDate = currentDate,
hasDailies = hasDailies,
onClickDate = onClickDate,
onCalendarLocalDateChanged = onCalendarLocalDateChanged,
)
Expand Down Expand Up @@ -127,6 +129,7 @@ fun CalendarContent(
modifier: Modifier = Modifier,
themeColor: TdsColor,
currentDate: LocalDate,
hasDailies: List<LocalDate>,
onClickDate: (LocalDate) -> Unit,
onCalendarLocalDateChanged: (LocalDate) -> Unit,
) {
Expand Down Expand Up @@ -221,6 +224,7 @@ fun CalendarContent(
Day(
day = day,
isSelected = currentDate == day.date,
hasDaily = hasDailies.contains(day.date),
themeColor = themeColor,
) { selectedDay ->
if (currentDate != selectedDay.date) {
Expand Down Expand Up @@ -255,36 +259,58 @@ fun CalendarContent(
fun Day(
day: CalendarDay,
isSelected: Boolean,
hasDaily: Boolean,
themeColor: TdsColor,
onClickDate: (CalendarDay) -> Unit,
) {
Box(
modifier = Modifier
.padding(horizontal = 5.dp)
.aspectRatio(1f)
.clip(CircleShape)
.background(
color = if (isSelected) {
themeColor.getColor()
} else {
Color.Transparent
},
)
.clickable(
enabled = day.position == DayPosition.MonthDate,
onClick = { onClickDate(day) },
),
contentAlignment = Alignment.Center,
) {
Text(
text = day.date.dayOfMonth.toString(),
color = if (day.position == DayPosition.MonthDate) {
TdsColor.TEXT.getColor()
} else {
Color.Gray
},
style = TdsTextStyle.SEMI_BOLD_TEXT_STYLE.getTextStyle(fontSize = 18.sp),
)
Box(
modifier = Modifier
.fillMaxSize(0.75f)
.clip(CircleShape)
.background(
color = if (isSelected) {
themeColor.getColor()
} else {
Color.Transparent
},
).align(Alignment.Center),
contentAlignment = Alignment.Center,
) {
Text(
text = day.date.dayOfMonth.toString(),
color = if (day.position == DayPosition.MonthDate) {
TdsColor.TEXT.getColor()
} else {
Color.Gray
},
style = TdsTextStyle.SEMI_BOLD_TEXT_STYLE.getTextStyle(fontSize = 18.sp),
)
}

if (hasDaily) {
Box(
modifier = Modifier
.size(3.dp)
.clip(CircleShape)
.background(
color = if (isSelected) {
themeColor.getColor()
} else {
Color.Red
},
)
.align(Alignment.BottomCenter),
)
}
}
}

Expand Down Expand Up @@ -511,6 +537,7 @@ private fun DailyScreenPreview() {
tdsColors = tdsColors,
totalTime = "08:00:00",
maxTime = "03:00:00",
hasDailies = emptyList(),
timeLines = timeLines,
timeTableData = timeTableData,
currentDate = LocalDate.now(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fun LogScreen(viewModel: LogViewModel = mavericksViewModel()) {

1 -> DailyScreen(
currentDate = uiState.dailyUiState.currentDate,
hasDailies = uiState.dailyUiState.hasDailies,
totalTime = uiState.dailyUiState.dailyGraphData.totalTime,
maxTime = uiState.dailyUiState.dailyGraphData.maxTime,
taskData = uiState.dailyUiState.dailyGraphData.taskData,
Expand All @@ -111,6 +112,7 @@ fun LogScreen(viewModel: LogViewModel = mavericksViewModel()) {

2 -> WeekScreen(
weekInformation = uiState.weekUiState.weekGraphData.weekInformation,
hasDailies = uiState.weekUiState.hasDailies,
totalTime = uiState.weekUiState.weekGraphData.totalWeekTime,
averageTime = uiState.weekUiState.weekGraphData.averageWeekTime,
weekLineChardData = uiState.weekUiState.weekGraphData.weekLineChartData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,21 @@ class LogViewModel @AssistedInject constructor(
val state = awaitState()
if (
state.weekUiState.currentDate.month == date.month &&
state.weekUiState.hasDaily.isNotEmpty()
state.weekUiState.hasDailies.isNotEmpty()
) {
setState {
copy(
dailyUiState = dailyUiState.copy(
hasDaily = state.weekUiState.hasDaily,
hasDailies = state.weekUiState.hasDailies,
),
)
}
} else {
val hasDaily = hasDailyForCurrentMonthUseCase(date)
val hasDailies = hasDailyForCurrentMonthUseCase(date)
setState {
copy(
dailyUiState = dailyUiState.copy(
hasDaily = hasDaily,
hasDailies = hasDailies,
),
)
}
Expand Down Expand Up @@ -170,21 +170,21 @@ class LogViewModel @AssistedInject constructor(
val state = awaitState()
if (
state.dailyUiState.currentDate.month == date.month &&
state.dailyUiState.hasDaily.isNotEmpty()
state.dailyUiState.hasDailies.isNotEmpty()
) {
setState {
copy(
weekUiState = weekUiState.copy(
hasDaily = state.dailyUiState.hasDaily,
hasDailies = state.dailyUiState.hasDailies,
),
)
}
} else {
val hasDaily = hasDailyForCurrentMonthUseCase(date)
val hasDailies = hasDailyForCurrentMonthUseCase(date)
setState {
copy(
weekUiState = weekUiState.copy(
hasDaily = hasDaily,
hasDailies = hasDailies,
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import java.time.LocalDate
fun WeekScreen(
totalTime: String,
averageTime: String,
hasDailies: List<LocalDate>,
weekLineChardData: List<TdsWeekLineChartData>,
weekInformation: Triple<String, String, String>,
tdsColors: List<TdsColor>,
Expand All @@ -45,6 +46,7 @@ fun WeekScreen(
modifier = Modifier.fillMaxWidth(),
themeColor = tdsColors.first(),
currentDate = currentDate,
hasDailies = hasDailies,
onClickDate = onClickDate,
onCalendarLocalDateChanged = onCalendarLocalDateChanged,
)
Expand Down Expand Up @@ -153,6 +155,7 @@ private fun WeekScreenPreview() {
averageTime = "03:00:00",
weekLineChardData = weekLineChardData,
tdsColors = tdsColors,
hasDailies = emptyList(),
topLevelTaskData = taskData,
topLevelTaskTotal = "08:00:00",
currentDate = LocalDate.now(),
Expand Down

0 comments on commit abeb0cc

Please sign in to comment.