Skip to content

Instantly share code, notes, and snippets.

View PaulWoodIII's full-sized avatar

Paul Wood III PaulWoodIII

View GitHub Profile
@PaulWoodIII
PaulWoodIII / SwiftUI_List.swift
Created August 3, 2019 23:50
The Interface of List we are using
public struct List<SelectionValue, Content> : View where SelectionValue : Hashable, Content : View {
public init(selection: Binding<Set<SelectionValue>>?, @ViewBuilder content: () -> Content)
}
@PaulWoodIII
PaulWoodIII / SimpleIdentifiableList.swift
Created August 3, 2019 23:19
A Simple list that uses the Identifiable protocol
import SwiftUI
import PlaygroundSupport
struct Name: Identifiable, ExpressibleByStringLiteral {
var name: String
public init(stringLiteral value: Swift.StringLiteralType) {
self.name = value
}
var id: String { return name }
}
@PaulWoodIII
PaulWoodIII / IdentifiableAlertView.swift
Created August 3, 2019 22:59
An example of a complex SwiftUI Alert view using and Identifiable binding
//: [Previous](@previous)
import SwiftUI
import PlaygroundSupport
enum AlertTypes: String, Identifiable {
case simple = "A Simple Alert"
case complex = "A Complex Alert"
@PaulWoodIII
PaulWoodIII / IdentifiableActionSheet.swift
Last active August 3, 2019 21:54
Quick example of Identifiable Action Sheets using SwiftUI, one view may need many different action sheets and this is one implementation to handle that, and even share action sheet logic across your application
//: [Previous](@previous)
import SwiftUI
import UIKit
import PlaygroundSupport
struct IdentifiableActionSheet : View {
@State var displaySheet: SheetTypes? = nil
@PaulWoodIII
PaulWoodIII / MultipleIdentifiableList.swift
Last active August 4, 2019 00:18
Wrapper around specialized datatype with SwiftUI Identifiable will work
//: [Previous](@previous)
import SwiftUI
import PlaygroundSupport
protocol Nameable {
var name: String { get }
}
struct Name: Nameable {
@PaulWoodIII
PaulWoodIII / MultipleIdentifiableList-CompilerError.swift
Last active August 3, 2019 23:27
Protocol Associated Types with SwiftUI Identifiable will not work
//: [Previous](@previous)
import Foundation
import SwiftUI
import UIKit
import PlaygroundSupport
// This doesnt work because the protocol has an assoicated Type
// To understand more
// https://chariotsolutions.com/screencast/philly-ete-2019-rob-napier-generic-swift-it-isnt-supposed-to-hurt/
//: A UIKit based Playground for presenting user interface
import SwiftUI
import UIKit
import PlaygroundSupport
import Combine
class ObservingSource: BindableObject {
var someString: String = ""
var willChange = PassthroughSubject<String,Never>()
import XCTest
import Combine
import Entwine
import EntwineTest
class EntwineTestSchedulerExampleTests: XCTestCase {
func testSchedulerInjection() {
let scheduler = TestScheduler(initialClock: 0)
var didSink = false
@PaulWoodIII
PaulWoodIII / Emoji.swift
Created October 29, 2016 17:24
Emoji as a model object extra bits for full text searching and a string extension "isEmoji"
//
// Emoji.swift
// Tipski
//
// Created by Paul Wood on 10/29/16.
// Copyright © 2016 Paul Wood. All rights reserved.
//
// Assumes you have a file named emojis.json as a resource
// That file can be found here: https://github.com/muan/emoji/blob/gh-pages/javascripts/emojilib/emojis.json
// Thanks so much to the contributors of emojilib!
#!/usr/bin/env xcrun swift
import Foundation
print("This is a swift script!")
print("Arguments: \(ProcessInfo.processInfo.arguments)")