Skip to content

Instantly share code, notes, and snippets.

View stleamist's full-sized avatar

Dongkyu Kim (Max.kim) stleamist

View GitHub Profile
@eneko
eneko / swiftui_public_interface.swift
Created November 10, 2023 16:35
SwiftUI public interface - Xcode 15.0 15A240d
This file has been truncated, but you can view the full file.
import Accessibility
import AppKit
import Combine
import CoreData
import CoreFoundation
import CoreGraphics
import CoreText
import CoreTransferable
import Darwin
import React
import UIKit
class SecureImageView: UIView {
@objc var url: String = "" {
didSet {
do {
let imageUrl = URL(string: url)
let data = try Data(contentsOf: imageUrl!)
let image = UIImage(data: data)
@swiftui-lab
swiftui-lab / showSizes.swift
Last active April 2, 2024 22:37
A debugging modifier for SwiftUI views (showSizes)
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: Implementation of the showSizes() debugging modifier
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
struct MeasureExample: View {
var body: some View {
VStack {
import SwiftUI
struct ContentView: View {
@State var path: [String] = []
func navigationButton(value: String) -> some View {
NavigationButton {
path.append(value)
} label: {
Text("NavigationButton")
@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 March 27, 2024 19:14
Variadic Views
import SwiftUI
struct MyValue: _ViewTraitKey {
static var defaultValue: Int = 0
}
extension View {
func myValue(_ value: Int) -> some View {
_trait(MyValue.self, value)
}
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 March 28, 2024 01:53
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 March 12, 2024 21:10
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 April 26, 2024 12:51
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.