mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Extended Piped support
This commit is contained in:
9
Shared/Gestures/GestureTimer.swift
Normal file
9
Shared/Gestures/GestureTimer.swift
Normal file
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// GestureTimer.swift
|
||||
// SwiftUIKit
|
||||
//
|
||||
// Created by Daniel Saidi on 2021-02-17.
|
||||
// Copyright © 2021 Daniel Saidi. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
22
Shared/Gestures/View+SwipeGesture.swift
Normal file
22
Shared/Gestures/View+SwipeGesture.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
import SwiftUI
|
||||
|
||||
extension View {
|
||||
func onSwipeGesture(
|
||||
up: @escaping () -> Void = {},
|
||||
down: @escaping () -> Void = {}
|
||||
) -> some View {
|
||||
gesture(
|
||||
DragGesture(minimumDistance: 10)
|
||||
.onEnded { gesture in
|
||||
let translation = gesture.translation
|
||||
|
||||
if abs(translation.height) > 100_000 {
|
||||
return
|
||||
}
|
||||
|
||||
let isUp = translation.height < 0
|
||||
isUp ? up() : down()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user