add locale currency

fix grammar
paca_championship
Raz 1 year ago
parent b6e8144bfd
commit 0c0b492d8f
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 4
      PadelClub/Data/Tournament.swift
  3. 5
      PadelClub/Extensions/Locale+Extensions.swift
  4. 8
      PadelClub/Views/Cashier/CashierDetailView.swift
  5. 59
      PadelClub/Views/Cashier/CashierSettingsView.swift
  6. 8
      PadelClub/Views/Planning/PlanningByCourtView.swift
  7. 4
      PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift

@ -3246,7 +3246,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.27;
MARKETING_VERSION = 1.0.28;
PRODUCT_BUNDLE_IDENTIFIER = app.padelclub;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -3290,7 +3290,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.27;
MARKETING_VERSION = 1.0.28;
PRODUCT_BUNDLE_IDENTIFIER = app.padelclub;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

@ -1592,10 +1592,10 @@ defer {
var entryFeeMessage: String {
if let entryFee {
let message: String = "Inscription: \(entryFee.formatted(.currency(code: "EUR"))) par joueur."
let message: String = "Inscription : \(entryFee.formatted(.currency(code: Locale.defaultCurrency()))) par joueur."
return [message, self._paymentMethodMessage()].compactMap { $0 }.joined(separator: "\n")
} else {
return "Inscription: gratuite."
return "Inscription : gratuite."
}
}

@ -20,4 +20,9 @@ extension Locale {
return countries.sorted()
}
static func defaultCurrency() -> String {
// return "EUR"
Locale.current.currency?.identifier ?? "EUR"
}
}

