Skip to content

Instantly share code, notes, and snippets.

View zntfdr's full-sized avatar
🌙
BRB GOING TO THE MOON

Federico Zanetello zntfdr

🌙
BRB GOING TO THE MOON
View GitHub Profile
// Original article here: https://www.fivestars.blog/code/redacted-custom-effects.html
import SwiftUI
extension RedactionReasons {
public static let confidential = RedactionReasons(rawValue: 1 << 10)
}
struct ContentView: View {
var body: some View {
// Original article here: https://www.fivestars.blog/swiftui/app-scene-storage.html
import Combine
import SwiftUI
// MARK: Appearance
enum Appearance: String, Codable, CaseIterable, Identifiable {
case dark
case light
// Original article here: https://www.fivestars.blog/code/swiftui-hierarchy-list.html
import SwiftUI
struct FileItem: Identifiable {
let name: String
var children: [FileItem]?
var id: String { name }
@zntfdr
zntfdr / CustomPicker.swift
Created March 27, 2021 04:37 — forked from apptekstudios/CustomPicker.swift
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
//
// CustomPicker.swift
//
// Created by T Brennan on 27/3/21.
//
import SwiftUI
struct ContentView: View {
@State private var selection: Int? = 0
// "Fix" for Xcode 12.5 SwiftUI navigation issue.
import SwiftUI
enum ContentViewNavigation: Identifiable {
case one
case two(number: Int)
case three(text: String)
// MARK: Identifiable
// Original article here: https://www.fivestars.blog/code/swiftui-hierarchy-list.html
import SwiftUI
struct FileItem: Identifiable {
let name: String
var children: [FileItem]?
var id: String { name }
// Original article here: https://fivestars.blog/swiftui/swiftui-share-layout-information.html
import SwiftUI
extension View {
func readSize(onChange: @escaping (CGSize) -> Void) -> some View {
background(
GeometryReader { geometryProxy in
Color.clear
.preference(key: SizePreferenceKey.self, value: geometryProxy.size)
// Original article here: https://www.fivestars.blog/code/redacted-custom-effects.html
import SwiftUI
// MARK: Step 1: Create RedactionReason
public enum RedactionReason {
case placeholder
case confidential
// Original article here: https://www.fivestars.blog/code/swiftui-hierarchy-list.html
import SwiftUI
struct FileItem: Identifiable {
let name: String
var children: [FileItem]?
var id: String { name }
@zntfdr
zntfdr / disableBackButtonMenuSwiftui.swift
Created June 9, 2021 16:57
Hide the iOS 14 navigation menu (shown on a long press on any back button)
// Usage: call `UIViewController.classInit` in your UISceneDelegate
private func swizzle(
targetClass: AnyClass,
originalSelector: Selector,
swizzledSelector: Selector
) {
let originalMethod = class_getInstanceMethod(targetClass, originalSelector)
let swizzledMethod = class_getInstanceMethod(targetClass, swizzledSelector)
method_exchangeImplementations(originalMethod!, swizzledMethod!)