Skip to content

Instantly share code, notes, and snippets.

Ray Fix rayfix

View GitHub Profile
View ActivityRing.swift
//
// ContentView.swift
// Ring
//
// Created by Ray Fix on 6/20/20.
// Copyright © 2020 Ray Fix. All rights reserved.
//
import SwiftUI
@rayfix
rayfix / SetCard.swift
Created Jun 14, 2020
SetCard abstraction
View SetCard.swift
func combinations<S1: Sequence, S2: Sequence>(_ sequence1: S1, _ sequence2: S2) -> AnySequence<(S1.Element, S2.Element)> {
AnySequence(
sequence1.lazy.flatMap { element1 in
sequence2.lazy.map { element2 in
(element1, element2)
}
}
)
}
@rayfix
rayfix / Observe.swift
Created May 23, 2020
Some example of using observable object
View Observe.swift
import SwiftUI
import Combine
final class ViewModel: ObservableObject {
var subs: Set<AnyCancellable> = []
// For some reason this does not work!
init() {
View Environment.swift
import SwiftUI
extension View {
func printType() -> Self {
print(type(of: self))
return self
}
}
// Need to make a key; all it needs is a default value.
@rayfix
rayfix / PublishedViewModel.swift
Last active May 16, 2020
Some SwiftUI/Combine examples
View PublishedViewModel.swift
//
// ContentView.swift
// Pub
//
// Created by Ray Fix on 5/16/20.
// Copyright © 2020 Ray Fix. All rights reserved.
//
import SwiftUI
import Combine
@rayfix
rayfix / draggable.swift
Created May 9, 2020
make views draggable
View draggable.swift
//
// ContentView.swift
//
// Created by Ray Fix on 5/9/20.
// Copyright © 2020 Ray Fix. All rights reserved.
//
import SwiftUI
struct ContentView: View {
@rayfix
rayfix / SwiftUIChartsExample.swift
Last active May 2, 2020
John James demonstrated using SwiftUI charts
View SwiftUIChartsExample.swift
// Load the Swift Package: https://github.com/AppPear/ChartView
import SwiftUI
import SwiftUICharts
struct ContentView: View {
@State var tabIndex:Int = 0
@rayfix
rayfix / AnchorPointDemo.swift
Created May 2, 2020
A demonstration of using anchor points in SwiftUI
View AnchorPointDemo.swift
import SwiftUI
struct ContentView: View {
@State private var scale: CGFloat = 1
@State private var angle = Angle(radians: 0)
@State private var color = UIColor.blue
var body: some View {
Image(systemName: "heart.fill")
@rayfix
rayfix / KeyPathDemo.swift
Created Apr 6, 2020
Playing around with KeyPaths in Swift
View KeyPathDemo.swift
struct Paragraph {
var words: String
}
struct Chapter {
var title: String
var content: [Paragraph]
}
View UIImage+heicData.swift
extension UIImage {
enum HEICError: Error {
case heicNotSupported
case cgImageMissing
case couldNotFinalize
}
static var isHEICSupported: Bool = {
let data = NSMutableData()
You can’t perform that action at this time.