From bc3a7b447b410098b0288e412fffbc2a9f2e1a0d Mon Sep 17 00:00:00 2001 From: Lucas Jorge Hubert Date: Wed, 17 May 2023 14:05:46 -0300 Subject: [PATCH 1/5] Search and menu button added --- MarvelUI.xcodeproj/project.pbxproj | 44 ++++++++++++++++++- MarvelUI/Core/Home/View/HomeView.swift | 30 +++++++++++++ .../Core/Home/View/MapViewActionButton.swift | 31 +++++++++++++ .../View/UberMapViewRepresentable.swift | 0 .../View/LocationSearchActivationView.swift | 36 +++++++++++++++ MarvelUI/Core/View/HomeView.swift | 21 --------- 6 files changed, 139 insertions(+), 23 deletions(-) create mode 100644 MarvelUI/Core/Home/View/HomeView.swift create mode 100644 MarvelUI/Core/Home/View/MapViewActionButton.swift rename MarvelUI/Core/{ => Home}/View/UberMapViewRepresentable.swift (100%) create mode 100644 MarvelUI/Core/LocationSearch/View/LocationSearchActivationView.swift delete mode 100644 MarvelUI/Core/View/HomeView.swift diff --git a/MarvelUI.xcodeproj/project.pbxproj b/MarvelUI.xcodeproj/project.pbxproj index 94fdb6f..5993fad 100644 --- a/MarvelUI.xcodeproj/project.pbxproj +++ b/MarvelUI.xcodeproj/project.pbxproj @@ -18,6 +18,8 @@ C9CFFE7D2A151D2400708A15 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CFFE7C2A151D2400708A15 /* HomeView.swift */; }; C9CFFE7F2A151D9000708A15 /* UberMapViewRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CFFE7E2A151D9000708A15 /* UberMapViewRepresentable.swift */; }; C9CFFE812A151F7400708A15 /* LocationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CFFE802A151F7400708A15 /* LocationManager.swift */; }; + C9CFFE872A153D7500708A15 /* LocationSearchActivationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CFFE862A153D7500708A15 /* LocationSearchActivationView.swift */; }; + C9CFFE892A153FA800708A15 /* MapViewActionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CFFE882A153FA800708A15 /* MapViewActionButton.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -53,6 +55,8 @@ C9CFFE7C2A151D2400708A15 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; C9CFFE7E2A151D9000708A15 /* UberMapViewRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UberMapViewRepresentable.swift; sourceTree = ""; }; C9CFFE802A151F7400708A15 /* LocationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationManager.swift; sourceTree = ""; }; + C9CFFE862A153D7500708A15 /* LocationSearchActivationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationSearchActivationView.swift; sourceTree = ""; }; + C9CFFE882A153FA800708A15 /* MapViewActionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapViewActionButton.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -167,8 +171,8 @@ C9CFFE782A151CB700708A15 /* Core */ = { isa = PBXGroup; children = ( - C9CFFE7B2A151D0C00708A15 /* View */, - C9CFFE7A2A151D0400708A15 /* ViewModel */, + C9CFFE832A153D3E00708A15 /* LocationSearch */, + C9CFFE822A153D3400708A15 /* Home */, ); path = Core; sourceTree = ""; @@ -193,10 +197,44 @@ children = ( C9CFFE7C2A151D2400708A15 /* HomeView.swift */, C9CFFE7E2A151D9000708A15 /* UberMapViewRepresentable.swift */, + C9CFFE882A153FA800708A15 /* MapViewActionButton.swift */, + ); + path = View; + sourceTree = ""; + }; + C9CFFE822A153D3400708A15 /* Home */ = { + isa = PBXGroup; + children = ( + C9CFFE7B2A151D0C00708A15 /* View */, + C9CFFE7A2A151D0400708A15 /* ViewModel */, + ); + path = Home; + sourceTree = ""; + }; + C9CFFE832A153D3E00708A15 /* LocationSearch */ = { + isa = PBXGroup; + children = ( + C9CFFE852A153D5200708A15 /* ViewModel */, + C9CFFE842A153D4D00708A15 /* View */, + ); + path = LocationSearch; + sourceTree = ""; + }; + C9CFFE842A153D4D00708A15 /* View */ = { + isa = PBXGroup; + children = ( + C9CFFE862A153D7500708A15 /* LocationSearchActivationView.swift */, ); path = View; sourceTree = ""; }; + C9CFFE852A153D5200708A15 /* ViewModel */ = { + isa = PBXGroup; + children = ( + ); + path = ViewModel; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -333,6 +371,8 @@ C9CFFE502A1517A200708A15 /* MarvelUI.xcdatamodeld in Sources */, C9CFFE442A15179E00708A15 /* MarvelUIApp.swift in Sources */, C9CFFE7F2A151D9000708A15 /* UberMapViewRepresentable.swift in Sources */, + C9CFFE872A153D7500708A15 /* LocationSearchActivationView.swift in Sources */, + C9CFFE892A153FA800708A15 /* MapViewActionButton.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MarvelUI/Core/Home/View/HomeView.swift b/MarvelUI/Core/Home/View/HomeView.swift new file mode 100644 index 0000000..ff14677 --- /dev/null +++ b/MarvelUI/Core/Home/View/HomeView.swift @@ -0,0 +1,30 @@ +// +// HomeView.swift +// MarvelUI +// +// Created by Lucas Hubert on 17/05/23. +// + +import SwiftUI + +struct HomeView: View { + var body: some View { + ZStack(alignment: .top) { + UberMapViewRepresentable() + .ignoresSafeArea() + + LocationSearchActivationView() + .padding(.vertical, 72) + + MapViewActionButton() + .padding(.leading) + .padding(.top, 4) + } + } +} + +struct HomeView_Previews: PreviewProvider { + static var previews: some View { + HomeView() + } +} diff --git a/MarvelUI/Core/Home/View/MapViewActionButton.swift b/MarvelUI/Core/Home/View/MapViewActionButton.swift new file mode 100644 index 0000000..774541c --- /dev/null +++ b/MarvelUI/Core/Home/View/MapViewActionButton.swift @@ -0,0 +1,31 @@ +// +// MapViewActionButton.swift +// MarvelUI +// +// Created by Lucas Hubert on 17/05/23. +// + +import SwiftUI + +struct MapViewActionButton: View { + var body: some View { + Button { + + } label: { + Image(systemName: "line.3.horizontal") + .font(.title2) + .foregroundColor(.black) + .padding() + .background(.white) + .clipShape(Circle()) + .shadow(radius: 6) + } + .frame(maxWidth: .infinity, alignment: .leading) + } +} + +struct MapViewActionButton_Previews: PreviewProvider { + static var previews: some View { + MapViewActionButton() + } +} diff --git a/MarvelUI/Core/View/UberMapViewRepresentable.swift b/MarvelUI/Core/Home/View/UberMapViewRepresentable.swift similarity index 100% rename from MarvelUI/Core/View/UberMapViewRepresentable.swift rename to MarvelUI/Core/Home/View/UberMapViewRepresentable.swift diff --git a/MarvelUI/Core/LocationSearch/View/LocationSearchActivationView.swift b/MarvelUI/Core/LocationSearch/View/LocationSearchActivationView.swift new file mode 100644 index 0000000..b5f3d89 --- /dev/null +++ b/MarvelUI/Core/LocationSearch/View/LocationSearchActivationView.swift @@ -0,0 +1,36 @@ +// +// LocationSearchActivationView.swift +// MarvelUI +// +// Created by Lucas Hubert on 17/05/23. +// + +import SwiftUI + +struct LocationSearchActivationView: View { + var body: some View { + HStack { + Rectangle() + .fill(Color.black) + .frame(width: 8, height: 8) + .padding(.horizontal) + + Text("Where to?") + .foregroundColor(Color(.darkGray)) + + Spacer() + } + .frame(width: UIScreen.main.bounds.width - 64, height: 50) + .background( + Rectangle() + .fill(Color.white) + .shadow(color: .black, radius: 6) + ) + } +} + +struct LocationSearchActivationView_Previews: PreviewProvider { + static var previews: some View { + LocationSearchActivationView() + } +} diff --git a/MarvelUI/Core/View/HomeView.swift b/MarvelUI/Core/View/HomeView.swift deleted file mode 100644 index 4e9d385..0000000 --- a/MarvelUI/Core/View/HomeView.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// HomeView.swift -// MarvelUI -// -// Created by Lucas Hubert on 17/05/23. -// - -import SwiftUI - -struct HomeView: View { - var body: some View { - UberMapViewRepresentable() - .ignoresSafeArea() - } -} - -struct HomeView_Previews: PreviewProvider { - static var previews: some View { - HomeView() - } -} From 7a524989b471fd2de758db8ae76373f128c61755 Mon Sep 17 00:00:00 2001 From: Lucas Jorge Hubert Date: Wed, 17 May 2023 14:30:52 -0300 Subject: [PATCH 2/5] create a search result screen --- MarvelUI.xcodeproj/project.pbxproj | 8 ++ .../View/LocationSeachView.swift | 73 +++++++++++++++++++ .../View/LocationSearchResultCell.swift | 40 ++++++++++ 3 files changed, 121 insertions(+) create mode 100644 MarvelUI/Core/LocationSearch/View/LocationSeachView.swift create mode 100644 MarvelUI/Core/LocationSearch/View/LocationSearchResultCell.swift diff --git a/MarvelUI.xcodeproj/project.pbxproj b/MarvelUI.xcodeproj/project.pbxproj index 5993fad..3277738 100644 --- a/MarvelUI.xcodeproj/project.pbxproj +++ b/MarvelUI.xcodeproj/project.pbxproj @@ -20,6 +20,8 @@ C9CFFE812A151F7400708A15 /* LocationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CFFE802A151F7400708A15 /* LocationManager.swift */; }; C9CFFE872A153D7500708A15 /* LocationSearchActivationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CFFE862A153D7500708A15 /* LocationSearchActivationView.swift */; }; C9CFFE892A153FA800708A15 /* MapViewActionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CFFE882A153FA800708A15 /* MapViewActionButton.swift */; }; + C9CFFE8B2A15410900708A15 /* LocationSeachView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CFFE8A2A15410900708A15 /* LocationSeachView.swift */; }; + C9CFFE8D2A15447800708A15 /* LocationSearchResultCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CFFE8C2A15447800708A15 /* LocationSearchResultCell.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -57,6 +59,8 @@ C9CFFE802A151F7400708A15 /* LocationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationManager.swift; sourceTree = ""; }; C9CFFE862A153D7500708A15 /* LocationSearchActivationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationSearchActivationView.swift; sourceTree = ""; }; C9CFFE882A153FA800708A15 /* MapViewActionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapViewActionButton.swift; sourceTree = ""; }; + C9CFFE8A2A15410900708A15 /* LocationSeachView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationSeachView.swift; sourceTree = ""; }; + C9CFFE8C2A15447800708A15 /* LocationSearchResultCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationSearchResultCell.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -224,6 +228,8 @@ isa = PBXGroup; children = ( C9CFFE862A153D7500708A15 /* LocationSearchActivationView.swift */, + C9CFFE8A2A15410900708A15 /* LocationSeachView.swift */, + C9CFFE8C2A15447800708A15 /* LocationSearchResultCell.swift */, ); path = View; sourceTree = ""; @@ -365,10 +371,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + C9CFFE8B2A15410900708A15 /* LocationSeachView.swift in Sources */, C9CFFE4D2A1517A200708A15 /* Persistence.swift in Sources */, C9CFFE7D2A151D2400708A15 /* HomeView.swift in Sources */, C9CFFE812A151F7400708A15 /* LocationManager.swift in Sources */, C9CFFE502A1517A200708A15 /* MarvelUI.xcdatamodeld in Sources */, + C9CFFE8D2A15447800708A15 /* LocationSearchResultCell.swift in Sources */, C9CFFE442A15179E00708A15 /* MarvelUIApp.swift in Sources */, C9CFFE7F2A151D9000708A15 /* UberMapViewRepresentable.swift in Sources */, C9CFFE872A153D7500708A15 /* LocationSearchActivationView.swift in Sources */, diff --git a/MarvelUI/Core/LocationSearch/View/LocationSeachView.swift b/MarvelUI/Core/LocationSearch/View/LocationSeachView.swift new file mode 100644 index 0000000..5ff5161 --- /dev/null +++ b/MarvelUI/Core/LocationSearch/View/LocationSeachView.swift @@ -0,0 +1,73 @@ +// +// LocationSeachView.swift +// MarvelUI +// +// Created by Lucas Hubert on 17/05/23. +// + +import SwiftUI + +struct LocationSeachView: View { + @State private var startLocationText = "" + @State private var destinationLocationText = "" + + var body: some View { + VStack { + // Header View + HStack { + VStack { + Circle() + .fill(Color(.systemGray3)) + .frame(width: 6, height: 6) + + Rectangle() + .fill(Color(.systemGray3)) + .frame(width: 1, height: 24) + + Rectangle() + .fill(Color.black) + .frame(width: 6, height: 6) + } + + VStack { + TextField("Current Location", text: + $startLocationText + ) + .frame(height: 32) + .background(Color(.systemGroupedBackground)) + .padding(.trailing) + + TextField("Where to?", text: + $startLocationText + ) + .frame(height: 32) + .background(Color(.systemGray4)) + .padding(.trailing) + } + } + .padding(.horizontal) + .padding(.top, 64) + + Divider() + .padding(.vertical) + + ScrollView { + VStack(alignment: .leading) { + ForEach(0 ..< 20, id: \.self) { _ in + LocationSearchResultCell() + } + } + } + + + + // List View + } + } +} + +struct LocationSeachView_Previews: PreviewProvider { + static var previews: some View { + LocationSeachView() + } +} diff --git a/MarvelUI/Core/LocationSearch/View/LocationSearchResultCell.swift b/MarvelUI/Core/LocationSearch/View/LocationSearchResultCell.swift new file mode 100644 index 0000000..5a07fb5 --- /dev/null +++ b/MarvelUI/Core/LocationSearch/View/LocationSearchResultCell.swift @@ -0,0 +1,40 @@ +// +// LocationSearchResultCell.swift +// MarvelUI +// +// Created by Lucas Hubert on 17/05/23. +// + +import SwiftUI + +struct LocationSearchResultCell: View { + var body: some View { + HStack { + Image(systemName: "mappin.circle.fill") + .resizable() + .foregroundColor(.blue) + .accentColor(.white) + .frame(width: 40, height: 40) + + VStack(alignment: .leading) { + Text("Starbucks Coffee") + .font(.body) + + Text("123 Main ST, Cupertino CA") + .font(.system(size: 15)) + .foregroundColor(.gray) + + Divider() + } + .padding(.leading, 8) + .padding(.vertical, 8) + } + .padding(.leading) + } +} + +struct LocationSearchResultCell_Previews: PreviewProvider { + static var previews: some View { + LocationSearchResultCell() + } +} From 8d7902ce4cfa9904fcffbd6685ada8b9a15d4f1f Mon Sep 17 00:00:00 2001 From: Lucas Jorge Hubert Date: Wed, 17 May 2023 14:38:51 -0300 Subject: [PATCH 3/5] add action to search input --- MarvelUI/Core/Home/View/HomeView.swift | 12 ++++++++++-- .../Core/LocationSearch/View/LocationSeachView.swift | 7 ++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/MarvelUI/Core/Home/View/HomeView.swift b/MarvelUI/Core/Home/View/HomeView.swift index ff14677..770b743 100644 --- a/MarvelUI/Core/Home/View/HomeView.swift +++ b/MarvelUI/Core/Home/View/HomeView.swift @@ -8,13 +8,21 @@ import SwiftUI struct HomeView: View { + @State private var showLocationSearchView = false var body: some View { ZStack(alignment: .top) { UberMapViewRepresentable() .ignoresSafeArea() - LocationSearchActivationView() - .padding(.vertical, 72) + if showLocationSearchView { + LocationSeachView() + } else { + LocationSearchActivationView() + .padding(.vertical, 72) + .onTapGesture { + showLocationSearchView.toggle() + } + } MapViewActionButton() .padding(.leading) diff --git a/MarvelUI/Core/LocationSearch/View/LocationSeachView.swift b/MarvelUI/Core/LocationSearch/View/LocationSeachView.swift index 5ff5161..f9b61d9 100644 --- a/MarvelUI/Core/LocationSearch/View/LocationSeachView.swift +++ b/MarvelUI/Core/LocationSearch/View/LocationSeachView.swift @@ -13,7 +13,6 @@ struct LocationSeachView: View { var body: some View { VStack { - // Header View HStack { VStack { Circle() @@ -58,11 +57,9 @@ struct LocationSeachView: View { } } } - - - - // List View } + .background(.white) + .opacity(0.9) } } From b70be9ef525ab3ac367104aee37163eee35ff6f6 Mon Sep 17 00:00:00 2001 From: Lucas Jorge Hubert Date: Wed, 17 May 2023 14:46:29 -0300 Subject: [PATCH 4/5] Add binding to return to main view --- MarvelUI/Core/Home/View/HomeView.swift | 2 +- MarvelUI/Core/Home/View/MapViewActionButton.swift | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/MarvelUI/Core/Home/View/HomeView.swift b/MarvelUI/Core/Home/View/HomeView.swift index 770b743..0ffb6b4 100644 --- a/MarvelUI/Core/Home/View/HomeView.swift +++ b/MarvelUI/Core/Home/View/HomeView.swift @@ -24,7 +24,7 @@ struct HomeView: View { } } - MapViewActionButton() + MapViewActionButton(showLocationSearchView: $showLocationSearchView) .padding(.leading) .padding(.top, 4) } diff --git a/MarvelUI/Core/Home/View/MapViewActionButton.swift b/MarvelUI/Core/Home/View/MapViewActionButton.swift index 774541c..d9c0f67 100644 --- a/MarvelUI/Core/Home/View/MapViewActionButton.swift +++ b/MarvelUI/Core/Home/View/MapViewActionButton.swift @@ -8,9 +8,11 @@ import SwiftUI struct MapViewActionButton: View { + @Binding var showLocationSearchView: Bool + var body: some View { Button { - + showLocationSearchView.toggle() } label: { Image(systemName: "line.3.horizontal") .font(.title2) @@ -26,6 +28,6 @@ struct MapViewActionButton: View { struct MapViewActionButton_Previews: PreviewProvider { static var previews: some View { - MapViewActionButton() + MapViewActionButton(showLocationSearchView: .constant(true)) } } From 0f078ecd965ab8f2d4ac5ec30a95c61840af1f94 Mon Sep 17 00:00:00 2001 From: Lucas Jorge Hubert Date: Wed, 17 May 2023 14:50:32 -0300 Subject: [PATCH 5/5] add animation --- MarvelUI/Core/Home/View/HomeView.swift | 4 +++- MarvelUI/Core/Home/View/MapViewActionButton.swift | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/MarvelUI/Core/Home/View/HomeView.swift b/MarvelUI/Core/Home/View/HomeView.swift index 0ffb6b4..447fd01 100644 --- a/MarvelUI/Core/Home/View/HomeView.swift +++ b/MarvelUI/Core/Home/View/HomeView.swift @@ -20,7 +20,9 @@ struct HomeView: View { LocationSearchActivationView() .padding(.vertical, 72) .onTapGesture { - showLocationSearchView.toggle() + withAnimation(.spring()) { + showLocationSearchView.toggle() + } } } diff --git a/MarvelUI/Core/Home/View/MapViewActionButton.swift b/MarvelUI/Core/Home/View/MapViewActionButton.swift index d9c0f67..30cbc4c 100644 --- a/MarvelUI/Core/Home/View/MapViewActionButton.swift +++ b/MarvelUI/Core/Home/View/MapViewActionButton.swift @@ -12,9 +12,15 @@ struct MapViewActionButton: View { var body: some View { Button { - showLocationSearchView.toggle() + withAnimation(.spring()) { + showLocationSearchView.toggle() + } } label: { - Image(systemName: "line.3.horizontal") + Image( + systemName: showLocationSearchView + ? "arrow.left" + : "line.3.horizontal" + ) .font(.title2) .foregroundColor(.black) .padding()