Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend swift #69

Merged
merged 13 commits into from
Apr 3, 2024
Prev Previous commit
Next Next commit
major changes quality of light code refactoring.
mortezafa committed Feb 24, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 980090b7b82766c94a012a35d5d1559587718c3a
30 changes: 18 additions & 12 deletions Rethread/Rethread.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
7C9D4E262B85BC4E0034C385 /* AccountNotificationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C9D4E252B85BC4E0034C385 /* AccountNotificationView.swift */; };
7CF454A92B86948C00DB3105 /* PhotoPickerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CF454A82B86948C00DB3105 /* PhotoPickerModel.swift */; };
7CF454AB2B8697B200DB3105 /* ScannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CF454AA2B8697B200DB3105 /* ScannerView.swift */; };
7CF454AD2B87DCF400DB3105 /* aboutBrandView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CF454AC2B87DCF400DB3105 /* aboutBrandView.swift */; };
7CF454AF2B87EBE600DB3105 /* FilterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CF454AE2B87EBE600DB3105 /* FilterModel.swift */; };
983014C22B451A3E004A6A07 /* NavigationTransitions in Frameworks */ = {isa = PBXBuildFile; productRef = 983014C12B451A3E004A6A07 /* NavigationTransitions */; };
983286B92B05698F00851B19 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 983286B82B05698F00851B19 /* Assets.xcassets */; };
983286BC2B05698F00851B19 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 983286BB2B05698F00851B19 /* Preview Assets.xcassets */; };
@@ -32,13 +34,12 @@
98BBA11E2B68A6A100003AC2 /* VerificationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1102B68A6A100003AC2 /* VerificationView.swift */; };
98BBA11F2B68A6A100003AC2 /* ProductView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1112B68A6A100003AC2 /* ProductView.swift */; };
98BBA1202B68A6A100003AC2 /* MapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1122B68A6A100003AC2 /* MapView.swift */; };
98BBA1212B68A6A100003AC2 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1132B68A6A100003AC2 /* HomeView.swift */; };
98BBA1212B68A6A100003AC2 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1132B68A6A100003AC2 /* MainView.swift */; };
98BBA1222B68A6A100003AC2 /* testest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1142B68A6A100003AC2 /* testest.swift */; };
98BBA1232B68A6A100003AC2 /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1152B68A6A100003AC2 /* WelcomeView.swift */; };
98BBA1242B68A6A100003AC2 /* SignInView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1162B68A6A100003AC2 /* SignInView.swift */; };
98BBA1252B68A6A100003AC2 /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1172B68A6A100003AC2 /* SwiftUIView.swift */; };
98BBA1262B68A6A100003AC2 /* ClothingItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1182B68A6A100003AC2 /* ClothingItemView.swift */; };
98BBA1272B68A6A100003AC2 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1192B68A6A100003AC2 /* MainView.swift */; };
98BBA1272B68A6A100003AC2 /* AuthenticationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA1192B68A6A100003AC2 /* AuthenticationView.swift */; };
98BBA1282B68A6A100003AC2 /* SignUpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA11A2B68A6A100003AC2 /* SignUpView.swift */; };
98BBA1292B68A6A100003AC2 /* OnboardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA11B2B68A6A100003AC2 /* OnboardingView.swift */; };
98BBA12B2B68A75200003AC2 /* OnboardingApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98BBA12A2B68A75200003AC2 /* OnboardingApp.swift */; };
@@ -75,6 +76,8 @@
7C9D4E252B85BC4E0034C385 /* AccountNotificationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountNotificationView.swift; sourceTree = "<group>"; };
7CF454A82B86948C00DB3105 /* PhotoPickerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoPickerModel.swift; sourceTree = "<group>"; };
7CF454AA2B8697B200DB3105 /* ScannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScannerView.swift; sourceTree = "<group>"; };
7CF454AC2B87DCF400DB3105 /* aboutBrandView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = aboutBrandView.swift; sourceTree = "<group>"; };
7CF454AE2B87EBE600DB3105 /* FilterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterModel.swift; sourceTree = "<group>"; };
983286B12B05698E00851B19 /* Rethread.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Rethread.app; sourceTree = BUILT_PRODUCTS_DIR; };
983286B82B05698F00851B19 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
983286BB2B05698F00851B19 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
@@ -94,13 +97,12 @@
98BBA1102B68A6A100003AC2 /* VerificationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VerificationView.swift; sourceTree = "<group>"; };
98BBA1112B68A6A100003AC2 /* ProductView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProductView.swift; sourceTree = "<group>"; };
98BBA1122B68A6A100003AC2 /* MapView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapView.swift; sourceTree = "<group>"; };
98BBA1132B68A6A100003AC2 /* HomeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
98BBA1132B68A6A100003AC2 /* MainView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
98BBA1142B68A6A100003AC2 /* testest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = testest.swift; sourceTree = "<group>"; };
98BBA1152B68A6A100003AC2 /* WelcomeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = "<group>"; };
98BBA1162B68A6A100003AC2 /* SignInView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignInView.swift; sourceTree = "<group>"; };
98BBA1172B68A6A100003AC2 /* SwiftUIView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftUIView.swift; sourceTree = "<group>"; };
98BBA1182B68A6A100003AC2 /* ClothingItemView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClothingItemView.swift; sourceTree = "<group>"; };
98BBA1192B68A6A100003AC2 /* MainView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
98BBA1192B68A6A100003AC2 /* AuthenticationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthenticationView.swift; sourceTree = "<group>"; };
98BBA11A2B68A6A100003AC2 /* SignUpView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignUpView.swift; sourceTree = "<group>"; };
98BBA11B2B68A6A100003AC2 /* OnboardingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingView.swift; sourceTree = "<group>"; };
98BBA12A2B68A75200003AC2 /* OnboardingApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingApp.swift; sourceTree = "<group>"; };
@@ -151,6 +153,7 @@
98F525CD2B46A96F00CCAD78 /* TermsAndConditions.swift */,
7C8446E42B58CE8F00911C00 /* MapViewModel.swift */,
7CF454A82B86948C00DB3105 /* PhotoPickerModel.swift */,
7CF454AE2B87EBE600DB3105 /* FilterModel.swift */,
);
path = Models;
sourceTree = "<group>";
@@ -260,15 +263,15 @@
7C3B47122B853E520068DCCE /* AccountSettingsView.swift */,
7C9D4E252B85BC4E0034C385 /* AccountNotificationView.swift */,
98BBA1102B68A6A100003AC2 /* VerificationView.swift */,
7CF454AC2B87DCF400DB3105 /* aboutBrandView.swift */,
98BBA1112B68A6A100003AC2 /* ProductView.swift */,
98BBA1122B68A6A100003AC2 /* MapView.swift */,
98BBA1132B68A6A100003AC2 /* HomeView.swift */,
98BBA1132B68A6A100003AC2 /* MainView.swift */,
98BBA1142B68A6A100003AC2 /* testest.swift */,
98BBA1152B68A6A100003AC2 /* WelcomeView.swift */,
98BBA1162B68A6A100003AC2 /* SignInView.swift */,
98BBA1172B68A6A100003AC2 /* SwiftUIView.swift */,
98BBA1182B68A6A100003AC2 /* ClothingItemView.swift */,
98BBA1192B68A6A100003AC2 /* MainView.swift */,
98BBA1192B68A6A100003AC2 /* AuthenticationView.swift */,
98BBA11A2B68A6A100003AC2 /* SignUpView.swift */,
98BBA11B2B68A6A100003AC2 /* OnboardingView.swift */,
7CF454AA2B8697B200DB3105 /* ScannerView.swift */,
@@ -450,8 +453,8 @@
files = (
98BBA1292B68A6A100003AC2 /* OnboardingView.swift in Sources */,
98BBA1222B68A6A100003AC2 /* testest.swift in Sources */,
98BBA1262B68A6A100003AC2 /* ClothingItemView.swift in Sources */,
9868A7DE2B1FAE780063D9BA /* ButtonStyles.swift in Sources */,
7CF454AF2B87EBE600DB3105 /* FilterModel.swift in Sources */,
98EA47352B6065C600AA2E8F /* User.swift in Sources */,
98BBA12D2B68ACBF00003AC2 /* Verification.swift in Sources */,
7CF454A92B86948C00DB3105 /* PhotoPickerModel.swift in Sources */,
@@ -460,6 +463,7 @@
7CF454AB2B8697B200DB3105 /* ScannerView.swift in Sources */,
98BBA1242B68A6A100003AC2 /* SignInView.swift in Sources */,
98F541222B60A2CC00B6AA04 /* AuthViewModel.swift in Sources */,
7CF454AD2B87DCF400DB3105 /* aboutBrandView.swift in Sources */,
98F525CE2B46A96F00CCAD78 /* TermsAndConditions.swift in Sources */,
7C9D4E262B85BC4E0034C385 /* AccountNotificationView.swift in Sources */,
98F525C92B469BBD00CCAD78 /* PlayerView.swift in Sources */,
@@ -469,8 +473,8 @@
98434A5D2B63342700F81127 /* ContentView.swift in Sources */,
988A0F992B3C112300ACDC90 /* DatePickerModel.swift in Sources */,
9897C7732B3E6C4000EDE9D9 /* CustomDropdownMenu.swift in Sources */,
98BBA1272B68A6A100003AC2 /* MainView.swift in Sources */,
98BBA1212B68A6A100003AC2 /* HomeView.swift in Sources */,
98BBA1272B68A6A100003AC2 /* AuthenticationView.swift in Sources */,
98BBA1212B68A6A100003AC2 /* MainView.swift in Sources */,
98BBA1252B68A6A100003AC2 /* SwiftUIView.swift in Sources */,
7C3B47132B853E520068DCCE /* AccountSettingsView.swift in Sources */,
98BBA11E2B68A6A100003AC2 /* VerificationView.swift in Sources */,
@@ -647,6 +651,7 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Rethread/Info.plist;
INFOPLIST_KEY_NSCameraUsageDescription = "reThread needs to acess your camera to in order to take photos";
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Rethread needs your location";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
@@ -682,6 +687,7 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Rethread/Info.plist;
INFOPLIST_KEY_NSCameraUsageDescription = "reThread needs to acess your camera to in order to take photos";
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Rethread needs your location";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "patagoniaFont.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "patagoniaHeader.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "patagoniaQuar.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 8 additions & 12 deletions Rethread/Rethread/Core/ContentView.swift
Original file line number Diff line number Diff line change
@@ -5,18 +5,14 @@ struct ContentView: View {


var body: some View {
Group {
if viewModel.isLoading {
ProgressView("Loading...")
} else {
if viewModel.currentUser?.onboardingComplete == false {
WelcomeView()
} else if viewModel.userSession != nil {
HomeView()
} else {
MainView()
}
}
if viewModel.isLoading {
ProgressView("Loading...")
} else if viewModel.currentUser?.onboardingComplete == false {
WelcomeView()
} else if viewModel.userSession != nil {
MainView()
} else {
AuthenticationView()
}
}
}
5 changes: 2 additions & 3 deletions Rethread/Rethread/Core/OnboardingApp.swift
Original file line number Diff line number Diff line change
@@ -13,9 +13,8 @@ struct OnboardingApp: App {

var body: some Scene {
WindowGroup {
// ContentView()
// .environmentObject(viewModel)
ProfileView()
ContentView()
.environmentObject(viewModel)
}
}
}
24 changes: 24 additions & 0 deletions Rethread/Rethread/Models/FilterModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// FilterModel.swift

import Foundation

struct ClothingItem: Identifiable {
let id = UUID()
var name: String
var type: ClothingType
var color: String
var price: Int
var imageName: String
}

enum ClothingType: String, CaseIterable {
case pants = "Pants"
case tShirt = "T-Shirt"
case jacket = "Jacket"
}

var allItems: [ClothingItem] = [
// Populate with your actual clothing items
ClothingItem(name: "1/4 zip fleece", type: .jacket, color: "Red", price: Int(100), imageName: "patagoniaQuar"),
// Add more items...
]
23 changes: 7 additions & 16 deletions Rethread/Rethread/Models/MapViewModel.swift
Original file line number Diff line number Diff line change
@@ -2,28 +2,19 @@

import MapKit


final class MapViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {

@Published var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.331516, longitude: -121.891054), span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))


