-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from shinrenpan/develop
Refactoring
- Loading branch information
Showing
38 changed files
with
1,138 additions
and
1,033 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// DetailModel.swift | ||
// | ||
// Created by Shinren Pan on 2024/5/22. | ||
// | ||
|
||
import UIKit | ||
|
||
enum DetailModel { | ||
typealias DataSource = UICollectionViewDiffableDataSource<Int, Episode> | ||
typealias Snapshot = NSDiffableDataSourceSnapshot<Int, Episode> | ||
typealias CellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, Episode> | ||
} | ||
|
||
// MARK: - Action | ||
|
||
extension DetailModel { | ||
enum Action { | ||
case loadCache | ||
case loadRemote | ||
case tapFavorite | ||
} | ||
} | ||
|
||
// MARK: - State | ||
|
||
extension DetailModel { | ||
enum State { | ||
case none | ||
case cacheLoaded(response: CacheLoadedResponse) | ||
case remoteLoaded(response: RemoteLoadedResponse) | ||
case favoriteUpdated(response: FavoriteUpdatedResponse) | ||
} | ||
|
||
struct CacheLoadedResponse { | ||
let comic: Comic | ||
let episodes: [Episode] | ||
} | ||
|
||
struct RemoteLoadedResponse { | ||
let comic: Comic | ||
let episodes: [Episode] | ||
} | ||
|
||
struct FavoriteUpdatedResponse { | ||
let comic: Comic | ||
} | ||
} | ||
|
||
// MARK: - Models | ||
|
||
extension DetailModel { | ||
final class Episode: NSObject { | ||
let data: Comic.Episode | ||
let selected: Bool | ||
|
||
init(data: Comic.Episode, selected: Bool) { | ||
self.data = data | ||
self.selected = selected | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.