damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

EventBody.swift (1502B)


      1 //
      2 //  EventBody.swift
      3 //  damus
      4 //
      5 //  Created by William Casarin on 2023-01-23.
      6 //
      7 
      8 import SwiftUI
      9 
     10 struct EventBody: View {
     11     let damus_state: DamusState
     12     let event: NostrEvent
     13     let size: EventViewKind
     14     let should_blur_img: Bool
     15     let options: EventViewOptions
     16     
     17     init(damus_state: DamusState, event: NostrEvent, size: EventViewKind, should_blur_img: Bool? = nil, options: EventViewOptions) {
     18         self.damus_state = damus_state
     19         self.event = event
     20         self.size = size
     21         self.options = options
     22         self.should_blur_img = should_blur_img ?? should_blur_images(settings: damus_state.settings, contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey)
     23     }
     24 
     25     var note_content: some View {
     26         NoteContentView(damus_state: damus_state, event: event, blur_images: should_blur_img, size: size, options: options)
     27             .frame(maxWidth: .infinity, alignment: .leading)
     28     }
     29 
     30     var body: some View {
     31         if event.known_kind == .longform {
     32             LongformPreviewBody(state: damus_state, ev: event, options: options)
     33 
     34             // truncated longform bodies are just the preview
     35             if !options.contains(.truncate_content) {
     36                 note_content
     37             }
     38         } else {
     39             note_content
     40         }
     41     }
     42 }
     43 
     44 struct EventBody_Previews: PreviewProvider {
     45     static var previews: some View {
     46         EventBody(damus_state: test_damus_state, event: test_note, size: .normal, options: [])
     47     }
     48 }