custom symbols picker

This commit is contained in:
neon443 committed 2025-06-14 10:59:48 +01:00
1 parent 6e5b7adbc4
commit 13ef94ea3e
5 files changed
+118 -4

No files matched your search

@@ -0,0 +1,36 @@
//
// SymbolsLoader.swift
// NearFuture
//
// Created by neon443 on 14/06/2025.
//
import Foundation
class SymbolsLoader: ObservableObject {
@Published var allSymbols: [String] = []
init() {
self.allSymbols = getAllSymbols()
}
func getSymbols(_ searched: String) -> [String] {
if searched.isEmpty {
return allSymbols
} else {
return allSymbols.filter() { $0.localizedCaseInsensitiveContains(searched) }
}
}
func getAllSymbols() -> [String] {
var allSymbols = [String]()
if let bundle = Bundle(identifier: "com.apple.CoreGlyphs"),
let resPath = bundle.path(forResource: "name_availability", ofType: "plist"),
let plist = try? NSDictionary(contentsOf: URL(fileURLWithPath: resPath), error: ()),
let plistSymbols = plist["symbols"] as? [String: String]
{
allSymbols = Array(plistSymbols.keys)
}
return allSymbols
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.