From b4992ba793e66c0716c3fd638067c7ebf053dc14 Mon Sep 17 00:00:00 2001 From: "emre.kartal" Date: Fri, 19 Jan 2024 19:27:30 +0100 Subject: [PATCH] start of binding DetailsView --- .../Contents.json | 0 .../Exclude (1).png | Bin .../AllIn/Components/ReviewCard.swift | 4 +- .../AllIn/ViewModels/DetailsViewModel.swift | 4 +- .../AllInApp/AllIn/Views/DetailsView.swift | 49 ++++++++++-------- 5 files changed, 32 insertions(+), 25 deletions(-) rename Sources/AllInApp/AllIn/Assets.xcassets/{CloseiconRounded.imageset => closeIcon.imageset}/Contents.json (100%) rename Sources/AllInApp/AllIn/Assets.xcassets/{CloseiconRounded.imageset => closeIcon.imageset}/Exclude (1).png (100%) diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/CloseiconRounded.imageset/Contents.json b/Sources/AllInApp/AllIn/Assets.xcassets/closeIcon.imageset/Contents.json similarity index 100% rename from Sources/AllInApp/AllIn/Assets.xcassets/CloseiconRounded.imageset/Contents.json rename to Sources/AllInApp/AllIn/Assets.xcassets/closeIcon.imageset/Contents.json diff --git a/Sources/AllInApp/AllIn/Assets.xcassets/CloseiconRounded.imageset/Exclude (1).png b/Sources/AllInApp/AllIn/Assets.xcassets/closeIcon.imageset/Exclude (1).png similarity index 100% rename from Sources/AllInApp/AllIn/Assets.xcassets/CloseiconRounded.imageset/Exclude (1).png rename to Sources/AllInApp/AllIn/Assets.xcassets/closeIcon.imageset/Exclude (1).png diff --git a/Sources/AllInApp/AllIn/Components/ReviewCard.swift b/Sources/AllInApp/AllIn/Components/ReviewCard.swift index 130e085..2798c36 100644 --- a/Sources/AllInApp/AllIn/Components/ReviewCard.swift +++ b/Sources/AllInApp/AllIn/Components/ReviewCard.swift @@ -37,14 +37,14 @@ struct ReviewCard: View { HStack(){ Spacer() Text(amountBetted.description) - .foregroundColor(AllInColors.whiteColor) + .foregroundColor(.white) .font(.system(size: 25)) .fontWeight(.bold) Image("allcoinWhiteIcon") .resizable() .frame(width: 20, height: 20, alignment: .bottom) Text(isAWin ? "Gagnés!" : "Perdus!") - .foregroundColor(AllInColors.whiteColor) + .foregroundColor(.white) .font(.system(size: 25)) .fontWeight(.bold) Spacer() diff --git a/Sources/AllInApp/AllIn/ViewModels/DetailsViewModel.swift b/Sources/AllInApp/AllIn/ViewModels/DetailsViewModel.swift index d8db75d..e6980e6 100644 --- a/Sources/AllInApp/AllIn/ViewModels/DetailsViewModel.swift +++ b/Sources/AllInApp/AllIn/ViewModels/DetailsViewModel.swift @@ -15,7 +15,7 @@ class DetailsViewModel: ObservableObject { @Inject var manager: Manager var id: String - @Published var bet: BetDetail? + @Published var betDetail: BetDetail? init(id: String) { self.id = id @@ -24,7 +24,7 @@ class DetailsViewModel: ObservableObject { func getItem(withId id: String) { manager.getBet(withId: id) { bet in - self.bet = bet + self.betDetail = bet } } } diff --git a/Sources/AllInApp/AllIn/Views/DetailsView.swift b/Sources/AllInApp/AllIn/Views/DetailsView.swift index f317d0e..2dd996f 100644 --- a/Sources/AllInApp/AllIn/Views/DetailsView.swift +++ b/Sources/AllInApp/AllIn/Views/DetailsView.swift @@ -18,7 +18,7 @@ struct DetailsView: View { VStack(alignment: .trailing) { HStack{ Spacer() - Image("CloseiconRounded") + Image("closeIcon") .resizable() .padding(8) .frame(maxWidth: 40, maxHeight: 40) @@ -35,34 +35,45 @@ struct DetailsView: View { VStack(alignment: .leading,spacing: 5){ HStack{ Spacer() - Text("proposé par Lucas").font(.system(size: 10)).foregroundColor(AllInColors.grey800Color) + Text("proposé par " + (viewModel.betDetail?.bet.author.username ?? "Unknown").capitalized) + .font(.system(size: 10)) + .foregroundColor(AllInColors.grey800Color) } - Text("Etudes").font(.system(size: 15)).foregroundColor(AllInColors.grey800Color) - Text("Emre va réussir son TP de CI/CD mercredi?").font(.system(size: 20)).fontWeight(.bold).padding(.bottom, 10) + Text(viewModel.betDetail?.bet.theme ?? "Not loaded") + .font(.system(size: 15)) + .foregroundColor(AllInColors.grey800Color) + Text(viewModel.betDetail?.bet.phrase ?? "Not loaded") + .font(.system(size: 20)) + .fontWeight(.bold) + .padding(.bottom, 10) HStack{ - Text("Commence le").frame(maxWidth: 100).font(.system(size: 15)).foregroundColor(AllInColors.grey800Color) - TextCapsule(date: Date()) + Text("Commence le") + .frame(maxWidth: 100) + .font(.system(size: 15)) + .foregroundColor(AllInColors.grey800Color) + TextCapsule(date: viewModel.betDetail?.bet.endRegisterDate ?? Date()) Spacer() }.padding(.bottom, 10) HStack{ - Text("Fini le").frame(maxWidth: 100).font(.system(size: 15)).foregroundColor(AllInColors.grey800Color) - TextCapsule(date: Date()) + Text("Fini le") + .frame(maxWidth: 100) + .font(.system(size: 15)) + .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) + .background(AllInColors.componentBackgroundColor) + .cornerRadius(20, corners: [.topLeft,.topRight]).padding(.bottom,0) ResultBanner() - VStack(alignment: .leading,spacing: 2){ - - - + VStack(alignment: .leading, spacing: 2){ } - .frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/, maxHeight : .infinity) + .frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/, maxHeight: .infinity) .padding([.bottom,.trailing,.leading],8) .background(AllInColors.underComponentBackgroundColor) .border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) @@ -71,18 +82,14 @@ struct DetailsView: View { } .frame(maxWidth: .infinity, maxHeight: geometry.size.height*0.98) - .background(Color.white) + .background(AllInColors.componentBackgroundColor) .cornerRadius(15) ParticipateButton().padding(10) } .transition(.slideInFromBottom(yOffset: 800)) + .background(Color.white) + .edgesIgnoringSafeArea(.bottom) } } } - -struct DetailsView_Previews: PreviewProvider { - static var previews: some View { - ContentView() - } -}