feature/bet-ending #19

Merged
emre.kartal merged 3 commits from feature/bet-ending into master 1 year ago

@ -0,0 +1,32 @@
//
// ChoiceFinalAnswerCell.swift
// AllIn
//
// Created by Lucas Delanier on 29/01/2024.
//
import Foundation
import SwiftUI
import Model
struct ChoiceFinalAnswerCell: View {
var selected = false
var answer: AnswerDetail
var rawColor = AllInColors.blueAccentColor
var body: some View {
ZStack{
HStack{
Spacer()
Text(answer.response)
.textStyle(weight: .bold, color: selected ? AllInColors.whiteColor :rawColor, size: 40).padding(.vertical, 10)
Spacer()
}
HStack{
Spacer()
OddCapsule(backgroundColor: selected ? AllInColors.whiteColor : AllInColors.purpleAccentColor, foregroundColor: selected ? AllInColors.purpleAccentColor : AllInColors.whiteColor ,odd: answer.odds ).padding(.trailing,20).scaleEffect(0.9)
}
}.background(selected ? AllInColors.purpleAccentColor : AllInColors.whiteColor).cornerRadius(17)
}
}

@ -0,0 +1,33 @@
//
// OddCapsule.swift
// AllIn
//
// Created by Lucas Delanier on 03/02/2024.
//
import Foundation
import SwiftUI
struct OddCapsule: View {
var backgroundColor: Color = AllInColors.purpleAccentColor
var foregroundColor: Color = AllInColors.whiteColor
var odd: Float = 0.0
var body: some View {
HStack(alignment: .center) {
Text("x\(odd.description)")
.fontWeight(.bold)
.foregroundColor(foregroundColor)
}
.padding(.horizontal, 10)
.padding(.vertical,5)
.background(backgroundColor)
.cornerRadius(9999)
}
}
struct OddCapsule_Previews: PreviewProvider {
static var previews: some View {
AllcoinsCounter()
}
}

