Files
StickerSlack/StickerSlack/SwiftUI/SettingsView.swift
neon443 98d8f083a1 massively improved indexing performance:
cache the downloadedEmojis Set and Array
added resize image function, yet to use
the app icon and name are horizontally aligned in settings
2025-11-22 17:31:03 +00:00

101 lines
2.5 KiB
Swift

//
// SettingsView.swift
// StickerSlack
//
// Created by neon443 on 18/11/2025.
//
import SwiftUI
struct SettingsView: View {
@ObservedObject var hoarder: EmojiHoarder
@Environment(\.colorScheme) var colorScheme
var isDark: Bool {
return colorScheme == .dark
}
var body: some View {
NavigationStack {
List {
Section {
HStack {
Image(isDark ? "icon-dark" : "icon")
.resizable().scaledToFit()
.frame(width: 100, height: 100)
.clipShape(RoundedRectangle(cornerRadius: 24))
.foregroundStyle(.purple)
.shadow(color: isDark ? .white : .purple, radius: 5)
.padding(.trailing, 10)
VStack(alignment: .leading) {
Text("StickerSlack")
.font(.title2)
.monospaced()
.bold()
HStack(alignment: .center, spacing: 5) {
Text(Bundle.main.appVersion)
.bold()
.font(.subheadline)
Text(Bundle.main.appBuild)
.foregroundStyle(.gray)
.font(.subheadline)
}
}
}
}
Section {
Text("\(hoarder.emojis.count) total Emoji")
Text("\(hoarder.downloadedEmojis.count) downloaded Emoji")
NavigationLink {
List {
Picker(selection: $hoarder.letterStatsSorting.by) {
ForEach(EmojiHoarder.SortLetterStatsBy.allCases, id: \.self) { sortType in
Text(sortType.rawValue).tag(sortType)
}
} label: {
Label("Sort by", systemImage: "arrow.up.arrow.down")
}
Picker(selection: $hoarder.letterStatsSorting.ascending) {
Text("Ascending").tag(true)
Text("Descending").tag(false)
} label: {
Label("Order", systemImage: "greaterthan")
}
.onChange(of: hoarder.letterStatsSorting) { _ in
hoarder.sortLetterStats(by: hoarder.letterStatsSorting)
}
ForEach(hoarder.letterStats, id: \.self) { stat in
HStack {
Text("\(stat.char)")
Spacer()
Text("\(stat.count)")
}
}
}
} label: {
Label("Letter Stats", systemImage: "textformat")
}
}
Button("Show Welcome", systemImage: "arrow.trianglehead.clockwise") {
hoarder.setShowWelcome(to: true)
}
Section("Debug") {
NavigationLink {
TrieTestingView(hoarder: hoarder)
} label: {
Label("Tree", systemImage: "tree")
}
}
// Section(content: <#T##() -> View#>, header: <#T##() -> View#>, footer: <#T##() -> View#>)
}
}
}
}
#Preview {
SettingsView(hoarder: EmojiHoarder(localOnly: true, skipIndex: true))
}