mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f7898cf47 | ||
|
|
8b0e2a73d8 |
No files matched your search
@@ -932,7 +932,7 @@
|
|||||||
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
|
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 6.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,7";
|
TARGETED_DEVICE_FAMILY = "1,2,7";
|
||||||
XROS_DEPLOYMENT_TARGET = 1;
|
XROS_DEPLOYMENT_TARGET = 1;
|
||||||
};
|
};
|
||||||
@@ -984,7 +984,7 @@
|
|||||||
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
|
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 6.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,7";
|
TARGETED_DEVICE_FAMILY = "1,2,7";
|
||||||
XROS_DEPLOYMENT_TARGET = 1;
|
XROS_DEPLOYMENT_TARGET = 1;
|
||||||
};
|
};
|
||||||
@@ -1017,7 +1017,7 @@
|
|||||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 6.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
@@ -1049,7 +1049,7 @@
|
|||||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 6.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
VALIDATE_PRODUCT = YES;
|
VALIDATE_PRODUCT = YES;
|
||||||
};
|
};
|
||||||
@@ -1072,7 +1072,7 @@
|
|||||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 6.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/StickerSlack.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/StickerSlack";
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/StickerSlack.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/StickerSlack";
|
||||||
};
|
};
|
||||||
@@ -1095,7 +1095,7 @@
|
|||||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 6.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/StickerSlack.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/StickerSlack";
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/StickerSlack.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/StickerSlack";
|
||||||
VALIDATE_PRODUCT = YES;
|
VALIDATE_PRODUCT = YES;
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "2630"
|
||||||
|
wasCreatedForAppExtension = "YES"
|
||||||
|
version = "2.0">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES"
|
||||||
|
buildArchitectures = "Automatic">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "A986A6AC2EB658DF00B6E0FA"
|
||||||
|
BuildableName = "StickerSlackiMessageApp.appex"
|
||||||
|
BlueprintName = "StickerSlackiMessageApp"
|
||||||
|
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
||||||
|
BuildableName = "StickerSlack.app"
|
||||||
|
BlueprintName = "StickerSlack"
|
||||||
|
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
shouldAutocreateTestPlan = "YES">
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = ""
|
||||||
|
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||||
|
launchStyle = "0"
|
||||||
|
askForAppToLaunch = "Yes"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES"
|
||||||
|
launchAutomaticallySubstyle = "2">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
||||||
|
BuildableName = "StickerSlack.app"
|
||||||
|
BlueprintName = "StickerSlack"
|
||||||
|
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
askForAppToLaunch = "Yes"
|
||||||
|
launchAutomaticallySubstyle = "2">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
||||||
|
BuildableName = "StickerSlack.app"
|
||||||
|
BlueprintName = "StickerSlack"
|
||||||
|
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -11,16 +11,11 @@ import SwiftUI
|
|||||||
import Messages
|
import Messages
|
||||||
import UniformTypeIdentifiers
|
import UniformTypeIdentifiers
|
||||||
|
|
||||||
|
@MainActor
|
||||||
struct Emoji: StickerProtocol {
|
struct Emoji: StickerProtocol {
|
||||||
var id: String
|
var id: String
|
||||||
var name: String
|
var name: String
|
||||||
var typeGlyph: String = "slack.logo"
|
var typeGlyph: String = "slack.logo"
|
||||||
var localImageURLString: String {
|
|
||||||
let urlString = remoteImageURL.absoluteString
|
|
||||||
let split = urlString.split(separator: ".")
|
|
||||||
let fileExtension = ".\(split.last ?? "png")"
|
|
||||||
return EmojiHoarder.container.path()+name+"."+id+fileExtension
|
|
||||||
}
|
|
||||||
var remoteImageURL: URL
|
var remoteImageURL: URL
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import UniformTypeIdentifiers
|
|||||||
import Haptics
|
import Haptics
|
||||||
|
|
||||||
class EmojiHoarder: BaseHoarder {
|
class EmojiHoarder: BaseHoarder {
|
||||||
static let container: URL = library.appendingPathComponent("Emojis", conformingTo: .directory)
|
nonisolated static let container: URL = library.appendingPathComponent("Emojis", conformingTo: .directory)
|
||||||
nonisolated static let localEmojiDB: URL = EmojiHoarder.library.appendingPathComponent("_____localEmojiDB.json", conformingTo: .fileURL)
|
nonisolated static let localEmojiDB: URL = EmojiHoarder.library.appendingPathComponent("_____localEmojiDB.json", conformingTo: .fileURL)
|
||||||
nonisolated static let localTrieDict: URL = EmojiHoarder.library.appendingPathComponent("_____localTrieDict.json", conformingTo: .fileURL)
|
nonisolated static let localTrieDict: URL = EmojiHoarder.library.appendingPathComponent("_____localTrieDict.json", conformingTo: .fileURL)
|
||||||
let endpoint: URL = URL(string: "https://cachet.dunkirk.sh/emojis")!
|
let endpoint: URL = URL(string: "https://cachet.dunkirk.sh/emojis")!
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension Emoji {
|
extension Emoji {
|
||||||
static var test: Emoji = Emoji(
|
static var test: Emoji = Emoji(
|
||||||
name: "a test slack emoji",
|
name: "a test slack emoji",
|
||||||
@@ -19,6 +20,7 @@ extension Emoji {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension Gif {
|
extension Gif {
|
||||||
static var test: Gif = GifObject(
|
static var test: Gif = GifObject(
|
||||||
type: "gif",
|
type: "gif",
|
||||||
@@ -120,6 +122,7 @@ extension Gif {
|
|||||||
).toGif
|
).toGif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension EmojiPack {
|
extension EmojiPack {
|
||||||
static var test: EmojiPack {
|
static var test: EmojiPack {
|
||||||
EmojiPack(
|
EmojiPack(
|
||||||
|
|||||||
@@ -9,18 +9,11 @@ import Foundation
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import UniformTypeIdentifiers
|
import UniformTypeIdentifiers
|
||||||
|
|
||||||
|
@MainActor
|
||||||
struct Gif: StickerProtocol {
|
struct Gif: StickerProtocol {
|
||||||
var id: String
|
var id: String
|
||||||
var name: String
|
var name: String
|
||||||
var typeGlyph: String = "giphy.logo"
|
var typeGlyph: String = "giphy.logo"
|
||||||
|
|
||||||
var localImageURLString: String {
|
|
||||||
let urlString = remoteImageURL.absoluteString
|
|
||||||
let split = urlString.split(separator: ".")
|
|
||||||
let fileExtension = ".\(split.last ?? "png")"
|
|
||||||
|
|
||||||
return GifHoarder.container.path()+name+"."+id+fileExtension
|
|
||||||
}
|
|
||||||
var remoteImageURL: URL
|
var remoteImageURL: URL
|
||||||
|
|
||||||
var giphyImages: GiphyImages?
|
var giphyImages: GiphyImages?
|
||||||
@@ -40,23 +33,4 @@ struct Gif: StickerProtocol {
|
|||||||
self.giphyImages = giphyImages
|
self.giphyImages = giphyImages
|
||||||
self.remoteImageURL = url
|
self.remoteImageURL = url
|
||||||
}
|
}
|
||||||
|
|
||||||
func downloadImage() async throws {
|
|
||||||
if let data = try? Data(contentsOf: localImageURL),
|
|
||||||
let _ = UIImage(data: data) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var (data, _) = try await URLSession.shared.data(from: remoteImageURL)
|
|
||||||
|
|
||||||
if let uiImage = UIImage(data: data),
|
|
||||||
let cgImage = uiImage.cgImage,
|
|
||||||
!self.localImageURLString.contains(".gif"),
|
|
||||||
cgImage.width < 300 || cgImage.height < 300 {
|
|
||||||
data = resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()!
|
|
||||||
}
|
|
||||||
|
|
||||||
try! data.write(to: localImageURL)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ import UniformTypeIdentifiers
|
|||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
class GifHoarder: BaseHoarder {
|
class GifHoarder: BaseHoarder {
|
||||||
static let container: URL = library.appendingPathComponent("Gifs", conformingTo: .directory)
|
nonisolated static let container: URL = library.appendingPathComponent("Gifs", conformingTo: .directory)
|
||||||
|
|
||||||
static var apiKey: String = "a2mFsDTpX5blodY8ltkG6Q1xy5NgFSbc"
|
static var apiKey: String = "a2mFsDTpX5blodY8ltkG6Q1xy5NgFSbc"
|
||||||
var endpoint: URL = URL(string: "https://api.giphy.com/v1/gifs/trending")!
|
var endpoint: URL = URL(string: "https://api.giphy.com/v1/gifs/trending")!
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ protocol Hoarder: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BaseHoarder: Hoarder {
|
class BaseHoarder: Hoarder {
|
||||||
|
nonisolated static let library: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory)
|
||||||
static let library: URL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory)
|
|
||||||
|
|
||||||
@Published var downloadedStickers: Set<String> = []
|
@Published var downloadedStickers: Set<String> = []
|
||||||
|
|
||||||
@@ -49,7 +48,7 @@ class BaseHoarder: Hoarder {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var newSet: Set<String> = []
|
var newSet: Set<String> = []
|
||||||
let url = await BaseHoarder.library.appendingPathComponent(stickerType, conformingTo: .directory)
|
let url = BaseHoarder.library.appendingPathComponent(stickerType, conformingTo: .directory)
|
||||||
if let files = try? FileManager.default.contentsOfDirectory(atPath: url.path()) {
|
if let files = try? FileManager.default.contentsOfDirectory(atPath: url.path()) {
|
||||||
for file in files {
|
for file in files {
|
||||||
let name = String(file.split(separator: ".")[0])
|
let name = String(file.split(separator: ".")[0])
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
@MainActor
|
||||||
struct SlackResponse: Identifiable, Codable {
|
struct SlackResponse: Identifiable, Codable {
|
||||||
var type: String
|
var type: String
|
||||||
var id: String
|
var id: String
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
@MainActor
|
||||||
struct GifObject: Codable, Identifiable {
|
struct GifObject: Codable, Identifiable {
|
||||||
var type: String
|
var type: String
|
||||||
var id: String
|
var id: String
|
||||||
|
|||||||
@@ -8,31 +8,23 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Messages
|
import Messages
|
||||||
|
|
||||||
|
nonisolated
|
||||||
extension StickerProtocol {
|
extension StickerProtocol {
|
||||||
var localImageURL: URL {
|
nonisolated var localImageURLString: String {
|
||||||
|
let urlString = remoteImageURL.absoluteString
|
||||||
|
let split = urlString.split(separator: ".")
|
||||||
|
let fileExtension = ".\(split.last ?? "png")"
|
||||||
|
|
||||||
|
return GifHoarder.container.path()+name+"."+id+fileExtension
|
||||||
|
}
|
||||||
|
|
||||||
|
nonisolated var localImageURL: URL {
|
||||||
return URL(filePath: localImageURLString)
|
return URL(filePath: localImageURLString)
|
||||||
}
|
}
|
||||||
|
|
||||||
var msSticker: MSSticker? {
|
|
||||||
guard FileManager.default.fileExists(atPath: localImageURLString) else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return try? MSSticker(contentsOfFileURL: localImageURL, localizedDescription: name)
|
|
||||||
}
|
|
||||||
|
|
||||||
var image: UIImage? {
|
|
||||||
if FileManager.default.fileExists(atPath: localImageURLString),
|
|
||||||
let data = try? Data(contentsOf: localImageURL),
|
|
||||||
let img = UIImage(data: data) {
|
|
||||||
return img
|
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nonisolated
|
nonisolated
|
||||||
func downloadImage() async throws {
|
func downloadImage() async throws {
|
||||||
if let data = try? await Data(contentsOf: localImageURL),
|
if let data = try? Data(contentsOf: localImageURL),
|
||||||
let _ = UIImage(data: data) {
|
let _ = UIImage(data: data) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -41,19 +33,23 @@ extension StickerProtocol {
|
|||||||
|
|
||||||
if let uiImage = UIImage(data: data),
|
if let uiImage = UIImage(data: data),
|
||||||
let cgImage = uiImage.cgImage,
|
let cgImage = uiImage.cgImage,
|
||||||
await !self.localImageURLString.contains(".gif"),
|
!self.localImageURLString.contains(".gif"),
|
||||||
cgImage.width < 300 || cgImage.height < 300 {
|
cgImage.width < 300 || cgImage.height < 300 {
|
||||||
data = await resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()!
|
data = resize(image: uiImage, to: CGSize(width: 300, height: 300)).pngData()!
|
||||||
}
|
}
|
||||||
try! await data.write(to: localImageURL)
|
try! data.write(to: localImageURL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nonisolated
|
||||||
func deleteImage() {
|
func deleteImage() {
|
||||||
try? FileManager.default.removeItem(at: localImageURL)
|
try? FileManager.default.removeItem(at: localImageURL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
extension StickerProtocol {
|
||||||
func resize(image: UIImage, to targetSize: CGSize) -> UIImage {
|
func resize(image: UIImage, to targetSize: CGSize) -> UIImage {
|
||||||
let oldSize = image.size
|
let oldSize = image.size
|
||||||
let ratio: (x: CGFloat, y: CGFloat)
|
let ratio: (x: CGFloat, y: CGFloat)
|
||||||
@@ -84,4 +80,21 @@ extension StickerProtocol {
|
|||||||
image.draw(in: rect)
|
image.draw(in: rect)
|
||||||
return UIGraphicsGetImageFromCurrentImageContext() ?? UIImage()
|
return UIGraphicsGetImageFromCurrentImageContext() ?? UIImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*nonisolated*/ var msSticker: MSSticker? {
|
||||||
|
guard FileManager.default.fileExists(atPath: localImageURLString) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return try? MSSticker(contentsOfFileURL: localImageURL, localizedDescription: name)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*nonisolated*/ var image: UIImage? {
|
||||||
|
if FileManager.default.fileExists(atPath: localImageURLString),
|
||||||
|
let data = try? Data(contentsOf: localImageURL),
|
||||||
|
let img = UIImage(data: data) {
|
||||||
|
return img
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,21 +8,22 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Messages
|
import Messages
|
||||||
|
|
||||||
|
nonisolated
|
||||||
protocol StickerProtocol: Codable, Identifiable, Hashable {
|
protocol StickerProtocol: Codable, Identifiable, Hashable {
|
||||||
var id: String { get set }
|
nonisolated var id: String { get set }
|
||||||
var name: String { get set }
|
nonisolated var name: String { get set }
|
||||||
|
|
||||||
var typeGlyph: String { get }
|
nonisolated var typeGlyph: String { get }
|
||||||
|
|
||||||
var localImageURL: URL { get }
|
nonisolated var localImageURL: URL { get }
|
||||||
var localImageURLString: String { get }
|
nonisolated var localImageURLString: String { get }
|
||||||
var remoteImageURL: URL { get set }
|
nonisolated var remoteImageURL: URL { get set }
|
||||||
|
|
||||||
var msSticker: MSSticker? { get }
|
nonisolated var msSticker: MSSticker? { get }
|
||||||
var image: UIImage? { get }
|
nonisolated var image: UIImage? { get }
|
||||||
|
|
||||||
func downloadImage() async throws
|
nonisolated func downloadImage() async throws
|
||||||
func deleteImage()
|
nonisolated func deleteImage()
|
||||||
func resize(image: UIImage, to targetSize: CGSize) -> UIImage
|
nonisolated func resize(image: UIImage, to targetSize: CGSize) -> UIImage
|
||||||
static var test: Self { get }
|
nonisolated static var test: Self { get }
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ class TrieNode: Codable {
|
|||||||
var isEndOfWord: Bool = false
|
var isEndOfWord: Bool = false
|
||||||
}
|
}
|
||||||
|
|
||||||
nonisolated
|
//nonisolated
|
||||||
class Trie: ObservableObject {
|
class Trie: ObservableObject {
|
||||||
var root: TrieNode = TrieNode()
|
var root: TrieNode = TrieNode()
|
||||||
var dict: [String:Emoji] = [:]
|
var dict: [String:Emoji] = [:]
|
||||||
|
|||||||