-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
In addition to handling drag gesture changes & ending, also handle cancelled drag gesture. Fixes #148
- Loading branch information
Showing
3 changed files
with
53 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// ViewExtension.swift | ||
// | ||
// | ||
// Created by Jukka Hietanen on 12.12.2023. | ||
// | ||
|
||
import Foundation | ||
|
||
import SwiftUI | ||
import Combine | ||
|
||
internal extension View { | ||
/// A backwards compatible wrapper for iOS 14 `onChange` | ||
@ViewBuilder func valueChanged<T: Equatable>(value: T, onChange: @escaping (T) -> Void) -> some View { | ||
if #available(iOS 14.0, macOS 11.0, *) { | ||
self.onChange(of: value, perform: onChange) | ||
} else { | ||
self.onReceive(Just(value)) { (value) in | ||
onChange(value) | ||
} | ||
} | ||
} | ||
} |