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

[Team01][iOS] 로그인 기능 구현, SPM 적용 및 임시 달력 적용 #310

Open
wants to merge 9 commits into
base: team01
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
509 changes: 93 additions & 416 deletions iOS/airbnb/airbnb.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"pins" : [
{
"identity" : "alamofire",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Alamofire/Alamofire.git",
"state" : {
"revision" : "354dda32d89fc8cd4f5c46487f64957d355f53d8",
"version" : "5.6.1"
}
},
{
"identity" : "fscalendar",
"kind" : "remoteSourceControl",
"location" : "https://github.com/WenchaoD/FSCalendar.git",
"state" : {
"revision" : "0fbdec5172fccb90f707472eeaea4ffe095278f6",
"version" : "2.8.4"
}
},
{
"identity" : "horizoncalendar",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/HorizonCalendar.git",
"state" : {
"revision" : "93b188c52650b3999eeb20cf256b69715de515ef",
"version" : "1.13.4"
}
},
{
"identity" : "snapkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SnapKit/SnapKit.git",
"state" : {
"revision" : "f222cbdf325885926566172f6f5f06af95473158",
"version" : "5.6.0"
}
}
],
"version" : 2
}
10 changes: 0 additions & 10 deletions iOS/airbnb/airbnb.xcworkspace/contents.xcworkspacedata

This file was deleted.

This file was deleted.

11 changes: 11 additions & 0 deletions iOS/airbnb/airbnb/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>3.36.56.107:8080</string>
</array>
</dict>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "GitHub-Emblem.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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Google_Logo.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.
25 changes: 25 additions & 0 deletions iOS/airbnb/airbnb/Sources/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum Title {
}

enum Size {
static let barHeight = CGFloat(95)
static let heroImageCell = CGSize(width: 250, height: 500)
}

Expand Down Expand Up @@ -61,6 +62,16 @@ enum Layout {
return section
}()

static let calendarLayout: UICollectionViewCompositionalLayout = {
let item = NSCollectionLayoutItem(layoutSize: .init(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1.3)))

let group = NSCollectionLayoutGroup.horizontal(layoutSize: .init(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(0.5)), subitems: [item])

let section = NSCollectionLayoutSection(group: group)
section.contentInsets.bottom = 150
return UICollectionViewCompositionalLayout(section: section)
}()

