Skip to content

Instantly share code, notes, and snippets.

View trozware's full-sized avatar

Sarah Reichelt trozware

View GitHub Profile
@trozware
trozware / ContentView.swift
Last active April 29, 2022 05:11
Open a view in another window - SwiftUI for Mac
import SwiftUI
struct ContentView: View {
var body: some View {
Button("Open Secondary Window") {
openSecond()
}
.frame(width: 400, height: 150)
}
@trozware
trozware / ContentView.swift
Created November 1, 2021 04:28
SwiftUI Mac double-clicking in list
import SwiftUI
struct ContentView: View {
@State private var selectedRow: Int?
@State private var resultText = ""
var body: some View {
VStack {
List(0 ..< 5, selection: $selectedRow) { item in
HStack {
@trozware
trozware / ContentView.swift
Created October 4, 2019 07:13
Demonstration of dismissing sheet in SwiftUI and what can trigger the "onDismiss" action.
import SwiftUI
struct ContentView: View {
@State private var showingSheet = false
@State private var counter = 0
var body: some View {
VStack(spacing: 50.0) {
Text("Sheet has been shown \(counter) times.")
// https://eval.weheartswift.com/eval/playground/swift-sandbox
// https://swift.sandbox.bluemix.net/#/repl
// VARIABLES
////////////
var hitPoints = 29
print(hitPoints)
hitPoints = 12