Skip to content

Instantly share code, notes, and snippets.

@chriseidhof
chriseidhof / Alt.swift
Last active July 13, 2020 15:12
matchedGeometryEffect experiments
//
// ContentView.swift
// Effects
//
// Created by Chris Eidhof on 13.07.20.
//
import SwiftUI
struct MyModifier: AnimatableModifier {
//
// ContentView.swift
// TabBar
//
// Created by Chris Eidhof on 13.07.20.
//
import SwiftUI
struct ContentView: View {
//
// ContentView.swift
// AddressBook
//
// Created by Chris Eidhof on 13.07.20.
//
import SwiftUI
final class Contact: ObservableObject, Identifiable {
@chriseidhof
chriseidhof / bug1.swift
Created July 3, 2020 10:48
SwiftUI bugs
//
// ContentView.swift
// Bug1
//
// Created by Chris Eidhof on 03.07.20.
//
import SwiftUI
struct ContentView: View {
//
// ContentView.swift
// NotesClone
//
// Created by Chris Eidhof on 29.06.20.
//
import SwiftUI
@main
@chriseidhof
chriseidhof / ob-swiftui.el
Last active May 25, 2020 23:56 — forked from xenodium/ob-swiftui.el
Preview SwiftUI layouts using Emacs org blocks
(use-package org
:hook ((org-mode . org-display-inline-images))
:config
(use-package ob
:bind (:map org-mode-map
("C-c C-c" . org-ctrl-c-ctrl-c))
:config
(use-package ob-swift
@chriseidhof
chriseidhof / wrapper.swift
Created May 21, 2020 11:05
NSBrowser Delegate Wrapper
import Cocoa
// Insipired by http://dcandi.com/post/cocoa-filesystem-browser/
extension URL {
var isDirectory: Bool {
return (try? resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory ?? false
}
var fileIcon : NSImage {
@chriseidhof
chriseidhof / boilerplate.swift
Last active January 3, 2024 05:54
QuickMacApp
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
//
// ContentView.swift
//
// Created by Chris Eidhof on 20.04.20.
// Copyright © 2020 objc.io. All rights reserved.
//
import SwiftUI
import UIKit
@chriseidhof
chriseidhof / helpers.swift
Created March 9, 2020 13:31
SwiftUI helpers
struct <#MyView#>: View {
var body: some View {
<#body#>
}
}
extension View {
func geometryPreference<P: PreferenceKey>(_ key: P.Type, value: @escaping (GeometryProxy) -> P.Value) -> some View {
overlay(GeometryReader { proxy in
Color.clear.preference(key: P.self, value: value(proxy))