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

Feature/58 timetable design #71

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -1,5 +1,10 @@
package io.github.droidkaigi.confsched.model

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Star
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector

@Immutable
data class TimetableRooms(val rooms: List<TimetableRoom>)

Expand All @@ -15,6 +20,56 @@ data class TimetableRoom(
}
return sort.compareTo(other.sort)
}

fun getColor(): Color {
return when(name.enTitle) {
"Chipmunk" -> {
Color(0xFFFF974B)
}
"Dolphin" -> {
Color(0xFFBB85FF)
}
"Bumblebee" -> {
Color(0xFFDDD33C)
}
"Arctic Fox" -> {
Color(0xFF45E761)
}
else -> {
Color.White
}
}
}

fun getShape(): Shapes {
return when(name.enTitle) {
"Arctic Fox" -> {
Shapes.SQUARE
}
"Bumblebee" -> {
Shapes.CIRCLE
}
"Chipmunk" -> {
Shapes.SHARP_DIAMOND
}
"Dolphin" -> {
Shapes.DIAMOND
}
else -> {
Shapes.SQUARE
}
}
}

enum class Shapes {
SQUARE,
CIRCLE,
SHARP_DIAMOND,
DIAMOND
}



}

val TimetableRoom.nameAndFloor: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,53 @@
package io.github.droidkaigi.confsched.sessions.section

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
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.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Button
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Circle
import androidx.compose.material.icons.filled.Diamond
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.Square
import androidx.compose.material.icons.filled.Star
import androidx.compose.material.icons.filled.Thermostat
import androidx.compose.material.icons.outlined.FavoriteBorder
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment.Companion
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.seiko.imageloader.rememberImagePainter
import io.github.droidkaigi.confsched.model.Timetable
import io.github.droidkaigi.confsched.model.TimetableItem
import io.github.droidkaigi.confsched.model.TimetableRoom.Shapes.CIRCLE
import io.github.droidkaigi.confsched.model.TimetableRoom.Shapes.DIAMOND
import io.github.droidkaigi.confsched.model.TimetableRoom.Shapes.SHARP_DIAMOND
import io.github.droidkaigi.confsched.model.TimetableRoom.Shapes.SQUARE
import io.github.droidkaigi.confsched.sessions.TimetableListItemBookmarkIconTestTag
import io.github.droidkaigi.confsched.sessions.TimetableListItemTestTag
import kotlinx.collections.immutable.PersistentMap
Expand All @@ -39,28 +71,139 @@ fun TimetableList(
LazyColumn(
modifier = modifier.testTag(TimetableListTestTag),
state = scrollState,
verticalArrangement = Arrangement.spacedBy(10.dp),
contentPadding = contentPadding,
) {
items(uiState.timetable.timetableItems, key = { it.id.value }) { timetableItem ->
val isBookmarked = uiState.timetable.bookmarks.contains(timetableItem.id)
Row {
val roomName = timetableItem.room.name.currentLangTitle

//TODO: Replace with the real icons. Probably need to embed them.
val roomIcon = when (timetableItem.room.getShape()) {
SQUARE -> { Icons.Filled.Square }
CIRCLE -> { Icons.Filled.Circle }
DIAMOND -> {Icons.Filled.Thermostat }
SHARP_DIAMOND -> {Icons.Filled.Diamond }
else -> { Icons.Filled.Star }
}
val roomColor = timetableItem.room.getColor()

Column(
modifier = Modifier
.border(border= BorderStroke(width=1.dp,color=Color.White), shape = RoundedCornerShape(5.dp))
.padding(15.dp)
) {
Row {
TagView(tagText=roomName, icon = roomIcon, tagColor=roomColor)
Spacer(modifier = Modifier.padding(3.dp))
timetableItem.language.labels.forEach { label ->
TagView(tagText=label, tagColor=Color.White)
Spacer(modifier = Modifier.padding(3.dp))
}
Spacer(modifier = Modifier.weight(1f))
TextButton(
onClick = { onBookmarkClick(timetableItem, true) },
modifier = Modifier.testTag(TimetableListItemBookmarkIconTestTag)
) {
if (isBookmarked) {
Icon(
Icons.Filled.Favorite,
contentDescription = "Bookmarked",
tint = Color.Green,
)
} else {
Icon(
Icons.Outlined.FavoriteBorder,
contentDescription = "Not Bookmarked",
tint = Color.White,
)
}
}
}
Text(
text = timetableItem.title.currentLangTitle,
fontSize = 24.sp,
modifier = Modifier
.padding(horizontal = 16.dp)
.testTag(TimetableListItemTestTag)
.padding(bottom=5.dp)
.clickable { onTimetableItemClick(timetableItem) },
)
Spacer(modifier = Modifier.weight(1f))
Button(
modifier = Modifier.testTag(TimetableListItemBookmarkIconTestTag),
onClick = { onBookmarkClick(timetableItem, true) },
) {
Text(
text = "Bookmark $isBookmarked",
)
timetableItem.speakers.forEach { speaker ->
Row {
//TODO: This style of image loading was included by default but it seems slow
val painter = rememberImagePainter(speaker.iconUrl)
Image(
painter = painter,
modifier = Modifier
.width(32.dp)
.height(32.dp)
.clip(CircleShape),
contentDescription = "image",
)
Text(
text = speaker.name,
fontSize = 24.sp,
modifier = Modifier
.testTag(TimetableListItemTestTag)
.padding(5.dp)
.align(Alignment.CenterVertically)
)
}
}
//TODO: There is no data for the warning string right now. (Should go here)

}
}
}
}

@Composable
fun TagView (tagText: String, icon: ImageVector?=null, tagColor: Color) {
Row(modifier = Modifier
.border(border = BorderStroke(width = 1.dp, color = tagColor))
.clip(RoundedCornerShape(15.dp))
.padding(5.dp)) {
icon?.let { ico ->
Icon(ico, "", tint=tagColor)
}
Spacer(modifier = Modifier.padding(3.dp))
Text(
color = tagColor,
text = tagText,
modifier = Modifier.padding(end=5.dp)
)
}
}

//@Composable
//fun testItem() {
// val isBookmarked = false
// Row {
// Text(
// text = "Placeholder",//timetableItem.title.currentLangTitle,
// modifier = Modifier
// .padding(horizontal = 16.dp)
// //.testTag(TimetableListItemTestTag)
// //.clickable { onTimetableItemClick(timetableItem) },
// )
// Spacer(modifier = Modifier.weight(1f))
// TextButton(
// onClick = {}
// //onClick = { onBookmarkClick(timetableItem, true) }//,
// //modifier = Modifier.testTag(TimetableListItemBookmarkIconTestTag)
// ) {
// if (isBookmarked) {
// Icon(Icons.Filled.Favorite, contentDescription = "Bookmarked", tint= Color.Green)
// } else {
// Icon(Icons.Outlined.FavoriteBorder, contentDescription = "Not Bookmarked", tint= Color.White)
// }
// }
// }
//}
//
//@Preview @Composable
//fun previewItem() {
// testItem()
//}


Copy link
Member

Choose a reason for hiding this comment

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

If you want to use this later we can leave as it is. But if we don't need this I think we can remove.

Suggested change
//@Composable
//fun testItem() {
// val isBookmarked = false
// Row {
// Text(
// text = "Placeholder",//timetableItem.title.currentLangTitle,
// modifier = Modifier
// .padding(horizontal = 16.dp)
// //.testTag(TimetableListItemTestTag)
// //.clickable { onTimetableItemClick(timetableItem) },
// )
// Spacer(modifier = Modifier.weight(1f))
// TextButton(
// onClick = {}
// //onClick = { onBookmarkClick(timetableItem, true) }//,
// //modifier = Modifier.testTag(TimetableListItemBookmarkIconTestTag)
// ) {
// if (isBookmarked) {
// Icon(Icons.Filled.Favorite, contentDescription = "Bookmarked", tint= Color.Green)
// } else {
// Icon(Icons.Outlined.FavoriteBorder, contentDescription = "Not Bookmarked", tint= Color.White)
// }
// }
// }
//}
//
//@Preview @Composable
//fun previewItem() {
// testItem()
//}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I had intended to split into sub components but I gave up part way s the previewer was not showing in this project. I was able to get the view up and running without needing the preview but left this commented out.

I will try to be more careful about comments in the future.

Loading