Skip to content

Commit

Permalink
Show cfp chip for past events (#1351)
Browse files Browse the repository at this point in the history
Co-authored-by: Ashley Davies <[email protected]>
  • Loading branch information
ashdavies and ashdavies authored Nov 21, 2024
1 parent 3c928b5 commit 4968691
Showing 1 changed file with 33 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SuggestionChip
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
Expand All @@ -35,6 +36,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.CompositingStrategy
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
Expand Down Expand Up @@ -163,6 +165,7 @@ private fun EventSectionContent(

if (windowClassSize.widthSizeClass == WindowWidthSizeClass.Expanded) {
EventStatusChips(
cfpSite = event?.cfpSite,
cfpEnd = event?.cfpEnd,
isOnlineOnly = event?.online == true,
modifier = Modifier.padding(start = 12.dp),
Expand All @@ -178,6 +181,7 @@ private fun EventSectionContent(

if (windowClassSize.widthSizeClass == WindowWidthSizeClass.Compact) {
EventStatusChips(
cfpSite = event?.cfpSite,
cfpEnd = event?.cfpEnd,
isOnlineOnly = event?.online == true,
)
Expand Down Expand Up @@ -236,18 +240,44 @@ private fun EventDateLabel(

@Composable
private fun EventStatusChips(
cfpSite: String?,
cfpEnd: String?,
isOnlineOnly: Boolean,
modifier: Modifier = Modifier,
) {
Row(modifier) {
if (cfpEnd != null && LocalDate.parse(cfpEnd) > Today) {
SuggestionChip(stringResource(Res.string.call_for_papers, cfpEnd))
if (cfpEnd != null) {
val uriHandler = LocalUriHandler.current

SuggestionChip(
onClick = { uriHandler.openUri(requireNotNull(cfpSite)) },
label = {
Text(
text = stringResource(Res.string.call_for_papers, cfpEnd),
color = LocalContentColor.current,
style = MaterialTheme.typography.labelSmall,
)
},
enabled = cfpSite != null && LocalDate.parse(cfpEnd) > Today,
shape = MaterialTheme.shapes.small,
)

HorizontalDivider(Modifier.width(8.dp))
}

if (isOnlineOnly) {
SuggestionChip(stringResource(Res.string.online_only))
SuggestionChip(
onClick = { },
label = {
Text(
text = stringResource(Res.string.online_only),
color = LocalContentColor.current,
style = MaterialTheme.typography.labelSmall,
)
},
enabled = false,
shape = MaterialTheme.shapes.small,
)
}
}
}
Expand Down Expand Up @@ -277,26 +307,6 @@ private fun EventSectionBackground(
)
}

@Composable
private fun SuggestionChip(
text: String,
modifier: Modifier = Modifier,
) {
androidx.compose.material3.SuggestionChip(
onClick = { },
label = {
Text(
text = text,
color = LocalContentColor.current,
style = MaterialTheme.typography.labelSmall,
)
},
modifier = modifier,
enabled = false,
shape = MaterialTheme.shapes.small,
)
}

@Composable
internal fun PlaceholderText(
text: String?,
Expand Down

0 comments on commit 4968691

Please sign in to comment.