From c3f4ac0a681c85b18781fd897c71cd6909e602e3 Mon Sep 17 00:00:00 2001 From: ludelanier Date: Thu, 6 Jun 2024 11:36:48 +0200 Subject: [PATCH] fix mistake ispublic --- Sources/AllInApp/AllIn/Components/BetCard.swift | 2 +- .../AllIn/Components/TrendingBetCard.swift | 2 +- .../AllIn/ViewModels/CreationBetViewModel.swift | 15 ++++++++------- .../AllInApp/AllIn/Views/CreationBetView.swift | 10 +++++----- .../Api/Sources/Api/Factory/FactoryApiBet.swift | 2 +- Sources/Model/Sources/Model/Bet.swift | 14 +++++++------- Sources/Model/Sources/Model/MatchBet.swift | 8 ++++---- Sources/StubLib/Sources/StubLib/Stub.swift | 8 ++++---- 8 files changed, 31 insertions(+), 30 deletions(-) diff --git a/Sources/AllInApp/AllIn/Components/BetCard.swift b/Sources/AllInApp/AllIn/Components/BetCard.swift index 9d2a9e3..599e537 100644 --- a/Sources/AllInApp/AllIn/Components/BetCard.swift +++ b/Sources/AllInApp/AllIn/Components/BetCard.swift @@ -77,7 +77,7 @@ struct BetCard_Previews: PreviewProvider { phrase: "Le gagnant de la finale sera l'équipe avec le plus de tirs au but.", endRegisterDate: Date().addingTimeInterval(86400), endBetDate: Date().addingTimeInterval(172800), - isPublic: true, + isPrivate: false, status: .inProgress, invited: [], author: "Imri", diff --git a/Sources/AllInApp/AllIn/Components/TrendingBetCard.swift b/Sources/AllInApp/AllIn/Components/TrendingBetCard.swift index dd8c328..3db03e4 100644 --- a/Sources/AllInApp/AllIn/Components/TrendingBetCard.swift +++ b/Sources/AllInApp/AllIn/Components/TrendingBetCard.swift @@ -77,7 +77,7 @@ struct TrendingBetCard_Previews: PreviewProvider { phrase: "Le gagnant de la finale sera l'équipe avec le plus de tirs au but.", endRegisterDate: Date().addingTimeInterval(86400), endBetDate: Date().addingTimeInterval(172800), - isPublic: true, + isPrivate: true, status: .inProgress, invited: [], author: "Imri", diff --git a/Sources/AllInApp/AllIn/ViewModels/CreationBetViewModel.swift b/Sources/AllInApp/AllIn/ViewModels/CreationBetViewModel.swift index 4e92112..6456378 100644 --- a/Sources/AllInApp/AllIn/ViewModels/CreationBetViewModel.swift +++ b/Sources/AllInApp/AllIn/ViewModels/CreationBetViewModel.swift @@ -15,7 +15,7 @@ class CreationBetViewModel: ObservableObject { @Inject var manager: Manager @Published var theme: String = "" @Published var description: String = "" - @Published var isPublic = true + @Published var isPrivate = false @Published var endRegisterDate = Date() @Published var endBetDate = Date() @Published var betAdded = false @@ -38,7 +38,8 @@ class CreationBetViewModel: ObservableObject { resetAllFieldErrors() if let user = AppStateContainer.shared.user { - manager.addBet(bet: toBet(theme: theme, description: description, endRegister: endRegisterDate, endBet: endBetDate, isPublic: isPublic, status: .inProgress, creator: user.username, type: selectedOption)) { statusCode in + manager.addBet(bet: toBet(theme: theme, description: description, endRegister: endRegisterDate, endBet: endBetDate, isPrivate: isPrivate, status: .inProgress, creator: user.username, type: selectedOption)) { statusCode in + print(statusCode) switch statusCode { case 201: self.betAdded = true @@ -113,16 +114,16 @@ class CreationBetViewModel: ObservableObject { self.errorMessage = errorMessage } - func toBet(theme: String, description: String, endRegister: Date, endBet: Date, isPublic: Bool, status: BetStatus, creator: String, type: Int) -> Bet { + func toBet(theme: String, description: String, endRegister: Date, endBet: Date, isPrivate: Bool, status: BetStatus, creator: String, type: Int) -> Bet { switch type { case 0: - return BinaryBet(theme: theme, phrase: description, endRegisterDate: endRegister, endBetDate: endBet, isPublic: isPublic, status: status, invited: [], author: creator, registered: []) + return BinaryBet(theme: theme, phrase: description, endRegisterDate: endRegister, endBetDate: endBet, isPrivate: isPrivate, status: status, invited: [], author: creator, registered: []) case 1: - return MatchBet(theme: theme, phrase: description, endRegisterDate: endRegister, endBetDate: endBet, isPublic: isPublic, status: status, invited: [], author: creator, registered: [], nameTeam1: "", nameTeam2: "") + return MatchBet(theme: theme, phrase: description, endRegisterDate: endRegister, endBetDate: endBet, isPrivate: isPrivate, status: status, invited: [], author: creator, registered: [], nameTeam1: "", nameTeam2: "") case 2: - return CustomBet(theme: theme, phrase: description, endRegisterDate: endRegister, endBetDate: endBet, isPublic: isPublic, status: status, invited: [], author: creator, registered: []) + return CustomBet(theme: theme, phrase: description, endRegisterDate: endRegister, endBetDate: endBet, isPrivate: isPrivate, status: status, invited: [], author: creator, registered: []) default: - return BinaryBet(theme: theme, phrase: description, endRegisterDate: endRegister, endBetDate: endBet, isPublic: isPublic, status: status, invited: [], author: creator, registered: []) + return BinaryBet(theme: theme, phrase: description, endRegisterDate: endRegister, endBetDate: endBet, isPrivate: isPrivate, status: status, invited: [], author: creator, registered: []) } } } diff --git a/Sources/AllInApp/AllIn/Views/CreationBetView.swift b/Sources/AllInApp/AllIn/Views/CreationBetView.swift index c553e49..36cbf47 100644 --- a/Sources/AllInApp/AllIn/Views/CreationBetView.swift +++ b/Sources/AllInApp/AllIn/Views/CreationBetView.swift @@ -257,15 +257,15 @@ struct CreationBetView: View { .padding(.leading, 10) HStack(spacing: 5) { - ConfidentialityButton(image: "globe", text: String(localized: "bet_public"), selected: viewModel.isPublic) + ConfidentialityButton(image: "globe", text: String(localized: "bet_public"), selected: !viewModel.isPrivate) .onTapGesture { - viewModel.isPublic = true + viewModel.isPrivate = false } .padding(.trailing, 5) - ConfidentialityButton(image: "lock", text: String(localized: "bet_private"), selected: !viewModel.isPublic) + ConfidentialityButton(image: "lock", text: String(localized: "bet_private"), selected: viewModel.isPrivate) .onTapGesture { - viewModel.isPublic = false + viewModel.isPrivate = true } Spacer() } @@ -276,7 +276,7 @@ struct CreationBetView: View { VStack(spacing: 10) { - if !self.viewModel.isPublic { + if self.viewModel.isPrivate { DropDownFriends() .padding(.bottom, 30) diff --git a/Sources/Api/Sources/Api/Factory/FactoryApiBet.swift b/Sources/Api/Sources/Api/Factory/FactoryApiBet.swift index 2465156..9f4b584 100644 --- a/Sources/Api/Sources/Api/Factory/FactoryApiBet.swift +++ b/Sources/Api/Sources/Api/Factory/FactoryApiBet.swift @@ -23,7 +23,7 @@ public class FactoryApiBet: FactoryBet { "sentenceBet": bet.phrase, "endRegistration": formatZonedDateTime(dateTime: bet.endRegisterDate), "endBet": formatZonedDateTime(dateTime: bet.endBetDate), - "isPrivate": String(bet.isPublic), + "isPrivate": String(bet.isPrivate), "response": ["Yes","No"], "type": betTypeString(fromType: String(describing: type(of: bet))) ] diff --git a/Sources/Model/Sources/Model/Bet.swift b/Sources/Model/Sources/Model/Bet.swift index a976803..c48c540 100644 --- a/Sources/Model/Sources/Model/Bet.swift +++ b/Sources/Model/Sources/Model/Bet.swift @@ -26,7 +26,7 @@ public class Bet: ObservableObject, Identifiable, Codable { public private(set) var endBetDate: Date /// Indicates whether the bet is public or private. - public private(set) var isPublic: Bool + public private(set) var isPrivate: Bool /// The current status of the bet. public private(set) var status: BetStatus @@ -46,7 +46,7 @@ public class Bet: ObservableObject, Identifiable, Codable { case phrase = "sentenceBet" case endRegisterDate = "endRegistration" case endBetDate = "endBet" - case isPublic = "isPrivate" + case isPrivate = "isPrivate" case status case author = "createdBy" } @@ -63,7 +63,7 @@ public class Bet: ObservableObject, Identifiable, Codable { self.endRegisterDate = formatter.date(from: endRegisterDateString)! let endBetDateString = try container.decode(String.self, forKey: .endBetDate) self.endBetDate = formatter.date(from: endBetDateString)! - self.isPublic = try container.decode(Bool.self, forKey: .isPublic) + self.isPrivate = try container.decode(Bool.self, forKey: .isPrivate) self.status = try container.decode(BetStatus.self, forKey: .status) self.author = try container.decode(String.self, forKey: .author) } @@ -81,13 +81,13 @@ public class Bet: ObservableObject, Identifiable, Codable { /// - invited: List of users who are invited to participate in the bet. /// - author: The user who created the bet. /// - registered: List of users who have registered for the bet. - public init(id: String, theme: String, phrase: String, endRegisterDate: Date, endBetDate: Date, isPublic: Bool, status: BetStatus, invited: [User], author: String, registered: [User]) { + public init(id: String, theme: String, phrase: String, endRegisterDate: Date, endBetDate: Date, isPrivate: Bool, status: BetStatus, invited: [User], author: String, registered: [User]) { self.id = id self.theme = theme self.phrase = phrase self.endRegisterDate = endRegisterDate self.endBetDate = endBetDate - self.isPublic = isPublic + self.isPrivate = isPrivate self.status = status self.invited = invited self.author = author @@ -106,13 +106,13 @@ public class Bet: ObservableObject, Identifiable, Codable { /// - invited: List of users who are invited to participate in the bet. /// - author: The user who created the bet. /// - registered: List of users who have registered for the bet. - public init(theme: String, phrase: String, endRegisterDate: Date, endBetDate: Date, isPublic: Bool, status: BetStatus, invited: [User], author: String, registered: [User]) { + public init(theme: String, phrase: String, endRegisterDate: Date, endBetDate: Date, isPrivate: Bool, status: BetStatus, invited: [User], author: String, registered: [User]) { self.id = UUID().uuidString self.theme = theme self.phrase = phrase self.endRegisterDate = endRegisterDate self.endBetDate = endBetDate - self.isPublic = isPublic + self.isPrivate = isPrivate self.status = status self.invited = invited self.author = author diff --git a/Sources/Model/Sources/Model/MatchBet.swift b/Sources/Model/Sources/Model/MatchBet.swift index d171562..b68844c 100644 --- a/Sources/Model/Sources/Model/MatchBet.swift +++ b/Sources/Model/Sources/Model/MatchBet.swift @@ -36,10 +36,10 @@ public class MatchBet: Bet { /// - registered: List of users who have registered for the match bet. /// - nameTeam1: The name of the first team involved in the match. /// - nameTeam2: The name of the second team involved in the match. - public init(id: String, theme: String, phrase: String, endRegisterDate: Date, endBetDate: Date, isPublic: Bool, status: BetStatus, invited: [User], author: String, registered: [User], nameTeam1: String, nameTeam2: String) { + public init(id: String, theme: String, phrase: String, endRegisterDate: Date, endBetDate: Date, isPrivate: Bool, status: BetStatus, invited: [User], author: String, registered: [User], nameTeam1: String, nameTeam2: String) { self.nameTeam1 = nameTeam1 self.nameTeam2 = nameTeam2 - super.init(id: id, theme: theme, phrase: phrase, endRegisterDate: endRegisterDate, endBetDate: endBetDate, isPublic: isPublic, status: status, invited: invited, author: author, registered: registered) + super.init(id: id, theme: theme, phrase: phrase, endRegisterDate: endRegisterDate, endBetDate: endBetDate, isPrivate: isPrivate, status: status, invited: invited, author: author, registered: registered) } /// Custom Constructor without Id @@ -56,10 +56,10 @@ public class MatchBet: Bet { /// - registered: List of users who have registered for the match bet. /// - nameTeam1: The name of the first team involved in the match. /// - nameTeam2: The name of the second team involved in the match. - public init(theme: String, phrase: String, endRegisterDate: Date, endBetDate: Date, isPublic: Bool, status: BetStatus, invited: [User], author: String, registered: [User], nameTeam1: String, nameTeam2: String) { + public init(theme: String, phrase: String, endRegisterDate: Date, endBetDate: Date, isPrivate: Bool, status: BetStatus, invited: [User], author: String, registered: [User], nameTeam1: String, nameTeam2: String) { self.nameTeam1 = nameTeam1 self.nameTeam2 = nameTeam2 - super.init(theme: theme, phrase: phrase, endRegisterDate: endRegisterDate, endBetDate: endBetDate, isPublic: isPublic, status: status, invited: invited, author: author, registered: registered) + super.init(theme: theme, phrase: phrase, endRegisterDate: endRegisterDate, endBetDate: endBetDate, isPrivate: isPrivate, status: status, invited: invited, author: author, registered: registered) } public required init(from decoder: Decoder) throws { diff --git a/Sources/StubLib/Sources/StubLib/Stub.swift b/Sources/StubLib/Sources/StubLib/Stub.swift index 097ad0d..1af9f7f 100644 --- a/Sources/StubLib/Sources/StubLib/Stub.swift +++ b/Sources/StubLib/Sources/StubLib/Stub.swift @@ -35,7 +35,7 @@ struct Stub { phrase: "Le gagnant de la finale sera l'équipe avec le plus de tirs au but.", endRegisterDate: Date().addingTimeInterval(-86400), endBetDate: Date().addingTimeInterval(172800), - isPublic: true, + isPrivate: false, status: .inProgress, invited: [], author: "Lucas", @@ -48,7 +48,7 @@ struct Stub { phrase: "Le plat préféré du jury sera une recette végétarienne.", endRegisterDate: Date().addingTimeInterval(172800), endBetDate: Date().addingTimeInterval(259200), - isPublic: false, + isPrivate: false, status: .inProgress, invited: [user3], author: "Lucas", @@ -61,7 +61,7 @@ struct Stub { phrase: "Le nombre total de précommandes dépassera-t-il 1 million dans la première semaine ?", endRegisterDate: Date().addingTimeInterval(259200), endBetDate: Date().addingTimeInterval(345600), - isPublic: true, + isPrivate: true, status: .finished, invited: [], author: "Lucas", @@ -74,7 +74,7 @@ struct Stub { phrase: "Le film favori des critiques remportera-t-il le prix du meilleur film ?", endRegisterDate: Date().addingTimeInterval(345600), endBetDate: Date().addingTimeInterval(432000), - isPublic: false, + isPrivate: false, status: .finished, invited: [user1], author: "Lucase",