fmodf
b3b3b3aef7
Reviewed-on: narayana/conversations-classic-ios#1 Co-authored-by: fmodf <fmodf.ios@gmail.com> Co-committed-by: fmodf <fmodf.ios@gmail.com>
28 lines
670 B
Swift
28 lines
670 B
Swift
import SwiftUI
|
|
|
|
extension View {
|
|
func tappablePadding(_ insets: EdgeInsets, onTap: @escaping () -> Void) -> some View {
|
|
modifier(TappablePadding(insets: insets, onTap: onTap))
|
|
}
|
|
}
|
|
|
|
struct TappablePadding: ViewModifier {
|
|
let insets: EdgeInsets
|
|
let onTap: () -> Void
|
|
|
|
public init(insets: EdgeInsets, onTap: @escaping () -> Void) {
|
|
self.insets = insets
|
|
self.onTap = onTap
|
|
}
|
|
|
|
public func body(content: Content) -> some View {
|
|
content
|
|
.padding(insets)
|
|
.contentShape(Rectangle())
|
|
.onTapGesture {
|
|
onTap()
|
|
}
|
|
.padding(insets.inverted)
|
|
}
|
|
}
|