Skip to content

Commit

Permalink
More updates
Browse files Browse the repository at this point in the history
  • Loading branch information
beyzanurcayrat committed Jan 29, 2024
1 parent a388e7b commit b876a7e
Show file tree
Hide file tree
Showing 7 changed files with 600 additions and 9 deletions.
28 changes: 28 additions & 0 deletions AirbnbApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
36A6D0392B6529D600439F28 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 36A6D0382B6529D600439F28 /* Assets.xcassets */; };
36A6D03C2B6529D600439F28 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 36A6D03B2B6529D600439F28 /* Preview Assets.xcassets */; };
36A6D0522B652C4F00439F28 /* ExploreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36A6D0512B652C4F00439F28 /* ExploreView.swift */; };
36A6D0542B65320E00439F28 /* ListingItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36A6D0532B65320E00439F28 /* ListingItemView.swift */; };
36A6D0562B66F8EA00439F28 /* SearchAndFilterBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36A6D0552B66F8EA00439F28 /* SearchAndFilterBar.swift */; };
36A6D0582B67000900439F28 /* ListingDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36A6D0572B67000900439F28 /* ListingDetailView.swift */; };
36A6D05A2B67009B00439F28 /* ListingImageCarouselView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36A6D0592B67009B00439F28 /* ListingImageCarouselView.swift */; };
36A6D05D2B6713CE00439F28 /* DestinationSearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36A6D05C2B6713CE00439F28 /* DestinationSearchView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -21,6 +26,11 @@
36A6D0382B6529D600439F28 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
36A6D03B2B6529D600439F28 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
36A6D0512B652C4F00439F28 /* ExploreView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExploreView.swift; sourceTree = "<group>"; };
36A6D0532B65320E00439F28 /* ListingItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListingItemView.swift; sourceTree = "<group>"; };
36A6D0552B66F8EA00439F28 /* SearchAndFilterBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchAndFilterBar.swift; sourceTree = "<group>"; };
36A6D0572B67000900439F28 /* ListingDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListingDetailView.swift; sourceTree = "<group>"; };
36A6D0592B67009B00439F28 /* ListingImageCarouselView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListingImageCarouselView.swift; sourceTree = "<group>"; };
36A6D05C2B6713CE00439F28 /* DestinationSearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DestinationSearchView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -96,6 +106,7 @@
36A6D0452B652A2700439F28 /* Core */ = {
isa = PBXGroup;
children = (
36A6D05B2B6700B300439F28 /* Components */,
36A6D0472B652B2B00439F28 /* Explore */,
36A6D04E2B652C0800439F28 /* Listings */,
36A6D0492B652B3900439F28 /* MapView */,
Expand All @@ -120,6 +131,8 @@
isa = PBXGroup;
children = (
36A6D0512B652C4F00439F28 /* ExploreView.swift */,
36A6D0552B66F8EA00439F28 /* SearchAndFilterBar.swift */,
36A6D05C2B6713CE00439F28 /* DestinationSearchView.swift */,
);
name = Explore;
sourceTree = "<group>";
Expand Down Expand Up @@ -162,10 +175,20 @@
36A6D04E2B652C0800439F28 /* Listings */ = {
isa = PBXGroup;
children = (
36A6D0532B65320E00439F28 /* ListingItemView.swift */,
36A6D0572B67000900439F28 /* ListingDetailView.swift */,
);
name = Listings;
sourceTree = "<group>";
};
36A6D05B2B6700B300439F28 /* Components */ = {
isa = PBXGroup;
children = (
36A6D0592B67009B00439F28 /* ListingImageCarouselView.swift */,
);
name = Components;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -236,8 +259,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
36A6D05A2B67009B00439F28 /* ListingImageCarouselView.swift in Sources */,
36A6D05D2B6713CE00439F28 /* DestinationSearchView.swift in Sources */,
36A6D0372B6529D400439F28 /* ContentView.swift in Sources */,
36A6D0542B65320E00439F28 /* ListingItemView.swift in Sources */,
36A6D0522B652C4F00439F28 /* ExploreView.swift in Sources */,
36A6D0562B66F8EA00439F28 /* SearchAndFilterBar.swift in Sources */,
36A6D0582B67000900439F28 /* ListingDetailView.swift in Sources */,
36A6D0352B6529D400439F28 /* AirbnbApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
186 changes: 184 additions & 2 deletions AirbnbApp/DestinationSearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,194 @@

import SwiftUI

enum DestinationSearchOptions {
case location
case dates
case guest
}


struct DestinationSearchView: View {
@Binding var show: Bool
@State private var destination = ""
@State private var selectedOption: DestinationSearchOptions = .location
@State private var startDate = Date()
@State private var endDate = Date()
@State private var numGuests = 0

var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)

VStack {
HStack {
Button {
withAnimation(.snappy){
show.toggle()
}

} label: {
Image(systemName: "xmark.circle")
.imageScale(.large)
.foregroundStyle(.black)
}

Spacer()


if !destination.isEmpty {
Button("Clear") {
destination = ""
}
.foregroundStyle(.black)
.font(.subheadline)
.fontWeight(.semibold)
}
}
.padding()

VStack(alignment: .leading){

if selectedOption == .location {
Text("Where to?")
.font(.title2)
.fontWeight(.semibold)

HStack{
Image(systemName: "magnifyingglass")
.imageScale(.small)

TextField("Search destinatios", text: $destination)
.font(.subheadline)
}
.frame(height: 44)
.padding(.horizontal)
.overlay {
RoundedRectangle(cornerRadius: 8)
.stroke(lineWidth: /*@START_MENU_TOKEN@*/1.0/*@END_MENU_TOKEN@*/)
.foregroundColor(Color(.systemGray4))
}


} else {
CollapsedPickerView(title: "Where", description: "Add destination")

}
}

