Merge pull request 'view/details-page' (#15) from view/details-page into feature/display_bet_details

Reviewed-on: #15
pull/16/head
Emre KARTAL 1 year ago
commit d24a1cc244

@ -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
}
}

@ -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
}
}

@ -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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 986 B

@ -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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

@ -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"

@ -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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

@ -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
}
}

@ -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
}
}

@ -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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 B

@ -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
}
}

@ -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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -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])
}

@ -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)
}
}
}

@ -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)
}
}

@ -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..<options.count, id: \.self) { index in
if options[index].0 != selectedOption {
Button(action: {self.selectedOption = options[index].0
self.expand.toggle()}) {
HStack{
Text(options[index].1.description)
.textStyle(weight: .bold, color: AllInColors.blueAccentColor, size: 20)
Text(options[index].2.description)
.textStyle(weight: .bold, color: AllInColors.lightPurpleColor, size: 10)
Spacer()
}
}
.padding(.bottom, 15)
}
}
}
.padding([.leading, .trailing], 15)
}
})
.frame(width: .infinity)
.background(AllInColors.componentBackgroundColor)
.cornerRadius(10)
}
}
struct DropDownAnswerMenu_Previews: PreviewProvider {
static var previews: some View {
DropDownAnswerMenu(selectedOption: .constant(0), options: [
(0, "questionMarkIcon", 1.2),
(1, "footballIcon", 2.2),
(2, "paintbrushIcon", 3.3)
])
.preferredColorScheme(.dark)
}
}

@ -0,0 +1,29 @@
//
// ParticiationCell.swift
// AllIn
//
// Created by Lucas Delanier on 21/01/2024.
//
import SwiftUI
import Model
struct ParticiationCell: View {
@State var participation: Participation?
var body: some View {
HStack(alignment: .center, spacing: 0){
Circle().frame(width: 30, height: 30).foregroundColor(AllInColors.grey700Color).padding(.trailing, 5)
Text(participation?.user.username ?? "Unknown")
.font(.system(size: 15))
.foregroundStyle(AllInColors.grey100Color)
.fontWeight(.semibold)
Spacer()
Text(participation?.stake.description ?? "NaN")
.font(.system(size: 18))
.foregroundStyle(AllInColors.lightPurpleColor)
.fontWeight(.bold).padding(.trailing, 5)
Image("PurpleAllCoin").resizable().frame(width: 11, height: 12)
}
}
}

@ -6,32 +6,71 @@
//
import SwiftUI
import Model
struct ParticipateButton: View {
@Binding var isOpen : Bool
@Binding var isParticapatedOpen: Bool
@State var bet: Bet?
var isDisabled: Bool {
let endRegisterDate: Date? = bet?.endRegisterDate
if endRegisterDate != nil{
let currentDate = Date()
switch currentDate.compare(endRegisterDate!) {
case .orderedAscending:
return false
case .orderedDescending:
return true
case .orderedSame:
return true
}
} else {
return true
}
}
var body: some View {
Button {
isOpen = true
isParticapatedOpen = true
} label: {
Text("Participer")
.font(.system(size: 30))
.fontWeight(.bold)
.font(.system(size: 27))
.fontWeight(.semibold)
.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)
)
switch isDisabled{
case true:
AllInColors.grey700Color.frame(width: 170)
.mask(
Text("Participer")
.font(.system(size: 27))
.fontWeight(.semibold)
.frame(maxWidth: .infinity).padding(10)
)
case false:
AllInColors.primaryGradient.frame(width: 170)
.mask(
Text("Participer")
.font(.system(size: 27))
.fontWeight(.semibold)
.frame(maxWidth: .infinity).padding(10)
)
}
}
}
.accentColor(AllInColors.componentBackgroundColor)
.buttonStyle(.borderedProminent).cornerRadius(4.0)
.overlay(
RoundedRectangle(cornerRadius: 12).stroke(AllInColors.delimiterGrey, lineWidth: 1)
)
.accentColor(AllInColors.componentBackgroundColor)
.background(isDisabled ? AllInColors.delimiterGrey.opacity(0.5):AllInColors.whiteColor)
.buttonStyle(.borderedProminent).cornerRadius(4.0)
.overlay(
RoundedRectangle(cornerRadius: 12).stroke(AllInColors.delimiterGrey, lineWidth: 1)
)
}.disabled(isDisabled)
}
}

