-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #513 from mash-up-kr/feature/schedule_daily
전체 일정 탭 화면 만들기
- Loading branch information
Showing
7 changed files
with
327 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
app/src/main/java/com/mashup/ui/schedule/component/DailySchedule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.mashup.ui.schedule.component | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Column | ||
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.size | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
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.res.painterResource | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import com.mashup.core.ui.colors.Gray50 | ||
import com.mashup.core.ui.colors.Gray600 | ||
import com.mashup.core.ui.typography.Body5 | ||
import com.mashup.ui.schedule.ScheduleState | ||
import com.mashup.ui.schedule.daily.DailyScheduleByMonth | ||
import com.mashup.core.common.R as CR | ||
|
||
@Composable | ||
fun DailySchedule( | ||
scheduleState: ScheduleState, | ||
modifier: Modifier = Modifier, | ||
onClickScheduleInformation: (Int) -> Unit = {} | ||
) { | ||
var cacheScheduleState by remember { | ||
mutableStateOf(scheduleState) | ||
} | ||
|
||
LaunchedEffect(scheduleState) { | ||
if (scheduleState is ScheduleState.Success) { | ||
cacheScheduleState = scheduleState | ||
} | ||
} | ||
|
||
(cacheScheduleState as? ScheduleState.Success)?.let { state -> | ||
if (state.monthlyScheduleList.isEmpty()) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth(), | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Spacer(modifier = Modifier.height(200.dp)) | ||
Image( | ||
painter = painterResource(id = CR.drawable.img_placeholder_sleeping), | ||
contentDescription = null, | ||
modifier = Modifier.size(88.dp) | ||
) | ||
Spacer(modifier = Modifier.height(12.dp)) | ||
Text( | ||
text = "열심히 일정을 준비하고 있어요\n조금만 기다려 주세요!", | ||
style = Body5.copy(color = Gray600), | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
} else { | ||
Spacer(modifier = Modifier.height(22.dp)) | ||
state.monthlyScheduleList.forEach { (title, scheduleList) -> | ||
DailyScheduleByMonth( | ||
title = title, | ||
scheduleList = scheduleList, | ||
modifier = Modifier | ||
.background(Gray50) | ||
.padding(horizontal = 20.dp), | ||
isWeeklySchedule = { scheduleId -> | ||
state.weeklySchedule.any { scheduleId == it.getScheduleId() } | ||
}, | ||
onClickScheduleInformation = onClickScheduleInformation | ||
) | ||
} | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
app/src/main/java/com/mashup/ui/schedule/daily/DailyScheduleByMonth.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.mashup.ui.schedule.daily | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.mashup.core.common.extensions.day | ||
import com.mashup.core.common.extensions.week | ||
import com.mashup.core.ui.colors.Gray500 | ||
import com.mashup.core.ui.theme.MashUpTheme | ||
import com.mashup.core.ui.typography.Body3 | ||
import com.mashup.core.ui.typography.Caption2 | ||
import com.mashup.core.ui.typography.Title3 | ||
import com.mashup.data.dto.ScheduleResponse | ||
|
||
/** | ||
* DailyScheduleByMonth.kt | ||
* | ||
* Created by Minji Jeong on 2024/06/29 | ||
* Copyright © 2024 MashUp All rights reserved. | ||
*/ | ||
|
||
@Composable | ||
fun DailyScheduleByMonth( | ||
title: String, | ||
scheduleList: List<ScheduleResponse>, | ||
modifier: Modifier = Modifier, | ||
isWeeklySchedule: (Int) -> Boolean = { false }, | ||
onClickScheduleInformation: (Int) -> Unit = {} | ||
) { | ||
Column(modifier = modifier) { | ||
Text(title, style = Title3) | ||
Spacer(modifier = Modifier.height(18.dp)) | ||
scheduleList | ||
.groupBy { it.startedAt.day() } | ||
.forEach { (_, dailySchedule) -> | ||
DailyScheduleByDay(dailySchedule, isWeeklySchedule, onClickScheduleInformation) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun DailyScheduleByDay( | ||
schedule: List<ScheduleResponse>, | ||
isWeeklySchedule: (Int) -> Boolean, | ||
onClickScheduleInformation: (Int) -> Unit | ||
) { | ||
Row(modifier = Modifier.padding(bottom = 32.dp)) { | ||
Column( | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
modifier = Modifier.padding(top = 14.dp, end = 14.dp) | ||
) { | ||
Text(text = "${schedule[0].startedAt.day()}", style = Body3) | ||
Text(text = schedule[0].startedAt.week(), style = Caption2.copy(color = Gray500)) | ||
} | ||
|
||
Column { | ||
schedule.forEach { | ||
val highlight = isWeeklySchedule.invoke(it.scheduleId) | ||
DailyScheduleItem( | ||
title = it.name, | ||
time = it.getTimeLine(), | ||
place = it.location?.detailAddress ?: "-", | ||
highlight = highlight, | ||
modifier = Modifier.padding(bottom = 12.dp), | ||
onClickScheduleInformation = { onClickScheduleInformation.invoke(it.scheduleId) } | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewDailySchedule() { | ||
MashUpTheme { | ||
DailyScheduleByMonth("2024년 8월", emptyList()) | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
app/src/main/java/com/mashup/ui/schedule/daily/DailyScheduleItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.mashup.ui.schedule.daily | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Column | ||
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.shape.RoundedCornerShape | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Brush | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.mashup.core.ui.colors.Brand500 | ||
import com.mashup.core.ui.colors.Gray100 | ||
import com.mashup.core.ui.colors.White | ||
import com.mashup.core.ui.theme.MashUpTheme | ||
import com.mashup.core.ui.typography.SubTitle1 | ||
import com.mashup.ui.schedule.detail.composable.ScheduleInfoText | ||
import com.mashup.core.common.R as CR | ||
|
||
/** | ||
* TotalScheduleItem.kt | ||
* | ||
* Created by Minji Jeong on 2024/06/29 | ||
* Copyright © 2024 MashUp All rights reserved. | ||
*/ | ||
|
||
@Composable | ||
fun DailyScheduleItem( | ||
title: String, | ||
time: String, | ||
place: String, | ||
highlight: Boolean, | ||
modifier: Modifier = Modifier, | ||
onClickScheduleInformation: () -> Unit = {} | ||
) { | ||
val borderColor = if (highlight) { | ||
listOf(Brand500, Color(0xFF31C1FF)) | ||
} else { | ||
listOf(Gray100, Gray100) | ||
} | ||
|
||
Column( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.clip(RoundedCornerShape(16.dp)) | ||
.clickable { onClickScheduleInformation() } | ||
.background(White) | ||
.border( | ||
width = if (highlight) (1.5).dp else 1.dp, | ||
brush = Brush.horizontalGradient(borderColor), | ||
shape = RoundedCornerShape(16.dp) | ||
) | ||
.padding(horizontal = 20.dp, vertical = 16.dp) | ||
) { | ||
Text(text = title, style = SubTitle1) | ||
Spacer(modifier = Modifier.height(4.dp)) | ||
ScheduleInfoText(iconRes = CR.drawable.ic_clock, info = time) | ||
Spacer(modifier = Modifier.height(4.dp)) | ||
ScheduleInfoText(iconRes = CR.drawable.ic_mappin, info = place) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewDailyScheduleItemHighlight() { | ||
MashUpTheme { | ||
DailyScheduleItem( | ||
"안드로이드 팀 세미나", | ||
"오후 3:00 - 오전 7:00", | ||
"디스코드", | ||
true | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun PreviewDailyScheduleItem() { | ||
MashUpTheme { | ||
DailyScheduleItem( | ||
"안드로이드 팀 세미나", | ||
"오후 3:00 - 오전 7:00", | ||
"디스코드", | ||
false | ||
) | ||
} | ||
} |
Oops, something went wrong.