@ -6,11 +6,12 @@
// //
import SwiftUI import SwiftUI
import Model
struct ReviewCard: View { struct ReviewCard: View {
@State var showDetails: Bool = false @State var showDetails: Bool = false
@State var showPartipated: Bool = false @State var showPartipated: Bool = false
@State var betDetail: BetDetail
var amountBetted: Int var amountBetted: Int
var isAWin: Bool var isAWin: Bool
var body: some View { var body: some View {
@ -18,14 +19,14 @@ struct ReviewCard: View {
VStack(alignment: .leading,spacing: 2){ VStack(alignment: .leading,spacing: 2){
HStack{ HStack{
Spacer() Spacer()
Text("proposé par Lucas").font(.system(size: 10)).foregroundColor(AllInColors.grey800Color) Text("proposé par \(betDetail.bet.author.username)").font(.system(size: 10)).foregroundColor(AllInColors.grey800Color)
} }
Text("Etudes").font(.system(size: 15)).foregroundColor(AllInColors.grey800Color) Text(betDetail.bet.theme).font(.system(size: 15)).foregroundColor(AllInColors.grey800Color)
Text("Emre va réussir son TP de CI/CD mercredi?").font(.system(size: 20)).fontWeight(.bold) Text(betDetail.bet.phrase).font(.system(size: 20)).fontWeight(.bold)
HStack{ HStack{
Text("Fini le").font(.system(size: 15)).foregroundColor(AllInColors.grey800Color) Text("Fini le").font(.system(size: 15)).foregroundColor(AllInColors.grey800Color)
TextCapsule(date: Date()) TextCapsule(date: betDetail.bet.endBetDate)
Spacer() Spacer()
} }
@ -37,7 +38,13 @@ struct ReviewCard: View {
VStack(alignment: .center,spacing:0){ VStack(alignment: .center,spacing:0){
HStack(){ HStack(){
Spacer() Spacer()
Text(amountBetted.description) if(betDetail.bet.isFinish()){
Text("Terminé")
.foregroundColor(.white)
.font(.system(size: 25))
.fontWeight(.bold)
}
else{Text(amountBetted.description)
.foregroundColor(.white) .foregroundColor(.white)
.font(.system(size: 25)) .font(.system(size: 25))
.fontWeight(.bold) .fontWeight(.bold)
@ -48,6 +55,7 @@ struct ReviewCard: View {
.foregroundColor(.white) .foregroundColor(.white)
.font(.system(size: 25)) .font(.system(size: 25))
.fontWeight(.bold) .fontWeight(.bold)
}
Spacer() Spacer()
} }
@ -62,7 +70,7 @@ struct ReviewCard: View {
.frame(width: .infinity) .frame(width: .infinity)
.padding(.all,2) .padding(.all,2)
.background( .background(
isAWin ? isAWin || betDetail.bet.isFinish() ?
AnyView(AllInColors.primaryGradient) : AnyView(AllInColors.primaryGradient) :
AnyView(Color.black) AnyView(Color.black)
) .cornerRadius(20, corners: [.bottomLeft,.bottomRight]) ) .cornerRadius(20, corners: [.bottomLeft,.bottomRight])

@ -78,7 +78,7 @@ struct InfiniteScroller<Content: View>: View {
content() content()
content() content()
} }
.offset(x: xOffset, y: 0) .offset(x: xOffset, y: 0).opacity(0.3)
} }
.disabled(true) .disabled(true)
.onAppear { .onAppear {
@ -89,9 +89,9 @@ struct InfiniteScroller<Content: View>: View {
xOffset = +contentWidth xOffset = +contentWidth
} }
} }
.frame(width: 1000, height: 1000) .frame(width: 1300, height: 1300)
.padding(.leading, -400) .padding(.leading, -400)
.rotationEffect(.degrees(30)) .rotationEffect(.degrees(30))
.opacity(0.04) .opacity(0.1)
} }
} }

@ -7,10 +7,14 @@
import Foundation import Foundation
import SwiftUI import SwiftUI
import Model
import StubLib
struct BetEndingValidation: View { struct BetEndingValidation: View {
@Environment(\.dismiss) var dismiss @Environment(\.dismiss) var dismiss
@State var xOffset: CGFloat = 0 @State var xOffset: CGFloat = 0
@State var selectedAnswer : String?
var bet: BetDetail = BetStubManager().getABetDetail()
var body: some View { var body: some View {
ZStack{ ZStack{
GeometryReader { geometry in GeometryReader { geometry in
@ -32,18 +36,42 @@ struct BetEndingValidation: View {
} }
} }
HStack{ ReviewCard(betDetail: bet, amountBetted: 0, isAWin: false).padding(.top, 20).padding(.bottom, 10)
Text("FÉLICITATIONS").font(.system(size: 20)).foregroundColor(.white).fontWeight(.semibold).italic() Text("Ce bet est arrivé à la date de fin. Vous devez à présent distribuer les gains en validant le pari gagnant.")
Text("PSEUDO!").padding(.top,9).font(.system(size: 33)).fontWeight(.heavy).foregroundColor(.white) .textStyle(weight: .regular, color: AllInColors.grey800Color, size: 13).multilineTextAlignment(.center)
Text("Veuillez choisir la réponse finale:")
.font(.system(size: 17))
.foregroundStyle(AllInColors.whiteColor)
.fontWeight(.bold)
.padding(.top, 30)
.padding(.bottom, 10)
.frame(maxWidth: .infinity, alignment: .leading)
VStack(spacing: 14){
ForEach(bet.answers, id: \.self) { answer in
ChoiceFinalAnswerCell(selected : answer.response == selectedAnswer, answer: answer).onTapGesture {
if(selectedAnswer == answer.response){
selectedAnswer = nil
}
else {
selectedAnswer = answer.response
}
}
}
} }
.rotationEffect(.degrees(-4))
.padding(.top,40)
Spacer()
AllcoinsCapsule()
Spacer()
RecapBetCard()
Spacer() Spacer()
selectedAnswer != nil ? Button {
dismiss()
} label: {
Text("Valider")
.font(.system(size: 23))
.foregroundColor(AllInColors.whiteColor)
.fontWeight(.bold)
.frame(maxWidth: .infinity)
.padding(.vertical, 3)
}
.buttonStyle(.borderedProminent)
.tint(AllInColors.purpleAccentColor)
: nil
} }
.padding([.all],20) .padding([.all],20)
} }
@ -52,3 +80,5 @@ struct BetEndingValidation: View {
} }
} }

@ -58,7 +58,7 @@ struct BetView: View {
viewModel.getItems() viewModel.getItems()
} }
.sheet(isPresented: $showingSheet) { .sheet(isPresented: $showingSheet) {
WinModal() BetEndingValidation()
} }
Spacer() Spacer()
} }

@ -23,8 +23,8 @@ struct HistoricBetView: View {
.textStyle(weight: .bold, color: AllInColors.grey500Color, size: 25) .textStyle(weight: .bold, color: AllInColors.grey500Color, size: 25)
.padding([.top],15) .padding([.top],15)
VStack(spacing: 20){ VStack(spacing: 20){
ReviewCard(amountBetted: 110, isAWin: true) // ReviewCard(amountBetted: 110, isAWin: true)
ReviewCard(amountBetted: 3, isAWin: false) // ReviewCard(amountBetted: 3, isAWin: false)
} }
.padding([.trailing, .leading, .bottom],25) .padding([.trailing, .leading, .bottom],25)
} }

