mirror of
https://github.com/yattee/yattee.git
synced 2025-04-27 23:40:35 +05:30
chapters can only be clicked if expanded or horizontal
This commit is contained in:
parent
586cea7d44
commit
d65224320e
@ -29,7 +29,7 @@ struct ChaptersView: View {
|
|||||||
.listStyle(.plain)
|
.listStyle(.plain)
|
||||||
#else
|
#else
|
||||||
ScrollView(.horizontal) {
|
ScrollView(.horizontal) {
|
||||||
LazyHStack(spacing: 20) { chapterViews(for: chapters.prefix(3), opacity: 1.0) }.padding(.horizontal, 15)
|
LazyHStack(spacing: 20) { chapterViews(for: chapters[...]) }.padding(.horizontal, 15)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if expand {
|
} else if expand {
|
||||||
@ -40,7 +40,7 @@ struct ChaptersView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Section { chapterViews(for: chapters[...], opacity: 1.0) }.padding(.horizontal)
|
Section { chapterViews(for: chapters[...]) }.padding(.horizontal)
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
@ -48,12 +48,12 @@ struct ChaptersView: View {
|
|||||||
self.expand.toggle()
|
self.expand.toggle()
|
||||||
}) {
|
}) {
|
||||||
Section {
|
Section {
|
||||||
chapterViews(for: chapters.prefix(3), opacity: 0.3)
|
chapterViews(for: chapters.prefix(3), opacity: 0.3, clickable: false)
|
||||||
}.padding(.horizontal)
|
}.padding(.horizontal)
|
||||||
}
|
}
|
||||||
#elseif os(macOS)
|
#elseif os(macOS)
|
||||||
Section {
|
Section {
|
||||||
chapterViews(for: chapters.prefix(3), opacity: 0.3)
|
chapterViews(for: chapters.prefix(3), opacity: 0.3, clickable: false)
|
||||||
}.padding(.horizontal)
|
}.padding(.horizontal)
|
||||||
#else
|
#else
|
||||||
Section {
|
Section {
|
||||||
@ -67,12 +67,13 @@ struct ChaptersView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
private func chapterViews(for chaptersToShow: ArraySlice<Chapter>, opacity: Double = 1.0) -> some View {
|
private func chapterViews(for chaptersToShow: ArraySlice<Chapter>, opacity: Double = 1.0, clickable: Bool = true) -> some View {
|
||||||
ForEach(Array(chaptersToShow.indices), id: \.self) { index in
|
ForEach(Array(chaptersToShow.indices), id: \.self) { index in
|
||||||
let chapter = chaptersToShow[index]
|
let chapter = chaptersToShow[index]
|
||||||
let nextChapterStart: Double? = index < chaptersToShow.count - 1 ? chaptersToShow[index + 1].start : nil
|
let nextChapterStart: Double? = index < chaptersToShow.count - 1 ? chaptersToShow[index + 1].start : nil
|
||||||
ChapterView(chapter: chapter, nextChapterStart: nextChapterStart, chapterIndex: index)
|
ChapterView(chapter: chapter, nextChapterStart: nextChapterStart, chapterIndex: index)
|
||||||
.opacity(index == 0 ? 1.0 : opacity)
|
.opacity(index == 0 ? 1.0 : opacity)
|
||||||
|
.allowsHitTesting(clickable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user