-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Include event details * Update padding details --------- Co-authored-by: Ashley Davies <[email protected]>
- Loading branch information
Showing
11 changed files
with
150 additions
and
88 deletions.
There are no files selected for viewing
67 changes: 0 additions & 67 deletions
67
conferences-app/src/commonMain/kotlin/io/ashdavies/party/events/EventsDetail.kt
This file was deleted.
Oops, something went wrong.
133 changes: 133 additions & 0 deletions
133
conferences-app/src/commonMain/kotlin/io/ashdavies/party/events/EventsDetailPane.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package io.ashdavies.party.events | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.Event | ||
import androidx.compose.material.icons.outlined.MyLocation | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
import coil3.compose.AsyncImage | ||
import okio.ByteString.Companion.encode | ||
|
||
@Composable | ||
internal fun EventsDetailPane( | ||
event: Event, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Scaffold( | ||
modifier = modifier, | ||
topBar = { EventsTopBar(event.name) }, | ||
) { contentPadding -> | ||
Column(Modifier.padding(contentPadding)) { | ||
Card( | ||
modifier = Modifier.padding( | ||
horizontal = 16.dp, | ||
vertical = 8.dp, | ||
), | ||
) { | ||
EventsDetailImage( | ||
imageUrl = event.imageUrl, | ||
name = event.name, | ||
) | ||
} | ||
|
||
Card( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding( | ||
horizontal = 16.dp, | ||
vertical = 8.dp, | ||
), | ||
) { | ||
EventsDetailDate( | ||
dateStart = event.dateStart, | ||
dateEnd = event.dateEnd, | ||
) | ||
|
||
EventsDetailLocation( | ||
location = event.location, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun EventsDetailImage( | ||
imageUrl: String?, | ||
name: String, | ||
modifier: Modifier = Modifier, | ||
) { | ||
AsyncImage( | ||
model = imageUrl, | ||
contentDescription = null, | ||
modifier = modifier | ||
.background(randomColor(name)) | ||
.fillMaxWidth() | ||
.height(200.dp), | ||
placeholder = null, | ||
) | ||
} | ||
|
||
@Composable | ||
private fun EventsDetailDate( | ||
dateStart: String, | ||
dateEnd: String, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Row( | ||
modifier = modifier, | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
Icon( | ||
imageVector = Icons.Outlined.Event, | ||
contentDescription = null, | ||
modifier = Modifier.padding(16.dp), | ||
) | ||
|
||
Column { | ||
Text("$dateStart - $dateEnd") | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun EventsDetailLocation( | ||
location: String, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Row( | ||
modifier = modifier, | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
Icon( | ||
imageVector = Icons.Outlined.MyLocation, | ||
contentDescription = null, | ||
modifier = Modifier.padding(16.dp), | ||
) | ||
|
||
Column { | ||
Text(location) | ||
} | ||
} | ||
} | ||
|
||
private fun randomColor(seed: String) = with(seed.encode().md5()) { | ||
Color( | ||
red = get(0).toUByte().toInt(), | ||
green = get(1).toUByte().toInt(), | ||
blue = get(2).toUByte().toInt(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+17 KB
(190%)
...ashdavies/party/events/EventsDetailTests/EventsDetailPreview_Day_839dc042_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+17.1 KB
(190%)
...hdavies/party/events/EventsDetailTests/EventsDetailPreview_Night_a6299619_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters