diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/BlackTitleColor.colorset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/BlackTitleColor.colorset/Contents.json new file mode 100644 index 0000000..0e54db2 --- /dev/null +++ b/Sources/AllInApp/AllIn/Assets.xcassets/BlackTitleColor.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x49", + "green" : "0x49", + "red" : "0x49" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x49", + "green" : "0x49", + "red" : "0x49" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/Bleue200.colorset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/Bleue200.colorset/Contents.json new file mode 100644 index 0000000..0286b3d --- /dev/null +++ b/Sources/AllInApp/AllIn/Assets.xcassets/Bleue200.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF8", + "green" : "0x99", + "red" : "0x23" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF8", + "green" : "0x99", + "red" : "0x23" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/BleueBadge.imageset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/BleueBadge.imageset/Contents.json new file mode 100644 index 0000000..446d6be --- /dev/null +++ b/Sources/AllInApp/AllIn/Assets.xcassets/BleueBadge.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Vector.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/BleueBadge.imageset/Vector.png b/Sources/AllInApp/AllIn/Assets.xcassets/BleueBadge.imageset/Vector.png new file mode 100644 index 0000000..2114e9d Binary files /dev/null and b/Sources/AllInApp/AllIn/Assets.xcassets/BleueBadge.imageset/Vector.png differ diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/BleueCoin.imageset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/BleueCoin.imageset/Contents.json new file mode 100644 index 0000000..67a98bf --- /dev/null +++ b/Sources/AllInApp/AllIn/Assets.xcassets/BleueCoin.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Group 107 (1).png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/BleueCoin.imageset/Group 107 (1).png b/Sources/AllInApp/AllIn/Assets.xcassets/BleueCoin.imageset/Group 107 (1).png new file mode 100644 index 0000000..d982a56 Binary files /dev/null and b/Sources/AllInApp/AllIn/Assets.xcassets/BleueCoin.imageset/Group 107 (1).png differ diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/Grey100Color.colorset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/Grey100Color.colorset/Contents.json index cf9f629..806eef5 100644 --- a/Sources/AllInApp/AllIn/Assets.xcassets/Grey100Color.colorset/Contents.json +++ b/Sources/AllInApp/AllIn/Assets.xcassets/Grey100Color.colorset/Contents.json @@ -20,12 +20,12 @@ } ], "color" : { - "color-space" : "srgb", + "color-space" : "display-p3", "components" : { "alpha" : "1.000", - "blue" : "0x45", - "green" : "0x45", - "red" : "0x45" + "blue" : "0xCF", + "green" : "0xCF", + "red" : "0xCF" } }, "idiom" : "universal" diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/LoadingHeart.imageset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/LoadingHeart.imageset/Contents.json new file mode 100644 index 0000000..063d4f3 --- /dev/null +++ b/Sources/AllInApp/AllIn/Assets.xcassets/LoadingHeart.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Group 280.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/LoadingHeart.imageset/Group 280.png b/Sources/AllInApp/AllIn/Assets.xcassets/LoadingHeart.imageset/Group 280.png new file mode 100644 index 0000000..956a97a Binary files /dev/null and b/Sources/AllInApp/AllIn/Assets.xcassets/LoadingHeart.imageset/Group 280.png differ diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/Pink100.colorset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/Pink100.colorset/Contents.json new file mode 100644 index 0000000..3492dff --- /dev/null +++ b/Sources/AllInApp/AllIn/Assets.xcassets/Pink100.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x8A", + "green" : "0x2B", + "red" : "0xFE" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x8A", + "green" : "0x2B", + "red" : "0xFE" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/Pink200.colorset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/Pink200.colorset/Contents.json new file mode 100644 index 0000000..c0ba743 --- /dev/null +++ b/Sources/AllInApp/AllIn/Assets.xcassets/Pink200.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xA8", + "green" : "0x49", + "red" : "0xC2" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xA8", + "green" : "0x49", + "red" : "0xC2" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/PinkBadge.imageset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/PinkBadge.imageset/Contents.json new file mode 100644 index 0000000..b0b4a62 --- /dev/null +++ b/Sources/AllInApp/AllIn/Assets.xcassets/PinkBadge.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Vector (1).png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/PinkBadge.imageset/Vector (1).png b/Sources/AllInApp/AllIn/Assets.xcassets/PinkBadge.imageset/Vector (1).png new file mode 100644 index 0000000..c6c1d71 Binary files /dev/null and b/Sources/AllInApp/AllIn/Assets.xcassets/PinkBadge.imageset/Vector (1).png differ diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/Purple200.colorset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/Purple200.colorset/Contents.json new file mode 100644 index 0000000..8beecea --- /dev/null +++ b/Sources/AllInApp/AllIn/Assets.xcassets/Purple200.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xC5", + "green" : "0x66", + "red" : "0x8A" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xC5", + "green" : "0x66", + "red" : "0x8A" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/PurpleAllCoin.imageset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/PurpleAllCoin.imageset/Contents.json new file mode 100644 index 0000000..1904c47 --- /dev/null +++ b/Sources/AllInApp/AllIn/Assets.xcassets/PurpleAllCoin.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Vector (3).png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/PurpleAllCoin.imageset/Vector (3).png b/Sources/AllInApp/AllIn/Assets.xcassets/PurpleAllCoin.imageset/Vector (3).png new file mode 100644 index 0000000..2ae155a Binary files /dev/null and b/Sources/AllInApp/AllIn/Assets.xcassets/PurpleAllCoin.imageset/Vector (3).png differ diff --git a/Sources/AllInApp/AllIn/Components/AllcoinsCounter.swift b/Sources/AllInApp/AllIn/Components/AllcoinsCounter.swift index eb21bd1..8d2a444 100644 --- a/Sources/AllInApp/AllIn/Components/AllcoinsCounter.swift +++ b/Sources/AllInApp/AllIn/Components/AllcoinsCounter.swift @@ -8,6 +8,8 @@ import SwiftUI struct AllcoinsCounter: View { + var backgroundColor: Color = .white + var foregroundColor: Color = AllInColors.primaryColor var body: some View { HStack(alignment: .center) { Image("allcoinIcon") @@ -15,10 +17,10 @@ struct AllcoinsCounter: View { .frame(width: 17, height: 17, alignment: .leading) Text(String(AppStateContainer.shared.user?.nbCoins ?? 0)) .fontWeight(.black) - .foregroundColor(AllInColors.primaryColor) + .foregroundColor(foregroundColor) } .frame(width: 90, height: 40) - .background(Color.white) + .background(backgroundColor) .cornerRadius(9999, corners: [.topLeft, .bottomLeft]) } diff --git a/Sources/AllInApp/AllIn/Components/BetCard.swift b/Sources/AllInApp/AllIn/Components/BetCard.swift index 8f29bcf..b8ca216 100644 --- a/Sources/AllInApp/AllIn/Components/BetCard.swift +++ b/Sources/AllInApp/AllIn/Components/BetCard.swift @@ -12,22 +12,28 @@ struct BetCard: View { var bet: Bet @State var showDetails: Bool = false - + @State var showParticipate: Bool = false + var body: some View { VStack(spacing: 0){ VStack(alignment: .leading,spacing: 2){ HStack{ Spacer() - Text("proposé par " + bet.author.username.capitalized).font(.system(size: 10)).foregroundColor(AllInColors.grey800Color) + Text("proposé par " + bet.author.username.capitalized) + .font(.system(size: 10)) + .foregroundColor(AllInColors.grey800Color) } - Text(bet.theme).font(.system(size: 15)).foregroundColor(AllInColors.grey800Color) - Text(bet.phrase).font(.system(size: 20)).fontWeight(.bold) + Text(bet.theme) + .font(.system(size: 15)) + .foregroundColor(AllInColors.grey800Color) + Text(bet.phrase) + .font(.system(size: 20)) + .fontWeight(.bold) HStack{ Text("Commence le").font(.system(size: 15)).foregroundColor(AllInColors.grey800Color) TextCapsule(date: bet.endRegisterDate) Spacer() - } } .frame(width: .infinity) @@ -38,35 +44,14 @@ struct BetCard: View { HStack{ Spacer() UsersPreview() - Text(String(bet.registered.count) + " joueurs en attente").font(.system(size: 15)).foregroundColor(AllInColors.grey800Color).fontWeight(.medium) - + Text(String(bet.registered.count) + " joueurs en attente") + .font(.system(size: 15)) + .foregroundColor(AllInColors.grey800Color) + .fontWeight(.medium) Spacer() }.padding(0) - Button { - - } label: { - Text("Participer") - .font(.system(size: 30)) - .fontWeight(.bold) - .frame(maxWidth: .infinity).padding(10) - .multilineTextAlignment(.center) - .overlay { - AllInColors.primaryGradient.frame(width: 170) - .mask( - Text("Participer") - .font(.system(size: 30)) - .fontWeight(.bold) - .frame(maxWidth: .infinity).padding(10) - ) - } - } - .accentColor(AllInColors.componentBackgroundColor) - .buttonStyle(.borderedProminent).cornerRadius(4.0) - .overlay( - RoundedRectangle(cornerRadius: 12).stroke(AllInColors.delimiterGrey, lineWidth: 1) - ).padding([.top],5) - + ParticipateButton(isOpen: $showDetails, isParticapatedOpen: $showParticipate, bet: bet).padding(.top, 5) } .frame(width: .infinity) .padding(.all,8) @@ -78,7 +63,7 @@ struct BetCard: View { showDetails.toggle() } .fullScreenCover(isPresented: $showDetails) { - DetailsView(isModalPresented: $showDetails, id: bet.id) + DetailsView(isModalPresented: $showDetails, isModalParticipated: $showParticipate,id: bet.id) } } } diff --git a/Sources/AllInApp/AllIn/Components/BetLineLoading.swift b/Sources/AllInApp/AllIn/Components/BetLineLoading.swift new file mode 100644 index 0000000..8bf0d58 --- /dev/null +++ b/Sources/AllInApp/AllIn/Components/BetLineLoading.swift @@ -0,0 +1,101 @@ +// +// BetLineLoading.swift +// AllIn +// +// Created by Lucas Delanier on 19/01/2024. +// + +import SwiftUI +import Model + +struct BetLineLoading: View { + + @State var participations: [Participation] + + var value: CGFloat { + let totalParticipations = participations.count + let numberOfYes = participations.filter { $0.response == "OUI" }.count + let numberOfNo = participations.filter { $0.response == "NON" }.count + if(numberOfNo == 0 && numberOfYes == 0){ + return 0.5 + } + + return totalParticipations > 0 ? CGFloat(numberOfYes) / CGFloat(totalParticipations) : 0.0 + } + + + + var yesParticipations: [Participation] { + return participations.filter { $0.response == "OUI" } + } + + var noParticipations: [Participation] { + return participations.filter { $0.response == "NON" } + } + + + var body: some View { + GeometryReader { geometry in + VStack(alignment: .leading,spacing: 0){ + HStack(spacing: 5){ + Text("OUI").font(.system(size: 25)).fontWeight(.bold).foregroundColor(AllInColors.bleue200) + Spacer() + Text("NON").font(.system(size: 25)).fontWeight(.bold).foregroundColor(AllInColors.pink100) + + } + ZStack(alignment: .leading) { + HStack{ + Spacer() + Rectangle().frame(width: min(CGFloat(1-self.value)*geometry.size.width, geometry.size.width), height: 17) + .foregroundStyle(AllInColors.PinkBetGradiant).cornerRadius(999) + } + + HStack(spacing: 0){ + Rectangle().frame(width: min(CGFloat(self.value)*geometry.size.width, geometry.size.width), height: 17) + .foregroundStyle(AllInColors.BlueBetGradiant).cornerRadius(999) + .animation(.linear) + Image("LoadingHeart").resizable().frame(width: 29, height: 32).padding(.leading, -10) + } + + } + VStack(spacing: 1){ + HStack(spacing: 5){ + Image("BlueAllCoinIcon").resizable().frame(width:12, height: 12) + Text(yesParticipations.reduce(0, {x,y in x + y.stake}).description).font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.bleue200) + Spacer() + Text(noParticipations.reduce(0, {x,y in x + y.stake}).description).font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.pink100) + Image("PinkBadge").resizable().frame(width:10, height: 14) + + } + HStack(spacing: 5){ + Image("BleuePersonIcon").resizable().frame(width:14, height: 12) + Text(yesParticipations.count.description).font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.bleue200) + Spacer() + Text(noParticipations.count.description).font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.pink100) + Image("PinkBadge").resizable().frame(width:10, height: 14) + + } + HStack(spacing: 5){ + Image("BleueBadge").resizable().frame(width:10, height: 14) + Text(yesParticipations.max(by: { $0.stake < $1.stake })?.stake.description ?? "0").font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.bleue200) + Spacer() + Text(noParticipations.max(by: { $0.stake < $1.stake })?.stake.description ?? "0").font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.pink100) + Image("PinkBadge").resizable().frame(width:10, height: 14) + + } + HStack(spacing: 5){ + Image("BleueTrophyIcon").resizable().frame(width:14, height: 13) + Text("1.2").font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.bleue200) + Spacer() + Text("1.2").font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.pink100) + Image("PinkBadge").resizable().frame(width:10, height: 14) + + } + } + } + + }.frame(height: 140) + } +} + + diff --git a/Sources/AllInApp/AllIn/Components/DropDownAnswerMenu.swift b/Sources/AllInApp/AllIn/Components/DropDownAnswerMenu.swift new file mode 100644 index 0000000..b3c3c99 --- /dev/null +++ b/Sources/AllInApp/AllIn/Components/DropDownAnswerMenu.swift @@ -0,0 +1,81 @@ +// +// DropDownAnswerMenu.swift +// AllIn +// +// Created by Lucas Delanier on 16/01/2024. +// + +import SwiftUI + +// +// DropDownMenu.swift +// AllIn +// +// Created by Emre on 19/10/2023. +// + +import SwiftUI + +struct DropDownAnswerMenu: View { + + @State var expand = false + @Binding var selectedOption: Int + var options: [(Int, String, Float)] + + var body: some View { + VStack(spacing: 0, content: { + Button(action: { self.expand.toggle() }) { + HStack{ + Text(options[selectedOption].1.description) + .textStyle(weight: .bold, color: AllInColors.blueAccentColor, size: 20) + Text(options[selectedOption].2.description) + .textStyle(weight: .bold, color: AllInColors.lightPurpleColor, size: 10) + + Spacer() + Image(expand ? "chevronUpIcon" : "chevronDownIcon").resizable().frame(width: 15, height: 10).scaledToFill() + } + .padding([.leading, .trailing], 15) + .frame(height: 43) + } + if expand { + Rectangle() + .frame(height: 1) + .foregroundColor(AllInColors.delimiterGrey) + .padding(.bottom, 18) + VStack(spacing: 0) { + ForEach(0.., id: String) { + init(isModalPresented: Binding, isModalParticipated: Binding,id: String) { self._isModalPresented = isModalPresented + self._isModalParticipated = isModalParticipated self.id = id self._viewModel = StateObject(wrappedValue: DetailsViewModel(id: id)) } @@ -15,21 +59,21 @@ struct DetailsView: View { var body: some View { GeometryReader { geometry in ZStack(alignment: .bottom) { - VStack(alignment: .trailing) { + VStack(alignment: .center) { HStack{ + Text(StatusValues.0).font(.system(size: 25)).fontWeight(.bold).padding(.bottom, 10).foregroundStyle(Color.black).opacity(0.4) Spacer() Image("closeIcon") .resizable() - .padding(8) - .frame(maxWidth: 40, maxHeight: 40) + .frame(maxWidth: 25, maxHeight: 25) .onTapGesture { isModalPresented = false } } Spacer() } - .frame(maxWidth: .infinity, maxHeight: .infinity) - .background(Color.green) + .padding(.horizontal, 15) + .background(StatusValues.1) .transition(.slideInFromBottom(yOffset:0)) VStack(spacing: 0) { VStack(alignment: .leading,spacing: 5){ @@ -63,32 +107,49 @@ struct DetailsView: View { .foregroundColor(AllInColors.grey800Color) TextCapsule(date: viewModel.betDetail?.bet.endBetDate ?? Date()) Spacer() - + } } .frame(width: .infinity) .padding(.all,15).padding(.vertical, 10) .background(AllInColors.componentBackgroundColor) .cornerRadius(20, corners: [.topLeft,.topRight]).padding(.bottom,0) - ResultBanner() - VStack(alignment: .leading, spacing: 2){ + if isFinished { + ResultBanner() + } + VStack(alignment: .leading, spacing: 5) { + BetLineLoading(participations: viewModel.betDetail!.participations).padding(.vertical,15) + Text("Liste des participants") + .font(.system(size: 18)) + .foregroundStyle(AllInColors.grey100Color) + .fontWeight(.bold) + .padding(.bottom, 10) + ForEach(viewModel.betDetail?.participations ?? []) { (participation: Participation) in + ParticiationCell(participation: participation).padding(.horizontal, 10) + } + + Spacer() } .frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/, maxHeight: .infinity) - .padding([.bottom,.trailing,.leading],8) + .padding([.bottom,.trailing,.leading], 15) .background(AllInColors.underComponentBackgroundColor) .border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) Spacer() + } .frame(maxWidth: .infinity, maxHeight: geometry.size.height*0.98) .background(AllInColors.componentBackgroundColor) .cornerRadius(15) - ParticipateButton().padding(10) + + ParticipateButton(isOpen: $isModalPresented, isParticapatedOpen: $isModalParticipated,bet: viewModel.betDetail?.bet ).padding(10) + + + } + .sheet(isPresented: $isModalParticipated) { + ParticipationModal().presentationDetents([.fraction(0.55)]) } - .transition(.slideInFromBottom(yOffset: 800)) - .background(Color.white) - .edgesIgnoringSafeArea(.bottom) } } diff --git a/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj b/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj index 3199431..3fbc216 100644 --- a/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj +++ b/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj @@ -7,11 +7,15 @@ objects = { /* Begin PBXBuildFile section */ + 120919182B56D0AE00D0FA29 /* ParticipationModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 120919172B56D0AE00D0FA29 /* ParticipationModal.swift */; }; + 1209191A2B56DC6C00D0FA29 /* DropDownAnswerMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 120919192B56DC6C00D0FA29 /* DropDownAnswerMenu.swift */; }; 123590B42B51792000F7AEBD /* DetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B32B51792000F7AEBD /* DetailsView.swift */; }; 123590B62B5537E200F7AEBD /* ResultBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B52B5537E200F7AEBD /* ResultBanner.swift */; }; 123590B82B5541BA00F7AEBD /* ParticipateButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B72B5541BA00F7AEBD /* ParticipateButton.swift */; }; 1244EF602B4EC31E00374ABF /* HistoricBetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */; }; 1244EF622B4EC67000374ABF /* ReviewCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF612B4EC67000374ABF /* ReviewCard.swift */; }; + 12C370482B5A5EE500CD9F0F /* BetLineLoading.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */; }; + 12C3704A2B5D5BD000CD9F0F /* ParticiationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C370492B5D5BD000CD9F0F /* ParticiationCell.swift */; }; EC0193782B25BF16005D81E6 /* AllcoinsCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */; }; EC01937A2B25C12B005D81E6 /* BetCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC0193792B25C12B005D81E6 /* BetCard.swift */; }; EC01937C2B25C2A8005D81E6 /* AllcoinsCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC01937B2B25C2A8005D81E6 /* AllcoinsCounter.swift */; }; @@ -100,6 +104,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 120919172B56D0AE00D0FA29 /* ParticipationModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticipationModal.swift; sourceTree = ""; }; + 120919192B56DC6C00D0FA29 /* DropDownAnswerMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownAnswerMenu.swift; sourceTree = ""; }; 122278B72B4BDE1100E632AA /* DependencyInjection.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = DependencyInjection.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 122278B92B4BDE9500E632AA /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../Model/Package.swift; sourceTree = ""; }; 123590B32B51792000F7AEBD /* DetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsView.swift; sourceTree = ""; }; @@ -107,6 +113,8 @@ 123590B72B5541BA00F7AEBD /* ParticipateButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticipateButton.swift; sourceTree = ""; }; 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoricBetView.swift; sourceTree = ""; }; 1244EF612B4EC67000374ABF /* ReviewCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewCard.swift; sourceTree = ""; }; + 12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetLineLoading.swift; sourceTree = ""; }; + 12C370492B5D5BD000CD9F0F /* ParticiationCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticiationCell.swift; sourceTree = ""; }; EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllcoinsCapsule.swift; sourceTree = ""; }; EC0193792B25C12B005D81E6 /* BetCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetCard.swift; sourceTree = ""; }; EC01937B2B25C2A8005D81E6 /* AllcoinsCounter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllcoinsCounter.swift; sourceTree = ""; }; @@ -326,6 +334,10 @@ 1244EF612B4EC67000374ABF /* ReviewCard.swift */, 123590B52B5537E200F7AEBD /* ResultBanner.swift */, 123590B72B5541BA00F7AEBD /* ParticipateButton.swift */, + 120919172B56D0AE00D0FA29 /* ParticipationModal.swift */, + 120919192B56DC6C00D0FA29 /* DropDownAnswerMenu.swift */, + 12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */, + 12C370492B5D5BD000CD9F0F /* ParticiationCell.swift */, ); path = Components; sourceTree = ""; @@ -502,6 +514,7 @@ EC6B969E2B24B4CC00FC1C58 /* ContentView.swift in Sources */, EC89F7BD2B250D66003821CE /* LoginView.swift in Sources */, EC650A442B25CDF3003AFCAD /* ParameterMenu.swift in Sources */, + 120919182B56D0AE00D0FA29 /* ParticipationModal.swift in Sources */, ECB26A132B406A9400FE06B3 /* BetViewModel.swift in Sources */, EC30770F2B24FCB00060E34D /* RegisterView.swift in Sources */, EC650A522B2794DD003AFCAD /* BetView.swift in Sources */, @@ -529,6 +542,7 @@ EC3077072B24CB840060E34D /* SplashView.swift in Sources */, EC01937E2B25C52E005D81E6 /* TopBar.swift in Sources */, ECA9D1CB2B2DA2320076E0EC /* DropDownFriends.swift in Sources */, + 12C3704A2B5D5BD000CD9F0F /* ParticiationCell.swift in Sources */, 123590B82B5541BA00F7AEBD /* ParticipateButton.swift in Sources */, EC01FCC32B56650400BB2390 /* DetailsViewModel.swift in Sources */, ECB26A1B2B40746C00FE06B3 /* FriendsViewModel.swift in Sources */, @@ -540,9 +554,11 @@ 123590B62B5537E200F7AEBD /* ResultBanner.swift in Sources */, EC01FCC52B56791B00BB2390 /* HistoricBetViewModel.swift in Sources */, EC01937C2B25C2A8005D81E6 /* AllcoinsCounter.swift in Sources */, + 12C370482B5A5EE500CD9F0F /* BetLineLoading.swift in Sources */, EC650A542B279545003AFCAD /* ChoiceCapsule.swift in Sources */, ECB7BC6C2B2F43EE002A6654 /* AppState.swift in Sources */, ECA9D1C92B2D9ADA0076E0EC /* UserInfo.swift in Sources */, + 1209191A2B56DC6C00D0FA29 /* DropDownAnswerMenu.swift in Sources */, EC650A582B279D9D003AFCAD /* RecapBetCard.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Sources/Model/Sources/Model/Bet.swift b/Sources/Model/Sources/Model/Bet.swift index b99b7c2..4ad6268 100644 --- a/Sources/Model/Sources/Model/Bet.swift +++ b/Sources/Model/Sources/Model/Bet.swift @@ -90,4 +90,8 @@ public class Bet: ObservableObject, Identifiable { self.author = author self.registered = registered } + + public func addRegistered(newUser: User){ + self.registered.append(newUser) + } } diff --git a/Sources/Model/Sources/Model/BetDetail.swift b/Sources/Model/Sources/Model/BetDetail.swift index e9d7804..d492e8f 100644 --- a/Sources/Model/Sources/Model/BetDetail.swift +++ b/Sources/Model/Sources/Model/BetDetail.swift @@ -22,6 +22,8 @@ public class BetDetail: ObservableObject { /// The user's own participation in the bet. public private(set) var userParticipation: Participation + public private(set) var finalAnswer: String? + /// Custom Constructor /// /// - Parameters: @@ -29,10 +31,25 @@ public class BetDetail: ObservableObject { /// - answers: Details about the answers available for the bet. /// - participations: List of user participations in the bet. /// - userParticipation: The user's own participation in the bet. - public init(bet: Bet, answers: [BetAnswerDetail], participations: [Participation], userParticipation: Participation) { + public init(bet: Bet, answers: [BetAnswerDetail], participations: [Participation], userParticipation: Participation, finalAnswer: String? = nil) { self.bet = bet self.answers = answers self.participations = participations self.userParticipation = userParticipation + self.finalAnswer = finalAnswer + } + + public func updateFinalAnswer(newFinalAnswer: String) { + self.finalAnswer = newFinalAnswer + } + + public func addParticipation(newParticipation: Participation){ + if !self.bet.registered.contains(where: { existingUser in + return existingUser.email == newParticipation.user.email + }) { + self.bet.addRegistered(newUser: newParticipation.user) + } + + self.participations.append(newParticipation) } } diff --git a/Sources/Model/Sources/Model/Participation.swift b/Sources/Model/Sources/Model/Participation.swift index 4040e22..9b5d088 100644 --- a/Sources/Model/Sources/Model/Participation.swift +++ b/Sources/Model/Sources/Model/Participation.swift @@ -8,8 +8,9 @@ import Foundation /// A class representing a user's participation in a bet. -public class Participation: ObservableObject { - +public class Participation: ObservableObject, Identifiable{ + + public let id: UUID /// The amount of stake in the bet. public private(set) var stake: Int @@ -39,5 +40,6 @@ public class Participation: ObservableObject { self.response = response self.user = user self.betId = betId + self.id = UUID() } } diff --git a/Sources/StubLib/Sources/StubLib/Stub.swift b/Sources/StubLib/Sources/StubLib/Stub.swift index 5e70aa0..2692c33 100644 --- a/Sources/StubLib/Sources/StubLib/Stub.swift +++ b/Sources/StubLib/Sources/StubLib/Stub.swift @@ -35,7 +35,7 @@ struct Stub { let bet1 = BinaryBet( theme: "Football - Finale de la Ligue des Champions", phrase: "Le gagnant de la finale sera l'équipe avec le plus de tirs au but.", - endRegisterDate: Date().addingTimeInterval(86400), + endRegisterDate: Date().addingTimeInterval(-86400), endBetDate: Date().addingTimeInterval(172800), totalStakes: 100, isPublic: true, @@ -88,10 +88,16 @@ struct Stub { let betDetail = BetDetail(bet: bet, answers: [], participations: [], userParticipation: Participation(stake: 0, date: Date(), response: "", user: user1, betId: "")) self.betsDetail.append(betDetail) } + + self.betsDetail[0].addParticipation(newParticipation: Participation(stake: 120, date: Date(), response: "OUI", user: user1, betId: "1")) + self.betsDetail[0].addParticipation(newParticipation: Participation(stake: 20, date: Date(), response: "NON", user: user2, betId: "2")) + self.betsDetail[0].addParticipation(newParticipation: Participation(stake: 320, date: Date(), response: "OUI", user: user3, betId: "3")) + self.betsDetail[0].addParticipation(newParticipation: Participation(stake: 320, date: Date(), response: "OUI", user: user3, betId: "3")) + } public mutating func add(bet: Bet) { - let newBetDetail = BetDetail(bet: bet, answers: [], participations: [], userParticipation: Participation(stake: 0, date: Date(), response: "", user: users[1], betId: "")) + let newBetDetail = BetDetail(bet: bet, answers: [], participations: [], userParticipation: Participation(stake: 0, date: Date(), response: "", user: users[1], betId: ""), finalAnswer: "test") self.betsDetail.append(newBetDetail) } }