From d5e50e41681b775ae74e490d8df542087dde8f3b Mon Sep 17 00:00:00 2001 From: ludelanier Date: Tue, 11 Jun 2024 14:14:56 +0200 Subject: [PATCH] fix multiple issues with floats, responsive etc --- .../AllIn/Components/BinaryBetLine.swift | 4 +-- .../AllIn/Components/CustomBetLine.swift | 2 +- .../AllIn/Components/DropDownAnswerMenu.swift | 4 +-- .../AllIn/Components/OddCapsule.swift | 2 +- .../AllIn/Components/RecapBetCard.swift | 5 ++-- .../AllIn/Components/ResultBanner.swift | 8 ++--- .../AllIn/Components/ReviewCard.swift | 16 +++++----- .../AllIn/ViewModels/BetViewModel.swift | 3 +- .../AllInApp/AllIn/Views/DetailsView.swift | 4 ++- .../AllInApp/AllIn/Views/FriendsView.swift | 30 +++++++++++-------- 10 files changed, 44 insertions(+), 34 deletions(-) diff --git a/Sources/AllInApp/AllIn/Components/BinaryBetLine.swift b/Sources/AllInApp/AllIn/Components/BinaryBetLine.swift index 68fb4ab..cdc8932 100644 --- a/Sources/AllInApp/AllIn/Components/BinaryBetLine.swift +++ b/Sources/AllInApp/AllIn/Components/BinaryBetLine.swift @@ -52,13 +52,13 @@ struct BinaryBetLine: View { HStack{ Spacer() Rectangle() - .frame(width: min(CGFloat(1-self.value) * geometry.size.width, geometry.size.width), height: 17) + .frame(width: min(CGFloat(1-self.value) * geometry.size.width, geometry.size.width-20), 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) + .frame(width: min(CGFloat(self.value) * geometry.size.width, geometry.size.width-20), height: 17) .foregroundStyle(AllInColors.BlueBetGradiant) .cornerRadius(999) Image("loadingHeartIcon") diff --git a/Sources/AllInApp/AllIn/Components/CustomBetLine.swift b/Sources/AllInApp/AllIn/Components/CustomBetLine.swift index e452c5e..f23b814 100644 --- a/Sources/AllInApp/AllIn/Components/CustomBetLine.swift +++ b/Sources/AllInApp/AllIn/Components/CustomBetLine.swift @@ -57,7 +57,7 @@ struct CustomBetLine: View { ZStack(alignment: .leading) { HStack(spacing: 0) { Rectangle() - .frame(width: min(percentage * geometry.size.width, geometry.size.width), height: 17) + .frame(width: min(percentage * geometry.size.width, geometry.size.width-20), height: 17) .foregroundStyle(getGradiant(for: answer)) .cornerRadius(999, corners: [.topLeft, .bottomLeft]) Image(getFlameImage(for: answer)) diff --git a/Sources/AllInApp/AllIn/Components/DropDownAnswerMenu.swift b/Sources/AllInApp/AllIn/Components/DropDownAnswerMenu.swift index f0c39a7..91f009b 100644 --- a/Sources/AllInApp/AllIn/Components/DropDownAnswerMenu.swift +++ b/Sources/AllInApp/AllIn/Components/DropDownAnswerMenu.swift @@ -20,7 +20,7 @@ struct DropDownAnswerMenu: View { HStack{ Text(selectedAnswer.response) .textStyle(weight: .bold, color: AllInColors.blueAccentColor, size: 20) - Text(selectedAnswer.odds.description) + Text("\(selectedAnswer.odds, specifier: "%.2f")") .textStyle(weight: .bold, color: AllInColors.lightPurpleColor, size: 10) Spacer() @@ -44,7 +44,7 @@ struct DropDownAnswerMenu: View { HStack{ Text(answer.response) .textStyle(weight: .bold, color: AllInColors.blueAccentColor, size: 20) - Text(answer.odds.description) + Text("\(answer.odds, specifier: "%.2f")") .textStyle(weight: .bold, color: AllInColors.lightPurpleColor, size: 10) Spacer() } diff --git a/Sources/AllInApp/AllIn/Components/OddCapsule.swift b/Sources/AllInApp/AllIn/Components/OddCapsule.swift index 67844dd..a658e29 100644 --- a/Sources/AllInApp/AllIn/Components/OddCapsule.swift +++ b/Sources/AllInApp/AllIn/Components/OddCapsule.swift @@ -14,7 +14,7 @@ struct OddCapsule: View { var odd: Float = 0.0 var body: some View { HStack(alignment: .center) { - Text("x\(odd.description)") + Text("x\(odd, specifier: "%.2f")") .fontWeight(.bold) .foregroundColor(foregroundColor) } diff --git a/Sources/AllInApp/AllIn/Components/RecapBetCard.swift b/Sources/AllInApp/AllIn/Components/RecapBetCard.swift index fc52509..ead4c59 100644 --- a/Sources/AllInApp/AllIn/Components/RecapBetCard.swift +++ b/Sources/AllInApp/AllIn/Components/RecapBetCard.swift @@ -73,7 +73,7 @@ struct RecapBetCard: View { .overlay { AllInColors.primaryGradient.frame(width: 50) .mask( - Text("1630").font(.system(size: 15)).fontWeight(.medium) + Text(betResult.amount.description).font(.system(size: 15)).fontWeight(.medium) ) } .padding(0) @@ -89,7 +89,8 @@ struct RecapBetCard: View { HStack{ Text("Côte totale").font(.system(size: 15)).fontWeight(.medium) Spacer() - Text("3,46") + // TODO bind le odd + Text("1,0") .textStyle(weight: .bold, color: .white, size: 18) .padding([.leading,.trailing],10) .padding([.top,.bottom],5) diff --git a/Sources/AllInApp/AllIn/Components/ResultBanner.swift b/Sources/AllInApp/AllIn/Components/ResultBanner.swift index b29f321..74bbda7 100644 --- a/Sources/AllInApp/AllIn/Components/ResultBanner.swift +++ b/Sources/AllInApp/AllIn/Components/ResultBanner.swift @@ -19,16 +19,16 @@ struct ResultBanner: View { }.frame(height: 80) HStack(spacing: 20){ HStack{ - Image("BlueAllCoinIcon").resizable().frame(maxWidth: 12, maxHeight: 12) + Image("blueAllCoinIcon").resizable().frame(maxWidth: 12, maxHeight: 12) Text(finalAnswer.stake.description).font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color) } HStack{ - Image("BleuePersonIcon").resizable().frame(maxWidth: 15, maxHeight: 12) + Image("bluePersonIcon").resizable().frame(maxWidth: 15, maxHeight: 12) Text(finalAnswer.username).font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color) } HStack{ - Image("BleueTrophyIcon").resizable().frame(maxWidth: 15, maxHeight: 12) - Text(odds.description).font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color) + Image("blueTrophyIcon").resizable().frame(maxWidth: 15, maxHeight: 12) + Text("\(odds, specifier: "%.2f")").font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color) } } } diff --git a/Sources/AllInApp/AllIn/Components/ReviewCard.swift b/Sources/AllInApp/AllIn/Components/ReviewCard.swift index c04b9d3..47a3263 100644 --- a/Sources/AllInApp/AllIn/Components/ReviewCard.swift +++ b/Sources/AllInApp/AllIn/Components/ReviewCard.swift @@ -42,13 +42,15 @@ struct ReviewCard: View { VStack(alignment: .center,spacing:0){ HStack(){ Spacer() - Text(amount.description) - .foregroundColor(.white) - .font(.system(size: 25)) - .fontWeight(.bold) - Image("allcoinWhiteIcon") - .resizable() - .frame(width: 18, height: 20) + if bet.status == .finished { + Text(amount.description) + .foregroundColor(.white) + .font(.system(size: 25)) + .fontWeight(.bold) + Image("allcoinWhiteIcon") + .resizable() + .frame(width: 18, height: 20) + } switch bet.status { case .waiting, .inProgress: diff --git a/Sources/AllInApp/AllIn/ViewModels/BetViewModel.swift b/Sources/AllInApp/AllIn/ViewModels/BetViewModel.swift index 553c951..0169f35 100644 --- a/Sources/AllInApp/AllIn/ViewModels/BetViewModel.swift +++ b/Sources/AllInApp/AllIn/ViewModels/BetViewModel.swift @@ -13,7 +13,7 @@ import Combine class BetViewModel: ObservableObject { @Inject var manager: Manager - + @Inject var authService: IAuthService @Published var popularBet: Bet? @Published private(set) var bets: [Bet] = [] @Published var betsOver: [BetDetail] = [] @@ -58,6 +58,7 @@ class BetViewModel: ObservableObject { self.betsWon = bets if !self.betsWon.isEmpty { self.showingSheetWon = true + self.authService.refreshAuthentication() } } } diff --git a/Sources/AllInApp/AllIn/Views/DetailsView.swift b/Sources/AllInApp/AllIn/Views/DetailsView.swift index 3472e83..8104a9f 100644 --- a/Sources/AllInApp/AllIn/Views/DetailsView.swift +++ b/Sources/AllInApp/AllIn/Views/DetailsView.swift @@ -6,6 +6,7 @@ struct DetailsView: View { @Binding var isModalPresented: Bool @Binding var isModalParticipated: Bool @StateObject private var viewModel: DetailsViewModel + @State private var isLoading = true var isFinished: Bool { viewModel.betDetail?.wonParticipation == nil ? false : true @@ -59,7 +60,7 @@ struct DetailsView: View { .background(StatusValues.1) if viewModel.betDetail != nil{ ScrollView { - VStack(alignment: .leading, spacing: 5) { + VStack(alignment: .leading, spacing: 0) { HStack(spacing: 3) { Spacer() Text("bet_proposed_by_format") @@ -132,6 +133,7 @@ struct DetailsView: View { Spacer() } .padding([.trailing,.leading], 15) + .padding(.bottom, 100) } .frame(maxWidth: .infinity, maxHeight: (geometry.size.height + geometry.safeAreaInsets.bottom) - 50) diff --git a/Sources/AllInApp/AllIn/Views/FriendsView.swift b/Sources/AllInApp/AllIn/Views/FriendsView.swift index e1240d3..8ad9dbd 100644 --- a/Sources/AllInApp/AllIn/Views/FriendsView.swift +++ b/Sources/AllInApp/AllIn/Views/FriendsView.swift @@ -64,22 +64,26 @@ struct FriendsView: View { } .padding(.top, 50) .tag(0) - VStack(alignment: .center, spacing: 0) { - if(viewModel.requests.isEmpty){ - EmptyInfo(emoji:"📬", title: "Aucune demande d'amis en attente", explain: "").padding(.top, 40) - } - else{ - ScrollView(showsIndicators: false){ - ForEach(viewModel.requests, id: \.self) { request in - Friend(user: request, isRequest: true, viewModel: viewModel) - } + ScrollView{ + VStack(alignment: .center, spacing: 0) { + if(viewModel.requests.isEmpty){ + EmptyInfo(emoji:"📬", title: "Aucune demande d'amis en attente", explain: "").padding(.top, 40) } - .refreshable { - viewModel.getRequests() + else{ + ScrollView(showsIndicators: false){ + ForEach(viewModel.requests, id: \.self) { request in + Friend(user: request, isRequest: true, viewModel: viewModel) + } + } + .refreshable { + viewModel.getRequests() + } + .padding(.top, 25) } - .padding(.top, 25) + Spacer() } - Spacer() + }.refreshable { + viewModel.getRequests() } .padding(.top, 50) .tag(1)