Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit b7c468e

Browse files
authored
✨ Display API client for statuses (#326)
* ✨ Update fav icon to heart for Träwelldroid users * ✨ Display api client for status
1 parent e71d882 commit b7c468e

File tree

9 files changed

+51
-3
lines changed

9 files changed

+51
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package de.hbch.traewelling.api.models.status
2+
3+
data class ApiClient(
4+
val id: Int,
5+
val name: String
6+
)

app/src/main/kotlin/de/hbch/traewelling/api/models/status/Status.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ data class Status(
1818
var liked: Boolean?,
1919
@SerializedName("isLikable") val likeable: Boolean?,
2020
@SerializedName("train") val journey: Journey,
21-
val event: Event?
21+
val event: Event?,
22+
val client: ApiClient?
2223
) {
2324
fun getStatusBody(): String {
2425
var statusBody = body ?: ""
@@ -29,6 +30,8 @@ data class Status(
2930

3031
return statusBody
3132
}
33+
34+
val isTraewelldroidCheckIn get() = client?.id == 43
3235
}
3336

3437
enum class StatusVisibility() {

app/src/main/kotlin/de/hbch/traewelling/theme/Colors.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ import androidx.compose.ui.graphics.Color
55
val Traewelldroid = Color(0xFF3F51B5)
66
val TraewelldroidDark = Color(0xFF42A5F5)
77
val StarYellow = Color(0xFFFFC107)
8+
val HeartRed = Color(0xFFFF0000)
89
var PolylineColor = Traewelldroid

app/src/main/kotlin/de/hbch/traewelling/ui/include/status/CheckInCard.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import de.hbch.traewelling.api.models.status.StatusBusiness
5050
import de.hbch.traewelling.api.models.trip.ProductType
5151
import de.hbch.traewelling.shared.LoggedInUserViewModel
5252
import de.hbch.traewelling.theme.AppTypography
53+
import de.hbch.traewelling.theme.HeartRed
5354
import de.hbch.traewelling.theme.LocalColorScheme
5455
import de.hbch.traewelling.theme.StarYellow
5556
import de.hbch.traewelling.ui.composables.LineIcon
@@ -448,11 +449,15 @@ private fun CheckInCardFooter(
448449
targetState = likedState,
449450
label = "FavoriteAnimation"
450451
) {
451-
val icon = if (it) R.drawable.ic_faved else R.drawable.ic_not_faved
452+
val color = if (status.isTraewelldroidCheckIn) HeartRed else StarYellow
453+
val icon = when (status.isTraewelldroidCheckIn) {
454+
true -> if (it) R.drawable.ic_heart_filled else R.drawable.ic_heart
455+
false -> if (it) R.drawable.ic_faved else R.drawable.ic_not_faved
456+
}
452457
Icon(
453458
painterResource(id = icon),
454459
contentDescription = null,
455-
tint = StarYellow
460+
tint = color
456461
)
457462
}
458463
Text(

app/src/main/kotlin/de/hbch/traewelling/ui/statusDetail/StatusDetail.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,27 @@ fun StatusDetail(
192192
textAlign = TextAlign.End,
193193
style = AppTypography.labelMedium
194194
)
195+
Row(
196+
modifier = Modifier.fillMaxWidth(),
197+
verticalAlignment = Alignment.CenterVertically,
198+
horizontalArrangement = Arrangement.End
199+
) {
200+
if (status?.isTraewelldroidCheckIn == true) {
201+
Icon(
202+
painter = painterResource(id = R.drawable.ic_logo),
203+
contentDescription = null,
204+
modifier = Modifier.padding(end = 4.dp)
205+
)
206+
}
207+
Text(
208+
text = stringResource(
209+
id = R.string.checked_in_with,
210+
status?.client?.name ?: "Träwelling"
211+
),
212+
style = AppTypography.labelMedium,
213+
maxLines = 2
214+
)
215+
}
195216
}
196217
}
197218
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>
5+
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
5+
</vector>

app/src/main/res/values-de-rDE/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,5 @@
244244
<string name="travelynx_limited_functionality">Aktuell ist es nur möglich, Check-Ins für travelynx zu erstellen. Wenn du diese bearbeiten möchtest, nutze bitte die Website. Ziehe in Betracht, deine Träwelling-Synchronisation abzuschalten, um Fehler zu vermeiden.</string>
245245
<string name="travelynx_token">travelynx Travel-Token</string>
246246
<string name="changes_saved">Änderungen wurden gespeichert</string>
247+
<string name="checked_in_with">Eingecheckt mit %1$s</string>
247248
</resources>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,5 @@
249249
<string name="travelynx_limited_functionality">At the moment, it is only possible to create check-ins with travelynx. If you want to edit them, please use the website for that. Consider turning off your Träwelling sync to prevent issues.</string>
250250
<string name="travelynx_token">travelynx travel token</string>
251251
<string name="changes_saved">Changes have been saved</string>
252+
<string name="checked_in_with">Checked in with %1$s</string>
252253
</resources>

0 commit comments

Comments
 (0)