title: How to create a SwiftUI button that changes opacity and triggers button action when touched?
body: <p>I wanna create a button with SwiftUI that fires the moment my finger touches it (like UIKit's touch down instead of touch up inside). I also want the opacity of the button to become 0.7 when my finger is pressing the button. And I want the opacity of the button to change back to 1 ONLY when my finger is no longer touching the button.</p>
  
  <p>I've tried 2 different types of button styles to create such a button but both of them failed:</p>
  
  <pre><code>    struct ContentView: View {  
          var body: some View {  
              Button(action: {  
                  print("action triggered")  
              }){  
                  Text("Button").padding()  
              }  
                  .buttonStyle(SomeButtonStyle())  
          }  
      }  
  
      struct SomeButtonStyle: ButtonStyle {  
          func makeBody(configuration: Self.Configuration) -&gt; some View {  
              configuration.label  
                  .background(Color.green)  
                  .opacity(configuration.isPressed ? 0.7 : 1)  
                  .onLongPressGesture(  
                      minimumDuration: 0,  
                      perform: configuration.trigger//Value of type 'SomeButtonStyle.Configuration' (aka 'ButtonStyleConfiguration') has no member 'trigger'  
                  )  
          }  
      }  
  
      struct SomePrimativeButtonStyle: PrimitiveButtonStyle {  
          func makeBody(configuration: Configuration) -&gt; some View {  
            configuration.label  
              .background(Color.green)  
              .opacity(configuration.isPressed ? 0.7 : 1)//Value of type 'SomePrimativeButtonStyle.Configuration' (aka 'PrimitiveButtonStyleConfiguration') has no member 'isPressed'  
              .onLongPressGesture(  
                minimumDuration: 0,  
                perform: configuration.trigger  
              )  
          }  
      }
  </code></pre>
  
  <p>Apparently none of the button styles above worked because ButtonStyle and PrimitiveButtonStyle don't share the same methods and properties so I can't use both the isPressed property (which belongs to ButtonStyle) AND the trigger method (which belongs to PrimitiveButtonStyle) in the same button style.</p>
  
  <p>How should I configure my button style to make this work?</p>