parent
d131eae629
commit
fd661687c3
@ -0,0 +1,16 @@ |
||||
// |
||||
// NumberFormatter+Extensions.swift |
||||
// PadelClub |
||||
// |
||||
// Created by Razmig Sarkissian on 27/03/2024. |
||||
// |
||||
|
||||
import Foundation |
||||
|
||||
extension NumberFormatter { |
||||
static var ordinal: NumberFormatter { |
||||
let formatter = NumberFormatter() |
||||
formatter.numberStyle = .ordinal |
||||
return formatter |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@ |
||||
// |
||||
// ClubRowView.swift |
||||
// PadelClub |
||||
// |
||||
// Created by Razmig Sarkissian on 27/03/2024. |
||||
// |
||||
|
||||
import SwiftUI |
||||
|
||||
struct ClubRowView: View { |
||||
let club: Club |
||||
|
||||
var body: some View { |
||||
LabeledContent { |
||||
|
||||
} label: { |
||||
Text(club.name) |
||||
Text(club.acronym) |
||||
} |
||||
} |
||||
} |
||||
|
||||
#Preview { |
||||
ClubRowView(club: Club.mock()) |
||||
} |
||||
@ -0,0 +1,60 @@ |
||||
// |
||||
// RankCalculatorView.swift |
||||
// Padel Tournament |
||||
// |
||||
// Created by Razmig Sarkissian on 03/05/2023. |
||||
// |
||||
|
||||
import SwiftUI |
||||
|
||||
struct RankCalculatorView: View { |
||||
@State private var rank: Int = 1 |
||||
@AppStorage("lastRankCalculatorLevel") private var tournamentLevel: TournamentLevel = .p25 |
||||
@AppStorage("lastRankCalculatorCount") private var count: PlayersCountRange = .N8 |
||||
|
||||
var body: some View { |
||||
Form { |
||||
Section { |
||||
HStack { |
||||
let ordinal = NumberFormatter.ordinal.string(from: NSNumber(value:rank))! |
||||
Text("\(ordinal) d'un \(tournamentLevel.localizedLabel()) de \(count.localizedLabel()) équipes:") |
||||
Spacer() |
||||
Text(tournamentLevel.points(for: rank-1, count: count.rawValue).formatted(.number.sign(strategy: .always()))) |
||||
} |
||||
} |
||||
Section { |
||||
Picker(selection: $tournamentLevel) { |
||||
ForEach(TournamentLevel.allCases) { level in |
||||
Text(level.localizedLabel()).tag(level) |
||||
} |
||||
} label: { |
||||
Label("Niveau", systemImage: "gauge.medium") |
||||
} |
||||
Picker(selection: $count) { |
||||
ForEach(tournamentLevel.ranges, id: \.self) { |
||||
Text($0.localizedLabel()).tag($0) |
||||
} |
||||
} label: { |
||||
Label("Nombre d'équipes", systemImage: "person.2") |
||||
} |
||||
Picker(selection: $rank) { |
||||
ForEach((1...count.rawValue), id: \.self) { |
||||
Text("#\($0)").tag($0) |
||||
} |
||||
} label: { |
||||
Label("Votre position", systemImage: "number") |
||||
} |
||||
} |
||||
Section { |
||||
ForEach(tournamentLevel.allPoints(for: count.rawValue).indices, id: \.self) { i in |
||||
HStack { |
||||
Text("#"+(i+1).formatted()) |
||||
Spacer() |
||||
Text(tournamentLevel.allPoints(for: count.rawValue)[i].formatted(.number.sign(strategy: .always()))) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.navigationTitle("Calculateur de points") |
||||
} |
||||
} |
||||
Loading…
Reference in new issue