damus

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

ShareActionButton.swift (1378B)


      1 //
      2 //  ShareActionButton.swift
      3 //  damus
      4 //
      5 //  Created by William Casarin on 2023-04-19.
      6 //
      7 
      8 import SwiftUI
      9 
     10 struct ShareActionButton: View {
     11     let img: String
     12     let text: String
     13     let action: () -> ()
     14     
     15     init(img: String, text: String, action: @escaping () -> ()) {
     16         self.img = img
     17         self.text = text
     18         self.action = action
     19     }
     20     
     21     var col: Color {
     22         colorScheme == .light ? DamusColors.mediumGrey : DamusColors.white
     23     }
     24     
     25     @Environment(\.colorScheme) var colorScheme
     26         
     27     var body: some View {
     28         Button(action: action) {
     29             VStack() {
     30                 Image(img)
     31                     .foregroundColor(col)
     32                     .font(.system(size: 23, weight: .bold))
     33                     .overlay {
     34                         Circle()
     35                             .stroke(col, lineWidth: 1)
     36                             .frame(width: 55.0, height: 55.0)
     37                     }
     38                     .frame(height: 25)
     39                 Text(text)
     40                     .foregroundColor(col)
     41                     .font(.footnote)
     42                     .multilineTextAlignment(.center)
     43                     .padding(.top)
     44             }
     45         }
     46     }
     47 }
     48 
     49 struct ShareActionButton_Previews: PreviewProvider {
     50     static var previews: some View {
     51         ShareActionButton(img: "link", text: "Stretch", action: {})
     52     }
     53 }