@ -0,0 +1,73 @@
//
// ParticipationModal.swift
// AllIn
//
// Created by Lucas Delanier on 16/01/2024.
//
import SwiftUI
struct ParticipationModal: View {
@State private var selectedOption = 0
@State private var mise: String = ""
let options: [(Int, String, Float)] = [
(0, "OUI", 1.2),
(1, "NON", 3.3),
]
var body: some View {
VStack(alignment: .leading){
HStack{
Spacer()
Rectangle().foregroundStyle(AllInColors.grey800Color).frame(maxWidth: 80, maxHeight: 5).cornerRadius(999)
Spacer()
}.padding(10)
HStack{
Text("Faites vos paris").font(.system(size: 18)).foregroundColor(AllInColors.blackTitleColor).fontWeight(.semibold)
Spacer()
AllcoinsCounter(backgroundColor: AllInColors.purpleAccentColor, foregroundColor: AllInColors.whiteColor)
}
.padding(.leading, 15)
VStack(alignment: .leading){
Text("Emre va réussir son TP de CI/CD mercredi?").font(.system(size: 13)).foregroundColor(AllInColors.grey100Color).fontWeight(.light)
DropDownAnswerMenu(selectedOption: $selectedOption, options: options)
TextField("",text: $mise, prompt: Text("Mise")
.foregroundColor(AllInColors.lightGrey300Color)
.font(.system(size: 14))
.fontWeight(.bold))
.padding()
.keyboardType(.numberPad)
.background(
RoundedRectangle(cornerRadius: 9)
.fill(AllInColors.lightGrey200Color)
.frame(height: 40)
)
.frame(width: .infinity, height: 40)
.foregroundColor(AllInColors.primaryTextColor)
.overlay(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.stroke(AllInColors.delimiterGrey, lineWidth: 1)
)
.padding(.bottom, 5)
}
.padding(15)
Spacer()
VStack{
HStack{
Text("Gains possibles").font(.system(size: 13)).foregroundColor(AllInColors.blackTitleColor).fontWeight(.regular)
Spacer()
Text("231").font(.system(size: 13)).foregroundColor(AllInColors.blackTitleColor).fontWeight(.light)
}.padding(.top, 10).padding(.bottom, 0)
Button {
} label: {
Text("Miser").font(.system(size: 23)).foregroundColor(AllInColors.whiteColor).fontWeight(.bold)
.frame(maxWidth: .infinity).padding(.vertical, 3)
}
.buttonStyle(.borderedProminent).tint(AllInColors.purpleAccentColor)
}.padding(.horizontal, 10).background(AllInColors.whiteColor).border(width: 1, edges: [.top], color: AllInColors.delimiterGrey)
}.background(AllInColors.underComponentBackgroundColor)
}
}

