Skip to content

Instantly share code, notes, and snippets.

View robhasacamera's full-sized avatar

Robert Cole robhasacamera

View GitHub Profile
// Modified from https://swiftuirecipes.com/blog/pull-to-refresh-with-swiftui-scrollview
struct OffsetAwareScrollView<Content>: View where Content: View {
typealias OffsetReceiver = (CGFloat) -> Void
let axes: Axis.Set
let showsIndicators: Bool
let offsetReceiver: OffsetReceiver
let content: Content
init(_ axes: Axis.Set = .vertical,
import SwiftUI
// Adapted from: https://stackoverflow.com/questions/62102647/swiftui-hstack-with-wrap-and-dynamic-height/62103264#62103264
struct WrappingHStack<Model, V>: View where Model: Hashable, V: View {
typealias ViewGenerator = (Model) -> V
var models: [Model]
var viewGenerator: ViewGenerator
var horizontalSpacing: CGFloat = 2
var verticalSpacing: CGFloat = 0