title: SwiftUI + Dynamic action closure for Button
body: <p>I am exploring SwiftUI and I was able to create a subclass of <code>Button</code>.</p>
  
  <p>The subclass contains <code>image</code> &amp; <code>title</code> properties, which makes it a reusable component.</p>
  
  <p>But I am not able to define dynamic action behavior for <code>Button</code> class.</p>
  
  <p>Please refer code below.</p>
  
  <p><strong>Subclass of Round Button:</strong></p>
  
  <pre><code>struct RoundButton: View {
      var image: String
      var title: String
      var body: some View {
          VStack {
              Button(action: {
                  print("Button pressed")
              }){
                  Image(image)                
                     .renderingMode(Image.TemplateRenderingMode?.init(Image.TemplateRenderingMode.template))
              }
              .frame(width: 40, height: 40)
              .background(Color.blue)
              .cornerRadius(20)
              .accentColor(.white)
  
              Text(title)
                  .font(.footnote)
          }
      }
  }
  </code></pre>
  
  <p><strong>Example usage:</strong></p>
  
  <pre><code>HStack(alignment: .center) {
      Spacer(minLength: 50)
      RoundButton(image: "chat", title: "message")
      Spacer()
      RoundButton(image: "call", title: "call")
      Spacer()
      RoundButton(image: "video", title: "video")
      Spacer()
      RoundButton(image: "mail", title: "mail")
      Spacer(minLength: 50)
  }
  </code></pre>
  
  <p>You will see that <code>action</code> block print a message here. </p>
  
  <p>I would like to know how we can pass a function for a button's action event? </p>