1
0
mirror of https://github.com/yattee/yattee.git synced 2025-04-28 07:50:33 +05:30

iOS click on collapsed chapters expands the view

This commit is contained in:
Toni Förster 2023-11-26 15:15:30 +01:00
parent b0d81cdefd
commit a7baaeb485
No known key found for this signature in database
GPG Key ID: 292F3E5086C83FC7

View File

@ -47,16 +47,28 @@ struct ChaptersView: View {
} }
#endif #endif
} else if !chapters.isEmpty { } else if !chapters.isEmpty {
Section { #if os(iOS)
ChapterView(chapter: chapters[0]) Button(action: {
if chapters.count > 1 { self.expand.toggle() // Use your expanding logic here
ChapterView(chapter: chapters[1]) }) {
.opacity(0.3) contents
} }
} #else
.padding(.horizontal) contents
#endif
} }
} }
var contents: some View {
Section {
ForEach(chapters.prefix(3).indices, id: \.self) { index in
ChapterView(chapter: chapters[index])
.allowsHitTesting(expand)
.opacity(index == 0 ? 1.0 : 0.3)
}
}
.padding(.horizontal)
}
} }
struct ChaptersView_Previews: PreviewProvider { struct ChaptersView_Previews: PreviewProvider {