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
| // | |
| // Created by Sean Heber on 8/11/22. | |
| // | |
| import Foundation | |
| enum ExponentialBackoffError : Error { | |
| case retryLimitExceeded | |
| } |
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
| // | |
| // PagingView.swift | |
| // Wallaroo - https://wallaroo.app | |
| // | |
| // Created by Sean Heber (@BigZaphod) on 8/9/22. | |
| // | |
| import SwiftUI | |
| // This exists because SwiftUI's paging setup is kind of broken and/or wrong out of the box right now. |
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
| // The original Container protocol. | |
| protocol Container { | |
| associatedtype Item | |
| func deleteItem(_: Item) | |
| } | |
| // Let's make a couple of concrete containers that use our protocol: | |
| class StringContainer: Container { | |
| typealias Item = String |
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 TestLayout: Layout { | |
| func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize { | |
| // Assuming this layout is in a fixed size container and isn't sizing itself based on the subviews. | |
| return proposal.replacingUnspecifiedDimensions() | |
| } | |
| func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) { | |
| let availableWidth = bounds.size.width | |
| let offeredWidth = availableWidth / CGFloat(subviews.count) | |
| let subviewProposal = ProposedViewSize(width: offeredWidth, height: bounds.size.height) |
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
| final actor Worker: ObservableObject { | |
| @MainActor @Published private(set) var lastWorkDoneAt: Date? | |
| private var counter = 0 | |
| func doWork() { | |
| counter += 1 | |
| DispatchQueue.main.async { | |
| self.lastWorkDoneAt = .now |
OlderNewer