Renames call as summons

multistore
Laurent 2 years ago
parent ea004d220f
commit 27beca502b
  1. 2
      PadelClub/Data/AppSettings.swift
  2. 20
      PadelClub/Data/User.swift
  3. 14
      PadelClub/Utils/ContactManager.swift
  4. 30
      PadelClub/Views/Calling/CallMessageCustomizationView.swift

@ -43,7 +43,7 @@ class AppSettings: MicroStorable {
enum CodingKeys: String, CodingKey {
case _lastDataSource = "lastDataSource"
case _callMessageBody = "callMessageBody"
case _callMessageSignature = "callMessageSignature"
case _callMessageSignature = "summonsMessageSignature"
case _callDisplayFormat = "callDisplayFormat"
case _callDisplayEntryFee = "callDisplayEntryFee"
case _callUseFullCustomMessage = "callUseFullCustomMessage"

@ -32,11 +32,11 @@ class User: UserBase, Storable {
var phone: String?
var country: String?
var callMessageBody : String? = nil
var callMessageSignature: String? = nil
var callDisplayFormat: Bool = false
var callDisplayEntryFee: Bool = false
var callUseFullCustomMessage: Bool = false
var summonsMessageBody : String? = nil
var summonsMessageSignature: String? = nil
var summonsDisplayFormat: Bool = false
var summonsDisplayEntryFee: Bool = false
var summonsUseFullCustomMessage: Bool = false
var matchFormatsDefaultDuration: [MatchFormat: Int]? = nil
var bracketMatchFormatPreference: MatchFormat?
var groupStageMatchFormatPreference: MatchFormat?
@ -103,11 +103,11 @@ class User: UserBase, Storable {
case _lastName = "lastName"
case _phone = "phone"
case _country = "country"
case _callMessageBody = "callMessageBody"
case _callMessageSignature = "callMessageSignature"
case _callDisplayFormat = "callDisplayFormat"
case _callDisplayEntryFee = "callDisplayEntryFee"
case _callUseFullCustomMessage = "callUseFullCustomMessage"
case _summonsMessageBody = "summonsMessageBody"
case _summonsMessageSignature = "summonsMessageSignature"
case _summonsDisplayFormat = "summonsDisplayFormat"
case _summonsDisplayEntryFee = "summonsDisplayEntryFee"
case _summonsUseFullCustomMessage = "summonsUseFullCustomMessage"
case _matchFormatsDefaultDuration = "matchFormatsDefaultDuration"
case _bracketMatchFormatPreference = "bracketMatchFormatPreference"
case _groupStageMatchFormatPreference = "groupStageMatchFormatPreference"

@ -34,7 +34,7 @@ extension ContactType {
static let defaultSignature = ""
static func callingGroupStageCustomMessage(tournament: Tournament?, startDate: Date?, roundLabel: String) -> String {
let tournamentCustomMessage = DataStore.shared.user.callMessageBody ?? defaultCustomMessage
let tournamentCustomMessage = DataStore.shared.user.summonsMessageBody ?? defaultCustomMessage
let clubName = tournament?.clubName ?? ""
var text = tournamentCustomMessage
@ -49,7 +49,7 @@ extension ContactType {
text = text.replacingOccurrences(of: "#jour", with: "\(date.formatted(Date.FormatStyle().weekday(.wide).day().month(.wide)))")
text = text.replacingOccurrences(of: "#horaire", with: "\(date.formatted(Date.FormatStyle().hour().minute()))")
let signature = DataStore.shared.user.callMessageSignature ?? defaultSignature
let signature = DataStore.shared.user.summonsMessageSignature ?? defaultSignature
text = text.replacingOccurrences(of: "#signature", with: signature)
return text
@ -57,7 +57,7 @@ extension ContactType {
static func callingGroupStageMessage(tournament: Tournament?, startDate: Date?, roundLabel: String, matchFormat: MatchFormat?) -> String {
let useFullCustomMessage = DataStore.shared.user.callUseFullCustomMessage
let useFullCustomMessage = DataStore.shared.user.summonsUseFullCustomMessage
if useFullCustomMessage {
return callingGroupStageCustomMessage(tournament: tournament, startDate: startDate, roundLabel: roundLabel)
@ -66,17 +66,17 @@ extension ContactType {
let date = startDate ?? tournament?.startDate ?? Date()
let clubName = tournament?.clubName ?? ""
let message = DataStore.shared.user.callMessageBody ?? defaultCustomMessage
let signature = DataStore.shared.user.callMessageSignature ?? defaultSignature
let message = DataStore.shared.user.summonsMessageBody ?? defaultCustomMessage
let signature = DataStore.shared.user.summonsMessageSignature ?? defaultSignature
let localizedCalled = "convoqué" + (tournament?.tournamentCategory == .women ? "e" : "") + "s"
var formatMessage: String? {
(DataStore.shared.user.callDisplayFormat) ? matchFormat?.computedLongLabel.appending(".") : nil
(DataStore.shared.user.summonsDisplayFormat) ? matchFormat?.computedLongLabel.appending(".") : nil
}
var entryFeeMessage: String? {
(DataStore.shared.user.callDisplayEntryFee) ? tournament?.entryFeeMessage : nil
(DataStore.shared.user.summonsDisplayEntryFee) ? tournament?.entryFeeMessage : nil
}
var computedMessage: String {

@ -19,8 +19,8 @@ struct CallMessageCustomizationView: View {
init(tournament: Tournament) {
self.tournament = tournament
_customCallMessageBody = State(wrappedValue: DataStore.shared.user.callMessageBody ?? "")
_customCallMessageSignature = State(wrappedValue: DataStore.shared.user.callMessageSignature ?? "")
_customCallMessageBody = State(wrappedValue: DataStore.shared.user.summonsMessageBody ?? "")
_customCallMessageSignature = State(wrappedValue: DataStore.shared.user.summonsMessageSignature ?? "")
_customClubName = State(wrappedValue: tournament.clubName ?? "")
}
@ -29,11 +29,11 @@ struct CallMessageCustomizationView: View {
}
var formatMessage: String? {
dataStore.user.callDisplayFormat ? tournament.matchFormat.computedLongLabel + "." : nil
dataStore.user.summonsDisplayFormat ? tournament.matchFormat.computedLongLabel + "." : nil
}
var entryFeeMessage: String? {
dataStore.user.callDisplayEntryFee ? tournament.entryFeeMessage : nil
dataStore.user.summonsDisplayEntryFee ? tournament.entryFeeMessage : nil
}
var computedMessage: String {
@ -74,7 +74,7 @@ struct CallMessageCustomizationView: View {
_clubNameView()
Section {
if user.callUseFullCustomMessage {
if user.summonsUseFullCustomMessage {
Text(self.computedFullCustomMessage())
.contextMenu {
Button("Coller dans le presse-papier") {
@ -96,7 +96,7 @@ struct CallMessageCustomizationView: View {
Section {
LabeledContent {
Toggle(isOn: $user.callUseFullCustomMessage) {
Toggle(isOn: $user.summonsUseFullCustomMessage) {
}
} label: {
@ -112,13 +112,13 @@ struct CallMessageCustomizationView: View {
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Menu {
Picker(selection: $user.callDisplayFormat) {
Picker(selection: $user.summonsDisplayFormat) {
Text("Afficher le format").tag(true)
Text("Masquer le format").tag(false)
} label: {
}
Picker(selection: $user.callDisplayEntryFee) {
Picker(selection: $user.summonsDisplayEntryFee) {
Text("Afficher le prix d'inscription").tag(true)
Text("Masquer le prix d'inscription").tag(false)
} label: {
@ -139,24 +139,24 @@ struct CallMessageCustomizationView: View {
}
}
}
.onChange(of: user.callUseFullCustomMessage) {
if user.callUseFullCustomMessage == false {
user.callMessageBody = ContactType.defaultCustomMessage
.onChange(of: user.summonsUseFullCustomMessage) {
if user.summonsUseFullCustomMessage == false {
user.summonsMessageBody = ContactType.defaultCustomMessage
}
_save()
}
.onChange(of: customCallMessageBody) {
user.callMessageBody = customCallMessageBody
user.summonsMessageBody = customCallMessageBody
_save()
}
.onChange(of: customCallMessageSignature) {
user.callMessageSignature = customCallMessageSignature
user.summonsMessageSignature = customCallMessageSignature
_save()
}
.onChange(of: user.callDisplayEntryFee) {
.onChange(of: user.summonsDisplayEntryFee) {
_save()
}
.onChange(of: user.callDisplayFormat) {
.onChange(of: user.summonsDisplayFormat) {
_save()
}
}

Loading…
Cancel
Save