add welcome view with how to use steps

add listrow for reusability
added stats like total, downloaded emojis
added letterstats to count how many emojis there are starting with each letter
fix lag when opening settigns cos we were initing a new hoarder in trietestingview
fix downloaded view using screen width instead of window width now its good on mac and ipad split screen
added designed for ipad support
This commit is contained in:
neon443
2025-11-21 10:09:03 +00:00
parent c042e0a4bf
commit 3476751a31
7 changed files with 172 additions and 60 deletions

View File

@@ -26,8 +26,13 @@ class EmojiHoarder: ObservableObject {
@Published var downloadedEmojis: Set<String> = []
@Published var downloadedEmojisArr: [String] = []
@Published var searchTerm: String = ""
@Published var letterStats: [EmojiHoarder.LetterStat] = []
@Published var showWelcome: Bool = true
init(localOnly: Bool = false, skipIndex: Bool = false) {
self.showWelcome = !UserDefaults.standard.bool(forKey: "showWelcome")
let localDB = loadLocalDB()
withAnimation { self.emojis = localDB }
loadTrie()
@@ -196,6 +201,26 @@ class EmojiHoarder: ObservableObject {
Haptic.heavy.trigger()
}
func setShowWelcome(to newValue: Bool) {
UserDefaults.standard.set(!newValue, forKey: "shownWelcome")
self.showWelcome = newValue
}
func generateLetterStats() -> [EmojiHoarder.LetterStat] {
var result: [EmojiHoarder.LetterStat] = []
for child in trie.root.children {
let count = trie.collectWords(startingWith: child.key, from: child.value).count
let stat = LetterStat(char: child.key, count: count)
result.append(stat)
}
return result
}
struct LetterStat: Hashable {
var char: String
var count: Int
}
// func filterEmojis(byCategory category: FilterCategory, searchTerm: String) {
// guard category != .none else {
// filterEmojis(by: searchTerm)