From d83e59dd089220322c990eed732ad8ea25eaf336 Mon Sep 17 00:00:00 2001 From: bogeun jung Date: Wed, 17 Jan 2024 15:31:16 +0900 Subject: [PATCH] =?UTF-8?q?presenter=20=E3=82=92=E4=BB=8B=E3=81=97?= =?UTF-8?q?=E3=81=A6=20View=20=E3=81=AE=E6=93=8D=E4=BD=9C=E3=82=92?= =?UTF-8?q?=E8=A1=8C=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios-training-bjung/Presenters/HomePresenter.swift | 3 +++ ios-training-bjung/Views/HomeViewController.swift | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) 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)