Skip to content

Instantly share code, notes, and snippets.

View messeb's full-sized avatar
:octocat:
Commiting

Sebastian Messingfeld messeb

:octocat:
Commiting
View GitHub Profile
@ole
ole / Stateful.swift
Last active December 5, 2022 20:58
A wrapper view that provides a mutable Binding to its content closure. Useful in Xcode Previews for interactive previews of views that take a Binding. https://twitter.com/olebegemann/status/1565707085849010176
import SwiftUI
/// A wrapper view that provides a mutable Binding to its content closure.
///
/// Useful in Xcode Previews for interactive previews of views that take a Binding.
struct Stateful<Value, Content: View>: View {
var content: (Binding<Value>) -> Content
@State private var state: Value
init(initialState: Value, @ViewBuilder content: @escaping (Binding<Value>) -> Content) {
@bjhomer
bjhomer / cross-view-lines.swift
Last active November 5, 2022 05:31
Creating cross-view lines in SwiftUI
//
// ContentView.swift
// SwiftUIPlayground
//
// Created by BJ Homer on 4/26/21.
//
import SwiftUI