Skip to content

Commit

Permalink
Merge pull request #988 from Aniokrait/feature/show-msg-for-sp-session
Browse files Browse the repository at this point in the history
Fix to show message for special session
  • Loading branch information
takahirom authored Sep 7, 2024
2 parents 450c758 + 67002c6 commit 64abba6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public fun SessionsAllResponse.toTimetable(): Timetable {
} else {
apiSession.i18nDesc.toMultiLangText()
},
message = apiSession.message?.toMultiLangText(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import io.github.droidkaigi.confsched.droidkaigiui.animation.LocalFavoriteAnimat
import io.github.droidkaigi.confsched.droidkaigiui.previewOverride
import io.github.droidkaigi.confsched.model.TimetableItem
import io.github.droidkaigi.confsched.model.TimetableItem.Session
import io.github.droidkaigi.confsched.model.TimetableItem.Special
import org.jetbrains.compose.resources.stringResource

const val TimetableItemCardBookmarkButtonTestTag = "TimetableItemCardBookmarkButton"
Expand Down Expand Up @@ -170,25 +171,27 @@ fun TimetableItemCard(
}
}
}
if (timetableItem is Session) {
timetableItem.message?.let {
Row(
modifier = Modifier
.padding(top = 8.dp)
.height(IntrinsicSize.Min),
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
Icon(
Icons.Filled.Info,
contentDescription = stringResource(DroidKaigiUiRes.string.image),
tint = MaterialTheme.colorScheme.error,
)
Text(
text = it.currentLangTitle,
fontSize = 16.sp,
color = MaterialTheme.colorScheme.error,
)
}

when (timetableItem) {
is Session -> timetableItem.message
is Special -> timetableItem.message
}?.let {
Row(
modifier = Modifier
.padding(top = 8.dp)
.height(IntrinsicSize.Min),
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
Icon(
Icons.Filled.Info,
contentDescription = stringResource(DroidKaigiUiRes.string.image),
tint = MaterialTheme.colorScheme.error,
)
Text(
text = it.currentLangTitle,
fontSize = 16.sp,
color = MaterialTheme.colorScheme.error,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public fun Timetable.Companion.fake(): Timetable {
enTitle = "This is a description\nThis is a description\nThis is a description\n" +
"This is a description\nThis is a description\nThis is a description\n",
),
message = null,
),
)
for (day in -1..1) {
Expand Down Expand Up @@ -229,6 +230,10 @@ public fun Timetable.Companion.fake(): Timetable {
enTitle = "This is a description\nThis is a description\nThis is a description\n" +
"This is a description\nThis is a description\nThis is a description\n",
),
message = MultiLangText(
jaTitle = "このセッションは事情により中止となりました",
enTitle = "This session has been cancelled due to circumstances.",
),
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public sealed class TimetableItem {
override val levels: PersistentList<String>,
override val speakers: PersistentList<TimetableSpeaker>,
val description: MultiLangText,
val message: MultiLangText?,
) : TimetableItem()

private val startsDateString: String by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import io.github.droidkaigi.confsched.model.TimetableAsset
import io.github.droidkaigi.confsched.model.TimetableCategory
import io.github.droidkaigi.confsched.model.TimetableItem
import io.github.droidkaigi.confsched.model.TimetableItem.Session
import io.github.droidkaigi.confsched.model.TimetableItem.Special
import io.github.droidkaigi.confsched.model.TimetableItemId
import io.github.droidkaigi.confsched.model.TimetableLanguage
import io.github.droidkaigi.confsched.model.TimetableRoom
Expand Down Expand Up @@ -226,7 +227,10 @@ fun TimetableGridItem(
},
)

val shouldShowError = timetableItem is Session && timetableItem.message != null
val shouldShowError = when (timetableItem) {
is Session -> timetableItem.message
is Special -> timetableItem.message
} != null

if (isShowingAllContent && (speakers.isNotEmpty() || shouldShowError)) {
Row(
Expand Down Expand Up @@ -263,7 +267,7 @@ fun TimetableGridItem(
.size(TimetableGridItemSizes.errorHeight),
imageVector = Icons.Default.Error,
contentDescription = stringResource(SessionsRes.string.content_description_error_icon),
tint = MaterialTheme.colorScheme.errorContainer,
tint = MaterialTheme.colorScheme.error,
)
}
}
Expand Down Expand Up @@ -587,6 +591,7 @@ fun TimetableGridItemWelcomeTalkPreview() {
enTitle = "This is a description\nThis is a description\nThis is a description\n" +
"This is a description\nThis is a description\nThis is a description\n",
),
message = null,
),
onTimetableItemClick = {},
gridItemHeightPx = 154,
Expand Down

0 comments on commit 64abba6

Please sign in to comment.