@ -10,11 +10,13 @@
120919182B56D0AE00D0FA29 /* ParticipationModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 120919172B56D0AE00D0FA29 /* ParticipationModal.swift */; }; 120919182B56D0AE00D0FA29 /* ParticipationModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 120919172B56D0AE00D0FA29 /* ParticipationModal.swift */; };
1209191A2B56DC6C00D0FA29 /* DropDownAnswerMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 120919192B56DC6C00D0FA29 /* DropDownAnswerMenu.swift */; }; 1209191A2B56DC6C00D0FA29 /* DropDownAnswerMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 120919192B56DC6C00D0FA29 /* DropDownAnswerMenu.swift */; };
123225D92B67B46100D30BB3 /* BetEndingValidationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123225D82B67B46100D30BB3 /* BetEndingValidationView.swift */; }; 123225D92B67B46100D30BB3 /* BetEndingValidationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123225D82B67B46100D30BB3 /* BetEndingValidationView.swift */; };
123225DB2B67E41400D30BB3 /* ChoiceFinalAnswerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123225DA2B67E41400D30BB3 /* ChoiceFinalAnswerCell.swift */; };
123590B42B51792000F7AEBD /* DetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B32B51792000F7AEBD /* DetailsView.swift */; }; 123590B42B51792000F7AEBD /* DetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B32B51792000F7AEBD /* DetailsView.swift */; };
123590B62B5537E200F7AEBD /* ResultBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B52B5537E200F7AEBD /* ResultBanner.swift */; }; 123590B62B5537E200F7AEBD /* ResultBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B52B5537E200F7AEBD /* ResultBanner.swift */; };
123590B82B5541BA00F7AEBD /* ParticipateButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B72B5541BA00F7AEBD /* ParticipateButton.swift */; }; 123590B82B5541BA00F7AEBD /* ParticipateButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B72B5541BA00F7AEBD /* ParticipateButton.swift */; };
1244EF602B4EC31E00374ABF /* HistoricBetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */; }; 1244EF602B4EC31E00374ABF /* HistoricBetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */; };
1244EF622B4EC67000374ABF /* ReviewCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF612B4EC67000374ABF /* ReviewCard.swift */; }; 1244EF622B4EC67000374ABF /* ReviewCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF612B4EC67000374ABF /* ReviewCard.swift */; };
129D051D2B6E7FF0003D3E08 /* OddCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 129D051C2B6E7FF0003D3E08 /* OddCapsule.swift */; };
12C370482B5A5EE500CD9F0F /* BetLineLoading.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */; }; 12C370482B5A5EE500CD9F0F /* BetLineLoading.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */; };
12C3704A2B5D5BD000CD9F0F /* ParticiationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C370492B5D5BD000CD9F0F /* ParticiationCell.swift */; }; 12C3704A2B5D5BD000CD9F0F /* ParticiationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C370492B5D5BD000CD9F0F /* ParticiationCell.swift */; };
EC0193782B25BF16005D81E6 /* AllcoinsCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */; }; EC0193782B25BF16005D81E6 /* AllcoinsCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */; };
@ -110,11 +112,13 @@
122278B72B4BDE1100E632AA /* DependencyInjection.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = DependencyInjection.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 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>"; }; 122278B92B4BDE9500E632AA /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../Model/Package.swift; sourceTree = "<group>"; };
123225D82B67B46100D30BB3 /* BetEndingValidationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetEndingValidationView.swift; sourceTree = "<group>"; }; 123225D82B67B46100D30BB3 /* BetEndingValidationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetEndingValidationView.swift; sourceTree = "<group>"; };
123225DA2B67E41400D30BB3 /* ChoiceFinalAnswerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChoiceFinalAnswerCell.swift; sourceTree = "<group>"; };
123590B32B51792000F7AEBD /* DetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsView.swift; sourceTree = "<group>"; }; 123590B32B51792000F7AEBD /* DetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsView.swift; sourceTree = "<group>"; };
123590B52B5537E200F7AEBD /* ResultBanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultBanner.swift; sourceTree = "<group>"; }; 123590B52B5537E200F7AEBD /* ResultBanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultBanner.swift; sourceTree = "<group>"; };
123590B72B5541BA00F7AEBD /* ParticipateButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticipateButton.swift; sourceTree = "<group>"; }; 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>"; }; 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>"; }; 1244EF612B4EC67000374ABF /* ReviewCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewCard.swift; sourceTree = "<group>"; };
129D051C2B6E7FF0003D3E08 /* OddCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OddCapsule.swift; sourceTree = "<group>"; };
12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetLineLoading.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>"; }; 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>"; }; EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllcoinsCapsule.swift; sourceTree = "<group>"; };
@ -341,6 +345,8 @@
120919192B56DC6C00D0FA29 /* DropDownAnswerMenu.swift */, 120919192B56DC6C00D0FA29 /* DropDownAnswerMenu.swift */,
12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */, 12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */,
12C370492B5D5BD000CD9F0F /* ParticiationCell.swift */, 12C370492B5D5BD000CD9F0F /* ParticiationCell.swift */,
123225DA2B67E41400D30BB3 /* ChoiceFinalAnswerCell.swift */,
129D051C2B6E7FF0003D3E08 /* OddCapsule.swift */,
); );
path = Components; path = Components;
sourceTree = "<group>"; sourceTree = "<group>";
@ -540,6 +546,8 @@
EC30770D2B24DB7A0060E34D /* Extensions.swift in Sources */, EC30770D2B24DB7A0060E34D /* Extensions.swift in Sources */,
EC6B96D82B24BF2100FC1C58 /* Menu.swift in Sources */, EC6B96D82B24BF2100FC1C58 /* Menu.swift in Sources */,
EC650A4E2B278EDB003AFCAD /* TrendingBetCard.swift in Sources */, EC650A4E2B278EDB003AFCAD /* TrendingBetCard.swift in Sources */,
123225DB2B67E41400D30BB3 /* ChoiceFinalAnswerCell.swift in Sources */,
129D051D2B6E7FF0003D3E08 /* OddCapsule.swift in Sources */,
123225D92B67B46100D30BB3 /* BetEndingValidationView.swift in Sources */, 123225D92B67B46100D30BB3 /* BetEndingValidationView.swift in Sources */,
EC0193782B25BF16005D81E6 /* AllcoinsCapsule.swift in Sources */, EC0193782B25BF16005D81E6 /* AllcoinsCapsule.swift in Sources */,
EC650A4A2B25DD58003AFCAD /* FriendsView.swift in Sources */, EC650A4A2B25DD58003AFCAD /* FriendsView.swift in Sources */,

