added emojipreview to handle displaying images etc

next: animate when it spawns
revamped image display
remove the image param in Emoji
This commit is contained in:
neon443
2025-10-19 17:49:47 +01:00
parent 5b61f6ecf4
commit a3b28a4414
7 changed files with 229 additions and 5 deletions

View File

@@ -19,6 +19,7 @@
A969D6AC2EA3F1AF00399C05 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A969D6A62EA3F1AF00399C05 /* Assets.xcassets */; };
A969D6AE2EA3F1AF00399C05 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A969D6A92EA3F1AF00399C05 /* MainInterface.storyboard */; };
A969D6AF2EA3F1AF00399C05 /* MessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */; };
A9773C2F2EA54AF000F3B753 /* EmojiPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -60,6 +61,7 @@
A969D6A72EA3F1AF00399C05 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
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>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -104,6 +106,7 @@
isa = PBXGroup;
children = (
A949B1F02EA04E8200215164 /* ContentView.swift */,
A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */,
);
path = Views;
sourceTree = "<group>";
@@ -269,6 +272,7 @@
A949B1F52EA04E8200215164 /* StickerSlackApp.swift in Sources */,
A949B1FB2EA0518800215164 /* SlackResponse.swift in Sources */,
A949B1F82EA04F2300215164 /* EmojiHoarder.swift in Sources */,
A9773C2F2EA54AF000F3B753 /* EmojiPreview.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<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 = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<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">
<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>

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2600"
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 = "A969D6902EA3E86500399C05"
BuildableName = "StickerSlackiMessageExtension.appex"
BlueprintName = "StickerSlackiMessageExtension"
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">
<RemoteRunnable
runnableDebuggingMode = "1"
BundleIdentifier = "com.apple.MobileSMS">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A969D6902EA3E86500399C05"
BuildableName = "StickerSlackiMessageExtension.appex"
BlueprintName = "StickerSlackiMessageExtension"
ReferencedContainer = "container:StickerSlack.xcodeproj">
</BuildableReference>
</RemoteRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -32,7 +32,6 @@ struct Emoji: EmojiProtocol {
init(
name: String,
url: String,
image: UIImage = UIImage()
) {
self.name = name
self.urlString = url

View File

@@ -29,8 +29,7 @@ class EmojiHoarder: ObservableObject {
let data = try! Data(contentsOf: endpoint)
let decoded: [SlackResponse] = try! JSONDecoder().decode([SlackResponse].self, from: data)
var emojis = decoded.map { Emoji(name: $0.name, url: $0.imageUrl) }
self.emojis = emojis
self.emojis = decoded.map { Emoji(name: $0.name, url: $0.imageUrl) }
// Task {
// for i in emojis.indices {
// let newEmoji = await emojis[i].grabImage()

View File

@@ -15,8 +15,7 @@ struct ContentView: View {
TabView {
List {
ForEach(hoarder.emojis, id: \.self) { emoji in
Text(emoji.name)
AsyncImage(url: emoji.url)
EmojiPreview(emoji: emoji)
}
}
.tabItem {

View File

@@ -0,0 +1,47 @@
//
// EmojiPreview.swift
// StickerSlack
//
// Created by neon443 on 19/10/2025.
//
import SwiftUI
struct EmojiPreview: View {
@State var emoji: Emoji
@State private var id: UUID = UUID()
var body: some View {
VStack {
Text(emoji.name)
AsyncImage(url: emoji.url) { phase in
if let image = phase.image {
image
.resizable().scaledToFit()
} else if phase.error != nil {
Image(systemName: "xmark.app.fill")
.resizable().scaledToFit()
.symbolRenderingMode(.hierarchical)
.foregroundStyle(.red)
.onTapGesture {
id = UUID()
}
} else {
ProgressView()
}
}
.id(id)
.frame(width: 50, height: 50)
}
}
}
#Preview {
EmojiPreview(
emoji: Emoji(
name: "s?",
url: "https://neon443.github.io/images/fav.ico"
)
)
}