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

[Team05 - iOS] 네번째 PR #297

Open
wants to merge 19 commits into
base: team-05
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e269d5a
feat :sparkles:: Wishlist & Reservation 각 Vie에서 Lazy 삭제
JasonLee0223 Jun 6, 2022
e4bac74
feat :sparkles:: SearchVC에서 HomeVC로 네이밍 변경
JasonLee0223 Jun 6, 2022
6bccf6b
feat :sparkles:: SearchView 그룹명 HomeView로 네이밍 변경
JasonLee0223 Jun 6, 2022
0a86129
feat :sparkles:: SearchViewController 생성
JasonLee0223 Jun 7, 2022
c6b2a78
feat :sparkles:: searchViewDataSource 구현
JasonLee0223 Jun 7, 2022
4a12ad1
feat :sparkles:: searchViewDataSource 구현
JasonLee0223 Jun 7, 2022
78ffff0
feat :sparkles:: searchView Layout 호출 및 collectionView layout 구현
JasonLee0223 Jun 7, 2022
d2e0a99
feat :sparkles:: searchViewCell 구현
JasonLee0223 Jun 7, 2022
6085194
feat :sparkles:: searchViewLayout 구현
JasonLee0223 Jun 7, 2022
36d36e9
feat :sparkles:: searchController 구현
JasonLee0223 Jun 7, 2022
5e01e7f
feat :sparkles:: cocoapods 설치
JasonLee0223 Jun 7, 2022
adc8f42
feat :sparkles:: SPM으로 Snapkit 설치
JasonLee0223 Jun 8, 2022
babf72b
feat :sparkles:: 자동완성기능이 들어갈 LocationTableViewController 파일 생성
JasonLee0223 Jun 9, 2022
ba6867a
feat :sparkles:: location TableView에 들어갈 Cell 파일생성
JasonLee0223 Jun 9, 2022
d353d87
feat :sparkles:: LocationViewCell 구현
JasonLee0223 Jun 9, 2022
9967750
feat :sparkles:: locationViewController Mapkit 관련 내용 구현
JasonLee0223 Jun 9, 2022
994b839
feat :sparkles:: LocationViewDataSource 구현
JasonLee0223 Jun 9, 2022
9d5a18f
feat :sparkles:: LocationView 화면 출력까지 구현
JasonLee0223 Jun 9, 2022
6c3ee07
feat :sparkles:: SearchVC에서 LocationVC 로 넘어가는 부분 수정
JasonLee0223 Jun 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
231 changes: 214 additions & 17 deletions iOS/Airbnb/Airbnb.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>Airbnb.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>7</integer>
</dict>
</dict>
</dict>
Expand Down
10 changes: 10 additions & 0 deletions iOS/Airbnb/Airbnb.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "SnapKit",
"repositoryURL": "https://github.com/SnapKit/SnapKit",
"state": {
"branch": "develop",
"revision": "07c5d1f6044701d97e94dc11157259e8811977be",
"version": null
}
}
]
},
"version": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "cityBox.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.
115 changes: 115 additions & 0 deletions iOS/Airbnb/Airbnb/View/DataSource/HomeViewDataSource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//
// SearchViewDataSource.swift
// Airbnb
//
// Created by Jason on 2022/05/27.
//

import UIKit

