Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yungu0010 committed Jul 13, 2022
2 parents 1cd9793 + 366bdc6 commit e1f0b6e
Show file tree
Hide file tree
Showing 43 changed files with 557 additions and 89 deletions.
102 changes: 60 additions & 42 deletions HealthFoodMe/HealthFoodMe.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ protocol ModuleFactoryProtocol {

// MARK: - Map
func makeMainMapVC() -> MainMapVC
func makeHamburgerBarVC() -> HamburgerBarVC

// MARK: - Detail
func makeMainDetailVC() -> MainDetailVC
func makeMenuTabVC() -> MenuTabVC

// MARK: - Search
func makeSearchVC() -> SearchVC
}

class ModuleFactory: ModuleFactoryProtocol {

static func resolve() -> ModuleFactory {
return ModuleFactory()
}
Expand All @@ -36,6 +38,12 @@ class ModuleFactory: ModuleFactoryProtocol {
return vc
}

func makeHamburgerBarVC() -> HamburgerBarVC {
let vc = HamburgerBarVC.controllerFromStoryboard(.hamburgerBar)

return vc
}

// MARK: - Detail
func makeMainDetailVC() -> MainDetailVC {
let repository = DefaultMainDetailRepository()
Expand All @@ -47,14 +55,19 @@ class ModuleFactory: ModuleFactoryProtocol {
return vc
}

func makeMenuTabVC() -> MenuTabVC {
let vc = MenuTabVC.controllerFromStoryboard(.menuTab)

return vc
}

// MARK: - Search
func makeSearchVC() -> SearchVC {
let vc = SearchVC.controllerFromStoryboard(.search)

return vc
}


// MARK: - Plan

// func instantiatePlanPreviewVC(postID: Int) -> PlanPreviewVC {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class APIEventLogger: EventMonitor {

switch response.result {

case .success(_):
case .success:
print("3️⃣ 서버 연결 성공")
case .failure(_):
case .failure:
print("3️⃣ 서버 연결 실패")
print("올바른 URL인지 확인해보세요.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@

import UIKit

struct MainMapModel {
struct MapPointDataModel {
let latitude: Double
let longtitude: Double
let type: PointerType
}

enum PointerType {
case normalFood
case healthFood
}

struct MainMapCategory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ struct I18N {
}

struct Map {
struct Main {
static let searchBar = "식당, 음식 검색"
}

struct HamburgerBar {
static let logout = "로그아웃"
static let setting = "설정"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import UIKit

//필요한 셀에 TVC.register(target:TV이름) 형태로 등록 해주기!!!! (원래는 TVC, TV위치가 반대)
//isFromNib는 true일 경우에는 Xib로 TVC 만든거고, false일 경우에는 코드로 TVC 만든거!
protocol UITableViewRegisterable {
static var isFromNib: Bool { get }
static func register(target: UITableView)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@
{
"images" : [
{
"filename" : "icn_diet_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icn_diet_selected@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icn_diet_selected@3x.png",
"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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@
{
"images" : [
{
"filename" : "icn_normal_seleted.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icn_normal_seleted@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icn_normal_seleted@3x.png",
"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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions HealthFoodMe/HealthFoodMe/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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>UIUserInterfaceStyle</key>
<string>Light</string>
<key>UIAppFonts</key>
<array>
<string>Pretendard-Bold.otf</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ extension SocialLoginVC {
if UserApi.isKakaoTalkLoginAvailable() {
// 카카오톡 로그인. api 호출 결과를 클로저로 전달.
UserApi.shared.loginWithKakaoTalk { (oauthToken, error) in
if let _ = error { self.showKakaoLoginFailMessage() } else {
if error != nil { self.showKakaoLoginFailMessage() } else {
if let accessToken = oauthToken?.accessToken {
// 엑세스 토큰 받아와서 서버에게 넘겨주는 로직 작성

Expand All @@ -83,7 +83,7 @@ extension SocialLoginVC {
}
} else { // 웹으로 로그인해도 똑같이 처리되도록
UserApi.shared.loginWithKakaoAccount { (oauthToken, error) in
if let _ = error { self.showKakaoLoginFailMessage() } else {
if error != nil { self.showKakaoLoginFailMessage() } else {
if let accessToken = oauthToken?.accessToken {
print("TOKEN", accessToken)
self.postSocialLoginData(socialToken: accessToken, socialType: "KAKAO")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
//
// CustomSegementControl.swift
// HealthFoodMe
//
// Created by 송지훈 on 2022/07/13.
//

import UIKit

import SnapKit

final class CustomSegmentControl: UIView {

internal var areaClickEvent: ((Int) -> Void)?
internal var containerColor: UIColor = .init(red: 242/255, green: 242/255, blue: 242/255, alpha: 1)
internal var selectColor: UIColor = .white
internal var titleList: [String] = ["첫번째","두번째"]
internal var width: CGFloat = 226
private lazy var selectedView = UIView()
private lazy var containerStackView = UIStackView()

override init(frame: CGRect) {
super.init(frame: frame)
setUI()
setStackView()
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setUI()
setStackView()
}
}

extension CustomSegmentControl {
private func setStackView() {
containerStackView.axis = .horizontal
containerStackView.spacing = 0
containerStackView.distribution = .fillEqually
for (index, _) in titleList.enumerated() {
let buttonContainerView = UIView()
let button = UIButton()
let titleLabel = UILabel()

titleLabel.textAlignment = .center
titleLabel.text = titleList[index]
titleLabel.textColor = UIColor.init(red: 34/255,
green: 34/255,
blue: 34/255,
alpha: 1)
titleLabel.font = UIFont.systemFont(ofSize: 12)
buttonContainerView.addSubview(button)
buttonContainerView.addSubview(titleLabel)

button.snp.makeConstraints { make in
make.edges.equalToSuperview()
}

titleLabel.snp.makeConstraints { make in
make.centerX.centerY.equalToSuperview()
make.leading.trailing.equalToSuperview()
}

button.backgroundColor = .clear
button.tag = index
button.addTarget(self, action: #selector(buttonClicked(_:)), for: .touchUpInside)
containerStackView.addArrangedSubview(buttonContainerView)
}
}

private func setUI() {
backgroundColor = containerColor
layer.cornerRadius = 16
selectedView.backgroundColor = selectColor
selectedView.layer.cornerRadius = 16
containerStackView.backgroundColor = .clear

addSubview(selectedView)
addSubview(containerStackView)

selectedView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(4)
make.leading.equalToSuperview().offset(4)
make.bottom.equalToSuperview().offset(-4)
make.width.equalTo( (width - 8) / CGFloat(titleList.count))
}
containerStackView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}

@objc
func buttonClicked(_ button: UIButton) {
let generator = UIImpactFeedbackGenerator(style: .medium)
generator.impactOccurred()
let buttonTag = button.tag
areaClickEvent?(buttonTag)
let buttonWidth = (width - 8) / CGFloat(titleList.count)
selectedView.snp.updateConstraints { make in
make.leading.equalToSuperview().offset(CGFloat(buttonTag) * buttonWidth + 4)
}

UIView.animate(withDuration: 0.3) {
self.layoutIfNeeded()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ extension DetailTabTVC {

// MARK: - Initializer

func initCell() {

}

func scrollToSelectedIndex(index: Int) {
containerCollectionView.scrollToItem(at: IndexPath(item: index, section: 0), at: .centeredHorizontally, animated: true)
}
Expand Down Expand Up @@ -124,10 +120,10 @@ extension DetailTabTVC: UICollectionViewDataSource {
childControllers.count > 0 {
cell.addSubview(childControllers[indexPath.item].view)
childControllers[indexPath.item].view.frame = cell.bounds
} else if (indexPath.item == 1 && childControllers.count > 1) {
} else if indexPath.item == 1 && childControllers.count > 1 {
cell.addSubview(childControllers[indexPath.item].view)
childControllers[indexPath.item].view.frame = cell.bounds
} else if (indexPath.item == 2 && childControllers.count > 2) {
} else if indexPath.item == 2 && childControllers.count > 2 {
cell.addSubview(childControllers[indexPath.item].view)
childControllers[indexPath.item].view.frame = cell.bounds
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MainDetailVC: UIViewController {
var viewModel: MainDetailViewModel!
private var detailTabTVC = DetailTabTVC()
private var detailTabTitleHeader = DetailTabTitleHeader()
private var childVC = ModuleFactory.resolve().makeMainMapVC()
private var childVC = ModuleFactory.resolve().makeMenuTabVC()

// MARK: - UI Components

Expand Down Expand Up @@ -171,6 +171,11 @@ extension MainDetailVC: UITableViewDataSource {
} else {
guard let cell = tableView.dequeueReusableCell(withIdentifier: DetailTabTVC.className, for: indexPath) as? DetailTabTVC else { return UITableViewCell() }
detailTabTVC = cell

if childVC is MenuTabVC {
childVC.delegate = self
}

self.addChild(childVC)
cell.receiveChildVC(childVC: childVC)
cell.scrollRatio.asDriver(onErrorJustReturn: 0)
Expand All @@ -185,3 +190,17 @@ extension MainDetailVC: UITableViewDataSource {
}
}
}

extension MainDetailVC: ScrollDeliveryDelegate {

// TODO: - 이 부분 touchesBegan으로 해보자

func scrollStarted(velocity: CGFloat, scrollView: UIScrollView) {
if velocity < 0 {
self.mainTableView.setContentOffset(CGPoint(x: 0, y: 240), animated: true)
if mainTableView.contentOffset.y < 230 {
scrollView.setContentOffset(CGPoint(x: 0, y: 0), animated: true)
}
}
}
}
Loading

0 comments on commit e1f0b6e

Please sign in to comment.