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,48 @@
//
// SymbolsPicker.swift
// NearFuture
//
// Created by neon443 on 14/06/2025.
//
import SwiftUI
struct SymbolsPicker: View {
@StateObject private var symbolsLoader = SymbolsLoader()
@Binding var selection: String
@State var searchInput: String = ""
private func gridLayout(forWidth geoSizeWidth: CGFloat) -> [GridItem] {
let gridItem = GridItem(.fixed(40), spacing: 20, alignment: .center)
let columns = Int(geoSizeWidth/60.rounded(.up))
return Array(repeating: gridItem, count: columns)
}
var body: some View {
GeometryReader { geo in
ScrollView {
LazyVGrid(columns: gridLayout(forWidth: geo.size.width)) {
ForEach(symbolsLoader.getSymbols(searchInput), id: \.self) { symbol in
Button() {
selection = symbol
} label: {
Image(systemName: symbol)
.resizable()
.scaledToFit()
.frame(maxWidth: 40, maxHeight: 40)
.symbolRenderingMode(.palette)
.foregroundStyle(.blue, .gray, .black)
}
.buttonStyle(.plain)
}
}
}
.searchable(text: $searchInput)
}
}
}
#Preview {
SymbolsPicker(selection: .constant(""))
}
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.