Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…/MC2-Team5-Firefighter into feature/357-pushnotification-viewcontroller
  • Loading branch information
MMMIIIN committed Jan 16, 2023
2 parents 40591ab + 5faf0e6 commit ef5fe6f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Manito/Manito/Screens/Main/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ final class MainViewController: BaseViewController {
}
}
}

private let refreshControl = UIRefreshControl()

// MARK: - property

Expand Down Expand Up @@ -101,12 +103,13 @@ final class MainViewController: BaseViewController {
setupGifImage()
setupGuideArea()
renderGuideArea()
setupRefreshControl()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
requestCommonMission()
requestManittoList()
requestManittoRoomList()
}

override func render() {
Expand Down Expand Up @@ -197,6 +200,19 @@ final class MainViewController: BaseViewController {
}
}

private func setupRefreshControl() {
let action = UIAction { [weak self] _ in
self?.requestManittoRoomList()

DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self?.refreshControl.endRefreshing()
}
}
refreshControl.addAction(action, for: .valueChanged)
refreshControl.tintColor = .grey001
listCollectionView.refreshControl = refreshControl
}

// MARK: - API

private func requestCommonMission() {
Expand All @@ -214,7 +230,7 @@ final class MainViewController: BaseViewController {
}
}

private func requestManittoList() {
private func requestManittoRoomList() {
Task {
do {
let data = try await mainService.fetchManittoList()
Expand Down

0 comments on commit ef5fe6f

Please sign in to comment.