diff --git a/Sources/AllInApp/AllIn/Components/AllcoinsCapsule.swift b/Sources/AllInApp/AllIn/Components/AllcoinsCapsule.swift index 0fc7a7c..26c5584 100644 --- a/Sources/AllInApp/AllIn/Components/AllcoinsCapsule.swift +++ b/Sources/AllInApp/AllIn/Components/AllcoinsCapsule.swift @@ -8,11 +8,12 @@ import SwiftUI struct AllcoinsCapsule: View { + var gains: Int var body: some View { Text("Vous remportez") .foregroundColor(.white) HStack{ - Text("2340") + Text(gains.description) .textStyle(weight: .bold, color: .white, size: 60) Image("allcoinWhiteIcon") .resizable() @@ -30,6 +31,6 @@ struct AllcoinsCapsule: View { struct AllcoinsCapsule_Previews: PreviewProvider { static var previews: some View { - AllcoinsCapsule() + AllcoinsCapsule(gains: 100) } } diff --git a/Sources/AllInApp/AllIn/Components/RecapBetCard.swift b/Sources/AllInApp/AllIn/Components/RecapBetCard.swift index 15e0e73..fc52509 100644 --- a/Sources/AllInApp/AllIn/Components/RecapBetCard.swift +++ b/Sources/AllInApp/AllIn/Components/RecapBetCard.swift @@ -6,9 +6,11 @@ // import SwiftUI +import Model struct RecapBetCard: View { + var betResult: BetResultDetail @GestureState private var longPressTap = false @State private var isPressed = false @State var showDetails: Bool = false @@ -19,22 +21,22 @@ struct RecapBetCard: View { VStack(alignment: .leading,spacing: 2){ HStack{ Spacer() - Text("bet_proposed_by_format \("Lucas")") + Text("bet_proposed_by_format \(betResult.bet.author)") .font(.system(size: 10)) .foregroundColor(AllInColors.grey800Color) } - Text("Etudes") + Text(betResult.bet.theme) .font(.system(size: 15)) .foregroundColor(AllInColors.grey800Color) - Text("Emre va réussir son TP de CI/CD mercredi?") + Text(betResult.bet.phrase) .font(.system(size: 20)) .fontWeight(.bold) HStack{ Text("bet_ends") .font(.system(size: 15)) .foregroundColor(AllInColors.grey800Color) - TextCapsule(date: Date()) + TextCapsule(date: betResult.bet.endBetDate) Spacer() } } @@ -48,7 +50,7 @@ struct RecapBetCard: View { Text("Mise") .textStyle(weight: .regular, color: AllInColors.grey800Color, size: 15) Spacer() - Text("1630") + Text(betResult.participation.stake.description) .textStyle(weight: .regular, color: AllInColors.grey800Color, size: 15) Image("Allcoins") .resizable() @@ -65,7 +67,7 @@ struct RecapBetCard: View { Text("Gains") .textStyle(weight: .medium, color: AllInColors.lightPurpleColor, size: 15) Spacer() - Text("1630") + Text(betResult.amount.description) .font(.system(size: 15)) .fontWeight(.medium) .overlay { @@ -108,7 +110,7 @@ struct RecapBetCard: View { .onTapGesture { showDetails.toggle() }.fullScreenCover(isPresented: $showDetails) { - DetailsView(isModalPresented: $showDetails, isModalParticipated: $showPartipated,id: "1") + DetailsView(isModalPresented: $showDetails, isModalParticipated: $showPartipated, id: betResult.bet.id) } .gesture( LongPressGesture(minimumDuration: 0.5) @@ -118,10 +120,3 @@ struct RecapBetCard: View { ) } } - -struct RecapBetCard_Previews: PreviewProvider { - static var previews: some View { - RecapBetCard() - .preferredColorScheme(.dark) - } -} diff --git a/Sources/AllInApp/AllIn/Components/WinModal.swift b/Sources/AllInApp/AllIn/Components/WinModal.swift index 85544a8..7fed4b6 100644 --- a/Sources/AllInApp/AllIn/Components/WinModal.swift +++ b/Sources/AllInApp/AllIn/Components/WinModal.swift @@ -6,9 +6,11 @@ // import SwiftUI +import Model struct WinModal: View { @Environment(\.dismiss) var dismiss + var betResult: BetResultDetail @State var xOffset: CGFloat = 0 var body: some View { @@ -35,15 +37,15 @@ struct WinModal: View { } HStack{ Text("FÉLICITATIONS").font(.system(size: 20)).foregroundColor(.white).fontWeight(.semibold).italic() - Text("PSEUDO!").padding(.top,9).font(.system(size: 33)).fontWeight(.heavy).foregroundColor(.white) + Text(AppStateContainer.shared.user?.username ?? "").padding(.top,9).font(.system(size: 33)).fontWeight(.heavy).foregroundColor(.white) } .rotationEffect(.degrees(-4)) .padding(.top,40) Spacer() - AllcoinsCapsule() + AllcoinsCapsule(gains: betResult.amount) Spacer() - RecapBetCard() + RecapBetCard(betResult: betResult) Spacer() } .padding([.all],20) @@ -58,12 +60,6 @@ struct WinModal: View { } } -struct WinModal_Previews: PreviewProvider { - static var previews: some View { - WinModal() - } -} - struct InfiniteScroller: View { var contentWidth: CGFloat var content: (() -> Content) diff --git a/Sources/AllInApp/AllIn/ViewModels/BetViewModel.swift b/Sources/AllInApp/AllIn/ViewModels/BetViewModel.swift index 6f0b004..553c951 100644 --- a/Sources/AllInApp/AllIn/ViewModels/BetViewModel.swift +++ b/Sources/AllInApp/AllIn/ViewModels/BetViewModel.swift @@ -30,6 +30,7 @@ class BetViewModel: ObservableObject { getItems() getPopularBet() getBetsOver() + getBetsWon() } func getItems() { diff --git a/Sources/AllInApp/AllIn/Views/BetView.swift b/Sources/AllInApp/AllIn/Views/BetView.swift index c35d15b..e68a893 100644 --- a/Sources/AllInApp/AllIn/Views/BetView.swift +++ b/Sources/AllInApp/AllIn/Views/BetView.swift @@ -72,7 +72,7 @@ struct BetView: View { viewModel.showingSheetWon = !viewModel.betsWon.isEmpty }) { if let firstBetResultDetail = viewModel.betsWon.first { - WinModal() + WinModal(betResult: firstBetResultDetail) } } Spacer() diff --git a/Sources/Api/Sources/Api/UserApiManager.swift b/Sources/Api/Sources/Api/UserApiManager.swift index 65e4585..fad5cae 100644 --- a/Sources/Api/Sources/Api/UserApiManager.swift +++ b/Sources/Api/Sources/Api/UserApiManager.swift @@ -67,11 +67,14 @@ public struct UserApiManager: UserDataManager { print ("ALLIN : get bets won") do { if let httpResponse = response as? HTTPURLResponse, let jsonArray = try JSONSerialization.jsonObject(with: data, options: []) as? [[String: Any]] { + print(jsonArray) for json in jsonArray { if let bet = FactoryApiBet().toBetResultDetail(from: json) { + print(bet) bets.append(bet) } } + print(httpResponse.statusCode) completion(bets) }