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 { enum CodingKeys: String, CodingKey {
case _lastDataSource = "lastDataSource" case _lastDataSource = "lastDataSource"
case _callMessageBody = "callMessageBody" case _callMessageBody = "callMessageBody"
case _callMessageSignature = "callMessageSignature" case _callMessageSignature = "summonsMessageSignature"
case _callDisplayFormat = "callDisplayFormat" case _callDisplayFormat = "callDisplayFormat"
case _callDisplayEntryFee = "callDisplayEntryFee" case _callDisplayEntryFee = "callDisplayEntryFee"
case _callUseFullCustomMessage = "callUseFullCustomMessage" case _callUseFullCustomMessage = "callUseFullCustomMessage"

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

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

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

Loading…
Cancel
Save