-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
loadAnimationTrigger
to support calling loadAnimation
again a…
…fter `onAppear` (#2118)
- Loading branch information
1 parent
5f21ab0
commit 951daf7
Showing
6 changed files
with
121 additions
and
8 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
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,18 @@ | ||
// Created by miguel_jimenez on 7/27/23. | ||
// Copyright © 2023 Airbnb Inc. All rights reserved. | ||
|
||
import SwiftUI | ||
|
||
@available(iOS 13.0, tvOS 13.0, macOS 10.15, *) | ||
extension Binding { | ||
|
||
/// Helper to transform a `Binding` from one `Value` type to another. | ||
func map<Transformed>(transform: @escaping (Value) -> Transformed) -> Binding<Transformed> { | ||
.init { | ||
transform(wrappedValue) | ||
} set: { newValue in | ||
guard let newValue = newValue as? Value else { return } | ||
self.wrappedValue = newValue | ||
} | ||
} | ||
} |
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,20 @@ | ||
// Created by miguel_jimenez on 7/26/23. | ||
// Copyright © 2023 Airbnb Inc. All rights reserved. | ||
|
||
import Combine | ||
import SwiftUI | ||
|
||
@available(iOS 13.0, tvOS 13.0, macOS 10.15, *) | ||
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, tvOS 14.0) { | ||
self.onChange(of: value, perform: onChange) | ||
} else { | ||
onReceive(Just(value)) { value in | ||
onChange(value) | ||
} | ||
} | ||
} | ||
} |
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