Skip to content

Instantly share code, notes, and snippets.

Avatar

Apptek Studios apptekstudios

View GitHub Profile
@apptekstudios
apptekstudios / CustomPicker.swift
Last active May 28, 2021
A variation on the picker designed by Federico Zanetello in his blog post (https://fivestars.blog/swiftui/inspecting-views.html) that allows any type of content to be used
View CustomPicker.swift
//
// CustomPicker.swift
//
// Created by T Brennan on 27/3/21.
//
import SwiftUI
struct ContentView: View {
@State private var selection: Int? = 0
View ScaledMetricOniOS13.swift
import SwiftUI
struct AccessibleView: View {
@ScaledMetricCustom(relativeTo: .title) var someSize: CGFloat = 100
@ScaledFont(customFontName: "TimesNewRomanPS-BoldMT", size: 18, relativeTo: .body) var bodyFont
var body: some View {
VStack {
Rectangle()
.frame(width: someSize, height: someSize)
@apptekstudios
apptekstudios / conditionalView.swift
Last active Apr 20, 2020
Simple Conditional View Closures
View conditionalView.swift
import SwiftUI
@ViewBuilder
func `ifLet`<T, Content: View>(_ optional: T?, @ViewBuilder builder: ((T) -> Content)) -> some View {
optional.map(builder)
}
@ViewBuilder
func `ifNotLet`<T, Content: View>(_ optional: T?, @ViewBuilder builder: (() -> Content)) -> some View {
if optional == nil {
@apptekstudios
apptekstudios / 0_reuse_code.js
Created Nov 14, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console