ui updates to emojpackdetailview

added .type to sticker to get its type
added fromappname to stickertype
This commit is contained in:
neon443 committed 2026-04-14 21:18:58 +01:00
1 parent 988ea730d1
commit cf57bccf2f
8 files changed
+45 -33

No files matched your search

+9
View File
@@ -21,4 +21,13 @@ enum StickerType: CustomStringConvertible, CaseIterable, Identifiable {
return "Giphy GIFs" return "Giphy GIFs"
} }
} }
var fromAppName: String {
switch self {
case .slackEmoji:
return "Slack"
case .giphyGifs:
return "Giphy"
}
}
} }
+14 -4
View File
@@ -11,12 +11,11 @@ import Messages
extension StickerProtocol { extension StickerProtocol {
var localImageURLString: String { var localImageURLString: String {
let containerPath: String let containerPath: String
if type(of: self) == Emoji.self { switch type {
case .slackEmoji:
containerPath = EmojiHoarder.container.safePath containerPath = EmojiHoarder.container.safePath
} else if type(of: self) == Gif.self { case .giphyGifs:
containerPath = GifHoarder.container.safePath containerPath = GifHoarder.container.safePath
} else {
fatalError("sticker type unrecogniesd")
} }
let urlString = remoteImageURL.absoluteString let urlString = remoteImageURL.absoluteString
let split = urlString.split(separator: ".") let split = urlString.split(separator: ".")
@@ -49,6 +48,17 @@ extension StickerProtocol {
} }
} }
var type: StickerType {
let typeOfSelf = Swift.type(of: self)
if typeOfSelf == Emoji.self {
return .slackEmoji
} else if typeOfSelf == Gif.self {
return .giphyGifs
} else {
fatalError("unrecognised sticker type get crashed lmfao")
}
}
nonisolated nonisolated
func downloadImage() async throws { func downloadImage() async throws {
if let data = try? await Data(contentsOf: localImageURL), if let data = try? await Data(contentsOf: localImageURL),
@@ -105,10 +105,10 @@ struct EmojiPackDetailView: View {
let emoji = hoarder.trie.dict[name] ?? .test let emoji = hoarder.trie.dict[name] ?? .test
VStack { VStack {
StickerPreview(sticker: emoji) StickerPreview(sticker: emoji)
Spacer()
Text(emoji.UIName) Text(emoji.UIName)
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
.font(.caption) .font(.caption)
Spacer()
} }
.overlay(alignment: .topLeading) { .overlay(alignment: .topLeading) {
if edit { if edit {
@@ -124,11 +124,6 @@ struct EmojiPackDetailView: View {
.padding(-10) .padding(-10)
} }
} }
// .distortionEffect(
// ShaderLibrary.wiggle(.float(initDate.timeIntervalSinceNow)),
// maxSampleOffset: .zero,
// isEnabled: edit
// )
.rotationEffect( .rotationEffect(
.degrees( .degrees(
edit ? sin(initDate.timeIntervalSinceNow*20)*4 : 0 edit ? sin(initDate.timeIntervalSinceNow*20)*4 : 0
@@ -172,15 +167,21 @@ struct EmojiPackDetailView: View {
} }
.animation(.spring, value: pack.items) .animation(.spring, value: pack.items)
.padding() .padding()
.padding(.bottom, 32)
Text("\(pack.items.count) Emoji\(pack.items.count.plural)")
.bold()
.multilineTextAlignment(.center)
.padding(.bottom)
} }
.transition(.scale) .transition(.scale)
.navigationTitle(edit ? "Editing" : "Pack Details") .navigationTitle(edit ? "Editing" : "Pack Details")
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.overlay(alignment: .bottom) {
Text("\(pack.items.count) Emoji\(pack.items.count.plural)")
.bold()
.multilineTextAlignment(.center)
.shadow(radius: 5)
.padding(.bottom)
}
.onDisappear {
hoarder.saveEmojiPacks()
}
.toolbar { .toolbar {
ToolbarItem(placement: .topBarLeading) { ToolbarItem(placement: .topBarLeading) {
Button( Button(
@@ -219,9 +220,6 @@ struct EmojiPackDetailView: View {
} }
} }
} }
.onDisappear {
hoarder.saveEmojiPacks()
}
} }
} }
} }
@@ -11,6 +11,9 @@ struct EmojiPackImporterView: View {
@ObservedObject var emojiHoarder: EmojiHoarder @ObservedObject var emojiHoarder: EmojiHoarder
@Binding var pack: EmojiPack @Binding var pack: EmojiPack
@Environment(\.dismiss) var dismiss @Environment(\.dismiss) var dismiss
var isiPhone: Bool {
return UIDevice().userInterfaceIdiom == .phone
}
var body: some View { var body: some View {
EmojiPackDetailView(hoarder: emojiHoarder, pack: $pack) EmojiPackDetailView(hoarder: emojiHoarder, pack: $pack)
@@ -24,6 +27,7 @@ struct EmojiPackImporterView: View {
} }
.modifier(glassButtonIfAv()) .modifier(glassButtonIfAv())
.padding(.leading) .padding(.leading)
.padding(.bottom, isiPhone ? 0 : 16)
.tint(.gray) .tint(.gray)
} }
.overlay(alignment: .bottomTrailing) { .overlay(alignment: .bottomTrailing) {
@@ -38,6 +42,7 @@ struct EmojiPackImporterView: View {
} }
.modifier(glassButtonIfAv()) .modifier(glassButtonIfAv())
.padding(.trailing) .padding(.trailing)
.padding(.bottom, isiPhone ? 0 : 16)
.tint(.accentColor) .tint(.accentColor)
} }
} }
@@ -12,23 +12,13 @@ struct StickerPreview: View {
@State var sticker: any StickerProtocol @State var sticker: any StickerProtocol
@State var gifImage: Image? @State var gifImage: Image?
var type: StickerType {
let type = Swift.type(of: sticker)
if type == Emoji.self {
return .slackEmoji
} else if type == Gif.self {
return .giphyGifs
} else {
fatalError("sticker type unrecognisedd")
}
}
var body: some View { var body: some View {
if sticker.image != nil { if sticker.image != nil {
//local //local
GifView(url: sticker.localImageURL) GifView(url: sticker.localImageURL)
} else { } else {
//remote //remote
if type == .slackEmoji { if sticker.type == .slackEmoji {
GifView(url: sticker.remoteImageURL) GifView(url: sticker.remoteImageURL)
} else { } else {
let gif = sticker as! Gif let gif = sticker as! Gif
+1 -1
View File
@@ -41,7 +41,7 @@ struct StickerRow<T: Hoarder>: View {
} }
.tint(isDownloaded ? .red : .accent) .tint(isDownloaded ? .red : .accent)
.buttonStyle(.borderless) .buttonStyle(.borderless)
.alert("From Slack", isPresented: $showTooltip) { .alert("From \(sticker.type.fromAppName)", isPresented: $showTooltip) {
Button("Done") {} Button("Done") {}
} }
if isDownloaded { if isDownloaded {
+2 -2
View File
@@ -26,8 +26,8 @@ struct WelcomeView: View {
.font(.largeTitle.monospaced()) .font(.largeTitle.monospaced())
Spacer() Spacer()
} }
.padding(.vertical, 20) .padding(.vertical, 16)
.padding(.leading, 20) .padding(.leading, 16)
List { List {
Section("How to use") { Section("How to use") {
ListRow(number: 1, text: "Browse or search for an emoji") ListRow(number: 1, text: "Browse or search for an emoji")
+1 -1
View File
@@ -142,7 +142,7 @@ struct TrieNodeView: View {
.foregroundStyle(node.isEndOfWord ? .red : .primary) .foregroundStyle(node.isEndOfWord ? .red : .primary)
.frame(width: 20, height: 20) .frame(width: 20, height: 20)
TrieNodeView(trie: trie, trieNode: node) TrieNodeView(trie: trie, trieNode: node)
.padding(.leading, 20) .padding(.leading, 16)
} }
} }
} }
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.