mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-03-11 05:19:13 +00:00
added search
added emojipack, currently unused using the cahcet id in emoji
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
A9BE06DB2EA656B80033B213 /* EmojiHoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F72EA04F2300215164 /* EmojiHoarder.swift */; };
|
||||
A9BE06DC2EA657C70033B213 /* ApiEmoji.swift in Sources */ = {isa = PBXBuildFile; fileRef = A940FE3C2EA232590016870B /* ApiEmoji.swift */; };
|
||||
A9BE06DD2EA657CF0033B213 /* SlackResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1FA2EA0518800215164 /* SlackResponse.swift */; };
|
||||
A9D15B8A2EB1142C00404792 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; };
|
||||
A9D15B8B2EB1142C00404792 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -72,6 +74,7 @@
|
||||
A969D6A82EA3F1AF00399C05 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
|
||||
A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesViewController.swift; sourceTree = "<group>"; };
|
||||
A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPreview.swift; sourceTree = "<group>"; };
|
||||
A9D15B892EB1142C00404792 /* EmojiPack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPack.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -151,6 +154,7 @@
|
||||
A949B1FA2EA0518800215164 /* SlackResponse.swift */,
|
||||
A940FE3C2EA232590016870B /* ApiEmoji.swift */,
|
||||
A924C3712EA9127200F20781 /* Emoji.swift */,
|
||||
A9D15B892EB1142C00404792 /* EmojiPack.swift */,
|
||||
);
|
||||
path = Emoji;
|
||||
sourceTree = "<group>";
|
||||
@@ -292,6 +296,7 @@
|
||||
A949B1F52EA04E8200215164 /* StickerSlackApp.swift in Sources */,
|
||||
A949B1FB2EA0518800215164 /* SlackResponse.swift in Sources */,
|
||||
A924C3732EA9127200F20781 /* Emoji.swift in Sources */,
|
||||
A9D15B8B2EB1142C00404792 /* EmojiPack.swift in Sources */,
|
||||
A949B1F82EA04F2300215164 /* EmojiHoarder.swift in Sources */,
|
||||
A9773C2F2EA54AF000F3B753 /* EmojiPreview.swift in Sources */,
|
||||
);
|
||||
@@ -306,6 +311,7 @@
|
||||
A9BE06DB2EA656B80033B213 /* EmojiHoarder.swift in Sources */,
|
||||
A969D6AF2EA3F1AF00399C05 /* MessagesViewController.swift in Sources */,
|
||||
A9BE06DD2EA657CF0033B213 /* SlackResponse.swift in Sources */,
|
||||
A9D15B8A2EB1142C00404792 /* EmojiPack.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -42,8 +42,8 @@ struct ApiEmoji: EmojiProtocol {
|
||||
case urlString
|
||||
}
|
||||
|
||||
func toEmoji() -> Emoji {
|
||||
return Emoji(apiEmoji: self)
|
||||
func toEmoji(withID: UUID = UUID()) -> Emoji {
|
||||
return Emoji(apiEmoji: self, id: withID)
|
||||
}
|
||||
|
||||
func encode(to encoder: any Encoder) throws {
|
||||
|
||||
13
StickerSlack/Emoji/EmojiPack.swift
Normal file
13
StickerSlack/Emoji/EmojiPack.swift
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// EmojiPack.swift
|
||||
// StickerSlack
|
||||
//
|
||||
// Created by neon443 on 28/10/2025.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct EmojiPack: Identifiable, Codable {
|
||||
var id: UUID
|
||||
var emojiIDs: [UUID]
|
||||
}
|
||||
@@ -17,6 +17,11 @@ struct SlackResponse: Identifiable, Codable {
|
||||
|
||||
static func toEmojis(from response: [SlackResponse]?) -> [Emoji]? {
|
||||
guard let response else { return nil }
|
||||
return response.map { ApiEmoji(name: $0.name, url: $0.imageUrl).toEmoji() }
|
||||
return response.map { item in
|
||||
ApiEmoji(
|
||||
name: item.name,
|
||||
url: item.imageUrl
|
||||
).toEmoji(withID: item.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ class EmojiHoarder: ObservableObject {
|
||||
}
|
||||
|
||||
self.emojis = fetched
|
||||
self.filteredEmojis = emojis
|
||||
}
|
||||
|
||||
func storeStickers(_ toStore: [UUID]) {
|
||||
@@ -63,7 +62,7 @@ class EmojiHoarder: ObservableObject {
|
||||
|
||||
func filterEmojis(by searchTerm: String) {
|
||||
guard !searchTerm.isEmpty else {
|
||||
self.filteredEmojis = emojis
|
||||
self.filteredEmojis = []
|
||||
return
|
||||
}
|
||||
Task {
|
||||
|
||||
@@ -18,7 +18,12 @@ struct ContentView: View {
|
||||
TabView {
|
||||
List {
|
||||
HStack {
|
||||
Stepper("show?", value: $hoarder.prefix, step: 100) { $0 }
|
||||
TextField("", text: $searchTerm) {
|
||||
hoarder.filterEmojis(by: searchTerm)
|
||||
}
|
||||
|
||||
.autocorrectionDisabled()
|
||||
.textFieldStyle(.roundedBorder)
|
||||
// Button("downloaded", systemImage: "arrow.down.circle.fill") {
|
||||
// <#code#>
|
||||
// }
|
||||
@@ -28,13 +33,20 @@ struct ContentView: View {
|
||||
EmojiPreview(emoji: emoji, image: emoji.image)
|
||||
.frame(maxWidth: 100)
|
||||
Spacer()
|
||||
Button("", systemImage: "arrow.down.circle") {
|
||||
Task {
|
||||
try? await emoji.downloadImage()
|
||||
emoji.refresh()
|
||||
if emoji.isLocal {
|
||||
Button("", systemImage: "trash") {
|
||||
emoji.deleteImage()
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
} else {
|
||||
Button("", systemImage: "arrow.down.circle") {
|
||||
Task {
|
||||
try? await emoji.downloadImage()
|
||||
emoji.refresh()
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
.id(emoji.uiID)
|
||||
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
|
||||
@@ -49,6 +61,7 @@ struct ContentView: View {
|
||||
}
|
||||
// .searchable(text: $searchTerm, prompt: "Search")
|
||||
}
|
||||
.searchable(text: $searchTerm)
|
||||
.tabItem {
|
||||
Label("home", systemImage: "house")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user