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
fileprivate extension AsyncStream { | |
init<Base: AsyncSequence>(from sequence: Base, file: StaticString = #filePath, line: UInt = #line) where Element == Base.Element { | |
var iterator = sequence.makeAsyncIterator() | |
// FIXME: In later swift versions, AsyncSequence protocol will likely have an associated error type. | |
// FIXME: For now, produce an assertionFailure to let developer know to use an AsyncThrowingStream instead. | |
self.init { | |
do { | |
return try await iterator.next() | |
} catch { | |
assertionFailure("warning: Base AsyncSequence threw an error. Use AsyncThrowingStream instead", file: file, line: line) |
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
import SwiftUI | |
/// A layout that presents its children in a flow layout | |
/// Thanks to [objc.io](https://talk.objc.io/episodes/S01E308-the-layout-protocol?t=489) for the starting point | |
/// Added some additional changes here to support view spacing and resizing of subviews that are larger than the container. | |
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) | |
public struct FlowLayout: Layout { | |
private let spacing: CGFloat | |
public init(spacing: CGFloat = 8) { |
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
import Foundation | |
import SwiftUI | |
#if canImport(UIKit) | |
import UIKit | |
#elseif canImport(AppKit) | |
import AppKit | |
#endif | |
extension Image { | |
/// Initializes a SwiftUI `Image` from data. |
OlderNewer