@ -12,6 +12,7 @@ struct RecapBetCard: View {
@GestureState private var longPressTap = false
@State private var isPressed = false
@State var showDetails: Bool = false
@State var showPartipated: Bool = false
var body: some View {
VStack(spacing: 0){
VStack(alignment: .leading,spacing: 2){
@ -107,7 +108,7 @@ struct RecapBetCard: View {
.onTapGesture {
showDetails.toggle()
}.fullScreenCover(isPresented: $showDetails) {
DetailsView(isModalPresented: $showDetails, id: "1")
DetailsView(isModalPresented: $showDetails, isModalParticipated: $showPartipated,id: "1")
}
.gesture(
LongPressGesture(minimumDuration: 0.5)

@ -9,6 +9,7 @@ import SwiftUI
struct ReviewCard: View {
@State var showDetails: Bool = false
@State var showPartipated: Bool = false
var amountBetted: Int
var isAWin: Bool
@ -70,7 +71,7 @@ struct ReviewCard: View {
.onTapGesture {
showDetails.toggle()
}.fullScreenCover(isPresented: $showDetails) {
DetailsView(isModalPresented: $showDetails, id: "1")
DetailsView(isModalPresented: $showDetails, isModalParticipated: $showPartipated, id: "1")
}
}
}

@ -48,7 +48,11 @@ struct AllInColors {
static let componentBackgroundColor = Color("ComponentBackgroundColor")
static let underComponentBackgroundColor = Color("UnderComponentBackgroundColor")
static let winBannerBackground = Color("WinBannerBackground")
static let blackTitleColor = Color("BlackTitleColor")
static let bleue200 = Color("Bleue200")
static let purple200 = Color("Purple200")
static let pink200 = Color("Pink200")
static let pink100 = Color("Pink100")
// Gradients
static let primaryGradient = LinearGradient(
gradient: Gradient(colors: [AllInColors.pinkAccentColor, AllInColors.blueAccentColor]),
@ -61,4 +65,16 @@ struct AllInColors {
endPoint: .top
)
static let BlueBetGradiant = LinearGradient(
gradient: Gradient(colors: [AllInColors.bleue200, AllInColors.purple200]),
startPoint: .leading,
endPoint: .trailing
)
static let PinkBetGradiant = LinearGradient(
gradient: Gradient(colors: [AllInColors.pink100, AllInColors.pink200]),
startPoint: .leading,
endPoint: .trailing
)
}

@ -1,13 +1,57 @@
import SwiftUI
import Model
struct DetailsView: View {
@Binding var isModalPresented: Bool
@Binding var isModalParticipated: Bool
@State var progressValue: Float = 0.2
var isFinished: Bool {
viewModel.betDetail?.finalAnswer == nil ? false : true
}
var isDisabled: Bool {
if let endRegisterDate = viewModel.betDetail?.bet.endRegisterDate {
let currentDate = Date()
switch currentDate.compare(endRegisterDate) {
case .orderedAscending:
return false
case .orderedDescending:
return true
case .orderedSame:
return true
}
} else {
return true
}
}
var StatusValues: (String, Color) {
if let endRegisterDate = viewModel.betDetail?.bet.endRegisterDate {
let currentDate = Date()
switch currentDate.compare(endRegisterDate) {
case .orderedAscending:
return ("En cours...", AllInColors.purpleAccentColor)
case .orderedDescending:
return ("En attente...",AllInColors.pink100)
case .orderedSame:
return ("Fin des inscriptions...",AllInColors.grey50Color)
}
} else {
return ("Statut indisponible", AllInColors.whiteColor)
}
}
var id: String
@StateObject private var viewModel: DetailsViewModel
init(isModalPresented: Binding<Bool>, id: String) {
init(isModalPresented: Binding<Bool>, isModalParticipated: Binding<Bool>,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)
}
}

@ -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 = "<group>"; };
120919192B56DC6C00D0FA29 /* DropDownAnswerMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownAnswerMenu.swift; sourceTree = "<group>"; };
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 = "<group>"; };
123590B32B51792000F7AEBD /* DetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsView.swift; sourceTree = "<group>"; };
@ -107,6 +113,8 @@
123590B72B5541BA00F7AEBD /* ParticipateButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticipateButton.swift; sourceTree = "<group>"; };
1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoricBetView.swift; sourceTree = "<group>"; };
1244EF612B4EC67000374ABF /* ReviewCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewCard.swift; sourceTree = "<group>"; };
12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetLineLoading.swift; sourceTree = "<group>"; };
12C370492B5D5BD000CD9F0F /* ParticiationCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticiationCell.swift; sourceTree = "<group>"; };
EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllcoinsCapsule.swift; sourceTree = "<group>"; };
EC0193792B25C12B005D81E6 /* BetCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetCard.swift; sourceTree = "<group>"; };
EC01937B2B25C2A8005D81E6 /* AllcoinsCounter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllcoinsCounter.swift; sourceTree = "<group>"; };
@ -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 = "<group>";
@ -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;

@ -90,4 +90,8 @@ public class Bet: ObservableObject, Identifiable {
self.author = author
self.registered = registered
}
public func addRegistered(newUser: User){
self.registered.append(newUser)
}
}

@ -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)
}
}

@ -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()
}
}

@ -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)
}
}

Loading…
Cancel
Save