final class HomeViewDataSource: NSObject, UICollectionViewDataSource {

var homeData: [MyHomeSection] = [
.advertising([MyHomeSection.advertisingItem.init(image: UIImage(named: "mainImage") ?? UIImage())] ),
.destination([MyHomeSection.destinationItem].init(repeating: MyHomeSection.destinationItem.init(image: UIImage(named: "seoul") ?? UIImage(),
title: "서울", distance: "차로 30분 거리"), count: 20)),
.livingSpot([MyHomeSection.livingSpotItem].init(repeating: MyHomeSection.livingSpotItem.init(image: UIImage(named: "blackHouse") ?? UIImage(), title: "자연생활을 만끽할 수 있는 숙소"), count: 5))
]

func numberOfSections(in collectionView: UICollectionView) -> Int {
return homeData.count
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
switch homeData[section] {
case let .advertising(items):
return items.count
case let .destination(items):
return items.count
case let .livingSpot(items):
return items.count
}
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
switch homeData[indexPath.section] {
case let .advertising(items):
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: AdvertisingCell.identifier,
for: indexPath) as? AdvertisingCell else {
return UICollectionViewCell()
}
cell.configure(image: items[indexPath.item].image)

return cell
case let .destination(items):
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: NearbyDestinationCell.identifier,
for: indexPath) as? NearbyDestinationCell else {
return UICollectionViewCell()
}
let item = items[indexPath.item]
cell.configure(image: item.image, title: item.title, distance: item.distance)

return cell
case let .livingSpot(items):
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: LivingSpotCell.identifier,
for: indexPath) as? LivingSpotCell else {
return UICollectionViewCell()
}
let item = items[indexPath.item]
cell.configure(image: item.image, title: item.title)

return cell
}
}

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
switch kind {
case UICollectionView.elementKindSectionHeader:
guard let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: CollectionHeaderView.identifier, for: indexPath) as? CollectionHeaderView else {
return UICollectionReusableView()
}

let sectionType = SectionList.allCases[indexPath.section]
switch sectionType {
case .otherwise:
headerView.setHeaderText(text: "")
case .destination:
headerView.setHeaderText(text: "가까운 여행지 둘러보기")
headerView.setHeaderFontSize(size: 22)
case .livingSpot:
headerView.setHeaderText(text: "어디에서나,\n여행은 살아보는거야!")
headerView.setHeaderFontSize(size: 22)
}

return headerView
default:
return UICollectionReusableView()
}
}

enum MyHomeSection {
case advertising([advertisingItem])
case destination([destinationItem])
case livingSpot([livingSpotItem])

struct advertisingItem {
let image: UIImage
}

struct destinationItem {
let image: UIImage
let title: String
let distance: String
}

struct livingSpotItem {
let image: UIImage
let title: String
}
}
enum SectionList: Int, CaseIterable {
case otherwise = 0
case destination
case livingSpot
}
}
28 changes: 28 additions & 0 deletions iOS/Airbnb/Airbnb/View/DataSource/LocationViewDataSource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// LocationViewDataSource.swift
// Airbnb
//
// Created by Jason on 2022/06/10.
//

import UIKit
import MapKit

final class LocationViewDataSource: NSObject, UITableViewDataSource {

private var completerResults: [MKLocalSearchCompletion]?

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return completerResults?.count ?? 0
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: LocationViewCell.identifier, for: indexPath) as? LocationViewCell else { return UITableViewCell() }

if let suggestion = completerResults?[indexPath.row] {
cell.configure(location: suggestion.title)
}
return cell
}

}
93 changes: 21 additions & 72 deletions iOS/Airbnb/Airbnb/View/DataSource/SearchViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,114 +2,63 @@
// SearchViewDataSource.swift
// Airbnb
//
// Created by Jason on 2022/05/27.
// Created by 이건행 on 2022/06/07.
//

import UIKit

