damus

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

RepostAction.swift (2268B)


      1 //
      2 //  RepostAction.swift
      3 //  damus
      4 //
      5 //  Created by William Casarin on 2023-04-19.
      6 //
      7 
      8 import SwiftUI
      9 
     10 struct RepostAction: View {
     11     let damus_state: DamusState
     12     let event: NostrEvent
     13     
     14     @Environment(\.dismiss) var dismiss
     15     @Environment(\.colorScheme) var colorScheme
     16     
     17     var body: some View {
     18         VStack(alignment: .leading) {
     19             
     20             Button {
     21                 dismiss()
     22                             
     23                 guard let keypair = self.damus_state.keypair.to_full(),
     24                       let boost = make_boost_event(keypair: keypair, boosted: self.event) else {
     25                     return
     26                 }
     27 
     28                 damus_state.postbox.send(boost)
     29             } label: {
     30                 Label(NSLocalizedString("Repost", comment: "Button to repost a note"), image: "repost")
     31                     .frame(maxWidth: .infinity, minHeight: 50, maxHeight: 50, alignment: .leading)
     32 
     33             }
     34             .font(.system(size: 20, weight: .regular))
     35             .foregroundColor(colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite"))
     36             .padding(EdgeInsets(top: 25, leading: 50, bottom: 0, trailing: 50))
     37             
     38             Button {
     39                 dismiss()
     40                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
     41                     notify(.compose(.quoting(self.event)))
     42                 }
     43                 
     44             } label: {
     45                 Label(NSLocalizedString("Quote", comment: "Button to compose a quoted note"), systemImage: "quote.opening")
     46                     .frame(maxWidth: .infinity, minHeight: 50, maxHeight: 50, alignment: .leading)
     47 
     48             }
     49             .font(.system(size: 20, weight: .regular))
     50             .foregroundColor(colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite"))
     51             .padding(EdgeInsets(top: 0, leading: 50, bottom: 0, trailing: 50))
     52             
     53             HStack {
     54                 BigButton(NSLocalizedString("Cancel", comment: "Button to cancel a repost.")) {
     55                     dismiss()
     56                 }
     57             }
     58         }
     59     }
     60 }
     61 
     62 struct RepostAction_Previews: PreviewProvider {
     63     static var previews: some View {
     64         RepostAction(damus_state: test_damus_state, event: test_note)
     65     }
     66 }