'update'
This commit is contained in:
55
ipad_app/Sources/Views/BookDetailView.swift
Normal file
55
ipad_app/Sources/Views/BookDetailView.swift
Normal file
@@ -0,0 +1,55 @@
|
||||
#if os(iOS)
|
||||
import SwiftUI
|
||||
|
||||
@available(macOS 10.15, iOS 13.0, *)
|
||||
struct BookDetailView: View {
|
||||
let book: BookMeta
|
||||
let index: BundleIndex
|
||||
let bundleDir: URL
|
||||
|
||||
var annotations: [AnnotationRow] { index.annotationsMap[book.id] ?? [] }
|
||||
var review: String? { index.bookIntro[book.title] }
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
HStack(alignment:.top, spacing:16) {
|
||||
CoverImageView(book: book, bundleDir: bundleDir).frame(width:120,height:170)
|
||||
VStack(alignment:.leading, spacing:8) {
|
||||
Text(book.title).font(.title2).bold()
|
||||
Text(book.author).foregroundColor(.secondary)
|
||||
if let y = book.readtime_year { Text("全年阅读 \(y/60) 小时").font(.callout) }
|
||||
if book.is_finished_this_year == true { Text("今年已读完 ✅").font(.caption).foregroundColor(.green) }
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
if let review = review, !review.isEmpty {
|
||||
VStack(alignment:.leading, spacing:8) {
|
||||
Text("书籍简评").font(.headline)
|
||||
Text(review).font(.body)
|
||||
}
|
||||
}
|
||||
if !annotations.isEmpty {
|
||||
VStack(alignment:.leading, spacing:8) {
|
||||
Text("批注 (\(annotations.count))").font(.headline)
|
||||
ForEach(annotations) { ann in
|
||||
VStack(alignment:.leading, spacing:4) {
|
||||
if let sel = ann.selected { Text(sel).font(.body) }
|
||||
if let note = ann.note, !note.isEmpty { Text("✎ " + note).font(.footnote).foregroundColor(.secondary) }
|
||||
Divider()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text("无批注").foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
.navigationTitle("详情")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user