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

[fix] 코딩 컨벤션 맞추기 #169

Merged
merged 5 commits into from
Jul 14, 2024
Merged
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
214 changes: 143 additions & 71 deletions KkuMulKum.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion KkuMulKum/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

// 카카오 로그인
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
func application(
_ app: UIApplication,
Copy link
Member

Choose a reason for hiding this comment

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

갱!

open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
if AuthApi.isKakaoTalkLoginUrl(url) {
return AuthController.handleOpenUrl(url: url)
}
Expand Down
8 changes: 8 additions & 0 deletions KkuMulKum/Resource/Base/BaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ extension BaseViewController {
.foregroundColor: UIColor.gray8,
.font: UIFont.pretendard(.body03)
]

let lineView = UIView(backgroundColor: .gray2)
navigationController?.navigationBar.addSubviews(lineView)

lineView.snp.makeConstraints {
$0.horizontalEdges.bottom.equalToSuperview()
$0.height.equalTo(Screen.height(1))
}
}

/// 네비게이션 바 BackButton 구성
Expand Down
6 changes: 3 additions & 3 deletions KkuMulKum/Source/Core/MainTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class MainTabBarController: UITabBarController {
$0.tabBarItem.image = .iconHome
}

let groupListViewController: MeetingListViewController = MeetingListViewController().then {
let meetingListViewController: MeetingListViewController = MeetingListViewController().then {
$0.tabBarItem.title = "내 모임"
$0.tabBarItem.image = .iconGroup
}
Expand All @@ -54,7 +54,7 @@ final class MainTabBarController: UITabBarController {
$0.navigationBar.tintColor = .black
}

let groupListNavigationController = UINavigationController(rootViewController: groupListViewController).then {
let meetingListNavigationController = UINavigationController(rootViewController: meetingListViewController).then {
$0.navigationBar.topItem?.backButtonDisplayMode = .minimal
$0.navigationBar.tintColor = .black
}
Expand All @@ -66,7 +66,7 @@ final class MainTabBarController: UITabBarController {

setViewControllers([
homeNavigationController,
groupListNavigationController,
meetingListNavigationController,
myPageViewNavigationController
], animated: true)
}
Expand Down

This file was deleted.

5 changes: 4 additions & 1 deletion KkuMulKum/Source/Home/View/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ final class HomeView: BaseView {
}

private let promiseView = UIView(backgroundColor: .gray0).then {
$0.roundCorners(cornerRadius: 16, maskedCorners: [.layerMinXMinYCorner, .layerMaxXMinYCorner])
$0.roundCorners(
cornerRadius: 16,
maskedCorners: [.layerMinXMinYCorner, .layerMaxXMinYCorner]
)
}

private let todayLabel = UILabel().then {
Expand Down
194 changes: 106 additions & 88 deletions KkuMulKum/Source/Home/ViewController/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,22 @@ class HomeViewController: BaseViewController {
self.view = rootView
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(false)
navigationController?.isNavigationBarHidden = true
}

override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = .white
register()
setupDelegate()
setupAction()

register()
updateUI()
updateUpcomingPromise()
viewModel.dummy()
}


// MARK: - Function

private func register() {
rootView.upcomingPromiseView.register(UpcomingPromiseCollectionViewCell.self,
forCellWithReuseIdentifier: UpcomingPromiseCollectionViewCell.reuseIdentifier
)
}

override func setupDelegate() {
rootView.upcomingPromiseView.delegate = self
rootView.upcomingPromiseView.dataSource = self
rootView.scrollView.delegate = self
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.isNavigationBarHidden = true
}


// MARK: - Function

override func setupAction() {
rootView.todayPromiseView.prepareButton.addTarget(
self,
Expand All @@ -83,31 +63,118 @@ class HomeViewController: BaseViewController {
)
}

private func setDisableButton(_ sender: UIButton) {
override func setupDelegate() {
rootView.upcomingPromiseView.delegate = self
rootView.upcomingPromiseView.dataSource = self
rootView.scrollView.delegate = self
}
}


// MARK: - UICollectionViewDelegateFlowLayout

extension HomeViewController: UICollectionViewDelegateFlowLayout {
func collectionView(
_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath
) -> CGSize {
return CGSize(width: cellWidth, height: cellHeight)
}

func collectionView(
_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAt section: Int
) -> CGFloat {
return contentInterSpacing
}

func collectionView(
_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
insetForSectionAt section: Int
) -> UIEdgeInsets {
return contentInset
}
}


// MARK: - UICollectionViewDataSource

extension HomeViewController: UICollectionViewDataSource {
func collectionView(
_ collectionView: UICollectionView,
numberOfItemsInSection section: Int
) -> Int {
return viewModel.upcomingPromiseData.value.count
}

func collectionView(
_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath
) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(
withReuseIdentifier: UpcomingPromiseCollectionViewCell.reuseIdentifier,
for: indexPath
) as? UpcomingPromiseCollectionViewCell else { return UICollectionViewCell() }
cell.dataBind(viewModel.upcomingPromiseData.value[indexPath.item])
return cell
}
}


// MARK: - UIScrollViewDelegate

extension HomeViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if rootView.scrollView.contentOffset.y < 0 {
rootView.scrollView.contentOffset.y = 0
}

let maxOffsetY = rootView.scrollView.contentSize.height - rootView.scrollView.bounds.height
if rootView.scrollView.contentOffset.y > maxOffsetY {
rootView.scrollView.contentOffset.y = maxOffsetY
}
}
}


// MARK: - Function

