forked from markiv/SwiftUI-Shimmer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Remove IfElse To Keep State Correct
Refs: markiv#12
- Loading branch information
Vladyslav Sosiuk
committed
Nov 7, 2023
1 parent
2c632ed
commit 95ae26b
Showing
3 changed files
with
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Gradient+Convenience.swift | ||
// | ||
// | ||
// Created by Vladyslav Sosiuk on 06.11.2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
extension Gradient { | ||
static var transparent: Self { | ||
.init(colors: [.black]) // .black has no effect | ||
} | ||
} |
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 @@ | ||
// | ||
// View+iOS13Support.swift | ||
// | ||
// | ||
// Created by Vladyslav Sosiuk on 06.11.2023. | ||
// | ||
|
||
import SwiftUI | ||
import Combine | ||
|
||
extension View { | ||
/// A backwards compatible wrapper for iOS 14 `onChange` based on https://betterprogramming.pub/implementing-swiftui-onchange-support-for-ios13-577f9c086c9 | ||
@ViewBuilder func valueChanged<T: Equatable>(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) | ||
} | ||
} | ||
} | ||
} |