Skip to content

Instantly share code, notes, and snippets.

View stleamist's full-sized avatar

Dongkyu Kim stleamist

View GitHub Profile
@onmyway133
onmyway133 / arm64-apple-ios.swiftinterface
Created June 9, 2022 18:46
arm64-apple-ios16.swiftinterface
This file has been truncated, but you can view the full file.
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.7 (swiftlang-5.7.0.113.10 clang-1400.0.16.2)
// swift-module-flags: -target arm64-apple-ios16.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Osize -library-level api -library-level api -module-name SwiftUI
// swift-module-flags-ignorable: -user-module-version 4.0.66.3.102
import Accessibility
import Combine
import CoreData
import CoreFoundation
@_exported import CoreGraphics
@_exported import CoreTransferable
@chriseidhof
chriseidhof / ContentView.swift
Last active May 9, 2025 15:12
Variadic Views
import SwiftUI
struct MyValue: _ViewTraitKey {
static var defaultValue: Int = 0
}
extension View {
func myValue(_ value: Int) -> some View {
_trait(MyValue.self, value)
}
@edudnyk
edudnyk / TestsApp.swift
Last active November 13, 2024 04:51
SwiftUI Easter Eggs: Performance Benchmarking with _ViewTest and more
import SwiftUI
@main
struct App {
static func main() {
_TestApp().runBenchmarks([Benchmark()])
}
}
extension UIHostingController: _Test where Content == AnyView {}
@auramagi
auramagi / ConsoleOutput.txt
Last active October 3, 2024 04:07
SwiftUI _viewDebugData
// Output of print(_viewDebugData), formatted for easier viewing
[SwiftUI._ViewDebug.Data(
data: [
SwiftUI._ViewDebug.Property.value: SwiftUI._SafeAreaInsetsModifier(elements: [], nextInsets: nil),
SwiftUI._ViewDebug.Property.displayList: (display-list
(item #:identity 2 #:version 6
(frame (143.66666666666666 354.0; 88.0 20.333333333333332))
(text "Hello World" #:size (88.0, 20.333333333333332))
)
/**
```
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x00007fff2cb8dead in swift_retain ()
#1 0x00007fff2cb90e55 in swift::metadataimpl::ValueWitnesses<swift::metadataimpl::SwiftRetainableBox>::initializeWithCopy(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*) ()
#2 0x00007fff2cbaf29d in swift::metadataimpl::ValueWitnesses<swift::metadataimpl::OpaqueExistentialBox<1u> >::initializeWithCopy(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*) ()
#3 0x00007fff421b8f10 in outlined init with copy of ViewList? ()
#4 0x00007fff421b8e1a in TransformedList.TransformItem.apply(sublist:) ()
#5 0x00007fff421b8e3e in TransformedList.TransformItem.apply(sublist:) ()
#6 0x00007fff421b8783 in closure #1 in ViewList.visitChildNodes(from:transform:applying:) ()
import SwiftUI
import Combine
public struct ChangeObserver<V: Equatable>: ViewModifier {
public init(newValue: V, action: @escaping (V) -> Void) {
self.newValue = newValue
self.newAction = action
}
private typealias Action = (V) -> Void
@pilgwon
pilgwon / TCA_README_KR.md
Last active April 18, 2025 05:05
TCA README in Korean

The Composable Architecture

The Composable Architecture(TCA)는 일관되고 이해할 수 있는 방식으로 어플리케이션을 만들기 위해 탄생한 라이브러리입니다. 합성(Composition), 테스팅(Testing) 그리고 인체 공학(Ergonomics)을 염두에 둔 TCA는 SwiftUI, UIKit을 지원하며 모든 애플 플랫폼(iOS, macOS, tvOS, watchOS)에서 사용 가능합니다.

@timothycosta
timothycosta / SwiftUIKeyboardAnimation.swift
Last active April 9, 2025 14:42
Create a SwiftUI Animation with the correct curve and duration from UIKit keyboard notifications
func animation(from notification: Notification) -> Animation? {
guard
let info = notification.userInfo,
let duration = info[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double,
let curveValue = info[UIResponder.keyboardAnimationCurveUserInfoKey] as? Int,
let uiKitCurve = UIView.AnimationCurve(rawValue: curveValue)
else {
return nil
}
@mccutchen
mccutchen / github-graphql-examples.md
Last active December 17, 2024 05:03
A couple of ways to look up a GitHub pull request via the v4 GraphQL API

GitHub GraphQL API v4 Examples

Here are two queries that look up information about a pull request via GitHub's GraphQL API v4. The first looks up a pull request by number, the second looks up a pull request by ref (i.e. commit hash, branch name, tag name).

Why tho

While it is trivial to use the RESTful v3 API to look up a pull request by number, the GraphQL API is the only way to do the same thing for an arbitrary reference in a single HTTP request.

These took a bit of trial and error in the GitHub's GraphQL Explorer and various support threads to get right, so I'm putting them up here for posterity.

@gabrieltheodoropoulos
gabrieltheodoropoulos / PressActionsModifier.swift
Created November 1, 2020 17:56
PressActions modifier - Handle press and release events in SwiftUI
struct PressActions: ViewModifier {
var onPress: () -> Void
var onRelease: () -> Void
func body(content: Content) -> some View {
content
.simultaneousGesture(
DragGesture(minimumDistance: 0)
.onChanged({ _ in
onPress()