.modifier(CollapsibleDestinationViewModifier())
.frame(height: selectedOption == .location ? 120 : 64)

.onTapGesture {
withAnimation(.snappy) {
selectedOption = .location
}
}

//date selection view


VStack(alignment: .leading) {
if selectedOption == .dates {

Text("When's your trip?")
.font(.title2)
.fontWeight(.semibold)

VStack {
DatePicker("From", selection: $startDate, displayedComponents: .date)

Divider()

DatePicker("To", selection: $endDate, displayedComponents: .date)


}
.foregroundStyle(.gray)
.font(.subheadline)
.fontWeight(.semibold)


} else {

CollapsedPickerView(title: "When", description: "Add dates")

}
}
.modifier(CollapsibleDestinationViewModifier())
.frame(height: selectedOption == .dates ? 180 : 64)
.onTapGesture {
withAnimation(.snappy) {
selectedOption = .dates
}
}



VStack(alignment: .leading) {
if selectedOption == .guest {
Text("Who's coming")
.font(.title)
.fontWeight(.semibold)

Stepper {
Text("\(numGuests) Adults")
} onIncrement: {
numGuests += 1
} onDecrement: {
guard numGuests > 0 else {return}
numGuests -= 1
}

} else {
CollapsedPickerView(title: "Who", description: "Add guests")

}

}
.modifier(CollapsibleDestinationViewModifier())
.frame(height: selectedOption == .guest ? 120 : 64)
.onTapGesture {
withAnimation(.snappy) {
selectedOption = .guest
} }

Spacer()
}
}
}

#Preview {
DestinationSearchView()
DestinationSearchView(show: .constant(false))
}

struct CollapsibleDestinationViewModifier: ViewModifier {
func body(content: Content) -> some View {
content
.padding()
.background(.white)
.clipShape(RoundedRectangle(cornerRadius: 12))
.padding()
.shadow(radius: 10)
}
}


struct CollapsedPickerView: View {
let title: String
let description: String
var body: some View {

VStack {
HStack{
Text(title)
.foregroundStyle(.gray)

Spacer()

Text(description)
}
.fontWeight(.semibold)
.font(.subheadline)
}

}
}
34 changes: 33 additions & 1 deletion AirbnbApp/ExploreView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,47 @@
import SwiftUI

struct ExploreView: View {
@State private var showDestinationSearchView = false


var body: some View {
NavigationStack {
ScrollView{
if showDestinationSearchView{
DestinationSearchView(show: $showDestinationSearchView)

} else {


ScrollView{
SearchAndFilterBar()
.onTapGesture {
withAnimation(.snappy){
showDestinationSearchView.toggle()
}
}


LazyVStack(spacing: 32){
ForEach(0 ... 10, id: \.self) { listing in
NavigationLink(value: listing) {
ListingItemView()
.frame(height: 400)
.clipShape(RoundedRectangle(cornerRadius: 10))
}
}
}
.padding()
}
.navigationDestination(for: Int.self) { listing in
ListingDetailView()
.navigationBarBackButtonHidden()
}
}
}
}
}


#Preview {
ExploreView()
}
Loading

0 comments on commit b876a7e

Please sign in to comment.