Merge pull request #665 from stonerl/chapter-pictures

allow user to disable thumbnails and jump to current chapter in horizontal view
This commit is contained in:
Arkadiusz Fal
2024-05-16 18:22:19 +02:00
committed by GitHub
5 changed files with 136 additions and 76 deletions

View File

@@ -9,8 +9,13 @@ import SwiftUI
var chapterIndex: Int
@ObservedObject private var player = PlayerModel.shared
var showThumbnail: Bool
var isCurrentChapter: Bool {
player.currentChapterIndex == chapterIndex
if let currentChapterIndex = player.currentChapterIndex {
return currentChapterIndex == chapterIndex
}
return false
}
var body: some View {
@@ -27,7 +32,7 @@ import SwiftUI
var verticalChapter: some View {
VStack(spacing: 12) {
if !chapter.image.isNil {
if !chapter.image.isNil, showThumbnail {
smallImage(chapter)
}
VStack(alignment: .leading, spacing: 4) {
@@ -40,7 +45,7 @@ import SwiftUI
.font(.system(.subheadline).monospacedDigit())
.foregroundColor(.secondary)
}
.frame(maxWidth: !chapter.image.isNil ? Self.thumbnailWidth : nil, alignment: .leading)
.frame(maxWidth: !chapter.image.isNil && showThumbnail ? Self.thumbnailWidth : nil, alignment: .leading)
}
}
@@ -126,7 +131,7 @@ struct ChapterView_Preview: PreviewProvider {
ChapterViewTVOS(chapter: .init(title: "Chapter", start: 30))
.injectFixtureEnvironmentObjects()
#else
ChapterView(chapter: .init(title: "Chapter", start: 30), chapterIndex: 0)
ChapterView(chapter: .init(title: "Chapter", start: 30), chapterIndex: 0, showThumbnail: true)
.injectFixtureEnvironmentObjects()
#endif
}