var locationManager: CLLocationManager?

func isUserLocationOn() {
if CLLocationManager.locationServicesEnabled() {
locationManager = CLLocationManager()
locationManager!.delegate = self
}
else {
print("Show an alert showing user that they need to turn on location")
}
override init() {
locationManager = CLLocationManager()
super.init()
locationManager.delegate = self
}

private func checkLocationAuthorization () {
guard let locationManager = locationManager else { return }
@Published var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.331516, longitude: -121.891054), span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))

let locationManager: CLLocationManager

private func checkLocationAuthorization () {
switch locationManager.authorizationStatus {

case .notDetermined:
105 changes: 105 additions & 0 deletions Rethread/Rethread/Views/AuthenticationView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import SwiftUI
import NavigationTransitions

#if canImport(UIKit)
extension View {
func hideKeyboard() {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
}
#endif

struct AuthenticationView: View {
@State private var path: [String] = []

var body: some View {
NavigationStack (path: $path) {
ZStack (alignment: .bottom) {
// Add Image
Image("flowerMainPage")
.resizable()
.overlay(Color.black.opacity(0.1))
.clipped()
.edgesIgnoringSafeArea(.all)
.padding(.bottom, 220)

// Botom Part
VStack (spacing: 50) {

HStack {
Text("Get involved with" + "\n" + "sustainable fashion")
.font(.system(size: 20))
.fontWeight(.semibold)
.foregroundColor(Color.primaryDark)
.opacity(0.5)
.multilineTextAlignment(.leading)
.lineSpacing(6)
Spacer()
}
.padding(.horizontal, 35)
.padding(.top, 25)



VStack (spacing: 17) {
Button(action: {
path.append("SignInView")
}) {
HStack {
Text("Log In")
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.buttonStyle(PrimaryButtonStyle(width: 300))

HStack {
Spacer()

Button(action: {
path.append("SignUpView")
}) {
Text("Create Account")
.foregroundColor(Color.primaryDark)
.fontWeight(.semibold)
.underline()
}
}
.padding(.horizontal, 35)
}
.navigationDestination(for: String.self) { view in
if view == "SignInView" {
SignInView(path: $path)
} else if view == "SignUpView" {
SignUpView(path: $path)
} else if view == "WelcomeView" {
WelcomeView()
}
}
}
.background(RoundedCorners(
color: .white,
tl: 20,
tr: 20
))
.frame(height: 270)
}
.frame(maxHeight: .infinity)
}
.navigationTransition(.slide(axis: .vertical))
// Safe area for iPhone X and above
.edgesIgnoringSafeArea(.all) // This will extend the content to the edges
.background(Color(UIColor.systemGray6))
.overlay(
GeometryReader { geometry in
Color.white.opacity(0.3) // Adjust the opacity here for semi-transparency
.frame(width: geometry.size.width, height: geometry.safeAreaInsets.top)
.edgesIgnoringSafeArea(.top)
}, alignment: .top
)
}
}

#Preview {
AuthenticationView()
}

121 changes: 0 additions & 121 deletions Rethread/Rethread/Views/ClothingItemView.swift

This file was deleted.

396 changes: 0 additions & 396 deletions Rethread/Rethread/Views/HomeView.swift

This file was deleted.

498 changes: 405 additions & 93 deletions Rethread/Rethread/Views/MainView.swift

Large diffs are not rendered by default.

222 changes: 189 additions & 33 deletions Rethread/Rethread/Views/MapView.swift
Original file line number Diff line number Diff line change
@@ -1,51 +1,212 @@
// MapView.swift

import SwiftUI
import MapKit
import CoreLocation

struct MapView: View {
@StateObject private var viewModel = MapViewModel() // MapViewModel can be fouund in Models/MapViewModels in the directory
@State private var cameraPos: MapCameraPosition = .userLocation(fallback: .automatic)
var body: some View {
@State private var mapSelection: MKMapItem?
@State private var viewingRegion: MKCoordinateRegion?

@State private var searchText: String = ""
@State private var showSearch: Bool = false
@State private var searchResults: [MKMapItem] = []

@State private var showDetails: Bool = false
@State private var lookAroundScene: MKLookAroundScene?

VStack {
Text("Use your current postal code or enter a new one to see locations near you!")
.padding()
.foregroundStyle(Color(hex: "#2C4C52"))
@State private var routeDisplaying: Bool = false
@State private var route: MKRoute?
@State private var routeDestination: MKMapItem?

LocationSearchBar()
var body: some View {

Text("Locations Around you")
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.horizontal)
.foregroundStyle(Color(hex: "#2C4C52"))

CustomDropdownMenu(items: [
DropdownItem(id: 1, title: "24 Ave. NW", onSelect: {}),
DropdownItem(id: 2, title: "32 Deer foot trail NE", onSelect: {}),
DropdownItem(id: 3, title: "18 Blvd. Road W", onSelect: {})
])
.zIndex(1000)
.frame(maxHeight: .maximum(100, 100))
.padding(.horizontal)
// VStack {
// Text("meow")
// }
NavigationStack {

Map(position: $cameraPos, selection: $mapSelection) {

ForEach(searchResults, id: \.self) { mapItem in
if routeDisplaying {
if mapItem == routeDestination {
let placemark = mapItem.placemark
Marker(placemark.name ?? "Place", coordinate: placemark.coordinate)
.tint(Color(hex: "#2C4C52"))
}
} else {
let placemark = mapItem.placemark
Marker(placemark.name ?? "Place", coordinate: placemark.coordinate)
.tint(Color(hex: "#2C4C52"))
}
}

if let route {
MapPolyline(route.polyline)
.stroke(.blue, lineWidth: 7)
}

}
.onMapCameraChange({ ctx in
viewingRegion = ctx.region
})
.searchable(text: $searchText, isPresented: $showSearch)
.navigationTitle("Brands Near You!")
.accentColor(Color(hex: "#2C4C52"))
.mapControls {
MapCompass()
MapUserLocationButton()
MapPitchToggle()
}
.toolbar(routeDisplaying ? .hidden : .visible, for: .navigationBar)
.sheet(isPresented: $showDetails, onDismiss: {
withAnimation(.snappy) {
if let boundingRect = route?.polyline.boundingMapRect, routeDisplaying {
cameraPos = .rect(boundingRect)
}
}
}, content: {
MapDetails()
.presentationDetents([.height(300)])
.presentationBackgroundInteraction(.enabled(upThrough: .height(300)))
.presentationCornerRadius(25)
.interactiveDismissDisabled(true)
})
.safeAreaInset(edge: .bottom) {
if routeDisplaying {
Button("End Route") {
withAnimation(.snappy) {
routeDisplaying = false
showDetails = true
mapSelection = routeDestination
routeDestination = nil
route = nil
cameraPos = .region(viewModel.region)
}
}
.foregroundStyle(.white)
.frame(maxWidth: .infinity)
.padding(.vertical, 12)
.background(.red.gradient, in: .rect(cornerRadius: 15))
.padding()
.background(.ultraThinMaterial)

}
}
.onSubmit(of: .search) {
print("Search submitted for: \(searchText)")
Task {
guard !searchText.isEmpty else { return }
print("Starting search...")
await searchPlaces()
}
}
.onChange(of: showSearch, initial: false) {
if !showSearch {
searchResults.removeAll(keepingCapacity: false)
showDetails = false

withAnimation(.snappy) {
cameraPos = .region(viewModel.region)
}
}
}
.onChange(of: mapSelection) { oldValue, newValue in
showDetails = newValue != nil
fetchLookAroundData()
}
}


Map(position: $cameraPos) {
}

@ViewBuilder
func MapDetails() -> some View {
VStack(spacing: 15) {
ZStack {
if lookAroundScene == nil {
ContentUnavailableView("No Preview Available", systemImage: "eye.slash")
} else {
LookAroundPreview(scene: $lookAroundScene)
}
}
.mapControls {
MapCompass()
MapUserLocationButton()
MapPitchToggle()
}
.accentColor(Color(hex: "#2C4C52"))
.onAppear {
viewModel.isUserLocationOn()
.frame(height: 200)
.clipShape(.rect(cornerRadius: 15))
.overlay(alignment: .topTrailing) {
Button(action: {
showDetails = false
withAnimation(.snappy) {
mapSelection = nil
}
}, label: {
Image(systemName: "xmark.circle.fill")
.font(.title)
.foregroundStyle(.black)
.background(.white, in:.circle)
})
}

Button("Get Directions", action: fetchRoute)
.foregroundStyle(.white)
.frame(maxWidth: .infinity)
.padding(.vertical, 12)
.background(.blue.gradient, in: .rect(cornerRadius: 15))
}
.padding(15)
}



func searchPlaces() async {
print("Starting search for: \(searchText)")

let request = MKLocalSearch.Request()
request.naturalLanguageQuery = searchText
request.region = viewingRegion ?? viewModel.region

do {
let response = try await MKLocalSearch(request: request).start()
searchResults = response.mapItems
print("Search completed. Found \(searchResults.count) results.")
} catch {
print("Search failed with error: \(error)")
}
}


/// Fetching Look Around data :)

func fetchLookAroundData() {
guard let mapSelection else { return }
lookAroundScene = nil
Task {
let request = MKLookAroundSceneRequest(mapItem: mapSelection)
lookAroundScene = try? await request.scene
}
}


func fetchRoute() {
guard let mapSelection else { return }
let request = MKDirections.Request()
request.source = .init(placemark: .init(coordinate: viewModel.locationManager.location?.coordinate ?? CLLocationCoordinate2D(latitude: 37.331516, longitude: -121.891054)))
request.destination = mapSelection

Task {
let result = try? await MKDirections(request: request).calculate()
route = result?.routes.first
routeDestination = mapSelection


withAnimation(.snappy) {
routeDisplaying = true
showDetails = false

}
}
}
}

@@ -80,11 +241,6 @@ struct LocationSearchBar: View {








#Preview {
MapView()
}
4 changes: 4 additions & 0 deletions Rethread/Rethread/Views/ProductView.swift
Original file line number Diff line number Diff line change
@@ -2,7 +2,11 @@

import SwiftUI


struct ProductView: View {



var body: some View {
ZStack {
ScrollView {
2 changes: 1 addition & 1 deletion Rethread/Rethread/Views/ProfileView.swift
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ extension SectionType {
@ViewBuilder var view: some View {
switch self {
case .promotions:
HomeView()
MainView()
case .accountSettings:
AccountSettingsView()
case .notifications:
118 changes: 118 additions & 0 deletions Rethread/Rethread/Views/aboutBrandView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// aboutBrandView.swift

import SwiftUI



struct aboutBrandView: View {


@State private var selectedType: ClothingType? = nil
@State private var selectedColor: String? = nil
@State private var maxPrice: Int = 500

let columns: [GridItem] = [
GridItem(.flexible()),
GridItem(.flexible()),
]
var filteredItems: [ClothingItem] {
allItems.filter { item in
(selectedType == nil || item.type == selectedType) &&
(selectedColor == nil || item.color == selectedColor) &&
item.price <= maxPrice
}
}


var body: some View {
ScrollView(showsIndicators: false) {
VStack {
Image("patagoniaHeader")
.resizable()
.aspectRatio(contentMode: .fill)
}
Spacer()

VStack(alignment: .leading) {
Text("Patagonia's commitment to sustainablity:")
.foregroundStyle(Color(hex: "#2C4C52"))
.font(.title2)
.fontWeight(.bold)
.padding()
Text("Patagonia, founded in 1973 by Yvon Chouinard, emphasizes durable, repairable, and recyclable products, supporting a model that reduces waste and environmental impact.")
.foregroundStyle(Color(hex: "#2C4C52"))
.italic()
.font(.subheadline)
.padding(.horizontal)
.padding(.bottom)



VStack {
Picker("Type", selection: $selectedType) {
Text("All").tag(ClothingType?.none)
ForEach(ClothingType.allCases, id: \.self) { type in
Text(type.rawValue).tag(type as ClothingType?)
}
}
.pickerStyle(.segmented)

Picker("Color", selection: $selectedColor) {
Text("All").tag(String?.none)
.foregroundStyle(Color(hex: "#2C4C52"))
Image(uiImage: ImageRenderer(content: Image(systemName: "circle.fill").foregroundStyle(.red)).uiImage!.withRenderingMode(.alwaysOriginal))
.tag("Red" as String?)
Text("Blue").tag("Blue" as String?)
}

}
.foregroundStyle(Color(hex: "#2C4C52"))

.pickerStyle(.segmented)

HStack {
Text("$0")
Slider(value: Binding(get: {
Double(maxPrice)
}, set: { newValue in
maxPrice = Int(newValue)
}), in: 0...500, step: 50) // Only allow integer values
.tint(Color(hex: "#2C4C52"))

Text("$\(maxPrice)")
}
.foregroundStyle(Color(hex: "#2C4C52"))
.padding(.horizontal)
}
.padding(.horizontal)

HStack {
Text("Shop")
.font(.title2)
.fontWeight(.bold)
Image("patagoniaFont")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 120, height: 30)
Spacer()
}
.padding(.horizontal)




LazyVGrid(columns: columns) {
ForEach(filteredItems) { clothingItem in
ClothCard(width: 160, height: 150, clothingItem: clothingItem)
}
}
Spacer()
}

}
}


#Preview {
aboutBrandView()
}