- LegalDocumentView: renderiza HTML do bundle usando WebView nativo do WebKit (iOS 26+) com suporte a dark mode - AboutView: tela com identidade visual do app, links para os documentos legais e contato - politicadeprivacidade.html / termosecondicoes.html: adicionados ao bundle com CSS para dark mode - BooksView: botão ⓘ na barra de navegação abre AboutView como sheet - PlanSettingsView: seção "Legal" com links diretos para os documentos Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
108 lines
3.0 KiB
Swift
108 lines
3.0 KiB
Swift
//
|
|
// BooksView.swift
|
|
// Bible-Week
|
|
//
|
|
// Aba Bíblia: lista os livros agrupados por testamento.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct BooksView: View {
|
|
@State private var books: [Book] = []
|
|
@State private var isLoading = false
|
|
@State private var errorMessage: String?
|
|
@State private var showingAbout = false
|
|
|
|
/// Livros do Antigo Testamento, em ordem canônica.
|
|
private var oldTestament: [Book] {
|
|
books.filter { $0.testament == "OT" }.sorted { $0.bookOrder < $1.bookOrder }
|
|
}
|
|
|
|
/// Livros do Novo Testamento, em ordem canônica.
|
|
private var newTestament: [Book] {
|
|
books.filter { $0.testament == "NT" }.sorted { $0.bookOrder < $1.bookOrder }
|
|
}
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
Group {
|
|
if isLoading {
|
|
ProgressView("Carregando livros...")
|
|
} else if let errorMessage {
|
|
ContentUnavailableView {
|
|
Label("Não foi possível carregar", systemImage: "wifi.slash")
|
|
} description: {
|
|
Text(errorMessage)
|
|
} actions: {
|
|
Button("Tentar novamente") { Task { await loadBooks() } }
|
|
}
|
|
} else {
|
|
bookList
|
|
}
|
|
}
|
|
.navigationTitle("Bíblia")
|
|
.toolbar {
|
|
ToolbarItem(placement: .topBarTrailing) {
|
|
Button {
|
|
showingAbout = true
|
|
} label: {
|
|
Image(systemName: "info.circle")
|
|
}
|
|
.accessibilityLabel("Sobre o app")
|
|
}
|
|
}
|
|
.sheet(isPresented: $showingAbout) {
|
|
AboutView()
|
|
}
|
|
}
|
|
.task {
|
|
if books.isEmpty { await loadBooks() }
|
|
}
|
|
}
|
|
|
|
private var bookList: some View {
|
|
List {
|
|
Section("Antigo Testamento") {
|
|
ForEach(oldTestament) { book in
|
|
bookRow(book)
|
|
}
|
|
}
|
|
Section("Novo Testamento") {
|
|
ForEach(newTestament) { book in
|
|
bookRow(book)
|
|
}
|
|
}
|
|
}
|
|
.navigationDestination(for: Book.self) { book in
|
|
ChapterReaderView(book: book)
|
|
}
|
|
}
|
|
|
|
private func bookRow(_ book: Book) -> some View {
|
|
NavigationLink(value: book) {
|
|
HStack {
|
|
Text(book.name)
|
|
Spacer()
|
|
Text("\(book.chapterCount) cap.")
|
|
.font(.caption)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
}
|
|
}
|
|
|
|
private func loadBooks() async {
|
|
isLoading = true
|
|
errorMessage = nil
|
|
defer { isLoading = false }
|
|
do {
|
|
books = try await BibleAPI.books()
|
|
} catch {
|
|
errorMessage = "Verifique sua conexão e tente novamente."
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
BooksView()
|
|
}
|