update emojpreview

This commit is contained in:
neon443
2025-11-03 18:01:31 +00:00
parent caedb16ef5
commit 7e27375939

View File

@@ -18,40 +18,29 @@ struct EmojiPreview: View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text(emoji.name) Text(emoji.name)
Group { Group {
if emoji.isLocal { AsyncImage(url: emoji.localImageURL) { phase in
Image(uiImage: emoji.image ?? UIImage()) if let image = phase.image {
.resizable().scaledToFit() image
.border(.orange) .resizable().scaledToFit()
.overlay(alignment: .bottomLeading) { } else if phase.error != nil {
Image(systemName: "arrow.down.circle.fill") ImageErrorView()
.resizable().scaledToFit() .onTapGesture {
.frame(width: 20, height: 20) id = UUID()
.symbolRenderingMode(.hierarchical) }
.shadow(radius: 1) } else {
} AsyncImage(url: emoji.remoteImageURL) { phase in
} else { if let image = phase.image {
AsyncImage(url: emoji.remoteImageURL) { phase in image
if let image = phase.image {
image
.resizable().scaledToFit()
} else if phase.error != nil {
ZStack {
Image(systemName: "xmark.app.fill")
.resizable().scaledToFit() .resizable().scaledToFit()
.padding() } else if phase.error != nil {
.padding() ImageErrorView()
.symbolRenderingMode(.hierarchical)
.foregroundStyle(.red)
.onAppear {
id = UUID()
}
.onTapGesture { .onTapGesture {
id = UUID() id = UUID()
} }
} else {
ProgressView()
.frame(maxWidth: .infinity, maxHeight: .infinity)
} }
} else {
ProgressView()
.frame(maxWidth: .infinity, maxHeight: .infinity)
} }
} }
} }
@@ -70,3 +59,14 @@ struct EmojiPreview: View {
) )
) )
} }
struct ImageErrorView: View {
var body: some View {
Image(systemName: "xmark.app.fill")
.resizable().scaledToFit()
.padding()
.padding()
.symbolRenderingMode(.hierarchical)
.foregroundStyle(.red)
}
}