Implement ranking logic with SerieStandEntry, add support for streak results and binding types (Reiter+Pferd, Reiter, Pferd), update UI for detailed ranking display, and finalize Phase 10.
This commit is contained in:
+11
-1
@@ -8,9 +8,19 @@ data class Serie(
|
||||
val name: String,
|
||||
val beschreibung: String? = null,
|
||||
val reglementTyp: String = "STREICHER_NORMAL",
|
||||
val streichresultateCount: Int = 1,
|
||||
val bindungstyp: String = "PAAR_BINDUNG",
|
||||
val bewerbIds: Set<String> = emptySet()
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SerieStandEntry(
|
||||
val reiterId: String,
|
||||
val pferdId: String?,
|
||||
val punkte: Double,
|
||||
val anzahlWertungen: Int
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SeriePunkt(
|
||||
val id: String? = null,
|
||||
@@ -26,5 +36,5 @@ interface SeriesRepository {
|
||||
suspend fun getAll(): Result<List<Serie>>
|
||||
suspend fun getById(id: String): Result<Serie>
|
||||
suspend fun save(serie: Serie): Result<Serie>
|
||||
suspend fun getStand(serieId: String): Result<Map<String, Double>> // Einfache Map Reiter+Pferd ID zu Punkten
|
||||
suspend fun getStand(serieId: String): Result<List<SerieStandEntry>>
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package at.mocode.turnier.feature.presentation
|
||||
|
||||
import at.mocode.turnier.feature.domain.Serie
|
||||
import at.mocode.turnier.feature.domain.SerieStandEntry
|
||||
import at.mocode.turnier.feature.domain.SeriesRepository
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
@@ -11,7 +12,7 @@ import androidx.lifecycle.viewModelScope
|
||||
data class SeriesState(
|
||||
val series: List<Serie> = emptyList(),
|
||||
val isLoading: Boolean = false,
|
||||
val selectedSerieStand: Map<String, Double> = emptyMap(),
|
||||
val selectedSerieStand: List<SerieStandEntry> = emptyList(),
|
||||
val error: String? = null
|
||||
)
|
||||
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ package at.mocode.turnier.feature.data.remote
|
||||
|
||||
import at.mocode.frontend.core.network.ApiRoutes
|
||||
import at.mocode.turnier.feature.domain.Serie
|
||||
import at.mocode.turnier.feature.domain.SerieStandEntry
|
||||
import at.mocode.turnier.feature.domain.SeriesRepository
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.call.*
|
||||
@@ -34,7 +35,7 @@ class DefaultSeriesRepository(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getStand(serieId: String): Result<Map<String, Double>> = runCatching {
|
||||
override suspend fun getStand(serieId: String): Result<List<SerieStandEntry>> = runCatching {
|
||||
client.get(ApiRoutes.Series.stand(serieId)).body()
|
||||
}
|
||||
}
|
||||
|
||||
+17
-4
@@ -75,11 +75,24 @@ private fun SeriesList(state: SeriesState, onSelect: (String) -> Unit) {
|
||||
Column(Modifier.weight(0.6f).padding(16.dp)) {
|
||||
Text("Zwischenstand", style = MaterialTheme.typography.titleMedium)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
state.selectedSerieStand.forEach { (paar, punkte) ->
|
||||
Row(Modifier.fillMaxWidth().padding(vertical = 4.dp), horizontalArrangement = Arrangement.SpaceBetween) {
|
||||
Text(paar)
|
||||
Text("$punkte Pkt", fontWeight = FontWeight.Bold)
|
||||
state.selectedSerieStand.forEach { entry ->
|
||||
Row(
|
||||
Modifier.fillMaxWidth().padding(vertical = 4.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Column {
|
||||
Text("Reiter ID: ${entry.reiterId}", fontWeight = FontWeight.Medium)
|
||||
entry.pferdId?.let {
|
||||
Text("Pferd ID: $it", fontSize = 11.sp, color = Color.Gray)
|
||||
}
|
||||
}
|
||||
Column(horizontalAlignment = Alignment.End) {
|
||||
Text("${entry.punkte} Pkt", fontWeight = FontWeight.Bold, color = SeriesBlue)
|
||||
Text("${entry.anzahlWertungen} Wertungen", fontSize = 10.sp, color = Color.Gray)
|
||||
}
|
||||
}
|
||||
HorizontalDivider(thickness = 0.5.dp, color = Color.LightGray)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user