fix marquee

feature/bet-ending
Lucas DELANIER 1 year ago
parent 32202d8860
commit 1e7f0aa521

@ -7,21 +7,20 @@
import Foundation import Foundation
import SwiftUI import SwiftUI
import Model
struct ChoiceFinalAnswerCell: View { struct ChoiceFinalAnswerCell: View {
@State var selected = false var selected = false
var value = "OUI" var answer: AnswerDetail
var rawColor = AllInColors.blueAccentColor var rawColor = AllInColors.blueAccentColor
var body: some View { var body: some View {
HStack{ HStack{
Spacer() Spacer()
Text(value) Text(answer.response)
.textStyle(weight: .bold, color:rawColor, size: 40).padding(.vertical, 10) .textStyle(weight: .bold, color: selected ? AllInColors.whiteColor :rawColor, size: 40).padding(.vertical, 10)
Spacer() Spacer()
}.background(AllInColors.whiteColor).onTapGesture() { }.background(selected ? AllInColors.purpleAccentColor : AllInColors.whiteColor).cornerRadius(17)
selected.toggle()
}.cornerRadius(17)
} }
} }

@ -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,17 +38,24 @@ struct ReviewCard: View {
VStack(alignment: .center,spacing:0){ VStack(alignment: .center,spacing:0){
HStack(){ HStack(){
Spacer() Spacer()
Text(amountBetted.description) if(betDetail.bet.isFinish()){
.foregroundColor(.white) Text("Terminé")
.font(.system(size: 25)) .foregroundColor(.white)
.fontWeight(.bold) .font(.system(size: 25))
Image("allcoinWhiteIcon") .fontWeight(.bold)
.resizable() }
.frame(width: 20, height: 20, alignment: .bottom) else{Text(amountBetted.description)
Text(isAWin ? "Gagnés!" : "Perdus!") .foregroundColor(.white)
.foregroundColor(.white) .font(.system(size: 25))
.font(.system(size: 25)) .fontWeight(.bold)
.fontWeight(.bold) Image("allcoinWhiteIcon")
.resizable()
.frame(width: 20, height: 20, alignment: .bottom)
Text(isAWin ? "Gagnés!" : "Perdus!")
.foregroundColor(.white)
.font(.system(size: 25))
.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,17 +36,23 @@ 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 {
selectedAnswer = answer.response
}
}
} }
.rotationEffect(.degrees(-4))
.padding(.top,40)
Spacer()
AllcoinsCapsule()
Spacer()
RecapBetCard()
Spacer() Spacer()
} }
.padding([.all],20) .padding([.all],20)
@ -52,3 +62,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,6 +10,7 @@
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 */; };
@ -110,6 +111,7 @@
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>"; };
@ -341,6 +343,7 @@
120919192B56DC6C00D0FA29 /* DropDownAnswerMenu.swift */, 120919192B56DC6C00D0FA29 /* DropDownAnswerMenu.swift */,
12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */, 12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */,
12C370492B5D5BD000CD9F0F /* ParticiationCell.swift */, 12C370492B5D5BD000CD9F0F /* ParticiationCell.swift */,
123225DA2B67E41400D30BB3 /* ChoiceFinalAnswerCell.swift */,
); );
path = Components; path = Components;
sourceTree = "<group>"; sourceTree = "<group>";
@ -540,6 +543,7 @@
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 */,
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,8 +8,8 @@
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