-
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.
- Loading branch information
1 parent
9922edd
commit 1232fbb
Showing
11 changed files
with
154 additions
and
44 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
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,54 @@ | ||
// | ||
// AnimeEpisodeListView.swift | ||
// MyAnimeList | ||
// | ||
// Created by HG on 2020/09/22. | ||
// | ||
|
||
import SwiftUI | ||
import SwiftUIFlux | ||
import CrunchyrollSwift | ||
|
||
struct EpisodeListView: View { | ||
@EnvironmentObject var store: Store<AppState> | ||
|
||
let collectionId: Int | ||
|
||
var episodes: [CRAPIMedia] { | ||
return store.state.crState.collections[collectionId] ?? [] | ||
} | ||
|
||
var body: some View { | ||
LazyHStack(alignment: .center, spacing: 20) { | ||
ForEach(episodes) { | ||
EpisodeView(episode: $0) | ||
} | ||
} | ||
.onAppear() { | ||
if let session = store.state.crState.session { | ||
store.dispatch(action: CRActions.ListMedia(sessionId: session.id, collectionId: collectionId)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct EpisodeView: View { | ||
@State var modalDisplayed = false | ||
|
||
let episode: CRAPIMedia | ||
var body: some View { | ||
Button(action: { | ||
self.modalDisplayed = true | ||
if let episodeId = Int(episode.id), let session = store.state.crState.session { | ||
store.dispatch(action: CRActions.Info(sessionId: session.id, mediaId: episodeId)) | ||
} | ||
}, label: { | ||
Text("\(episode.episodeNumber) \(episode.name)") | ||
}) | ||
.sheet(isPresented: $modalDisplayed) { | ||
if let mediaId = Int(episode.id) { | ||
FullscreenVideoPlayer(mediaId: mediaId) | ||
} | ||
} | ||
} | ||
} |
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,16 @@ | ||
// | ||
// JikanCRActions.swift | ||
// MyAnimeList | ||
// | ||
// Created by HG on 2020/09/22. | ||
// | ||
|
||
import Foundation | ||
import SwiftUIFlux | ||
|
||
struct JikanCRActions { | ||
struct SetMalIdSeriesId: Action { | ||
let malId: Int | ||
let seriesId: Int | ||
} | ||
} |
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,20 @@ | ||
// | ||
// JikanCRReducer.swift | ||
// MyAnimeList | ||
// | ||
// Created by HG on 2020/09/22. | ||
// | ||
|
||
import Foundation | ||
import SwiftUIFlux | ||
|
||
func jikanCRStateReducer(state: JikanCRState, action: Action) -> JikanCRState { | ||
var state = state | ||
switch action { | ||
case let action as JikanCRActions.SetMalIdSeriesId: | ||
state.malIdSeriesId[action.malId] = action.seriesId | ||
default: | ||
break | ||
} | ||
return state | ||
} |
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,14 @@ | ||
// | ||
// JikanCRState.swift | ||
// MyAnimeList | ||
// | ||
// Created by HG on 2020/09/22. | ||
// | ||
|
||
import Foundation | ||
import SwiftUIFlux | ||
import JikanSwift | ||
|
||
struct JikanCRState: FluxState, Codable { | ||
var malIdSeriesId: [Int: Int] = [:] | ||
} |
Submodule CrunchyrollSwift
updated
2 files
+20 −0 | Sources/CrunchyrollSwiftWeb/CRNameParser.swift | |
+7 −0 | Sources/CrunchyrollSwiftWeb/CRWebParser.swift |