LongformView.swift (1921B)
1 // 2 // LongformEvent.swift 3 // damus 4 // 5 // Created by William Casarin on 2023-06-01. 6 // 7 8 import SwiftUI 9 10 struct LongformView: View { 11 let state: DamusState 12 let event: LongformEvent 13 @ObservedObject var artifacts: NoteArtifactsModel 14 15 init(state: DamusState, event: LongformEvent, artifacts: NoteArtifactsModel? = nil) { 16 self.state = state 17 self.event = event 18 self._artifacts = ObservedObject(wrappedValue: artifacts ?? state.events.get_cache_data(event.event.id).artifacts_model) 19 } 20 21 var options: EventViewOptions { 22 return [.wide, .no_mentions, .no_replying_to] 23 } 24 25 var body: some View { 26 EventShell(state: state, event: event.event, options: options) { 27 SelectableText(attributedString: AttributedString(stringLiteral: event.title ?? "Untitled"), size: .title) 28 29 NoteContentView(damus_state: state, event: event.event, blur_images: false, size: .selected, options: options) 30 } 31 } 32 } 33 34 let test_longform_event = LongformEvent.parse(from: NostrEvent( 35 content: longform_long_test_data, 36 keypair: test_keypair, 37 kind: NostrKind.longform.rawValue, 38 tags: [ 39 ["title", "What is WASTOIDS?"], 40 ["summary", "WASTOIDS is an audio/visual feed, created by Sam Means..."], 41 ["published_at", "1685638715"], 42 ["t", "coffee"], 43 ["t", "coffeechain"], 44 ["image", "https://cdn.jb55.com/s/038fe8f558153b52.jpg"], 45 ])! 46 ) 47 48 struct LongformView_Previews: PreviewProvider { 49 static var previews: some View { 50 let st = test_damus_state 51 let artifacts = render_note_content(ev: test_longform_event.event, profiles: st.profiles, keypair: Keypair(pubkey: .empty, privkey: nil)) 52 53 let model = NoteArtifactsModel(state: .loaded(artifacts)) 54 ScrollView { 55 LongformView(state: st, event: test_longform_event, artifacts: model) 56 } 57 } 58 }