Skip to content

Instantly share code, notes, and snippets.

View xiaoxidong's full-sized avatar
🎯
Focusing

XiaoDong xiaoxidong

🎯
Focusing
View GitHub Profile
@xiaoxidong
xiaoxidong / AdvancedToolbarWindow.swift
Created March 19, 2023 00:50 — forked from stephancasas/AdvancedToolbarWindow.swift
A SwiftUI-compatible window for macOS with advanced toolbar configurability.
//
// AdvancedToolbarWindow.swift
//
// Created by Stephan Casas on 3/17/23.
//
import SwiftUI;
import AppKit;
class AdvancedToolbarWindow<MainContent: View, TitleToolbarContent: View>: NSWindow, NSToolbarDelegate {
@xiaoxidong
xiaoxidong / adaptiveSheet.swift
Created November 17, 2022 12:01 — forked from fatbobman/adaptiveSheet.swift
Adaptive Height Sheet
import SwiftUI
struct ContentView: View {
@State var show = false
var body: some View {
VStack {
Button("Pop Sheet") { show.toggle() }
}
.adaptiveSheet(isPresent: $show) { SheetView() }
}
@xiaoxidong
xiaoxidong / AnimatableCGPointVector.swift
Created July 7, 2022 00:28 — forked from mecid/AnimatableCGPointVector.swift
The type that holds array of CGPoints and conforms to VectorArithmetic
import SwiftUI
struct AnimatableCGPointVector: VectorArithmetic {
static var zero = AnimatableCGPointVector(values: [.zero])
static func - (lhs: AnimatableCGPointVector, rhs: AnimatableCGPointVector) -> AnimatableCGPointVector {
let values = zip(lhs.values, rhs.values)
.map { lhs, rhs in lhs.animatableData - rhs.animatableData }
.map { CGPoint(x: $0.first, y: $0.second) }
return AnimatableCGPointVector(values: values)
@xiaoxidong
xiaoxidong / ColorText.swift
Created May 23, 2022 08:54 — forked from davidsteppenbeck/ColorText.swift
Attributed strings in Swift with color attributes [iOS 15+]. Add colors to strings in your Localizable.strings files.
import SwiftUI
struct ColorText: View {
// MARK:- Properties
/// The attributed string to display.
private let attributedString: AttributedString
var body: some View {
JSON:
https://unpkg.com/[email protected]/emoji.json
class EmojiManager: ObservableObject {
@Published var emojis: [EmojiObject] = []
init() {
decodeJSON()