diff --git a/ios-training-bjung/Presenters/HomePresenter.swift b/ios-training-bjung/Presenters/HomePresenter.swift index 2a322ce..4c7dddf 100644 --- a/ios-training-bjung/Presenters/HomePresenter.swift +++ b/ios-training-bjung/Presenters/HomePresenter.swift @@ -15,6 +15,8 @@ protocol HomePresenterInput { } protocol HomePresenterOutput: AnyObject { + @MainActor + func showLoadingUI() @MainActor func updateInfoDisplay(updatedInfo response: WeatherResponse) @MainActor @@ -38,6 +40,7 @@ final class HomePresenter: HomePresenterInput { // API 通信が課題なのであえて async await を使って表現 Task { do { + view?.showLoadingUI() let request = WeatherRequest(area: "tokyo", date: Date()) let response = try await model.fetchWeatherData(request: request) diff --git a/ios-training-bjung/Views/HomeViewController.swift b/ios-training-bjung/Views/HomeViewController.swift index 7b8c326..d435ae1 100644 --- a/ios-training-bjung/Views/HomeViewController.swift +++ b/ios-training-bjung/Views/HomeViewController.swift @@ -46,8 +46,6 @@ final class HomeViewController: UIViewController { } func loadWeatherData() { - indicator.startAnimating() - reloadButton.isEnabled = false presenter.loadWeatherData() } @@ -56,7 +54,6 @@ final class HomeViewController: UIViewController { } @IBAction func onReloadButtonClick(_ sender: UIButton) { - indicator.startAnimating() loadWeatherData() } @@ -84,6 +81,11 @@ final class HomeViewController: UIViewController { extension HomeViewController: HomePresenterOutput { + func showLoadingUI() { + indicator.startAnimating() + reloadButton.isEnabled = false + } + func updateInfoDisplay(updatedInfo response: WeatherResponse) { let resource = getDisplayResource(response: response.weatherCondition)