@ -8,7 +8,7 @@
import Foundation import Foundation
/// A class representing detailed information about a specific answer option for a bet. /// A class representing detailed information about a specific answer option for a bet.
public class AnswerDetail: ObservableObject { public class AnswerDetail: ObservableObject, Hashable {
/// The response or outcome associated with this answer. /// The response or outcome associated with this answer.
public private(set) var response: String public private(set) var response: String
@ -40,4 +40,17 @@ public class AnswerDetail: ObservableObject {
self.highestStake = highestStake self.highestStake = highestStake
self.odds = odds self.odds = odds
} }
public func hash(into hasher: inout Hasher) {
// Use properties that define the uniqueness of the instance for hashing
hasher.combine(response)
// ... (combine other properties)
}
public static func == (lhs: AnswerDetail, rhs: AnswerDetail) -> Bool {
// Check equality based on properties
return lhs.response == rhs.response
// ... (check other properties)
}
} }

@ -98,4 +98,8 @@ public class Bet: ObservableObject, Identifiable {
public func addRegistered(newUser: User){ public func addRegistered(newUser: User){
self.registered.append(newUser) self.registered.append(newUser)
} }
public func isFinish() -> Bool{
self.endBetDate < Date()
}
} }

@ -29,4 +29,8 @@ public struct BetStubManager: BetDataManager {
} }
} }
public func getABetDetail() -> BetDetail{
Stub.shared.betsDetail.first!
}
} }

@ -85,7 +85,7 @@ struct Stub {
self.bets.append(bet4) self.bets.append(bet4)
for bet in bets { for bet in bets {
let betDetail = BetDetail(bet: bet, answers: [], participations: []) let betDetail = BetDetail(bet: bet, answers: [AnswerDetail(response: "OUI", totalStakes: 120, totalParticipants: 2, highestStake: 200, odds: 1.2), AnswerDetail(response: "NON", totalStakes: 120, totalParticipants: 2, highestStake: 200, odds: 1.2)], participations: [])
self.betsDetail.append(betDetail) self.betsDetail.append(betDetail)
} }

Loading…
Cancel
Save