// // DocumentView.swift // GeminiRenderer // // Created by Shadowfacts on 7/12/20. // import SwiftUI import GeminiFormat public struct DocumentView: View { private let document: Document private let blocks: [RenderingBlock] private let changeURL: ((URL) -> Void)? public init(document: Document, changeURL: ((URL) -> Void)? = nil) { self.document = document self.blocks = document.renderingBlocks self.changeURL = changeURL } public var body: some View { ScrollView(.vertical) { MaybeLazyVStack(alignment: .leading) { ForEach(blocks.indices) { (index) in RenderingBlockView(block: blocks[index], changeURL: changeURL) } }.padding([.leading, .trailing, .bottom]) } } } struct DocumentView_Previews: PreviewProvider { static var doc: Document { Document(url: URL(string: "gemini://example.com")!, lines: [ .heading("Hello World", level: .h1), .text("Some text"), .preformattedToggle(alt: "blah"), .preformattedText("test"), .preformattedToggle(alt: nil), .quote("whatever"), .unorderedListItem("something") ]) } static var previews: some View { DocumentView(document: doc) } }