final class SearchViewDataSource: NSObject, UICollectionViewDataSource {

var homeData: [MyHomeSection] = [
.advertising([MyHomeSection.advertisingItem.init(image: UIImage(named: "mainImage") ?? UIImage())] ),
.destination([MyHomeSection.destinationItem].init(repeating: MyHomeSection.destinationItem.init(image: UIImage(named: "seoul") ?? UIImage(),
title: "서울", distance: "차로 30분 거리"), count: 20)),
.livingSpot([MyHomeSection.livingSpotItem].init(repeating: MyHomeSection.livingSpotItem.init(image: UIImage(named: "blackHouse") ?? UIImage(), title: "자연생활을 만끽할 수 있는 숙소"), count: 5))
var searchData: [MySearchSection] = [
.searchListSection([MySearchSection.searchListItem].init(repeating: MySearchSection.searchListItem.init(image: UIImage(named:"seoul") ?? UIImage(), title: "서울", distance: "차로 30분 거리"), count: 10))
]

func numberOfSections(in collectionView: UICollectionView) -> Int {
return homeData.count
return searchData.count
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
switch homeData[section] {
case let .advertising(items):
return items.count
case let .destination(items):
return items.count
case let .livingSpot(items):
switch searchData[section] {
case let .searchListSection(items):
return items.count
}
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
switch homeData[indexPath.section] {
case let .advertising(items):
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: AdvertisingCell.identifier,
for: indexPath) as? AdvertisingCell else {
return UICollectionViewCell()
}
cell.configure(image: items[indexPath.item].image)

switch searchData[indexPath.section] {

return cell
case let .destination(items):
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: NearbyDestinationCell.identifier,
for: indexPath) as? NearbyDestinationCell else {
case let .searchListSection(items):
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: SearchViewCell.identifier,
for: indexPath) as? SearchViewCell else {
return UICollectionViewCell()
}
let item = items[indexPath.item]
cell.configure(image: item.image, title: item.title, distance: item.distance)

return cell
case let .livingSpot(items):
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: LivingSpotCell.identifier,
for: indexPath) as? LivingSpotCell else {
return UICollectionViewCell()
}
let item = items[indexPath.item]
cell.configure(image: item.image, title: item.title)

return cell
}
}

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
switch kind {
case UICollectionView.elementKindSectionHeader:
guard let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: CollectionHeaderView.identifier, for: indexPath) as? CollectionHeaderView else {
return UICollectionReusableView()
}

let sectionType = SectionList.allCases[indexPath.section]
switch sectionType {
case .otherwise:
headerView.setHeaderText(text: "")
case .destination:
headerView.setHeaderText(text: "가까운 여행지 둘러보기")
headerView.setHeaderFontSize(size: 22)
case .livingSpot:
headerView.setHeaderText(text: "어디에서나,\n여행은 살아보는거야!")
headerView.setHeaderFontSize(size: 22)
}

return headerView
default:
guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: CollectionHeaderView.identifier, for: indexPath) as? CollectionHeaderView else {
return UICollectionReusableView()
}
if indexPath.section == 0 {
header.setHeaderText(text: "근처의 인기 여행지")
header.setHeaderFontSize(size: 22)
}

return header
}

enum MyHomeSection {
case advertising([advertisingItem])
case destination([destinationItem])
case livingSpot([livingSpotItem])

struct advertisingItem {
let image: UIImage
}
enum MySearchSection {
case searchListSection([searchListItem])

struct destinationItem {
struct searchListItem {
let image: UIImage
let title: String
let distance: String
}

struct livingSpotItem {
let image: UIImage
let title: String
}
}
enum SectionList: Int, CaseIterable {
case otherwise = 0
case destination
case livingSpot
}
}
44 changes: 44 additions & 0 deletions iOS/Airbnb/Airbnb/View/Location/LocationView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// LocationView.swift
// Airbnb
//
// Created by Jason on 2022/06/10.
//

import UIKit

final class LocationView: UITableView {

override init(frame: CGRect, style: UITableView.Style) {
super.init(frame: frame, style: .grouped)
setupLocationTableView()
setupLocationViewLayout()
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError()
}

private let tableView: UITableView = {
let tableView = UITableView()
tableView.backgroundColor = .yellow
return tableView
}()

func setupLocationTableView() {
tableView.register(LocationViewCell.self, forCellReuseIdentifier: LocationViewCell.identifier)
tableView.separatorStyle = .none
}

func setupLocationViewLayout() {
addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
tableView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor),
tableView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor),
tableView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor),
tableView.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor)
])
}
}
Loading