mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
fix animating removing items from sitckerpack
This commit is contained in:
4 files changed
+32
-22
No files matched your search
@@ -54,7 +54,7 @@ struct EmojiPackDetailView: View {
|
||||
TextField("", text: $pack.description)
|
||||
}
|
||||
|
||||
if pack.emojiNames.isEmpty {
|
||||
if pack.items.isEmpty {
|
||||
VStack(alignment: .center) {
|
||||
HStack {
|
||||
Image(systemName: "exclamationmark.triangle.fill")
|
||||
@@ -63,7 +63,7 @@ struct EmojiPackDetailView: View {
|
||||
Image(systemName: "exclamationmark.triangle.fill")
|
||||
}
|
||||
.foregroundStyle(.yellow)
|
||||
Text("This pack contians no emojis 😭")
|
||||
Text("This pack contians no emojis")
|
||||
.padding(.vertical, 5)
|
||||
.foregroundStyle(.foreground)
|
||||
Text("Add emojis to this pack by editing it using the pencil button in the toolbar.")
|
||||
@@ -80,14 +80,13 @@ struct EmojiPackDetailView: View {
|
||||
.blur(radius: 5)
|
||||
.shadow(color: .purple, radius: 5)
|
||||
}
|
||||
// .padding(.vertical)
|
||||
}
|
||||
|
||||
let columns: Int = max(1, Int((geo.size.width - 2*spacing) / (minColWidth + spacing)))
|
||||
let layout = Array(repeating: col, count: columns)
|
||||
LazyVGrid(columns: layout, spacing: spacing) {
|
||||
ForEach(pack.emojiNames, id: \.self) { name in
|
||||
let emoji = hoarder.trie.dict[name] ?? .test
|
||||
ForEach(pack.items) { item in
|
||||
let emoji = hoarder.trie.dict[item.name] ?? .test
|
||||
VStack {
|
||||
StickerPreview(sticker: emoji)
|
||||
Spacer()
|
||||
@@ -98,8 +97,8 @@ struct EmojiPackDetailView: View {
|
||||
.overlay(alignment: .topLeading) {
|
||||
if edit {
|
||||
Button(role: .destructive) {
|
||||
withAnimation {
|
||||
pack.emojiNames.removeAll { $0 == name }
|
||||
withAnimation(.spring) {
|
||||
pack.items.removeAll { $0.id == item.id }
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "minus.circle.fill")
|
||||
@@ -129,15 +128,21 @@ struct EmojiPackDetailView: View {
|
||||
SearchView(hoarder: hoarder, fromPackEditor: true) { selection in
|
||||
print(selection)
|
||||
withAnimation {
|
||||
pack.emojiNames.append(selection)
|
||||
guard let id = UUID(uuidString: selection.id) else {
|
||||
fatalError("bruh what happened to ur uuid")
|
||||
}
|
||||
pack.items.append(
|
||||
EmojiPack.Item(id: id, name: selection.name)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.animation(.spring, value: pack.items)
|
||||
.padding(.vertical)
|
||||
|
||||
Text("\(pack.emojiNames.count) Emoji\(pack.emojiNames.count.plural)")
|
||||
Text("\(pack.items.count) Emoji\(pack.items.count.plural)")
|
||||
.bold()
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ struct SearchView: View {
|
||||
@State var stickerType: StickerType = .slackEmoji
|
||||
|
||||
@State var fromPackEditor: Bool = false
|
||||
@State var callback: ((String) -> Void) = { _ in }
|
||||
@State var callback: ((Emoji) -> Void) = { _ in }
|
||||
var minColWidth: CGFloat { 75 }
|
||||
var spacing: CGFloat { 10 }
|
||||
var col: GridItem {
|
||||
@@ -43,7 +43,7 @@ struct SearchView: View {
|
||||
let emoji = hoarder.trie.dict[name] ?? .test
|
||||
StickerPreview(sticker: emoji)
|
||||
.onTapGesture {
|
||||
callback(emoji.name)
|
||||
callback(emoji)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||