diff --git a/Resources/Assets.xcassets/giphy.logo.imageset/Contents.json b/Resources/Assets.xcassets/giphy.logo.imageset/Contents.json new file mode 100644 index 0000000..95313e4 --- /dev/null +++ b/Resources/Assets.xcassets/giphy.logo.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "filename" : "giphy black.png", + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "filename" : "giphy.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Resources/Assets.xcassets/giphy.logo.imageset/giphy black.png b/Resources/Assets.xcassets/giphy.logo.imageset/giphy black.png new file mode 100644 index 0000000..216663d Binary files /dev/null and b/Resources/Assets.xcassets/giphy.logo.imageset/giphy black.png differ diff --git a/Resources/Assets.xcassets/giphy.logo.imageset/giphy.png b/Resources/Assets.xcassets/giphy.logo.imageset/giphy.png new file mode 100644 index 0000000..e46ac5c Binary files /dev/null and b/Resources/Assets.xcassets/giphy.logo.imageset/giphy.png differ diff --git a/StickerSlack/Emoji/Emoji.swift b/StickerSlack/Emoji/Emoji.swift index d259ad8..e203db7 100644 --- a/StickerSlack/Emoji/Emoji.swift +++ b/StickerSlack/Emoji/Emoji.swift @@ -14,6 +14,7 @@ import UniformTypeIdentifiers struct Emoji: StickerProtocol { var id: String var name: String + var typeGlyph: String = "slack.logo" var localImageURLString: String { let urlString = remoteImageURL.absoluteString let split = urlString.split(separator: ".") diff --git a/StickerSlack/Gifs/Gif.swift b/StickerSlack/Gifs/Gif.swift index a9f20dc..1bd5f80 100644 --- a/StickerSlack/Gifs/Gif.swift +++ b/StickerSlack/Gifs/Gif.swift @@ -12,6 +12,8 @@ import UniformTypeIdentifiers struct Gif: StickerProtocol { var id: String var name: String + var typeGlyph: String = "giphy.logo" + var localImageURLString: String { let urlString = remoteImageURL.absoluteString let split = urlString.split(separator: ".") diff --git a/StickerSlack/Stickers/Sticker.swift b/StickerSlack/Stickers/Sticker.swift index 0974ba1..4c2feb7 100644 --- a/StickerSlack/Stickers/Sticker.swift +++ b/StickerSlack/Stickers/Sticker.swift @@ -57,7 +57,7 @@ extension StickerProtocol { return } - func resize(image: UIImage, to targetSize: CGSize) -> UIImage { + func resize(image: UIImage, to targetSize: CGSize) -> UIImage { let oldSize = image.size let ratio: (x: CGFloat, y: CGFloat) ratio.x = targetSize.width / oldSize.width diff --git a/StickerSlack/Stickers/StickerProtocol.swift b/StickerSlack/Stickers/StickerProtocol.swift index d9fbce3..73fc182 100644 --- a/StickerSlack/Stickers/StickerProtocol.swift +++ b/StickerSlack/Stickers/StickerProtocol.swift @@ -12,6 +12,8 @@ protocol StickerProtocol: Codable, Identifiable, Hashable { var id: String { get set } var name: String { get set } + var typeGlyph: String { get } + var localImageURL: URL { get } var localImageURLString: String { get } var remoteImageURL: URL { get set } diff --git a/StickerSlack/SwiftUI/Emoji/StickerRow.swift b/StickerSlack/SwiftUI/Emoji/StickerRow.swift index 37d3bf7..1c76cc6 100644 --- a/StickerSlack/SwiftUI/Emoji/StickerRow.swift +++ b/StickerSlack/SwiftUI/Emoji/StickerRow.swift @@ -34,14 +34,10 @@ struct StickerRow: View { Button { showTooltip.toggle() } label: { - if type(of: sticker) == Emoji.self { - Image("slack.logo") - .resizable().scaledToFit() - .frame(width: 20, height: 20) - .foregroundStyle(.gray) - } else if type(of: sticker) == Gif.self { - Text("G") - } + Image(sticker.typeGlyph) + .resizable().scaledToFit() + .frame(maxHeight: 20) + .foregroundStyle(.gray) } .buttonStyle(.borderless) .alert("From Slack", isPresented: $showTooltip) {