diff --git a/MarvelUI.xcodeproj/project.pbxproj b/MarvelUI.xcodeproj/project.pbxproj index 94fdb6f..3277738 100644 --- a/MarvelUI.xcodeproj/project.pbxproj +++ b/MarvelUI.xcodeproj/project.pbxproj @@ -18,6 +18,10 @@ 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 */; }; + 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 */ @@ -53,6 +57,10 @@ 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 = ""; }; + 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 */ @@ -167,8 +175,8 @@ C9CFFE782A151CB700708A15 /* Core */ = { isa = PBXGroup; children = ( - C9CFFE7B2A151D0C00708A15 /* View */, - C9CFFE7A2A151D0400708A15 /* ViewModel */, + C9CFFE832A153D3E00708A15 /* LocationSearch */, + C9CFFE822A153D3400708A15 /* Home */, ); path = Core; sourceTree = ""; @@ -193,10 +201,46 @@ 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 */, + C9CFFE8A2A15410900708A15 /* LocationSeachView.swift */, + C9CFFE8C2A15447800708A15 /* LocationSearchResultCell.swift */, ); path = View; sourceTree = ""; }; + C9CFFE852A153D5200708A15 /* ViewModel */ = { + isa = PBXGroup; + children = ( + ); + path = ViewModel; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -327,12 +371,16 @@ 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 */, + 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..447fd01 --- /dev/null +++ b/MarvelUI/Core/Home/View/HomeView.swift @@ -0,0 +1,40 @@ +// +// HomeView.swift +// MarvelUI +// +// Created by Lucas Hubert on 17/05/23. +// + +import SwiftUI + +struct HomeView: View { + @State private var showLocationSearchView = false + var body: some View { + ZStack(alignment: .top) { + UberMapViewRepresentable() + .ignoresSafeArea() + + if showLocationSearchView { + LocationSeachView() + } else { + LocationSearchActivationView() + .padding(.vertical, 72) + .onTapGesture { + withAnimation(.spring()) { + showLocationSearchView.toggle() + } + } + } + + MapViewActionButton(showLocationSearchView: $showLocationSearchView) + .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..30cbc4c --- /dev/null +++ b/MarvelUI/Core/Home/View/MapViewActionButton.swift @@ -0,0 +1,39 @@ +// +// MapViewActionButton.swift +// MarvelUI +// +// Created by Lucas Hubert on 17/05/23. +// + +import SwiftUI + +struct MapViewActionButton: View { + @Binding var showLocationSearchView: Bool + + var body: some View { + Button { + withAnimation(.spring()) { + showLocationSearchView.toggle() + } + } label: { + Image( + systemName: showLocationSearchView + ? "arrow.left" + : "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(showLocationSearchView: .constant(true)) + } +} 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/LocationSeachView.swift b/MarvelUI/Core/LocationSearch/View/LocationSeachView.swift new file mode 100644 index 0000000..f9b61d9 --- /dev/null +++ b/MarvelUI/Core/LocationSearch/View/LocationSeachView.swift @@ -0,0 +1,70 @@ +// +// 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 { + 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() + } + } + } + } + .background(.white) + .opacity(0.9) + } +} + +struct LocationSeachView_Previews: PreviewProvider { + static var previews: some View { + LocationSeachView() + } +} 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/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() + } +} 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() - } -}