Skip to content

Instantly share code, notes, and snippets.

View zats's full-sized avatar

Sash Zats zats

View GitHub Profile
zats / SwiftUIInvertedList.swift
Created March 24, 2024 13:21
SwiftUI inverted List
import UIKit
import SwiftUI
struct RootView: View {
var body: some View {
List {
FlippedCell(text: "Hello")
FlippedCell(text: "Is it me")
FlippedCell(text: "you looking")
import UIKit
import UniformTypeIdentifiers
protocol TokenTextFieldDelegate: AnyObject {
func tokenizedTextField(_ sender: TokenTextField, didTapTokenView: UIView)
final class TokenTextField: UITextView {
enum AppNavigationTarget: Hashable {
case related(to: Post, showOriginal: Bool, postType: PostType)
case showPost(parentId: String, showRealted: Bool, postType: PostType)
case user(User, sort: FeedType.UserSort, postType: PostType)
case search(String, postType: PostType, searchType: SearchType)
case favorites(sort: FeedType.FavoritesSort, postType: PostType)
case follows(sort: FeedType.FollowsSort, postType: PostType)
case community(sort: FeedType.CommunitySort, postType: PostType)
zats /
Last active October 22, 2023 22:41
Scaling values proportional to font in SwiftUI


In UIKit we have access to a bunch of useful methods on UIFont such as UIFontMetrics.scaledValue(…) it allows to convert value to proportional one when user adjusts the dynamic size settings This is currently not support in SwiftUI, following extensions should help

TL;DR this method only works for system text styles which is more than I need for my app

public extension UIFont {
    convenience init(_ font: Font) {
zats /
Last active October 22, 2023 22:35
Square image container

Image in a square container

It took me way too long to figure out how to achieve following:


Key points to call out:

I wanted API to look something like

zats / ContentView.swift
Last active February 17, 2024 10:23
Internal SF Symbols
struct ContentView: View {
var body: some View {
let names = [
["", "buildings.3d", "emoji.chicken.face"],
["person.text.rectangle.and.nfc", "secure.element", "laugh.bubble.tapback.2.he"],
["", "apple.podcasts.square.stack", "apple.slice"],
VStack(spacing: 20) {
Grid(horizontalSpacing: 20, verticalSpacing: 20) {
ForEach(names, id: \.self) { nameRow in
zats /
Created October 12, 2023 03:08
Private SF Symbols

List of all the images in /Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/SFSymbols.framework/CoreGlyphsPrivate.bundle/

NSBundle *const sfSymbolsBundle = [SFSCoreGlyphsBundle private];
_UIAssetManager *const assetManager = [_UIAssetManager assetManagerForBundle:sfSymbolsBundle];
UIImage *const image = [assetManager imageNamed:@"apple.breathe"];
zats / EnableVoiceOver.m
Last active September 24, 2023 16:46
Set voice over enabled with private API - not for AppStore
static void _setVoiceOver(BOOL enabled) {
NSString* const accessibilityUtilitiesPath = [[NSBundle bundleForClass:UIApplication.class]
void* handler = dlopen([accessibilityUtilitiesPath cStringUsingEncoding:NSUTF8StringEncoding], RTLD_NOW);
if (!handler) {
Last active December 23, 2023 20:32
Apple M1 MacBook Do Not Disturb Key remapping

Following is a sample of LaungAgent that remaps do not disturb key to Siri (I am using Type to Siri)

This is a lightweight solution not relying on external apps.

Setting up

  1. Create ~/Library/LaunchAgents/com.local.KeyRemapping.plist
  2. Edit it to have following content
zats / EmojiTokensLoader.m
Last active November 22, 2023 15:52
[WIP] Emoji tokens - word matching with emojis as of macOS 12.1. So far only found a list of tokens, gotta find a mapping to the emojis
[[NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/EmojiFoundation.framework"] load];
EMFDefaultAutocompleteCandidateProvider *provider = [[EMFDefaultAutocompleteCandidateProvider alloc] initWithBundle:bundle];
[provider tokens]; // returns all the tokens recognized as emojis