extracted logic for packs, reorg

This commit is contained in:
neon443 committed 2026-04-09 00:58:59 +01:00
1 parent 8f3c22cc43
commit 68b63083a5
9 files changed
+46 -26

No files matched your search

@@ -6,6 +6,7 @@
//
import Foundation
import SwiftUI
struct EmojiPack: Identifiable, Codable {
var id: UUID
@@ -18,6 +19,22 @@ struct EmojiPack: Identifiable, Codable {
// var id: UUID
// var name: String
// }
mutating func add(_ newItem: String) {
guard !items.contains(newItem) else { return }
withAnimation {
self.items.append(newItem)
}
}
mutating func remove(_ itemToRemove: String) {
guard let index = self.items.firstIndex(where: { $0 == itemToRemove }) else {
return
}
let _ = withAnimation {
self.items.remove(at: index)
}
}
}
extension EmojiPack {
@@ -98,9 +98,7 @@ struct EmojiPackDetailView: View {
.overlay(alignment: .topLeading) {
if edit {
Button(role: .destructive) {
withAnimation(.spring) {
pack.items.removeAll { $0 == name }
}
pack.remove(name)
} label: {
Image(systemName: "minus.circle.fill")
.resizable().scaledToFit()
@@ -128,10 +126,7 @@ struct EmojiPackDetailView: View {
.sheet(isPresented: $showAdder) {
NavigationStack {
SearchView(hoarder: hoarder, fromPackEditor: true) { selection in
print(selection)
withAnimation {
pack.items.append(selection.name)
}
pack.add(selection.name)
}
.navigationTitle("Search Emojis")
.navigationBarTitleDisplayMode(.inline)
File renamed without changes.
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.