Skip to content

Commit

Permalink
Merge pull request #1 from LucasJorgeHubert/feature/location-search
Browse files Browse the repository at this point in the history
Feature - Location Search inputs and list
  • Loading branch information
LucasJorgeHubert authored May 17, 2023
2 parents a768ccf + 0f078ec commit d44b611
Show file tree
Hide file tree
Showing 8 changed files with 275 additions and 23 deletions.
52 changes: 50 additions & 2 deletions MarvelUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -53,6 +57,10 @@
C9CFFE7C2A151D2400708A15 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
C9CFFE7E2A151D9000708A15 /* UberMapViewRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UberMapViewRepresentable.swift; sourceTree = "<group>"; };
C9CFFE802A151F7400708A15 /* LocationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationManager.swift; sourceTree = "<group>"; };
C9CFFE862A153D7500708A15 /* LocationSearchActivationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationSearchActivationView.swift; sourceTree = "<group>"; };
C9CFFE882A153FA800708A15 /* MapViewActionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapViewActionButton.swift; sourceTree = "<group>"; };
C9CFFE8A2A15410900708A15 /* LocationSeachView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationSeachView.swift; sourceTree = "<group>"; };
C9CFFE8C2A15447800708A15 /* LocationSearchResultCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationSearchResultCell.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -167,8 +175,8 @@
C9CFFE782A151CB700708A15 /* Core */ = {
isa = PBXGroup;
children = (
C9CFFE7B2A151D0C00708A15 /* View */,
C9CFFE7A2A151D0400708A15 /* ViewModel */,
C9CFFE832A153D3E00708A15 /* LocationSearch */,
C9CFFE822A153D3400708A15 /* Home */,
);
path = Core;
sourceTree = "<group>";
Expand All @@ -193,10 +201,46 @@
children = (
C9CFFE7C2A151D2400708A15 /* HomeView.swift */,
C9CFFE7E2A151D9000708A15 /* UberMapViewRepresentable.swift */,
C9CFFE882A153FA800708A15 /* MapViewActionButton.swift */,
);
path = View;
sourceTree = "<group>";
};
C9CFFE822A153D3400708A15 /* Home */ = {
isa = PBXGroup;
children = (
C9CFFE7B2A151D0C00708A15 /* View */,
C9CFFE7A2A151D0400708A15 /* ViewModel */,
);
path = Home;
sourceTree = "<group>";
};
C9CFFE832A153D3E00708A15 /* LocationSearch */ = {
isa = PBXGroup;
children = (
C9CFFE852A153D5200708A15 /* ViewModel */,
C9CFFE842A153D4D00708A15 /* View */,
);
path = LocationSearch;
sourceTree = "<group>";
};
C9CFFE842A153D4D00708A15 /* View */ = {
isa = PBXGroup;
children = (
C9CFFE862A153D7500708A15 /* LocationSearchActivationView.swift */,
C9CFFE8A2A15410900708A15 /* LocationSeachView.swift */,
C9CFFE8C2A15447800708A15 /* LocationSearchResultCell.swift */,
);
path = View;
sourceTree = "<group>";
};
C9CFFE852A153D5200708A15 /* ViewModel */ = {
isa = PBXGroup;
children = (
);
path = ViewModel;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -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;
};
Expand Down
40 changes: 40 additions & 0 deletions MarvelUI/Core/Home/View/HomeView.swift
Original file line number Diff line number Diff line change
@@ -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()
}
}
39 changes: 39 additions & 0 deletions MarvelUI/Core/Home/View/MapViewActionButton.swift
Original file line number Diff line number Diff line change
@@ -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))
}
}
70 changes: 70 additions & 0 deletions MarvelUI/Core/LocationSearch/View/LocationSeachView.swift
Original file line number Diff line number Diff line change
@@ -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()
}
}
Original file line number Diff line number Diff line change
@@ -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()
}
}
40 changes: 40 additions & 0 deletions MarvelUI/Core/LocationSearch/View/LocationSearchResultCell.swift
Original file line number Diff line number Diff line change
@@ -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()
}
}
21 changes: 0 additions & 21 deletions MarvelUI/Core/View/HomeView.swift

This file was deleted.

0 comments on commit d44b611

Please sign in to comment.