more stuff for emoji pack editor:

edit mode has red - buttons to remove it
also has a plus button to add more but it currently doesnt add
modified searchview to add a variant for the pack editor
This commit is contained in:
neon443 committed 2026-04-07 18:43:33 +01:00
1 parent ec6893b945
commit 1c86d89a6b
7 files changed
+120 -43

No files matched your search

+6 -6
View File
@@ -117,10 +117,10 @@
A9CD6C3B2EDDE6B500B7F421 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; }; A9CD6C3B2EDDE6B500B7F421 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; };
A9D15B8B2EB1142C00404792 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; }; A9D15B8B2EB1142C00404792 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; };
A9D6A8212F7014AE00F198FB /* TestStructures.swift in Sources */ = {isa = PBXBuildFile; fileRef = A995D95A2F6EBBDD0043E5F5 /* TestStructures.swift */; }; A9D6A8212F7014AE00F198FB /* TestStructures.swift in Sources */ = {isa = PBXBuildFile; fileRef = A995D95A2F6EBBDD0043E5F5 /* TestStructures.swift */; };
A9EB72392EB93FDB00658CEB /* EmojiCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72382EB93FDB00658CEB /* EmojiCollectionView.swift */; }; A9EB72392EB93FDB00658CEB /* EmojiTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72382EB93FDB00658CEB /* EmojiTableView.swift */; };
A9EB72472EB948C400658CEB /* StickerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72462EB948C400658CEB /* StickerRow.swift */; }; A9EB72472EB948C400658CEB /* StickerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72462EB948C400658CEB /* StickerRow.swift */; };
A9EB72492EB948C400658CEB /* StickerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72462EB948C400658CEB /* StickerRow.swift */; }; A9EB72492EB948C400658CEB /* StickerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72462EB948C400658CEB /* StickerRow.swift */; };
A9EB724A2EB948E000658CEB /* EmojiCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72382EB93FDB00658CEB /* EmojiCollectionView.swift */; }; A9EB724A2EB948E000658CEB /* EmojiTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72382EB93FDB00658CEB /* EmojiTableView.swift */; };
A9EB724B2EB94A5700658CEB /* Trie.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C172DB2EB8C9AC008A7885 /* Trie.swift */; }; A9EB724B2EB94A5700658CEB /* Trie.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C172DB2EB8C9AC008A7885 /* Trie.swift */; };
A9EB724D2EB94A6B00658CEB /* TrieTestingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */; }; A9EB724D2EB94A6B00658CEB /* TrieTestingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */; };
A9EB724F2EB94A6B00658CEB /* TrieTestingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */; }; A9EB724F2EB94A6B00658CEB /* TrieTestingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */; };
@@ -217,7 +217,7 @@
A9CD6C372EDDE37500B7F421 /* EmojiPackManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackManager.swift; sourceTree = "<group>"; }; A9CD6C372EDDE37500B7F421 /* EmojiPackManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackManager.swift; sourceTree = "<group>"; };
A9D15B892EB1142C00404792 /* EmojiPack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPack.swift; sourceTree = "<group>"; }; A9D15B892EB1142C00404792 /* EmojiPack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPack.swift; sourceTree = "<group>"; };
A9E2ECD72EB74CE00038B2D6 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; A9E2ECD72EB74CE00038B2D6 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
A9EB72382EB93FDB00658CEB /* EmojiCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiCollectionView.swift; sourceTree = "<group>"; }; A9EB72382EB93FDB00658CEB /* EmojiTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiTableView.swift; sourceTree = "<group>"; };
A9EB72462EB948C400658CEB /* StickerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerRow.swift; sourceTree = "<group>"; }; A9EB72462EB948C400658CEB /* StickerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerRow.swift; sourceTree = "<group>"; };
A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrieTestingView.swift; sourceTree = "<group>"; }; A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrieTestingView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@@ -323,7 +323,7 @@
A91C098E2EBBD7C700210C34 /* UIKit */ = { A91C098E2EBBD7C700210C34 /* UIKit */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A9EB72382EB93FDB00658CEB /* EmojiCollectionView.swift */, A9EB72382EB93FDB00658CEB /* EmojiTableView.swift */,
); );
path = UIKit; path = UIKit;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -631,7 +631,7 @@
A957C17F2ECFAA1100EA3EE9 /* GifView.swift in Sources */, A957C17F2ECFAA1100EA3EE9 /* GifView.swift in Sources */,
A957C1742ECCE2CE00EA3EE9 /* SettingsView.swift in Sources */, A957C1742ECCE2CE00EA3EE9 /* SettingsView.swift in Sources */,
A9A7A44B2F6837A800BB84C6 /* GiphyUser.swift in Sources */, A9A7A44B2F6837A800BB84C6 /* GiphyUser.swift in Sources */,
A9EB72392EB93FDB00658CEB /* EmojiCollectionView.swift in Sources */, A9EB72392EB93FDB00658CEB /* EmojiTableView.swift in Sources */,
A955B3EE2EC22C4A00E1732D /* DownloadedView.swift in Sources */, A955B3EE2EC22C4A00E1732D /* DownloadedView.swift in Sources */,
A949B1FB2EA0518800215164 /* SlackResponse.swift in Sources */, A949B1FB2EA0518800215164 /* SlackResponse.swift in Sources */,
A957C17A2ECE542D00EA3EE9 /* GifManager.swift in Sources */, A957C17A2ECE542D00EA3EE9 /* GifManager.swift in Sources */,
@@ -713,7 +713,7 @@
A921C2E32ED071C900E57B1A /* ListRow.swift in Sources */, A921C2E32ED071C900E57B1A /* ListRow.swift in Sources */,
A9BE30EF2F5B004800A57668 /* GifHoarder.swift in Sources */, A9BE30EF2F5B004800A57668 /* GifHoarder.swift in Sources */,
A9A7A4492F68361200BB84C6 /* Meta.swift in Sources */, A9A7A4492F68361200BB84C6 /* Meta.swift in Sources */,
A9EB724A2EB948E000658CEB /* EmojiCollectionView.swift in Sources */, A9EB724A2EB948E000658CEB /* EmojiTableView.swift in Sources */,
A9EB724D2EB94A6B00658CEB /* TrieTestingView.swift in Sources */, A9EB724D2EB94A6B00658CEB /* TrieTestingView.swift in Sources */,
A9BBC51A2EB8FA4500FFE82F /* ViewModifiers.swift in Sources */, A9BBC51A2EB8FA4500FFE82F /* ViewModifiers.swift in Sources */,
A995D95B2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */, A995D95B2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */,
@@ -11,10 +11,10 @@ struct EmojiPackManager: View {
@ObservedObject var hoarder: EmojiHoarder @ObservedObject var hoarder: EmojiHoarder
var body: some View { var body: some View {
ForEach(hoarder.emojiPacks) { pack in ForEach($hoarder.emojiPacks) { $pack in
EmojiPackDetailView(hoarder: hoarder, pack: pack) EmojiPackDetailView(hoarder: hoarder, pack: $pack)
} }
EmojiPackDetailView(hoarder: hoarder, pack: .test) EmojiPackDetailView(hoarder: hoarder, pack: .constant(.test))
} }
} }
+1 -1
View File
@@ -24,7 +24,7 @@ struct BrowseView: View {
Group { Group {
switch browseWhat { switch browseWhat {
case .slackEmoji: case .slackEmoji:
EmojiCollectionView( EmojiTableView(
hoarder: emojiHoarder, hoarder: emojiHoarder,
items: emojiHoarder.emojis.map { $0.name } items: emojiHoarder.emojis.map { $0.name }
) )
@@ -9,8 +9,11 @@ import SwiftUI
struct EmojiPackDetailView: View { struct EmojiPackDetailView: View {
@ObservedObject var hoarder: EmojiHoarder @ObservedObject var hoarder: EmojiHoarder
@State var pack: EmojiPack @Binding var pack: EmojiPack
@State var edit: Bool = true @State var edit: Bool = true
@State var editName: Bool = false
@State var editDescription: Bool = false
@State var showAdder: Bool = true
var minColWidth: CGFloat { 75 } var minColWidth: CGFloat { 75 }
var spacing: CGFloat { 10 } var spacing: CGFloat { 10 }
@@ -21,28 +24,35 @@ struct EmojiPackDetailView: View {
alignment: .center alignment: .center
) )
} }
@Environment(\.dismiss) var dismiss
var body: some View { var body: some View {
NavigationStack { NavigationStack {
GeometryReader { geo in GeometryReader { geo in
VStack { VStack {
if #unavailable(iOS 19) {
Button() {
} label: {
Text(pack.name)
.bold()
.foregroundStyle(edit ? .blue : .primary)
.font(.title)
}
.disabled(!edit)
}
Button() { Button() {
editName.toggle()
} label: {
Text(pack.name)
.bold()
.foregroundStyle(edit ? .blue : .primary)
.font(.title)
}
.disabled(!edit)
.alert("Edit Name", isPresented: $editName) {
TextField("", text: $pack.name)
}
Button() {
editDescription.toggle()
} label: { } label: {
Text(pack.description) Text(pack.description)
.foregroundStyle(edit ? .blue : .primary) .foregroundStyle(edit ? .blue : .primary)
} }
.disabled(!edit) .disabled(!edit)
.alert("Edit Description", isPresented: $editDescription) {
TextField("", text: $pack.description)
}
let columns: Int = max(1, Int((geo.size.width - 2*spacing) / (minColWidth + spacing))) let columns: Int = max(1, Int((geo.size.width - 2*spacing) / (minColWidth + spacing)))
let layout = Array(repeating: col, count: columns) let layout = Array(repeating: col, count: columns)
@@ -55,6 +65,40 @@ struct EmojiPackDetailView: View {
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
.font(.caption) .font(.caption)
} }
.overlay(alignment: .topLeading) {
if edit {
Button(role: .destructive) {
withAnimation {
pack.emojiNames.removeAll { $0 == name }
}
} label: {
Image(systemName: "minus.circle.fill")
.resizable().scaledToFit()
}
.frame(maxWidth: 25)
.padding(-10)
}
}
}
if edit {
Button() {
showAdder.toggle()
} label: {
VStack {
Image(systemName: "plus.square.dashed")
.resizable().scaledToFit()
.foregroundStyle(.green.opacity(0.5))
Text("Add")
.multilineTextAlignment(.center)
.font(.caption)
.foregroundStyle(.green.opacity(0.5))
}
}
.sheet(isPresented: $showAdder) {
SearchView(hoarder: hoarder, fromPackEditor: true) {
print($0)
}
}
} }
} }
.padding(.vertical) .padding(.vertical)
@@ -64,7 +108,7 @@ struct EmojiPackDetailView: View {
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
} }
.padding() .padding()
.navigationTitle(edit ? "Editing" : pack.name) .navigationTitle(edit ? "Editing" : "Pack Details")
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbar { .toolbar {
ToolbarItem() { ToolbarItem() {
@@ -91,9 +135,11 @@ struct EmojiPackDetailView: View {
} }
} }
@available(iOS 17, *)
#Preview { #Preview {
@Previewable @State var pack: EmojiPack = .test
EmojiPackDetailView( EmojiPackDetailView(
hoarder: EmojiHoarder(localOnly: true, skipIndex: true), hoarder: EmojiHoarder(localOnly: true, skipIndex: false),
pack: .test pack: $pack
) )
} }
+45 -14
View File
@@ -17,21 +17,49 @@ struct SearchView: View {
@State var stickerType: StickerType = .slackEmoji @State var stickerType: StickerType = .slackEmoji
@State var fromPackEditor: Bool = false
@State var callback: ((String) -> Void) = { _ in }
var minColWidth: CGFloat { 75 }
var spacing: CGFloat { 10 }
var col: GridItem {
GridItem(
.flexible(minimum: minColWidth, maximum: 100),
spacing: spacing,
alignment: .center
)
}
var body: some View { var body: some View {
NavigationStack { NavigationStack {
Picker("", selection: $stickerType) { if fromPackEditor {
ForEach(StickerType.allCases) { type in GeometryReader { geo in
Text(type.description).tag(type) 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(searchResult, id: \.self) { name in
let emoji = hoarder.trie.dict[name] ?? .test
StickerPreview(sticker: emoji)
.onTapGesture {
callback(emoji.name)
}
}
}
}
} else {
Picker("", selection: $stickerType) {
ForEach(StickerType.allCases) { type in
Text(type.description).tag(type)
}
}
.pickerStyle(.segmented)
switch stickerType {
case .slackEmoji:
EmojiTableView(hoarder: hoarder, items: searchResult)
.id(searchResult)
.ignoresSafeArea(edges: .bottom)
case .giphyGifs:
Text("uhh")
} }
}
.pickerStyle(.segmented)
switch stickerType {
case .slackEmoji:
EmojiCollectionView(hoarder: hoarder, items: searchResult)
.id(searchResult)
.ignoresSafeArea(edges: .bottom)
case .giphyGifs:
Text("uhh")
} }
} }
.searchable(text: $searchTerm) .searchable(text: $searchTerm)
@@ -50,7 +78,7 @@ struct SearchView: View {
previousResult: Set(searchResult) previousResult: Set(searchResult)
) )
await MainActor.run { await MainActor.run {
withAnimation(.interactiveSpring) { withAnimation(.snappy) {
searchResult = result searchResult = result
previousSearches.append(searchTerm) previousSearches.append(searchTerm)
} }
@@ -61,5 +89,8 @@ struct SearchView: View {
} }
#Preview { #Preview {
SearchView(hoarder: EmojiHoarder(localOnly: true)) SearchView(
hoarder: EmojiHoarder(localOnly: true),
fromPackEditor: true
)
} }
+1 -1
View File
@@ -116,7 +116,7 @@ struct TrieTestingView: View {
} }
if uikit { if uikit {
EmojiCollectionView(hoarder: hoarder, items: searchResults) EmojiTableView(hoarder: hoarder, items: searchResults)
.animation(.snappy, value: searchResults) .animation(.snappy, value: searchResults)
} else { } else {
List(searchResults, id: \.self) { item in List(searchResults, id: \.self) { item in
@@ -1,5 +1,5 @@
// //
// EmojiCollectionView.swift // EmojiTableView.swift
// StickerSlack // StickerSlack
// //
// Created by neon443 on 03/11/2025. // Created by neon443 on 03/11/2025.
@@ -10,7 +10,7 @@ import UIKit
import SwiftUI import SwiftUI
import Haptics import Haptics
struct EmojiCollectionView: UIViewRepresentable { struct EmojiTableView: UIViewRepresentable {
let hoarder: EmojiHoarder let hoarder: EmojiHoarder
let items: [String] let items: [String]
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.