init: init proj
This commit is contained in:
40
DDYSClient/Views/Detail/EpisodeListView.swift
Normal file
40
DDYSClient/Views/Detail/EpisodeListView.swift
Normal file
@@ -0,0 +1,40 @@
|
||||
import SwiftUI
|
||||
|
||||
struct EpisodeListView: View {
|
||||
let episodes: [Episode]
|
||||
let selectedIndex: Int
|
||||
let onSelect: (Int) -> Void
|
||||
|
||||
private let columns = [
|
||||
GridItem(.adaptive(minimum: 70, maximum: 100), spacing: 8)
|
||||
]
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text("选集 (\(episodes.count)集)")
|
||||
.font(.headline)
|
||||
|
||||
LazyVGrid(columns: columns, spacing: 8) {
|
||||
ForEach(Array(episodes.enumerated()), id: \.element.id) { index, episode in
|
||||
Button {
|
||||
onSelect(index)
|
||||
} label: {
|
||||
Text(episode.name)
|
||||
.font(.caption)
|
||||
.lineLimit(1)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 8)
|
||||
.background(
|
||||
selectedIndex == index
|
||||
? Color.accentColor
|
||||
: Color.secondary.opacity(0.12),
|
||||
in: RoundedRectangle(cornerRadius: 6)
|
||||
)
|
||||
.foregroundStyle(selectedIndex == index ? .white : .primary)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user