Compare commits
1 commit
master
...
azea/Event
Author | SHA1 | Date | |
---|---|---|---|
fd8dfca5bf |
1 changed files with 78 additions and 8 deletions
|
@ -34,16 +34,85 @@ class MainActivity : ComponentActivity() {
|
|||
modifier = Modifier.fillMaxSize(),
|
||||
color = Color.White
|
||||
) {
|
||||
GreetingImage(
|
||||
message = getString(R.string.main_welcome_message),
|
||||
from = getString(R.string.tagline)
|
||||
)
|
||||
// GreetingImage(
|
||||
// message = getString(R.string.main_welcome_message),
|
||||
// from = getString(R.string.tagline)
|
||||
// )
|
||||
|
||||
EventDemo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//storing multiple events
|
||||
val events = mutableListOf<Event>(
|
||||
Event(
|
||||
title ="",
|
||||
daypart = DayPart.EVENING,
|
||||
duration = 40
|
||||
),
|
||||
Event(
|
||||
title ="",
|
||||
daypart = DayPart.MORNING,
|
||||
duration = 40
|
||||
),
|
||||
Event(
|
||||
title ="",
|
||||
daypart = DayPart.EVENING,
|
||||
duration = 40
|
||||
),
|
||||
Event(
|
||||
title ="",
|
||||
daypart = DayPart.AFTERNOON,
|
||||
duration = 40
|
||||
),
|
||||
Event(
|
||||
title ="",
|
||||
daypart = DayPart.EVENING,
|
||||
duration = 40
|
||||
),
|
||||
Event(
|
||||
title ="",
|
||||
daypart = DayPart.AFTERNOON,
|
||||
duration = 40
|
||||
),
|
||||
Event(
|
||||
title ="",
|
||||
daypart = DayPart.EVENING,
|
||||
duration = 40
|
||||
),
|
||||
)
|
||||
|
||||
val shortEvents = events.filter{
|
||||
it.duration < 60
|
||||
}
|
||||
|
||||
|
||||
enum class DayPart{
|
||||
MORNING,
|
||||
AFTERNOON,
|
||||
EVENING,
|
||||
}
|
||||
data class Event(
|
||||
val title: String,
|
||||
val description: String? = null,
|
||||
val daypart: DayPart,
|
||||
val duration: Int
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun EventDemo() {
|
||||
|
||||
Column {
|
||||
events.groupBy { it.daypart }.forEach{(daypart, events)->
|
||||
Text(text = "$daypart: ${events.size} Events")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun GreetingImage(message: String, from: String, modifier: Modifier = Modifier) {
|
||||
val image = painterResource(R.drawable.androidparty)
|
||||
|
@ -93,9 +162,10 @@ fun GreetingText(message: String, from: String, modifier: Modifier = Modifier) {
|
|||
@Composable
|
||||
fun BirthdayCardPreview() {
|
||||
OpheliaTheme {
|
||||
GreetingImage(
|
||||
message = stringResource(R.string.main_welcome_message),
|
||||
from = stringResource(R.string.tagline)
|
||||
)
|
||||
// GreetingImage(
|
||||
// message = stringResource(R.string.main_welcome_message),
|
||||
// from = stringResource(R.string.tagline)
|
||||
// )
|
||||
EventDemo()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue