// // 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] public init(document: Document) { self.document = document self.blocks = document.renderingBlocks } public var body: some View { ScrollView(.vertical) { MaybeLazyVStack(alignment: .leading) { ForEach(blocks.indices) { (index) in RenderingBlockView(block: blocks[index]) } }.padding() } } } 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) } }