Skip to content

Instantly share code, notes, and snippets.

View kirti-swiggy's full-sized avatar
:dependabot:
tch tch

Kirti Verma kirti-swiggy

:dependabot:
tch tch
View GitHub Profile
@kirti-swiggy
kirti-swiggy / viewtree.py
Created April 18, 2025 14:32 — forked from avielg/viewtree.py
SwiftUI View Tree Graph
#!/opt/homebrew/bin/python3
import re
import glob
import os
import graphviz
##################################################################################
######### USAGE #########
git stash show -p stash@{0} > Stash0.patch
@kirti-swiggy
kirti-swiggy / View+Discover.swift
Created February 13, 2024 08:00 — forked from IanKeen/View+Discover.swift
SwiftUI: discover underlying components to fill in gaps in SwiftUI api
import SwiftUI
extension View {
public func discover<T: UIView>(
tag: Int = .random(in: (.min)...(.max)),
where predicate: @escaping (T) -> Bool = { _ in true },
_ closure: @escaping (T) -> Void
) -> some View {
self.overlay(
DiscoveryView(tag: tag)
@kirti-swiggy
kirti-swiggy / AdaptsToSoftwareKeyboard.swift
Created December 24, 2023 15:53 — forked from scottmatthewman/AdaptsToSoftwareKeyboard.swift
An example of using Combine to automatically adapt a SwiftUI scrollable view to accommodate an iOS onscreen keyboard
import SwiftUI
import Combine
struct AdaptsToSoftwareKeyboard: ViewModifier {
@State var currentHeight: CGFloat = 0
func body(content: Content) -> some View {
content
.padding(.bottom, currentHeight)
.edgesIgnoringSafeArea(.bottom)
@kirti-swiggy
kirti-swiggy / sample.swift
Created October 19, 2023 04:33 — forked from chriseidhof/viewmirror.swift
View Inspection
import SwiftUI
struct SizeKey: PreferenceKey {
static func reduce(value: inout CGSize?, nextValue: () -> CGSize?) {
value = value ?? nextValue()
}
}
struct ContentView: View {
@State var width: CGFloat? = nil
var body: some View {
// The SwiftUI Lab
// Website: https://swiftui-lab.com
// Article: https://swiftui-lab.com/alignment-guides
import SwiftUI
class Model: ObservableObject {
@Published var minimumContainer = true
@Published var extendedTouchBar = false
@Published var twoPhases = true