static func createLayout() -> UICollectionViewCompositionalLayout {
return UICollectionViewCompositionalLayout { (sectionNumber, env) -> NSCollectionLayoutSection? in
if sectionNumber == 0 {
Expand All @@ -69,3 +80,17 @@ enum Layout {
}
}
}

enum UIComponents {
static let navigationBarUnderLineView: UIView = {
let view = UIView()
view.backgroundColor = .line
return view
}()

static let backButton: UIBarButtonItem = {
let buttonItem = UIBarButtonItem(title: "뒤로", style: .plain, target: nil, action: nil)
buttonItem.tintColor = .black
return buttonItem
}()
Comment on lines +91 to +95

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View가 Static하게 선언된다면 해당 View를 사용하는 모든 곳에서 변경 사항의 영향을 받게될 것 같네요..!
View의 생성 코드를 줄이고 싶으신 의도라면 factory method를 작성하는 게 방법이 될 것 같습니다.

}
65 changes: 65 additions & 0 deletions iOS/airbnb/airbnb/Sources/Controller/CalendarViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// CalendarViewController.swift
// airbnb
//
// Created by Jihee hwang on 2022/06/07.
//

import UIKit
import SnapKit
import FSCalendar

final class CalendarViewController: UIViewController {

private let clearButton: UIBarButtonItem = {
let buttonItem = UIBarButtonItem(title: "지우기", style: .plain, target: nil, action: nil)
buttonItem.tintColor = .gray3
return buttonItem
}()

private let nextButton: UIBarButtonItem = {
let buttonItem = UIBarButtonItem(title: "다음", style: .plain, target: nil, action: nil)
buttonItem.tintColor = .black
return buttonItem
}()

private lazy var toolBar: UIToolbar = {
let toolBar = UIToolbar()
let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil)
toolBar.setItems([clearButton, flexibleSpace, nextButton], animated: true)
return toolBar
}()

private let calendarView = FSCalendar(frame: .zero)

override func viewDidLoad() {
super.viewDidLoad()
configureView()
layout()
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(false)
navigationController?.tabBarController?.tabBar.isHidden = false
Comment on lines +42 to +43

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

animated는 무조건 false로 하는 걸까요?
그리고 viewWillDisappear에서 탭바를 나타내주는 동작이 있다면 혹시 사라져야하는 때도 있나요?

}

private func configureView() {
view.backgroundColor = .white
title = "숙소 찾기"

navigationController?.tabBarController?.tabBar.isHidden = true
}

private func layout() {
view.addSubview(toolBar)
view.addSubview(calendarView)

toolBar.snp.makeConstraints {
$0.bottom.leading.trailing.equalTo(view.safeAreaLayoutGuide)
}

calendarView.snp.makeConstraints {
$0.top.leading.trailing.bottom.equalTo(view.safeAreaLayoutGuide)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 모든 변에 같은 constraint를 설정하는 경우에는 edges를 사용할 수 있습니다 :)

}
}
}
21 changes: 12 additions & 9 deletions iOS/airbnb/airbnb/Sources/Controller/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ final class HomeViewController: UIViewController {

private let dataSource = HomeCollectionViewDataSource()

private let backButton: UIBarButtonItem = {
let buttonItem = UIBarButtonItem(title: "뒤로", style: .plain, target: nil, action: nil)
buttonItem.tintColor = .black
return buttonItem
}()
private lazy var loginButton = UIBarButtonItem(image: UIImage(systemName: "person"), style: .plain, target: self, action: #selector(didTabLoginButton))

private let searchBarController: UISearchController = {
let searchController = UISearchController(searchResultsController: nil)
Expand Down Expand Up @@ -52,8 +48,10 @@ final class HomeViewController: UIViewController {

navigationItem.searchController = searchBarController
navigationItem.titleView = logoImageView
navigationItem.backBarButtonItem = backButton
navigationItem.backBarButtonItem = UIComponents.backButton
navigationItem.rightBarButtonItem = loginButton
navigationItem.hidesSearchBarWhenScrolling = false
loginButton.tintColor = .black

searchBarController.searchBar.delegate = self
}
Expand All @@ -68,18 +66,23 @@ final class HomeViewController: UIViewController {

private func layout() {
view.addSubview(collectionView)

collectionView.snp.makeConstraints {
$0.edges.equalTo(view.safeAreaLayoutGuide)
}
}

@objc func didTabLoginButton(_ sender: Any) {
let nextViewController = LoginViewController()
navigationController?.pushViewController(nextViewController, animated: true)
}
}

// MARK: - extension

extension HomeViewController: UISearchBarDelegate {
func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
let searchViewController = SearchViewController()
navigationController?.pushViewController(searchViewController, animated: true)
let nextViewController = SearchViewController()
navigationController?.pushViewController(nextViewController, animated: true)
}
}
87 changes: 87 additions & 0 deletions iOS/airbnb/airbnb/Sources/Controller/LoginViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
//
// LoginViewController.swift
// airbnb
//
// Created by Jihee hwang on 2022/06/10.
//

import UIKit
import SnapKit

final class LoginViewController: UIViewController {

private let gitHubLoginButton: UIButton = {
var config = UIButton.Configuration.bordered()
config.baseBackgroundColor = .white
config.cornerStyle = .capsule
config.background.cornerRadius = 20
config.background.strokeColor = .line
config.baseForegroundColor = .black
config.image = UIImage(named: "GitHub_Logo")
config.imagePadding = 10
config.imagePlacement = .leading

let button = UIButton(configuration: config)
button.addTarget(self, action: #selector(didTabGithubLogin(_:)), for: .touchUpInside)
return button
}()

private let googleLoginButton: UIButton = {
var config = UIButton.Configuration.bordered()
config.baseBackgroundColor = .white
config.cornerStyle = .capsule
config.background.cornerRadius = 20
config.background.strokeColor = .line
config.baseForegroundColor = .black
config.image = UIImage(named: "Google_Logo")
config.imagePadding = 10
config.imagePlacement = .leading

let button = UIButton(configuration: config)
button.addTarget(self, action: #selector(didTabGithubLogin(_:)), for: .touchUpInside)
return button
}()

override func viewDidLoad() {
super.viewDidLoad()
configureView()
layout()
}

private func configureView() {
view.backgroundColor = .white
title = "로그인"
navigationItem.backBarButtonItem = UIComponents.backButton

navigationController?.tabBarController?.tabBar.isHidden = true
}

private func layout() {
view.addSubview(UIComponents.navigationBarUnderLineView)
view.addSubview(gitHubLoginButton)
view.addSubview(googleLoginButton)

UIComponents.navigationBarUnderLineView.snp.makeConstraints {
$0.top.leading.trailing.equalTo(view.safeAreaLayoutGuide)
$0.height.equalTo(1)
}

gitHubLoginButton.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.centerY.equalToSuperview().offset(-40)
$0.width.equalTo(300)
$0.height.equalTo(60)
}

googleLoginButton.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.centerY.equalToSuperview().offset(40)
$0.width.equalTo(300)
$0.height.equalTo(60)
}
Comment on lines +69 to +81

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런 경우에는 StackView를 만들어서 묶어주는 것도 좋아 보입니다!
중복적인 constraints를 줄일 수 있고, 소셜로그인 같은 경우엔 종류가 늘어날 가능성이 높으니까요 :)
참고삼아 말씀드리자면 실제 앱을 배포하기 위해서는 소셜로그인을 구현한 경우엔 apple sign up 버튼도 필수적으로 구현이 되어야 합니다ㅎㅎ

}

@objc func didTabGithubLogin(_ sender: Any) {
LoginManager.shared.requestCode()
}
}
Loading