@ -26,7 +26,7 @@ struct CashierDetailView: View {
Section {
LabeledContent {
if let earnings {
Text(earnings.formatted(.currency(code: "EUR").precision(.fractionLength(0))))
Text(earnings.formatted(.currency(code: Locale.defaultCurrency()).precision(.fractionLength(0))))
} else {
ProgressView()
}
@ -95,7 +95,7 @@ struct CashierDetailView: View {
Section {
LabeledContent {
if let earnings {
Text(earnings.formatted(.currency(code: "EUR").precision(.fractionLength(0))))
Text(earnings.formatted(.currency(code: Locale.defaultCurrency()).precision(.fractionLength(0))))
} else {
ProgressView()
}
@ -144,7 +144,7 @@ struct CashierDetailView: View {
var body: some View {
LabeledContent {
if let value {
Text(value.formatted(.currency(code: "EUR")))
Text(value.formatted(.currency(code: Locale.defaultCurrency())))
} else {
ProgressView()
}
@ -173,7 +173,7 @@ struct CashierDetailView: View {
LabeledContent {
if let entryFee = tournament.entryFee {
let sum = Double(count) * entryFee
Text(sum.formatted(.currency(code: "EUR")))
Text(sum.formatted(.currency(code: Locale.defaultCurrency())))
}
} label: {
Text(type.localizedLabel())

@ -24,87 +24,74 @@ struct CashierSettingsView: View {
var body: some View {
List {
Section {
LabeledContent {
TextField(tournament.isFree() ? "Gratuite" : "Inscription", value: $entryFee, format: .currency(code: Locale.current.currency?.identifier ?? "EUR"))
TextField(tournament.isFree() ? "Gratuite" : "Inscription", value: $entryFee, format: .currency(code: Locale.defaultCurrency()))
.keyboardType(.decimalPad)
.multilineTextAlignment(.trailing)
.frame(maxWidth: .infinity)
.focused($focusedField, equals: ._entryFee)
} label: {
Text("Inscription")
}
} header: {
Text("Prix de l'inscription")
} footer: {
Text("Si vous souhaitez que Padel Club vous aide à suivre les encaissements, indiquer un prix d'inscription. Sinon Padel Club vous aidera à suivre simplement l'arrivée et la présence des joueurs.")
}
let players = tournament.selectedPlayers()
if players.anySatisfy({ $0.hasArrived == false }) {
Section {
RowButtonView("Tout le monde est arrivé", role: .destructive) {
let players = tournament.selectedPlayers() // tournaments.flatMap({ $0.selectedPlayers() })
players.forEach { player in
player.hasArrived = true
}
do {
try tournament.tournamentStore.playerRegistrations.addOrUpdate(contentOfs: players)
} catch {
Logger.error(error)
}
_save(players: players)
}
} footer: {
Text("Indique tous les joueurs sont là")
}
}
if players.anySatisfy({ $0.hasArrived == true }) {
Section {
RowButtonView("Personne n'est là", role: .destructive) {
let players = tournament.selectedPlayers() // tournaments.flatMap({ $0.selectedPlayers() })
players.forEach { player in
player.hasArrived = false
}
do {
try tournament.tournamentStore.playerRegistrations.addOrUpdate(contentOfs: players)
} catch {
Logger.error(error)
}
_save(players: players)
}
} footer: {
Text("Indique qu'aucun joueur n'est arrivé")
}
}
if players.anySatisfy({ $0.hasPaid() == false }) {
Section {
RowButtonView("Tout le monde a réglé", role: .destructive) {
let players = tournament.selectedPlayers() // tournaments.flatMap({ $0.selectedPlayers() })
players.forEach { player in
if player.hasPaid() == false {
player.paymentType = .gift
}
}
do {
try tournament.tournamentStore.playerRegistrations.addOrUpdate(contentOfs: players)
} catch {
Logger.error(error)
}
_save(players: players)
}
} footer: {
Text("Passe tous les joueurs qui n'ont pas réglé en offert")
}
}
if players.anySatisfy({ $0.hasPaid() == true }) {
Section {
RowButtonView("Personne n'a réglé", role: .destructive) {
let store = tournament.tournamentStore
let players = tournament.selectedPlayers()
players.forEach { player in
player.paymentType = nil
}
do {
try store.playerRegistrations.addOrUpdate(contentOfs: players)
} catch {
Logger.error(error)
}
_save(players: players)
}
} footer: {
Text("Remet à zéro le type d'encaissement de tous les joueurs")
}
}
}
.navigationBarBackButtonHidden(focusedField != nil)
.toolbarBackground(.visible, for: .navigationBar)
.toolbar {
@ -119,7 +106,7 @@ struct CashierSettingsView: View {
HStack {
if tournament.isFree() {
ForEach(priceTags, id: \.self) { priceTag in
Button(priceTag.formatted(.currency(code: "EUR"))) {
Button(priceTag.formatted(.currency(code: Locale.defaultCurrency()))) {
entryFee = priceTag
tournament.entryFee = priceTag
focusedField = nil
@ -150,6 +137,14 @@ struct CashierSettingsView: View {
}
}
private func _save(players: [PlayerRegistration]) {
do {
try tournament.tournamentStore.playerRegistrations.addOrUpdate(contentOfs: players)
} catch {
Logger.error(error)
}
}
private func _save() {
do {
try dataStore.tournaments.addOrUpdate(instance: tournament)

@ -132,17 +132,17 @@ struct PlanningByCourtView: View {
}
} else if noStartDate == false {
ContentUnavailableView {
Label("Aucun match plannifié", systemImage: "clock.badge.questionmark")
Label("Aucun match planifié", systemImage: "clock.badge.questionmark")
} description: {
Text("Aucun match n'a été plannifié sur ce terrain et au jour sélectionné")
Text("Aucun match n'a été planifié sur ce terrain et au jour sélectionné")
} actions: {
}
}
} else if noStartDate == false {
ContentUnavailableView {
Label("Aucun match plannifié", systemImage: "clock.badge.questionmark")
Label("Aucun match planifié", systemImage: "clock.badge.questionmark")
} description: {
Text("Aucun match n'a été plannifié sur ce terrain et au jour sélectionné")
Text("Aucun match n'a été planifié sur ce terrain et au jour sélectionné")
} actions: {
}
}

@ -45,7 +45,7 @@ struct TournamentGeneralSettingsView: View {
TournamentDatePickerView()
TournamentDurationManagerView()
LabeledContent {
TextField(tournament.isFree() ? "Gratuite" : "Inscription", value: $entryFee, format: .currency(code: Locale.current.currency?.identifier ?? "EUR"))
TextField(tournament.isFree() ? "Gratuite" : "Inscription", value: $entryFee, format: .currency(code: Locale.defaultCurrency()))
.keyboardType(.decimalPad)
.multilineTextAlignment(.trailing)
.frame(maxWidth: .infinity)
@ -125,7 +125,7 @@ struct TournamentGeneralSettingsView: View {
if focusedField == ._entryFee {
if tournament.isFree() {
ForEach(priceTags, id: \.self) { priceTag in
Button(priceTag.formatted(.currency(code: "EUR"))) {
Button(priceTag.formatted(.currency(code: Locale.defaultCurrency()))) {
entryFee = priceTag
tournament.entryFee = priceTag
focusedField = nil

Loading…
Cancel
Save