diff --git a/.DS_Store b/.DS_Store index d0f9264..bcdeb61 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Resell.xcodeproj/project.pbxproj b/Resell.xcodeproj/project.pbxproj index a2b6266..8cb966b 100644 --- a/Resell.xcodeproj/project.pbxproj +++ b/Resell.xcodeproj/project.pbxproj @@ -799,7 +799,7 @@ attributes = { BuildIndependentTargetsInParallel = 1; LastSwiftUpdateCheck = 1540; - LastUpgradeCheck = 1540; + LastUpgradeCheck = 1620; TargetAttributes = { 2C9B4CC62C8FB7B70029DF61 = { CreatedOnToolsVersion = 15.4; @@ -1230,7 +1230,6 @@ 2C9B4CEF2C8FB7B80029DF61 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; @@ -1250,7 +1249,6 @@ 2C9B4CF02C8FB7B80029DF61 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; @@ -1270,7 +1268,6 @@ 2C9B4CF22C8FB7B80029DF61 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ZGMCXU7X3U; @@ -1288,7 +1285,6 @@ 2C9B4CF32C8FB7B80029DF61 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ZGMCXU7X3U; diff --git a/Resell.xcodeproj/xcshareddata/xcschemes/Resell.xcscheme b/Resell.xcodeproj/xcshareddata/xcschemes/Resell.xcscheme index bf4e49b..2b707d7 100644 --- a/Resell.xcodeproj/xcshareddata/xcschemes/Resell.xcscheme +++ b/Resell.xcodeproj/xcshareddata/xcschemes/Resell.xcscheme @@ -1,6 +1,6 @@ : 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/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() { 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) {