Skip to content

Commit

Permalink
- highlight button change
Browse files Browse the repository at this point in the history
  • Loading branch information
xramos committed May 30, 2022
1 parent f7a74c7 commit 2f14324
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Pokemon/Pokemon/Views/ButtonView/ButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ struct ButtonView: View {
private var width: CGFloat?
private var action: () -> Void

@State private var pressed: Bool = false

init(imageName: String, text: String, width: CGFloat? = 80, action: @escaping () -> Void) {

self.imageName = imageName
Expand All @@ -34,10 +36,20 @@ struct ButtonView: View {

Text(text)
}
.onTapGesture {
.background(pressed ? .gray.opacity(0.3) : .white)
.gesture(DragGesture(minimumDistance: 0.0)
.onChanged({ _ in
self.pressed = true
})
.onEnded({ _ in
self.pressed = false
self.action()
})
)
/*.onTapGesture {

self.action()
}
}*/
}
}

Expand Down

0 comments on commit 2f14324

Please sign in to comment.