private extension HomeViewController {
func register() {
rootView.upcomingPromiseView.register(
UpcomingPromiseCollectionViewCell.self,
forCellWithReuseIdentifier: UpcomingPromiseCollectionViewCell.reuseIdentifier
)
}

func setDisableButton(_ sender: UIButton) {
sender.setTitleColor(.gray3, for: .normal)
sender.layer.borderColor = UIColor.gray3.cgColor
sender.backgroundColor = .white
}

private func setEnableButton(_ sender: UIButton) {
func setEnableButton(_ sender: UIButton) {
sender.setTitleColor(.maincolor, for: .normal)
sender.layer.borderColor = UIColor.maincolor.cgColor
sender.backgroundColor = .white
}

private func setProgressButton(_ sender: UIButton) {
func setProgressButton(_ sender: UIButton) {
sender.setTitleColor(.maincolor, for: .normal)
sender.layer.borderColor = UIColor.maincolor.cgColor
sender.backgroundColor = .green2
}

private func setCompleteButton(_ sender: UIButton) {
func setCompleteButton(_ sender: UIButton) {
sender.setTitleColor(.white, for: .normal)
sender.layer.borderColor = UIColor.maincolor.cgColor
sender.backgroundColor = .maincolor
}

private func updateUI() {
func updateUI() {
viewModel.currentState.bind { [weak self] state in
switch state {
case .prepare:
Expand All @@ -122,15 +189,15 @@ class HomeViewController: BaseViewController {
}
}

private func updateUpcomingPromise() {
func updateUpcomingPromise() {
viewModel.upcomingPromiseData.bind { [weak self] _ in
DispatchQueue.main.async {
self?.rootView.upcomingPromiseView.reloadData()
}
}
}

private func setPrepareUI() {
func setPrepareUI() {
setProgressButton(rootView.todayPromiseView.prepareButton)
setEnableButton(rootView.todayPromiseView.moveButton)
setDisableButton(rootView.todayPromiseView.arriveButton)
Expand All @@ -142,11 +209,11 @@ class HomeViewController: BaseViewController {

rootView.todayPromiseView.prepareLabel.isHidden = true
rootView.todayPromiseView.moveLabel.isHidden = false

rootView.todayPromiseView.prepareLineView.isHidden = false
}

private func setMoveUI() {
func setMoveUI() {
setCompleteButton(rootView.todayPromiseView.prepareButton)
rootView.todayPromiseView.moveButton.setTitle("이동 중", for: .normal)
setProgressButton(rootView.todayPromiseView.moveButton)
Expand All @@ -166,11 +233,11 @@ class HomeViewController: BaseViewController {
rootView.todayPromiseView.moveLineView.isHidden = false
}

private func setArriveUI() {
func setArriveUI() {
setCompleteButton(rootView.todayPromiseView.prepareButton)
setCompleteButton(rootView.todayPromiseView.moveButton)
setCompleteButton(rootView.todayPromiseView.arriveButton)

rootView.todayPromiseView.moveButton.isEnabled = false
rootView.todayPromiseView.arriveButton.isEnabled = false

Expand All @@ -191,17 +258,17 @@ class HomeViewController: BaseViewController {
// MARK: - Action

@objc
private func prepareButtonDidTap(_ sender: UIButton) {
func prepareButtonDidTap(_ sender: UIButton) {
viewModel.updateState(newState: .prepare)
rootView.todayPromiseView.prepareTimeLabel.setText(
viewModel.homePrepareTime,
style: .caption02,
color: .gray8
)
}

@objc
private func moveButtonDidTap(_ sender: UIButton) {
func moveButtonDidTap(_ sender: UIButton) {
viewModel.updateState(newState: .move)
rootView.todayPromiseView.moveTimeLabel.setText(
viewModel.homeMoveTime,
Expand All @@ -211,7 +278,7 @@ class HomeViewController: BaseViewController {
}

@objc
private func arriveButtonDidTap(_ sender: UIButton) {
func arriveButtonDidTap(_ sender: UIButton) {
viewModel.updateState(newState: .arrive)
rootView.todayPromiseView.arriveTimeLabel.setText(
viewModel.homeArriveTime,
Expand All @@ -220,52 +287,3 @@ class HomeViewController: BaseViewController {
)
}
}


// MARK: - UICollectionViewDelegate

extension HomeViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: cellWidth, height: cellHeight)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return contentInterSpacing
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return contentInset
}
}

extension HomeViewController: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return viewModel.upcomingPromiseData.value.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(
withReuseIdentifier: UpcomingPromiseCollectionViewCell.reuseIdentifier, for: indexPath
) as? UpcomingPromiseCollectionViewCell else { return UICollectionViewCell() }
cell.dataBind(viewModel.upcomingPromiseData.value[indexPath.item])
return cell
}
}


// MARK: - UIScrollViewDelegate

extension HomeViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if rootView.scrollView.contentOffset.y < 0 {
rootView.scrollView.contentOffset.y = 0
}

let maxOffsetY = rootView.scrollView.contentSize.height - rootView.scrollView.bounds.height
if rootView.scrollView.contentOffset.y > maxOffsetY {
rootView.scrollView.contentOffset.y = maxOffsetY
}
}
}
1 change: 0 additions & 1 deletion KkuMulKum/Source/Home/ViewModel/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ enum ReadyState {

final class HomeViewModel {
var currentState = ObservablePattern<ReadyState>(.none)
//var upComingPromiseData = ObservablePattern<[UpcomingPromiseModel]>(UpcomingPromiseModel.dummy())
var upcomingPromiseData = ObservablePattern<[UpcomingPromiseModel]>([])

var homePrepareTime: String = ""
Expand Down
Loading