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/section-title-index-swiftui.html
import SwiftUI
let database: [String: [String]] = [
"iPhone": [
"iPhone", "iPhone 3G", "iPhone 3GS", "iPhone 4", "iPhone 4S", "iPhone 5", "iPhone 5C", "iPhone 5S", "iPhone 6", "iPhone 6 Plus", "iPhone 6S", "iPhone 6S Plus", "iPhone SE", "iPhone 7", "iPhone 7 Plus", "iPhone 8", "iPhone 8 Plus", "iPhone X", "iPhone Xs", "iPhone Xs Max", "iPhone Xʀ", "iPhone 11", "iPhone 11 Pro", "iPhone 11 Pro Max", "iPhone SE 2"
],
"iPad": [
"iPad", "iPad 2", "iPad 3", "iPad 4", "iPad 5", "iPad 6", "iPad 7", "iPad Air", "iPad Air 2", "iPad Air 3", "iPad Mini", "iPad Mini 2", "iPad Mini 3", "iPad Mini 4", "iPad Mini 5", "iPad Pro 9.7-inch", "iPad Pro 10.5-inch", "iPad Pro 11-inch", "iPad Pro 11-inch 2", "iPad Pro 12.9-inch", "iPad Pro 12.9-inch 2", "iPad Pro 12.9-inch 3", "iPad Pro 12.9-inch 4"
@zntfdr
zntfdr / firebase-iOS-breakdown.swift
Last active March 27, 2024 15:06
Firebase iOS Version breakdown
// How to:
// 1. Open the Firebase Analytics Dashboard
// 2. Scroll to bottom, where you see the "Users by Device model" widget
// 3. Click "View device models" in that widget (this opens the "Tech details" Firebase Analytics page)
// 4. Above the table shown in the new page, click on the “Device model” drop down menu and select “OS with Version”
// 5. Make sure to select “OS with version” and not “OS Version”
// 6. On the top right corner of the page, click on the “Share this report” icon (next to the date)
// 7. Click “Download file” on the new side bar, then “Download CSV"
// 8. Open the file and select the iOS/Android breakdown raw data
// 9. Replace the sample data in this script with your data
//
import SwiftUI
extension Notification.Name {
static let popEverything = Notification.Name("pop_everything")
}
struct MoreTabView: View {
@State var triggerNext: Bool = false
// Original article here: https://www.fivestars.blog/code/section-title-index-swiftui.html
import SwiftUI
let database: [String: [String]] = [
"iPhone": [
"iPhone", "iPhone 3G", "iPhone 3GS", "iPhone 4", "iPhone 4S", "iPhone 5", "iPhone 5C", "iPhone 5S", "iPhone 6", "iPhone 6 Plus", "iPhone 6S", "iPhone 6S Plus", "iPhone SE", "iPhone 7", "iPhone 7 Plus", "iPhone 8", "iPhone 8 Plus", "iPhone X", "iPhone Xs", "iPhone Xs Max", "iPhone Xʀ", "iPhone 11", "iPhone 11 Pro", "iPhone 11 Pro Max", "iPhone SE 2"
],
"iPad": [
"iPad", "iPad 2", "iPad 3", "iPad 4", "iPad 5", "iPad 6", "iPad 7", "iPad Air", "iPad Air 2", "iPad Air 3", "iPad Mini", "iPad Mini 2", "iPad Mini 3", "iPad Mini 4", "iPad Mini 5", "iPad Pro 9.7-inch", "iPad Pro 10.5-inch", "iPad Pro 11-inch", "iPad Pro 11-inch 2", "iPad Pro 12.9-inch", "iPad Pro 12.9-inch 2", "iPad Pro 12.9-inch 3", "iPad Pro 12.9-inch 4"
@zntfdr
zntfdr / invocation.sh
Created July 19, 2020 12:47 — forked from ole/!swiftui-reflection-dump.md
A dump of the SwiftUI.framework binary for the iOS simulator (as of Xcode 12.0 beta 2) using the swift-reflection-dump tool.
# Call this inside the bin directory of a build of the Swift compiler,
# e.g. build/Xcode-ReleaseAssert/swift-macosx-x86_64/Release/bin.
#
# Adjust the path to match your Xode installation or pick a different binary to dump.
#
# Tested with Xcode 12.0 beta 2.
#
# Note: I used a Swift 5.3 compiler build from a few weeks ago that I had laying around.
# Because of ABI stability, I don't think the swift-reflection-dump version has to match
# the compiler version that was used to build the binary, but I'm not 100% sure.
@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!)
// 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://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://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/swiftui-hierarchy-list.html
import SwiftUI
struct FileItem: Identifiable {
let name: String
var children: [FileItem]?
var id: String { name }