Skip to content

Commit

Permalink
Merge pull request #226 from OMZigak/feat/#213-connect
Browse files Browse the repository at this point in the history
[feat] 홈 화면 및 내 모임 리스트 화면 연결
  • Loading branch information
mmaybei authored Jul 18, 2024
2 parents 191779d + 336eda3 commit 0de2a1f
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
2 changes: 1 addition & 1 deletion KkuMulKum/Source/Home/View/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ final class HomeView: BaseView {
$0.setText("다가올 나의 약속은?", style: .body01, color: .gray8)
}

private let todayButton = UIButton().then {
let todayButton = UIButton().then {
let icon = UIImage(resource: .iconRight)
$0.setImage(icon, for: .normal)
}
Expand Down
39 changes: 39 additions & 0 deletions KkuMulKum/Source/Home/ViewController/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class HomeViewController: BaseViewController {
}

override func setupAction() {
rootView.todayButton.addTarget(
self,
action: #selector(todayButtonDidTap),
for: .touchUpInside
)
rootView.todayPromiseView.prepareButton.addTarget(
self,
action: #selector(prepareButtonDidTap),
Expand Down Expand Up @@ -116,6 +121,24 @@ extension HomeViewController: UICollectionViewDelegateFlowLayout {
) -> UIEdgeInsets {
return contentInset
}

func collectionView(
_ collectionView: UICollectionView,
didSelectItemAt indexPath: IndexPath
) {
// TODO: promiseID를 모임 상세로 전달
print(
"promiseID: ",
viewModel.upcomingPromiseList.value?.data?.promises[indexPath.item].promiseID ?? 0
)
// let viewController = PromiseInfoViewController(
// viewModel: PromiseInfoViewModel(
// promiseID: viewModel.upcomingPromiseList.value?.data?.promises[indexPath.item].promiseID ?? 0,
// service: PromiseService()
// )
// )
//tabBarController?.navigationController?.pushViewController(viewController, animated: true)
}
}


Expand Down Expand Up @@ -354,6 +377,22 @@ private extension HomeViewController {

// MARK: - Action

@objc
func todayButtonDidTap(_ sender: UIButton) {
print(
"promiseID: ",
viewModel.nearestPromise.value?.data?.promiseID ?? 0
)
// TODO: promiseID를 모임 상세로 전달
// let viewController = PromiseInfoViewController(
// viewModel: PromiseInfoViewModel(
// promiseID: viewModel.nearestPromise.value?.data?.promiseID ?? 0,
// service: PromiseService()
// )
// )
//tabBarController?.navigationController?.pushViewController(viewController, animated: true)
}

@objc
func prepareButtonDidTap(_ sender: UIButton) {
viewModel.updateState(newState: .prepare)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ protocol MeetingListServiceType {
func fetchMeetingList() -> ResponseBodyDTO<MeetingListModel>
}

//extension MeetingService: MeetingListServiceType {
// func fetchMeetingList() -> ResponseBodyDTO<MeetingListModel> {
// <#code#>
// }
//}

final class MockMeetingListService: MeetingListServiceType {
func fetchMeetingList() -> ResponseBodyDTO<MeetingListModel> {
let mockData = ResponseBodyDTO<MeetingListModel>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ extension MeetingListViewController: UITableViewDelegate {
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// TODO: MeetingID를 넘겨받기
let viewController = MeetingInfoViewController(
viewModel: MeetingInfoViewModel(
meetingID: 8,
meetingID: viewModel.meetingList.value?.data?.meetings[indexPath.item].meetingID ?? 0,
service: MeetingService()
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ final class SetReadyInfoViewModel {
}
}

private func calculateTimes() {
let readyHours = Int(readyHour.value) ?? 0
let readyMinutes = Int(readyMinute.value) ?? 0
let moveHours = Int(moveHour.value) ?? 0
let moveMinutes = Int(moveMinute.value) ?? 0

readyTime = readyHours * 60 + readyMinutes
moveTime = moveHours * 60 + moveMinutes
}

func updateTime(textField: String, time: String) {
guard let time = Int(time) else { return }

Expand All @@ -44,6 +54,8 @@ final class SetReadyInfoViewModel {
default:
break
}

calculateTimes()
}

func checkValid(
Expand Down

0 comments on commit 0de2a1f

Please sign in to comment.