From a0f28e6a1176936c7fc9825c800c74caac343737 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 4 Mar 2026 23:33:36 -0500 Subject: [PATCH 1/3] Warning message fixes --- .DS_Store | Bin 10244 -> 10244 bytes Resell.xcodeproj/project.pbxproj | 6 +----- .../xcshareddata/xcschemes/Resell.xcscheme | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.DS_Store b/.DS_Store index d0f926495972895ecf3a3ecda0c364cef9f64f33..bcdeb61107ae379c80a432939ad4383b750d0773 100644 GIT binary patch delta 37 qcmZn(XbG6$LAU^hRb)@B|7E7r{oqU~H08>}|7E7*fL` Date: Wed, 18 Mar 2026 16:38:39 -0400 Subject: [PATCH 2/3] Fixed save button, and making new post bug. Also fixed option list alignment and preliminary share functionality. --- Resell/Models/Listing.swift | 2 +- Resell/Models/Post.swift | 2 +- Resell/Models/Transaction.swift | 4 +- .../Views/Components/DraggableSheetView.swift | 70 +++---- Resell/Views/Components/OptionsMenuView.swift | 2 +- .../ProductDetails/ProductDetailsView.swift | 171 ++++++++---------- 6 files changed, 114 insertions(+), 137 deletions(-) diff --git a/Resell/Models/Listing.swift b/Resell/Models/Listing.swift index 06b76f3..80e7b60 100644 --- a/Resell/Models/Listing.swift +++ b/Resell/Models/Listing.swift @@ -18,7 +18,7 @@ struct Listing: Codable { enum CodingKeys: String, CodingKey { case id, title, description, categories - case originalPrice = "original_price" + case originalPrice = "originalPrice" case images, user } } diff --git a/Resell/Models/Post.swift b/Resell/Models/Post.swift index a83df62..e8bc687 100644 --- a/Resell/Models/Post.swift +++ b/Resell/Models/Post.swift @@ -101,7 +101,7 @@ struct PostBody: Codable { case description case categories case condition - case original_price = "original_price" + case original_price = "originalPrice" case imagesBase64 case userId } diff --git a/Resell/Models/Transaction.swift b/Resell/Models/Transaction.swift index 10c4ec5..a4e6a5b 100644 --- a/Resell/Models/Transaction.swift +++ b/Resell/Models/Transaction.swift @@ -127,8 +127,8 @@ struct PostSummary: Codable, Hashable { private enum CodingKeys: String, CodingKey { case id, title, images, description, condition, sold - case originalPrice = "original_price" - case alteredPrice = "altered_price" + case originalPrice = "originalPrice" + case alteredPrice = "alteredPrice" } } diff --git a/Resell/Views/Components/DraggableSheetView.swift b/Resell/Views/Components/DraggableSheetView.swift index 9bb4acf..eeb1ea5 100644 --- a/Resell/Views/Components/DraggableSheetView.swift +++ b/Resell/Views/Components/DraggableSheetView.swift @@ -21,45 +21,45 @@ struct DraggableSheetView: View { let halfScreen = screenHeight / 2 let travelDistance = startY - (halfScreen - 10) - - VStack(spacing: 0) { - content() - } - .frame(maxWidth: .infinity) - .background(Color.white) - .cornerRadius(40) - .offset(y: startY + dragOffset + lastDragOffset) - .gesture( - DragGesture() - .onChanged { value in - let translation = value.translation.height - let potential = lastDragOffset + translation - - if potential < -travelDistance { - dragOffset = (-travelDistance - lastDragOffset) + (translation - (-travelDistance - lastDragOffset)) * 0.2 - } - else if potential > 0 { - dragOffset = (0 - lastDragOffset) + (translation - (0 - lastDragOffset)) * 0.2 - } - else { - dragOffset = translation + + content() + .frame(maxWidth: .infinity) + .background( + RoundedRectangle(cornerRadius: 40) + .fill(Color.white) + ) + .offset(y: startY + dragOffset + lastDragOffset) + .gesture( + DragGesture() + .onChanged { value in + let translation = value.translation.height + let potential = lastDragOffset + translation + + if potential < -travelDistance { + dragOffset = (-travelDistance - lastDragOffset) + (translation - (-travelDistance - lastDragOffset)) * 0.2 + } + else if potential > 0 { + dragOffset = (0 - lastDragOffset) + (translation - (0 - lastDragOffset)) * 0.2 + } + else { + dragOffset = translation + } } - } - .onEnded { value in - let velocity = value.predictedEndTranslation.height - let finalPos = lastDragOffset + dragOffset + (velocity * 0.5) + .onEnded { value in + let velocity = value.predictedEndTranslation.height + let finalPos = lastDragOffset + dragOffset + (velocity * 0.5) - withAnimation(.spring(response: 0.4, dampingFraction: 0.8)) { - // If user flicked or dragged more than 30% of the way up - if finalPos < -travelDistance * 0.3 { - lastDragOffset = -travelDistance - } else { - lastDragOffset = 0 + withAnimation(.spring(response: 0.4, dampingFraction: 0.8)) { + // If user flicked or dragged more than 30% of the way up + if finalPos < -travelDistance * 0.3 { + lastDragOffset = -travelDistance + } else { + lastDragOffset = 0 + } + dragOffset = 0 } - dragOffset = 0 } - } - ) + ) } .ignoresSafeArea() } diff --git a/Resell/Views/Components/OptionsMenuView.swift b/Resell/Views/Components/OptionsMenuView.swift index 325de7f..358cc54 100644 --- a/Resell/Views/Components/OptionsMenuView.swift +++ b/Resell/Views/Components/OptionsMenuView.swift @@ -42,7 +42,7 @@ struct OptionsMenuView: View { } } - VStack { + VStack (spacing: 0) { ForEach(options.indices, id: \.self) { index in switch options[index] { case .share(let url, let item): diff --git a/Resell/Views/ProductDetails/ProductDetailsView.swift b/Resell/Views/ProductDetails/ProductDetailsView.swift index c90b829..c7cbab2 100644 --- a/Resell/Views/ProductDetails/ProductDetailsView.swift +++ b/Resell/Views/ProductDetails/ProductDetailsView.swift @@ -56,14 +56,18 @@ struct ProductDetailsView: View { DraggableSheetView(startY: imageHeight) { detailsView } + .zIndex(1) if !viewModel.isMyPost() { buttonGradientView + .zIndex(2) } if viewModel.didShowOptionsMenu { OptionsMenuView(showMenu: $viewModel.didShowOptionsMenu, didShowDeleteView: $viewModel.didShowDeleteView, options: { var options: [Option] = [ + // MARK - Need to get a real shareable url (put in post or viewmodel) +// .share(url: "TEST", itemName: viewModel.item?.title ?? "cool item"), .report(type: "Post", id: post.id) ] if viewModel.isUserPost() { @@ -181,68 +185,41 @@ struct ProductDetailsView: View { .tag(index) .clipped() } - -// private var detailsView: some View { -// -// GeometryReader { geometry in -// VStack(alignment: .leading) { -// HStack { -// RoundedRectangle(cornerRadius: 4) -// .frame(width: 50, height: 8) -// .foregroundStyle(Constants.Colors.inactiveGray) -// .padding(.top, 12) -// .frame(alignment: .center) -// } -// .frame(maxWidth: .infinity, alignment: .center) -// -// titlePriceView -// -// sellerProfileView -// .padding(.bottom, 24) -// -// itemDescriptionView -// .padding(.bottom, 32) -// -// similarItemsView -// -// Spacer() -// } -// .padding(.horizontal, Constants.Spacing.horizontalPadding) -// .background(Color.white) -// .cornerRadius(40) -// .position(x: UIScreen.width / 2, y: imageHeight - 50 + geometry.size.height / 2) -// } -// } private var detailsView: some View { - VStack(alignment: .leading, spacing: 0) { - // Drag Handle - HStack { - RoundedRectangle(cornerRadius: 4) - .frame(width: 50, height: 8) - .foregroundStyle(Constants.Colors.inactiveGray) - .padding(.top, 12) - } - .frame(maxWidth: .infinity) - - VStack(alignment: .leading) { - titlePriceView - .padding(.top, 10) - - sellerProfileView - .padding(.bottom, 24) - - itemDescriptionView - .padding(.bottom, 32) - - similarItemsView + ZStack (alignment: .topTrailing) { + VStack(alignment: .leading, spacing: 0) { + // Drag Handle + HStack { + RoundedRectangle(cornerRadius: 4) + .frame(width: 50, height: 8) + .foregroundStyle(Constants.Colors.inactiveGray) + .padding(.top, 12) + } + .frame(maxWidth: .infinity) - // This ensures the sheet is tall enough to cover the screen when pulled up - Spacer(minLength: 500) + VStack(alignment: .leading) { + titlePriceView + .padding(.top, 10) + + sellerProfileView + .padding(.bottom, 24) + + itemDescriptionView + .padding(.bottom, 32) + + similarItemsView + + // This ensures the sheet is tall enough to cover the screen when pulled up + Spacer(minLength: 500) + } + .padding(.horizontal, Constants.Spacing.horizontalPadding) } - .padding(.horizontal, Constants.Spacing.horizontalPadding) + + saveButton + .padding(.trailing, Constants.Spacing.horizontalPadding) + .offset(y: -95) } - .background(Color.white) } private var titlePriceView: some View { @@ -421,46 +398,46 @@ struct ProductDetailsView: View { @AppStorage("isNotificationAuthorized") var isNotificationAuthorized = false -// private var saveButton: some View { -// if isNotificationAuthorized { -// Button { -// viewModel.isSaved.toggle() -// viewModel.updateItemSaved() -// sendNotification() -// } label: { -// ZStack { -// Circle() -// .frame(width: 72, height: 72) -// .foregroundStyle(Constants.Colors.white) -// .opacity(viewModel.isSaved ? 1.0 : 0.9) -// .shadow(radius: 2) -// -// Image(viewModel.isSaved ? "saved.fill" : "saved") -// .resizable() -// .frame(width: 21, height: 27) -// } -// } -// } else { -// Button { -// viewModel.isSaved.toggle() -// viewModel.updateItemSaved() -// requestNotificationAuthorization() -// print("Test1") -// } label: { -// ZStack { -// Circle() -// .frame(width: 72, height: 72) -// .foregroundStyle(Constants.Colors.white) -// .opacity(viewModel.isSaved ? 1.0 : 0.9) -// .shadow(radius: 2) -// -// Image(viewModel.isSaved ? "saved.fill" : "saved") -// .resizable() -// .frame(width: 21, height: 27) -// } -// } -// } -// } + private var saveButton: some View { + if isNotificationAuthorized { + Button { + viewModel.isSaved.toggle() + viewModel.updateItemSaved() + sendNotification() + } label: { + ZStack { + Circle() + .frame(width: 72, height: 72) + .foregroundStyle(Constants.Colors.white) + .opacity(viewModel.isSaved ? 1.0 : 0.9) + .shadow(radius: 2) + + Image(viewModel.isSaved ? "saved.fill" : "saved") + .resizable() + .frame(width: 21, height: 27) + } + } + } else { + Button { + viewModel.isSaved.toggle() + viewModel.updateItemSaved() + requestNotificationAuthorization() + print("Test1") + } label: { + ZStack { + Circle() + .frame(width: 72, height: 72) + .foregroundStyle(Constants.Colors.white) + .opacity(viewModel.isSaved ? 1.0 : 0.9) + .shadow(radius: 2) + + Image(viewModel.isSaved ? "saved.fill" : "saved") + .resizable() + .frame(width: 21, height: 27) + } + } + } + } private var deletePostView: some View { VStack(spacing: 24) { From 16bcfbf80356607eafca475924bc093f49c0447e Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 19 Mar 2026 17:28:29 -0400 Subject: [PATCH 3/3] Fixed empty for you section alignment. --- Resell/Views/Home/ForYouView.swift | 39 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Resell/Views/Home/ForYouView.swift b/Resell/Views/Home/ForYouView.swift index 149e502..0b19f55 100644 --- a/Resell/Views/Home/ForYouView.swift +++ b/Resell/Views/Home/ForYouView.swift @@ -26,34 +26,35 @@ struct ForYouView: View { .font(.custom("Rubik-Medium", size: 22)) .foregroundStyle(.black) .padding(.leading, 24) - - ScrollView(.horizontal, showsIndicators: false) { - LazyHStack(spacing: 20) { - if !viewModel.savedItems.isEmpty || !recentPosts.isEmpty { + + if !viewModel.savedItems.isEmpty || !recentPosts.isEmpty { + ScrollView(.horizontal, showsIndicators: false) { + LazyHStack(spacing: 20) { if !viewModel.savedItems.isEmpty { forYouCard(title: titles[0], posts: viewModel.savedItems, loaded: $savedLoadedStates) } if !recentPosts.isEmpty { forYouCard(title: titles[1], posts: recentPosts, loaded: $recentLoadedStates) } - } else { - ZStack { - RoundedRectangle(cornerRadius: 8) - .stroke(Color.gray, lineWidth: 1) - .frame(width: 378, height: 110) - .foregroundStyle(.white) + } + .padding(.leading, 24) + } + } else { + ZStack { + RoundedRectangle(cornerRadius: 8) + .stroke(Color.gray, lineWidth: 1) + .foregroundStyle(.white) - VStack { - Text("You haven't saved any listings yet.") - .foregroundStyle(Constants.Colors.black) - - Text("Tap \(Image(systemName: "bookmark")) on a listing to save.") - .foregroundStyle(Constants.Colors.black) - } - } + VStack { + Text("You haven't saved any listings yet.") + .foregroundStyle(Constants.Colors.black) + + Text("Tap \(Image(systemName: "bookmark")) on a listing to save.") + .foregroundStyle(Constants.Colors.black) } } - .padding(.leading, 24) + .frame(height: 110) + .padding(.horizontal, 24) } } .onAppear() {