redid image loading, cos AsyncImage is hella buggy

moved emoji to a new file
This commit is contained in:
neon443
2025-10-17 20:04:57 +01:00
parent 244c4e0ba6
commit f4e85f7c50
4 changed files with 35 additions and 15 deletions

View File

@@ -7,6 +7,7 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
A940FE3D2EA232590016870B /* Emoji.swift in Sources */ = {isa = PBXBuildFile; fileRef = A940FE3C2EA232590016870B /* Emoji.swift */; };
A949B1F32EA04E8200215164 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A949B1EF2EA04E8200215164 /* Assets.xcassets */; }; A949B1F32EA04E8200215164 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A949B1EF2EA04E8200215164 /* Assets.xcassets */; };
A949B1F42EA04E8200215164 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F02EA04E8200215164 /* ContentView.swift */; }; A949B1F42EA04E8200215164 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F02EA04E8200215164 /* ContentView.swift */; };
A949B1F52EA04E8200215164 /* StickerSlackApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F12EA04E8200215164 /* StickerSlackApp.swift */; }; A949B1F52EA04E8200215164 /* StickerSlackApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F12EA04E8200215164 /* StickerSlackApp.swift */; };
@@ -16,6 +17,7 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
A940FE3C2EA232590016870B /* Emoji.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Emoji.swift; sourceTree = "<group>"; };
A949B1DF2EA04C0B00215164 /* StickerSlack.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StickerSlack.app; sourceTree = BUILT_PRODUCTS_DIR; }; A949B1DF2EA04C0B00215164 /* StickerSlack.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StickerSlack.app; sourceTree = BUILT_PRODUCTS_DIR; };
A949B1EF2EA04E8200215164 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; A949B1EF2EA04E8200215164 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
A949B1F02EA04E8200215164 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; }; A949B1F02EA04E8200215164 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -63,9 +65,9 @@
A949B1F22EA04E8200215164 /* StickerSlack */ = { A949B1F22EA04E8200215164 /* StickerSlack */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A949B1F92EA0517800215164 /* Emoji */,
A949B1F12EA04E8200215164 /* StickerSlackApp.swift */, A949B1F12EA04E8200215164 /* StickerSlackApp.swift */,
A949B1F72EA04F2300215164 /* EmojiHoarder.swift */, A949B1F72EA04F2300215164 /* EmojiHoarder.swift */,
A949B1F92EA0517800215164 /* Emoji */,
A949B1EE2EA04E8200215164 /* Views */, A949B1EE2EA04E8200215164 /* Views */,
A949B1F62EA04E8C00215164 /* Resources */, A949B1F62EA04E8C00215164 /* Resources */,
); );
@@ -85,6 +87,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A949B1FA2EA0518800215164 /* SlackResponse.swift */, A949B1FA2EA0518800215164 /* SlackResponse.swift */,
A940FE3C2EA232590016870B /* Emoji.swift */,
); );
path = Emoji; path = Emoji;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -162,6 +165,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
A940FE3D2EA232590016870B /* Emoji.swift in Sources */,
A949B1F42EA04E8200215164 /* ContentView.swift in Sources */, A949B1F42EA04E8200215164 /* ContentView.swift in Sources */,
A949B1F52EA04E8200215164 /* StickerSlackApp.swift in Sources */, A949B1F52EA04E8200215164 /* StickerSlackApp.swift in Sources */,
A949B1FB2EA0518800215164 /* SlackResponse.swift in Sources */, A949B1FB2EA0518800215164 /* SlackResponse.swift in Sources */,

View File

@@ -0,0 +1,29 @@
//
// Emoji.swift
// StickerSlack
//
// Created by neon443 on 17/10/2025.
//
import Foundation
import SwiftUI
struct Emoji: Codable, Hashable {
var name: String
var urlString: String
var url: URL {
return URL(string: urlString) ?? URL(string: "https://")!
}
var image: Image {
if let data = try? Data(contentsOf: url),
let uiimage = UIImage(data: data) {
return Image(uiImage: uiimage)
}
return Image(uiImage: UIImage())
}
init(name: String, url: String) {
self.name = name
self.urlString = url
}
}

View File

@@ -28,16 +28,3 @@ struct SlackResponse: Codable {
} }
} }
} }
struct Emoji: Codable, Hashable {
var name: String
var urlString: String
var url: URL {
return URL(string: urlString) ?? URL(string: "https://")!
}
init(name: String, url: String) {
self.name = name
self.urlString = url
}
}

View File

@@ -16,7 +16,7 @@ struct ContentView: View {
List { List {
ForEach(hoarder.testBundle.toEmojis(), id: \.self) { emoji in ForEach(hoarder.testBundle.toEmojis(), id: \.self) { emoji in
Text(emoji.name) Text(emoji.name)
AsyncImage(url: emoji.url) emoji.image
} }
} }
.tabItem { .tabItem {