-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
096afea
commit 70ee281
Showing
5 changed files
with
111 additions
and
39 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// GameResultView.swift | ||
// iosApp | ||
// | ||
// Created by Thomas Bernard on 22/07/2024. | ||
// Copyright © 2024 orgName. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Shared | ||
|
||
struct GameResultView: View { | ||
|
||
let scores : [KotlinPair<PlayerModel, KotlinInt>] | ||
|
||
var body: some View { | ||
List { | ||
ForEach(scores.sorted { Int(truncating: $0.second!) > Int(truncating: $1.second!) }, id: \.first!.id) { playerScore in | ||
|
||
let index = scores.sorted { Int(truncating: $0.second!) > Int(truncating: $1.second!) }.firstIndex { $0.first!.id == playerScore.first!.id }! | ||
|
||
HStack { | ||
ZStack { | ||
Circle() | ||
.foregroundColor(playerScore.first!.color.toColor()) | ||
.frame(width: 25, height: 25) | ||
Text("" + playerScore.first!.name.uppercased().prefix(1)) | ||
.foregroundColor(.white) | ||
.font(.system(size: 12)) | ||
} | ||
|
||
Text(playerScore.first!.name) | ||
|
||
Spacer() | ||
|
||
if index == 0 { | ||
Image(systemName: "medal.fill") | ||
.foregroundColor(.yellow) | ||
} else if index == 1 { | ||
Image(systemName: "medal.fill") | ||
.foregroundColor(.gray) | ||
} else if index == 2 { | ||
Image(systemName: "medal.fill") | ||
.foregroundColor(.brown) | ||
} | ||
|
||
|
||
Text(String(Int(truncating: playerScore.second!))) | ||
.foregroundColor(Int(truncating: playerScore.second!) >= 0 ? Color.green : Color.red) | ||
.frame(width:50) | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// HistoryGameView.swift | ||
// iosApp | ||
// | ||
// Created by Thomas Bernard on 22/07/2024. | ||
// Copyright © 2024 orgName. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Shared | ||
|
||
struct HistoryGameView: View { | ||
|
||
let game : GameModel | ||
|
||
var body: some View { | ||
Form { | ||
Section("Résultats"){ | ||
GameResultView(scores: game.calculateScore()) | ||
} | ||
Section("Tours"){ | ||
List(game.rounds, id: \.id){ round in | ||
RoundListItemView(round: round) | ||
} | ||
} | ||
} | ||
.navigationTitle("Partie du ") | ||
.toolbar { | ||
Button(action : {}) { | ||
Label("Reprendre", systemImage: "play.circle") | ||
} | ||
Button(action : {}) { | ||
Label("Supprimer", systemImage: "trash") | ||
} | ||
} | ||
} | ||
} |
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