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

Show event end time on schedule #7

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion core/src/main/java/com/advice/core/utils/TimeUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object TimeUtil {
val pattern = if (is24HourFormat) {
"HH:mm"
} else {
"h:mm a"
"hh:mm"
}

val timeFormat = DateTimeFormatter.ofPattern(pattern)
Expand Down
45 changes: 38 additions & 7 deletions ui/src/main/java/com/advice/ui/components/EventRowView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ fun EventRowView(
.fillMaxWidth()
) {
CategoryDash(tags)
Text(
time.replace(" ", "\n"),
textAlign = TextAlign.Center,
modifier = Modifier.width(85.dp)
)
Time(time)
Column(
Modifier
.weight(1f)
Expand Down Expand Up @@ -121,6 +117,30 @@ private fun CategoryDash(tags: List<Tag>) {
}
}

@Composable
private fun Time(time: String) {
val parts = time.split(" - ")
val begin = parts[0]
val end = parts.getOrNull(1)

Column(
Modifier.width(85.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
begin,
textAlign = TextAlign.Center
)
if (end != null) {
Text(
end,
textAlign = TextAlign.Center,
style = MaterialTheme.typography.labelSmall
)
}
}
}

@Composable
@OptIn(ExperimentalLayoutApi::class)
private fun Categories(tags: List<Tag>) {
Expand Down Expand Up @@ -168,7 +188,7 @@ private fun EventRowViewPreview() {
Column {
EventRowView(
title = "Compelled Decryption",
time = "5:30\nAM",
time = "05:30 - 07:00",
location = "Track 1",
tags = listOf(
createTag(label = "Introduction", color = "#EEAAFF"),
Expand All @@ -179,7 +199,7 @@ private fun EventRowViewPreview() {
)
EventRowView(
title = "Compelled Decryption",
time = "6:00\nAM",
time = "06:00 - 08:00",
location = "Track 1",
tags = listOf(
createTag(label = "Talk", color = "#FF61EEAA"),
Expand All @@ -189,6 +209,17 @@ private fun EventRowViewPreview() {
onEventPressed = {},
onBookmark = {},
)
EventRowView(
title = "Compelled Decryption",
time = "07:00",
location = "Track 1",
tags = listOf(
createTag(label = "Introduction", color = "#EEAAFF"),
),
isBookmarked = false,
onEventPressed = {},
onBookmark = {},
)
}
}
}
2 changes: 1 addition & 1 deletion ui/src/main/java/com/advice/ui/screens/ScheduleScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private fun ScheduleScreenContent(
item(key = it.id) {
EventRowView(
title = it.title,
time = TimeUtil.getTimeStamp(context, it),
time = TimeUtil.getEventTimeStamp(context, it),
location = it.location.name,
tags = it.types,
isBookmarked = it.isBookmarked,
Expand Down