Skip to content

Instantly share code, notes, and snippets.

View StefKors's full-sized avatar
๐Ÿ“Ÿ

Stef Kors StefKors

๐Ÿ“Ÿ
View GitHub Profile
//
// DividedStack.swift
// based on: https://github.com/aramayyes/Popovers/blob/54728a9ca199ffbffe444d5b04a9354f6a02da7c/Sources/Templates/Views.swift#L14
//
// Created by Stef Kors on 19/12/2024.
//
import SwiftUI
@StefKors
StefKors / ContentView.swift
Created April 4, 2024 20:46
ScrollView + Sheet
//
// ContentView.swift
// 324 Messenger
//
// Created by Stef Kors on 29/03/2024.
//
import SwiftUI
import SwiftData
@StefKors
StefKors / onKeyPress.swift
Last active April 3, 2025 01:22
SwiftUI keyboard events based on keyawareview and keyboardshortcuts
//
// KeyAwareView.swift
//
// Created by Stef Kors on 04/09/2023.
//
// source: https://onmyway133.com/posts/how-to-handle-keydown-in-swiftui-for-macos/
// source: https://github.com/sindresorhus/KeyboardShortcuts/blob/main/Sources/KeyboardShortcuts/Key.swift
import SwiftUI
import Carbon.HIToolbox
@StefKors
StefKors / FocusBlockingOnKeyPress keyboardshortcuts.swift
Last active September 4, 2023 08:51
OnKeyPress needs focus, which makes it totally useless for global keyboard actions
//
// ContentView.swift
// OnKeyPressIssue
//
// Created by Stef Kors on 04/09/2023.
//
import SwiftUI
struct ChildView: View {
@StefKors
StefKors / LazyContentWindow.swift
Created March 16, 2023 12:36
Example of SwiftUI Data loading with LazyVStack and ScrollViews. First you create an array with some identifier of your long list. Then in the child view you use `.task { }` to load the data based of the ID. The LazyVStack will take care of loading the next view.
//
// LazyContentWindow.swift
// Commitment
//
// Created by Stef Kors on 16/03/2023.
//
import SwiftUI
struct LazyLoadedView: View {
export type BaseCountry = {
// the ISO 3166-1 code for the country
code: string
// the name of the country (in english)
name: string
// the raw emoji for the country's flag (can be multiple codepoints)
emoji: string
// the international dialing code for the country (without the `+` prefix or escape codes)
dial_country_code: string
// the regions codes, if any
@StefKors
StefKors / Emoji.swift
Created December 15, 2022 11:15
Array of Emoji manually filtered to contain only all the fun and positive ones
let array = ["๐Ÿ˜€", "๐Ÿ˜ƒ", "๐Ÿ˜„", "๐Ÿ˜", "๐Ÿ˜†", "๐Ÿ˜…", "๐Ÿ˜‚", "๐Ÿคฃ", "๐Ÿฅฒ", "๐Ÿฅน", "๐Ÿ˜Š", "๐Ÿ˜‡", "๐Ÿ™‚", "๐Ÿ™ƒ", "๐Ÿ˜‰", "๐Ÿ˜Œ", "๐Ÿ˜", "๐Ÿฅฐ", "๐Ÿ˜˜", "๐Ÿ˜—", "๐Ÿ˜™", "๐Ÿ˜š", "๐Ÿ˜‹", "๐Ÿ˜›", "๐Ÿ˜", "๐Ÿ˜œ", "๐Ÿคช", "๐Ÿคจ", "๐Ÿง", "๐Ÿค“", "๐Ÿ˜Ž", "๐Ÿฅธ", "๐Ÿคฉ", "๐Ÿฅณ", "๐Ÿ˜", "๐Ÿ˜’", "๐Ÿ˜ž", "๐Ÿ˜”", "๐Ÿ˜Ÿ", "๐Ÿ˜•", "๐Ÿ™", "โ˜น๏ธ", "๐Ÿ˜ฃ", "๐Ÿ˜–", "๐Ÿ˜ซ", "๐Ÿ˜ฉ", "๐Ÿฅบ", "๐Ÿ˜ข", "๐Ÿ˜ญ", "๐Ÿคฏ", "๐Ÿฅถ", "๐Ÿ˜ฑ", "๐Ÿ˜จ", "๐Ÿ˜ฐ", "๐Ÿ˜ฅ", "๐Ÿ˜“", "๐Ÿซฃ", "๐Ÿค—", "๐Ÿซก", "๐Ÿค”", "๐Ÿซข", "๐Ÿคญ", "๐Ÿคซ", "๐Ÿคฅ", "๐Ÿ˜ถ", "๐Ÿ˜ถโ€๐ŸŒซ๏ธ", "๐Ÿ˜", "๐Ÿ˜‘", "๐Ÿ˜ฌ", "๐Ÿซ ", "๐Ÿ™„", "๐Ÿ˜ฏ", "๐Ÿ˜ฎ", "๐Ÿ˜ฒ", "๐Ÿฅฑ", "๐Ÿ˜ด", "๐Ÿคค", "๐Ÿ˜ช", "๐Ÿ˜ต", "๐Ÿ˜ตโ€๐Ÿ’ซ", "๐Ÿซฅ", "๐Ÿค", "๐Ÿฅด", "๐Ÿคข", "๐Ÿค‘", "๐Ÿค ", "๐Ÿคก", "๐Ÿ’ฉ", "๐Ÿ‘ป", "๐Ÿ‘ฝ", "๐Ÿ‘พ", "๐Ÿค–", "๐ŸŽƒ", "๐Ÿ˜บ", "๐Ÿ˜ธ", "๐Ÿ˜น", "๐Ÿ˜ป", "๐Ÿ˜ผ", "๐Ÿ˜ฝ", "๐Ÿ™€", "๐Ÿ‘‹", "๐Ÿคš", "๐Ÿ–", "โœ‹", "๐Ÿ––", "๐Ÿ‘Œ", "๐ŸคŒ", "๐Ÿค", "โœŒ๏ธ", "๐Ÿคž", "๐Ÿซฐ", "๐ŸคŸ", "๐Ÿค˜", "๐Ÿค™", "๐Ÿซต", "๐Ÿซฑ", "๐Ÿซฒ", "๐Ÿซณ", "๐Ÿซด", "๐Ÿ‘ˆ", "๐Ÿ‘‰", "๐Ÿ‘†", "๐Ÿ–•", "๐Ÿ‘‡", "โ˜๏ธ", "๐Ÿ‘", "๐Ÿ‘Ž", "โœŠ", "๐Ÿ‘Š", "๐Ÿค›", "๐Ÿคœ", "๐Ÿ‘", "๐Ÿซถ", "๐Ÿ™Œ", "๐Ÿ‘", "๐Ÿคฒ", "๐Ÿค", "๐Ÿ™", "โœ๏ธ", "๐Ÿ’…", "๐Ÿคณ", "๐Ÿ’ช", "๐Ÿฆพ", "๐Ÿฆต", "๐Ÿฆฟ", "๐Ÿฆถ", "๐Ÿ‘ฃ", "๐Ÿ‘‚", "๐Ÿฆป", "๐Ÿ‘ƒ", "๐Ÿซ€", "๐Ÿซ", "๐Ÿง ", "๐Ÿฆท", "๐Ÿฆด", "๐Ÿ‘€", "๐Ÿ‘", "๐Ÿ‘ถ", "๐Ÿ‘ง", "๐Ÿง’", "๐Ÿ‘ฆ", "๐Ÿ‘ฉ", "๐Ÿง‘", "๐Ÿ‘จ", "๐Ÿ‘ฉโ€๐Ÿฆฑ", "๐Ÿง‘โ€๐Ÿฆฑ", "๐Ÿ‘จโ€๐Ÿฆฑ", "๐Ÿ‘ฉโ€๐Ÿฆฐ", "๐Ÿง‘โ€๐Ÿฆฐ", "๐Ÿ‘จโ€๐Ÿฆฐ", "๐Ÿ‘ฑโ€โ™€๏ธ", "๐Ÿ‘ฑ", "๐Ÿ‘ฑโ€โ™‚๏ธ", "๐Ÿ‘ฉโ€๐Ÿฆณ", "๐Ÿง‘โ€๐Ÿฆณ", "๐Ÿ‘จโ€๐Ÿฆณ", "๐Ÿ‘ฉโ€๐Ÿฆฒ", "๐Ÿง‘โ€๐Ÿฆฒ", "๐Ÿ‘จโ€๐Ÿฆฒ", "๐Ÿง”โ€โ™€๏ธ", "๐Ÿง”", "๐Ÿง”โ€โ™‚๏ธ", "๐Ÿ‘ต", "๐Ÿง“", "๐Ÿ‘ด", "๐Ÿ‘ฒ", "๐Ÿ‘ณโ€โ™€๏ธ", "๐Ÿ‘ณ", "๐Ÿ‘ณโ€โ™‚๏ธ", "๐Ÿง•", "๐Ÿ‘ฎโ€โ™€๏ธ", "๐Ÿ‘ฎ
@StefKors
StefKors / DraggableView.swift
Created July 31, 2021 14:58 — forked from ohayon/DraggableView.swift
Example of making a reusable `draggable()` modifier for SwiftUI Views
struct DraggablePita: View {
var body: some View {
Image(uiImage: UIImage(named: "pita.png")!)
.draggable() // Add the new, custom modifier to make this draggable
}
}
// Handle dragging
struct DraggableView: ViewModifier {
@State var offset = CGPoint(x: 0, y: 0)
_ _ _ _
| | | | ___ | || | ___
| |_| | / _ \| || | / _ \
| _ || __/| || || (_) |
|_| |_| \___||_||_| \___/

install the following

xcode-select --install

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew install git

git config --global user.name "Your Name Here"