-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from c-villain/fix-drag-and-lazy
0.2.0
- Loading branch information
Showing
3 changed files
with
155 additions
and
55 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
22 changes: 22 additions & 0 deletions
22
Sources/SwipeActions/ViewModifiers/ValueChangedModifier.swift
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,22 @@ | ||
// | ||
// ValueChangedModifier.swift | ||
// | ||
// | ||
// Created by c-villain on 28.12.2021. | ||
// | ||
|
||
import SwiftUI | ||
import Combine | ||
|
||
extension View { | ||
/// A backwards compatible wrapper for iOS 14 `onChange` | ||
@ViewBuilder func valueChanged<T: Equatable>(of value: T, onChange: @escaping (T) -> Void) -> some View { | ||
if #available(iOS 14.0, *) { | ||
self.onChange(of: value, perform: onChange) | ||
} else { | ||
self.onReceive(Just(value)) { (value) in | ||
onChange(value) | ||
} | ||
} | ||
} | ||
} |