Skip to content

Session/13#11

Open
KaitoKudou wants to merge 32 commits intomainfrom
session/13
Open

Session/13#11
KaitoKudou wants to merge 32 commits intomainfrom
session/13

Conversation

@KaitoKudou
Copy link
Copy Markdown
Owner

やったこと

  • 呼び出しAPIのList verを使って天気情報をTableViewで表示
  • 明日、明後日、明々後日の3日分の天気を表示

課題へのリンク

API 仕様へのリンク

実行画面

天気一覧画面 詳細画面
スクリーンショット 2022-05-12 12 40 39 スクリーンショット 2022-05-12 12 40 01

懸念点

  • 詳細画面において、1日分でも取得が失敗した時は「予期せぬエラー」としてUIAlertで表示しているが、エラー自体が分かりにくい
    • 例えば、札幌における5/15の天気情報取得に失敗した時
    • 現状では取得に成功した日の天気情報だけを表示している
      スクリーンショット 2022-05-12 12 47 28

Copy link
Copy Markdown

@ykws ykws left a comment

Choose a reason for hiding this comment

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

詳細画面の要件が特に明記されていないので、やりづらかったですかね。
リスト表示から詳細へは選択した天気予報のデータを渡すだけで通信せずに、元の天気予報画面を表示する形式も、実際のアプリではよくある遷移パターンの一つになります。

今回の実装のように、詳細画面で詳細な情報を取得して表示するパターンもあり得ますが、画面遷移の度に通信するのは高コストなので、キャッシュ表示を組み合わせて展開されると思います。

全部見れていないですが、一旦コメントです。
ぱっと見、リスト表示に関しては良さそうですね。

Comment on lines +17 to +24
override func awakeFromNib() {
super.awakeFromNib()
}

override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nits-badge

super を呼ぶだけなら省略して良いです。

Suggested change
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}

Comment on lines +17 to +24
override func awakeFromNib() {
super.awakeFromNib()
}

override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nits-badge

super を呼ぶだけなら省略して良いです。

Suggested change
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}

super.setSelected(selected, animated: animated)
}

func configure(weatherResponses: WeatherListResponse) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nits-badge

複数ではない?

Suggested change
func configure(weatherResponses: WeatherListResponse) {
func configure(weatherListResponse: WeatherListResponse) {

またはリストと詳細で同じように扱っているので、共通の型に Convert しても良さそうですね

Copy link
Copy Markdown

@ykws ykws left a comment

Choose a reason for hiding this comment

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

課題を対応してもらっているのを見て、内容が曖昧であることに気付かされたので、 Session13での対応内容を以下のように追記しています。

ymm-oss/ios-training@4428324

課題を対応してからで申し訳ないのですが、
研修の課題を気づかせてくれてこの PR に感謝しています。


var model: WeatherFetcher!
private let viewController = R.storyboard.main.weatherViewController()
var model: WeatherListFetcher!
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

must-badge

WeatherView 用のテストは変わらない想定でした。
追加するなら、 WeatherListView 用のテストを追加してみてください。
(リスト表示向けのテストを同じ PR で扱うのは重そうなので、オプション課題かなと思います)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

テストはこのPRでは扱わないことにします....


import Foundation

final class Cache: NSCache<AnyObject, AnyObject> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

must-badge

Cache を保存する責務を担うものを命名で表現したいです。
また Presenter に含めるべきかも再考をお願いします。

ただ、今の段階では、 List から Detail に値渡しでも十分だと思います。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

課題内容が変わっていたことに気づきませんでした...

行選択で、詳細画面へ遷移する
詳細画面は今まで作成していた天気予報の画面を呼び出し、APIからではなく、リストで選択した天気予報のデータを渡して表示できるようにしてみましょう

と書いてあるので、今実装してる3日先の天気予報の表示ではなく、単に値渡しして詳細とし表示するように修正します!

Copy link
Copy Markdown

@ykws ykws left a comment

Choose a reason for hiding this comment

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

リストでセルをタップして詳細から戻ってきてもセルがタップされた状態になっていました。
UITableView に標準でその機能が用意されているので是非対応方法を調べて試してみてください。

func fetchWeather(areas: [String], date: Date) async -> Result<[WeatherListResponse], APIError>
}

class WeatherListFetcher: WeatherListFetchable {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

imo-badge

WeatherFetcher は List と 1件取得まとめて実装してしまっても良さそうですね。
天気予報を取得する形式が違うだけなので、別 Model に分けるのは分割し過ぎに感じました。

また詳細画面で 1件取得の Reload ができなくなっているので、そもそも List だけで良いですかね。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants