Skip to content

Commit

Permalink
UI adjustments to list (incomplete).
Browse files Browse the repository at this point in the history
  • Loading branch information
CHARLES BOND authored and CHARLES BOND committed Jun 24, 2024
1 parent 1c35b9e commit 1f7231b
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 12 deletions.
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,44 @@
package io.github.droidkaigi.confsched.sessions.section

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
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.padding
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.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.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 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 Down Expand Up @@ -43,24 +66,106 @@ fun TimetableList(
) {
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))
.clip(RoundedCornerShape(5.dp))
.padding(15.dp)) {
Row {
TagView(tagText=roomName, icon = roomIcon, tagColor=roomColor)
Spacer(modifier = Modifier.padding(3.dp))
TagView(tagText="JA", tagColor=Color.White)
Spacer(modifier = Modifier.padding(3.dp))
TagView(tagText="EN", tagColor=Color.White)
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,
modifier = Modifier
.padding(horizontal = 16.dp)
.testTag(TimetableListItemTestTag)
.clickable { onTimetableItemClick(timetableItem) },
)
Spacer(modifier = Modifier.weight(1f))
Button(
modifier = Modifier.testTag(TimetableListItemBookmarkIconTestTag),
onClick = { onBookmarkClick(timetableItem, true) },
) {
Text(
text = "Bookmark $isBookmarked",
)
}
}
}
}
}

@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()
//}


0 comments on commit 1f7231b

Please sign in to comment.