Skip to content

Instantly share code, notes, and snippets.

Avatar
✈️
We live in a twilight world.

Hiroshi Kimura muukii

✈️
We live in a twilight world.
View GitHub Profile
@muukii
muukii / SwiftUI.swiftinterface
Created Sep 21, 2022
iOS 16 SwiftUI interface
View SwiftUI.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.124.26 clang-1400.0.29.50)
// swift-module-flags: -target arm64-apple-ios16.0-simulator -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: -enable-bare-slash-regex -user-module-version 4.0.90.1.107
import Accessibility
import Combine
import CoreData
import CoreFoundation
@_exported import CoreGraphics
View Gen.swift
import SwiftUI
import Foundation
extension View {
func snapshot(scale: CGFloat) -> UIImage {
let controller = UIHostingController(rootView: self)
let view = controller.view
let targetSize = controller.view.intrinsicContentSize
view?.bounds = CGRect(origin: .zero, size: targetSize)
View UsingMondrianClassicalLayoutAPI.swift
let backgroundView = UIView.mock(backgroundColor: .neon(.violet))
let box1 = UIView.mock(backgroundColor: .neon(.red), preferredSize: .largeSquare)
let box2 = UIView.mock(backgroundColor: .neon(.yellow), preferredSize: .largeSquare)
view.addSubview(backgroundView)
view.addSubview(box1)
view.addSubview(box2)
mondrianBatchLayout {
View UsingMondrianLayoutStructuredLayoutAPI.swift
let backgroundView = UIView.mock(backgroundColor: .neon(.violet))
let box1 = UIView.mock(backgroundColor: .neon(.red), preferredSize: .largeSquare)
let box2 = UIView.mock(backgroundColor: .neon(.yellow), preferredSize: .largeSquare)
view.mondrian.buildSubviews {
HStackBlock(spacing: 10) {
box1
box2
}
.padding(10)
View UsingPlainAPI.swift
let backgroundView = UIView.mock(backgroundColor: .neon(.violet))
let box1 = UIView.mock(backgroundColor: .neon(.red), preferredSize: .largeSquare)
let box2 = UIView.mock(backgroundColor: .neon(.yellow), preferredSize: .largeSquare)
view.addSubview(backgroundView)
view.addSubview(box1)
view.addSubview(box2)
backgroundView.translatesAutoresizingMaskIntoConstraints = false
box1.translatesAutoresizingMaskIntoConstraints = false
View ComposedCornerView.swift
/// For Transition
public final class ComposedCornerView: CodeBasedView {
private let topRightMaskView = UIView()
private let topLeftMaskView = UIView()
private let bottomRightMaskView = UIView()
private let bottomLeftMaskView = UIView()
private let topRightView = UIView()
private let topLeftView = UIView()
View UIScrollView+insercepts-contentInset.swift
import ObjectiveC
import UIKit
let swizzle: Void = {
print("swizzle")
method_exchangeImplementations(
class_getInstanceMethod(UIScrollView.self, #selector(setter:UIScrollView.contentInset))!,
class_getInstanceMethod(UIScrollView.self, #selector(UIScrollView._mmm_setContentInset))!
@muukii
muukii / AppDelegate.swift
Last active May 31, 2021
Storybook-ios demo app starter template
View AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let newWindow = UIWindow()
View Experimental_KeyboardCollectionWrapperNode.swift
//
import AsyncDisplayKit
import Foundation
import KeyboardGuide
import AppFoundation
/**
A sub-class of ASCollectionNode that supports handling the height of the Keyboard.
Using `KeyboardGuide`, it changes its contentInset and scroll-indicator regarding the relative height of the Keyboard.