Skip to content

Commit

Permalink
chore: hide date selector when no schedules
Browse files Browse the repository at this point in the history
  • Loading branch information
mikucat0309 committed Mar 8, 2024
1 parent 705213e commit 81aac3d
Showing 1 changed file with 36 additions and 22 deletions.
58 changes: 36 additions & 22 deletions app/src/main/java/app/opass/ccip/view/ScheduleView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ private fun ScheduleScreen(sessions: ImmutableList<Session>, navigator: Destinat
topBar = {
TopAppBar(
navigationIcon = { BackIcon(navigator) },
title = { Text("議程") },
title = { Text("Schedule") },
colors = TopAppBarDefaults.topAppBarColors(containerColor = Theme.c.surfaceVariant),
)
},
) { pv ->
Column(Modifier.padding(pv)) {
DateTab(dates, selectedDate.value) { selectedDate.value = it }
HorizontalDivider()
if (sessions.isNotEmpty() && selectedDate.value != null) {
DateTab(dates, selectedDate.value) { selectedDate.value = it }
HorizontalDivider()
Sessions(groups[selectedDate.value]!!)
}
}
Expand All @@ -100,17 +100,20 @@ private fun ScheduleScreen(sessions: ImmutableList<Session>, navigator: Destinat

@Composable
private fun DateTab(
dates: ImmutableList<LocalDate>,
selectedDate: LocalDate?,
setSelectedDate: (LocalDate) -> Unit
dates: ImmutableList<LocalDate>,
selectedDate: LocalDate?,
setSelectedDate: (LocalDate) -> Unit
) {
Row(
Modifier.fillMaxWidth().height(56.dp).background(Theme.c.surfaceVariant),
Modifier
.fillMaxWidth()
.height(56.dp)
.background(Theme.c.surfaceVariant),
horizontalArrangement =
Arrangement.spacedBy(
32.dp,
alignment = Alignment.CenterHorizontally,
),
Arrangement.spacedBy(
32.dp,
alignment = Alignment.CenterHorizontally,
),
) {
for (date in dates) {
DateTabItem(date.dayOfMonth, date.dayOfWeek, date == selectedDate) { setSelectedDate(date) }
Expand All @@ -120,10 +123,10 @@ private fun DateTab(

@Composable
private fun DateTabItem(
day: Int,
dayOfWeek: DayOfWeek,
isSelected: Boolean = false,
onClick: () -> Unit = {}
day: Int,
dayOfWeek: DayOfWeek,
isSelected: Boolean = false,
onClick: () -> Unit = {}
) {
val textStyle =
if (isSelected) {
Expand All @@ -140,13 +143,18 @@ private fun DateTabItem(
)
}
Column(
Modifier.fillMaxHeight().width(32.dp).clickable { onClick() },
Modifier
.fillMaxHeight()
.width(32.dp)
.clickable { onClick() },
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(stringResource(WEEKDAY_LABELS[dayOfWeek]!!), style = textStyle)
Text(day.toString(), style = textStyle.copy(fontSize = 22.sp, fontWeight = FontWeight(700)))
Spacer(Modifier.weight(1.0f))
val m = Modifier.fillMaxWidth().height(3.dp)
val m = Modifier
.fillMaxWidth()
.height(3.dp)
Box(
if (isSelected) {
m.background(
Expand Down Expand Up @@ -184,7 +192,8 @@ private fun Sessions(sessions: ImmutableList<Session>) {
@Composable
private fun StartTimeTitle(start: LocalDateTime) {
Box(
Modifier.fillMaxWidth()
Modifier
.fillMaxWidth()
.background(Theme.c.surfaceVariant)
.padding(horizontal = 24.dp, vertical = 16.dp),
contentAlignment = Alignment.CenterStart,
Expand All @@ -201,7 +210,9 @@ private fun StartTimeTitle(start: LocalDateTime) {
@Composable
private fun SessionItem(session: Session) {
Row(
Modifier.fillMaxWidth().padding(horizontal = 24.dp, vertical = 16.dp),
Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp, vertical = 16.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(
Expand Down Expand Up @@ -245,7 +256,8 @@ private fun TimeRange(range: DateTimeRange) {
@Composable
private fun LocationTag(value: String) {
Box(
Modifier.background(Theme.c.primaryContainer, RoundedCornerShape(4.dp))
Modifier
.background(Theme.c.primaryContainer, RoundedCornerShape(4.dp))
.padding(horizontal = 6.dp),
contentAlignment = Alignment.Center,
) {
Expand All @@ -256,7 +268,8 @@ private fun LocationTag(value: String) {
@Composable
private fun SessionTypeTag(value: String) {
Box(
Modifier.background(Theme.c.surfaceVariant, RoundedCornerShape(4.dp))
Modifier
.background(Theme.c.surfaceVariant, RoundedCornerShape(4.dp))
.padding(horizontal = 6.dp),
contentAlignment = Alignment.Center,
) {
Expand All @@ -267,7 +280,8 @@ private fun SessionTypeTag(value: String) {
@Composable
private fun NormalTag(value: String) {
Box(
Modifier.border(
Modifier
.border(
width = 1.dp,
color = Theme.c.surfaceVariant,
shape = RoundedCornerShape(size = 4.dp),
Expand Down

0 comments on commit 81aac3d

Please sign in to comment.