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

Expanded Lunch Field (Grid) #712

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ sealed interface RoomTheme {
override val dimColor = Color(0xFF121E25)
}

data object Lunch : RoomTheme {
override val primaryColor = Color(0xFFC1C8C9)
override val containerColor = Color(0xFFC1C8C9).copy(alpha = 0.1f)
override val dimColor = Color(0xFF121E25)
}

val primaryColor: Color
val containerColor: Color
val dimColor: Color
Expand All @@ -49,6 +55,7 @@ sealed interface RoomTheme {
"giraffe" -> Giraffe
"flamingo" -> Flamingo
"jellyfish" -> Jellyfish
"lunch" -> Lunch
else -> null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public sealed class TimetableItem {
"https://2024.droidkaigi.jp/en/timetable/${id.value}"
}

public val isLunch: Boolean get() = startsTimeString.startsWith("13:00") && title.enTitle.lowercase().contains("lunch")

fun getSupportedLangString(isJapaneseLocale: Boolean): String {
val japanese = if (isJapaneseLocale) "日本語" else "Japanese"
val english = if (isJapaneseLocale) "英語" else "English"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fun TimetableGridItem(
derivedStateOf { (height - TimetableGridItemSizes.padding * 2) / 4 > titleMinHeightDp * 3 / 2 }
}

ProvideRoomTheme(timetableItem.room.getThemeKey()) {
Copy link
Member

Choose a reason for hiding this comment

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

Our formatter says this. Could you check it out?

/home/runner/work/conference-app-2024/conference-app-2024/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableGridItem.kt:109:22: Extra braces exist on this branch, remove them. [BracesOnIfStatements]
/home/runner/work/conference-app-2024/conference-app-2024/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableGridItem.kt:109:61: Extra braces exist on this branch, remove them. [BracesOnIfStatements]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Weird. I ran the format fixer....

I will try to fix this.

ProvideRoomTheme(if (timetableItem.isLunch) "lunch" else timetableItem.room.getThemeKey()) {
Copy link
Member

Choose a reason for hiding this comment

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

How about passing isLunch to getThemeKey()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

val titleTextStyle = MaterialTheme.typography.labelLarge.let {
check(it.fontSize.isSp)
val (titleFontSize, titleLineHeight) = calculateFontSizeAndLineHeight(
Expand Down Expand Up @@ -161,13 +161,15 @@ fun TimetableGridItem(
modifier = Modifier
.weight(1f, fill = false),
) {
Icon(
modifier = Modifier.height(TimetableGridItemSizes.scheduleHeight),
imageVector = vectorResource(checkNotNull(timetableItem.room.icon)),
contentDescription = timetableItem.room.name.currentLangTitle,
tint = LocalRoomTheme.current.primaryColor,
)
Spacer(modifier = Modifier.width(4.dp))
if (!timetableItem.isLunch) {
Icon(
modifier = Modifier.height(TimetableGridItemSizes.scheduleHeight),
imageVector = vectorResource(checkNotNull(timetableItem.room.icon)),
contentDescription = timetableItem.room.name.currentLangTitle,
tint = LocalRoomTheme.current.primaryColor,
)
Spacer(modifier = Modifier.width(4.dp))
}
var scheduleTextStyle = MaterialTheme.typography.labelSmall
if (titleTextStyle.fontSize < scheduleTextStyle.fontSize) {
scheduleTextStyle =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,25 @@ private data class TimetableItemLayout(
private val displayEndsAt = timetableItem.endsAt.minus(1, DateTimeUnit.MINUTE)
val height =
((displayEndsAt - timetableItem.startsAt).inWholeMinutes * minutePx).roundToInt()
val width = with(density) { TimetableSizes.columnWidth.roundToPx() }
val left = rooms.indexOf(timetableItem.room) * width
val top = ((timetableItem.startsAt - dayStart).inWholeMinutes * minutePx).toInt()
val right = left + width
val bottom = top + height

val width: Int
val left: Int
val right: Int

init {
if (timetableItem.isLunch) {
width = with(density) { TimetableSizes.columnWidth.roundToPx() * 5 }
left = 0 // rooms.indexOf(RoomType.RoomF) * width //.indexOf(timetableItem.room) * width
right = left + width
} else {
width = with(density) { TimetableSizes.columnWidth.roundToPx() }
left = rooms.indexOf(timetableItem.room) * width
right = left + width
}
}

fun isVisible(
screenWidth: Int,
screenHeight: Int,
Expand Down
Loading