This file contains hidden or 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
| import SwiftUI | |
| public extension Gradient { | |
| static func eased(from start: Color, to end: Color, curve: UnitCurve = .easeInOut, steps: Int = 10) -> Gradient { | |
| Gradient( | |
| stops: stride(from: 0, through: 1, by: 1/Double(steps)).map { progress in | |
| Gradient.Stop( | |
| color: start.mix(with: end, by: curve.value(at: progress)), | |
| location: progress | |
| ) |
This file contains hidden or 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
| import SwiftUI | |
| extension ShapeStyle { | |
| // Based on https://gist.github.com/sophiateutschler/54c0e6ca490fee658e303a63487dc382 | |
| func smoothShadow( | |
| color: Color = Color(white: 0.0, opacity: 1.0 / 3.0), | |
| layers: Int = 3, | |
| curve: UnitCurve = .easeInOut, | |
| radius baseRadius: CGFloat, | |
| x baseX: CGFloat = 0.0, |
This file contains hidden or 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
| public extension View { | |
| func task<T: Equatable>( | |
| id: T, | |
| priority: TaskPriority = .userInitiated, | |
| @_inheritActorContext _ action: @Sendable @escaping (T, T) async -> Void | |
| ) -> some View { | |
| self.modifier(TaskViewModifier(id: id, priority: priority, action: action)) | |
| } | |
| } |
This file contains hidden or 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
| import SwiftUI | |
| public extension EdgeInsets { | |
| init(_ edges: Edge.Set, _ insets: EdgeInsets) { | |
| func inset(for edge: Edge) -> CGFloat { | |
| return edges.contains(Edge.Set(edge)) ? insets[edge] : 0 | |
| } | |
| self.init( | |
| top: inset(for: .top), |
This file contains hidden or 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
| import SwiftUI | |
| enum MarketingBump: String, CaseIterable, Hashable { | |
| case none | |
| case patch | |
| case minor | |
| case major | |
| } | |
| enum ASCGroup: String, CaseIterable, Hashable { |
This file contains hidden or 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
| public extension Collection { | |
| func contractingPrefixes() -> some Collection<SubSequence> { | |
| self.indices.reversed().lazy.map { index in | |
| self[startIndex ... index] | |
| } | |
| } | |
| func expandingPrefixes() -> some Collection<SubSequence> { | |
| self.indices.lazy.map { index in | |
| self[startIndex ... index] |
This file contains hidden or 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
| struct CycledAnimationTimelineView<Content: View>: View { | |
| var duration: Double | |
| var isAnimating: Bool | |
| @ViewBuilder var content: (Double) -> Content | |
| @State private var isActuallyAnimating = false | |
| @State private var startDate: Date? | |
| var body: some View { | |
| TimelineView(.animation(paused: !isActuallyAnimating)) { context in |
This file contains hidden or 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
| import SwiftUI | |
| public struct Squircle: InsettableShape { | |
| // MARK: Properties | |
| var cornerSize: CGSize | |
| var inset = 0.0 | |
| // MARK: Initializers |
This file contains hidden or 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
| import SwiftUI | |
| public extension UnitPoint { | |
| var diametricallyOpposite: UnitPoint { | |
| UnitPoint(x: 1 - x, y: 1 - y) | |
| } | |
| } | |
| public extension LinearGradient { | |
| init(colors: [Color], towards end: UnitPoint) { |
NewerOlder