mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 20:54:51 +00:00
ui updates to emojpackdetailview
added .type to sticker to get its type added fromappname to stickertype
This commit is contained in:
8 files changed
+45
-33
No files matched your search
@@ -21,4 +21,13 @@ enum StickerType: CustomStringConvertible, CaseIterable, Identifiable {
|
||||
return "Giphy GIFs"
|
||||
}
|
||||
}
|
||||
|
||||
var fromAppName: String {
|
||||
switch self {
|
||||
case .slackEmoji:
|
||||
return "Slack"
|
||||
case .giphyGifs:
|
||||
return "Giphy"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,11 @@ import Messages
|
||||
extension StickerProtocol {
|
||||
var localImageURLString: String {
|
||||
let containerPath: String
|
||||
if type(of: self) == Emoji.self {
|
||||
switch type {
|
||||
case .slackEmoji:
|
||||
containerPath = EmojiHoarder.container.safePath
|
||||
} else if type(of: self) == Gif.self {
|
||||
case .giphyGifs:
|
||||
containerPath = GifHoarder.container.safePath
|
||||
} else {
|
||||
fatalError("sticker type unrecogniesd")
|
||||
}
|
||||
let urlString = remoteImageURL.absoluteString
|
||||
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
|
||||
func downloadImage() async throws {
|
||||
if let data = try? await Data(contentsOf: localImageURL),
|
||||
|
||||
@@ -105,10 +105,10 @@ struct EmojiPackDetailView: View {
|
||||
let emoji = hoarder.trie.dict[name] ?? .test
|
||||
VStack {
|
||||
StickerPreview(sticker: emoji)
|
||||
Spacer()
|
||||
Text(emoji.UIName)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.caption)
|
||||
Spacer()
|
||||
}
|
||||
.overlay(alignment: .topLeading) {
|
||||
if edit {
|
||||
@@ -124,11 +124,6 @@ struct EmojiPackDetailView: View {
|
||||
.padding(-10)
|
||||
}
|
||||
}
|
||||
// .distortionEffect(
|
||||
// ShaderLibrary.wiggle(.float(initDate.timeIntervalSinceNow)),
|
||||
// maxSampleOffset: .zero,
|
||||
// isEnabled: edit
|
||||
// )
|
||||
.rotationEffect(
|
||||
.degrees(
|
||||
edit ? sin(initDate.timeIntervalSinceNow*20)*4 : 0
|
||||
@@ -172,15 +167,21 @@ struct EmojiPackDetailView: View {
|
||||
}
|
||||
.animation(.spring, value: pack.items)
|
||||
.padding()
|
||||
|
||||
Text("\(pack.items.count) Emoji\(pack.items.count.plural)")
|
||||
.bold()
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.bottom)
|
||||
.padding(.bottom, 32)
|
||||
}
|
||||
.transition(.scale)
|
||||
.navigationTitle(edit ? "Editing" : "Pack Details")
|
||||
.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 {
|
||||
ToolbarItem(placement: .topBarLeading) {
|
||||
Button(
|
||||
@@ -219,9 +220,6 @@ struct EmojiPackDetailView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
hoarder.saveEmojiPacks()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ struct EmojiPackImporterView: View {
|
||||
@ObservedObject var emojiHoarder: EmojiHoarder
|
||||
@Binding var pack: EmojiPack
|
||||
@Environment(\.dismiss) var dismiss
|
||||
var isiPhone: Bool {
|
||||
return UIDevice().userInterfaceIdiom == .phone
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
EmojiPackDetailView(hoarder: emojiHoarder, pack: $pack)
|
||||
@@ -24,6 +27,7 @@ struct EmojiPackImporterView: View {
|
||||
}
|
||||
.modifier(glassButtonIfAv())
|
||||
.padding(.leading)
|
||||
.padding(.bottom, isiPhone ? 0 : 16)
|
||||
.tint(.gray)
|
||||
}
|
||||
.overlay(alignment: .bottomTrailing) {
|
||||
@@ -38,6 +42,7 @@ struct EmojiPackImporterView: View {
|
||||
}
|
||||
.modifier(glassButtonIfAv())
|
||||
.padding(.trailing)
|
||||
.padding(.bottom, isiPhone ? 0 : 16)
|
||||
.tint(.accentColor)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,23 +12,13 @@ struct StickerPreview: View {
|
||||
@State var sticker: any StickerProtocol
|
||||
@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 {
|
||||
if sticker.image != nil {
|
||||
//local
|
||||
GifView(url: sticker.localImageURL)
|
||||
} else {
|
||||
//remote
|
||||
if type == .slackEmoji {
|
||||
if sticker.type == .slackEmoji {
|
||||
GifView(url: sticker.remoteImageURL)
|
||||
} else {
|
||||
let gif = sticker as! Gif
|
||||
|
||||
@@ -41,7 +41,7 @@ struct StickerRow<T: Hoarder>: View {
|
||||
}
|
||||
.tint(isDownloaded ? .red : .accent)
|
||||
.buttonStyle(.borderless)
|
||||
.alert("From Slack", isPresented: $showTooltip) {
|
||||
.alert("From \(sticker.type.fromAppName)", isPresented: $showTooltip) {
|
||||
Button("Done") {}
|
||||
}
|
||||
if isDownloaded {
|
||||
|
||||
@@ -26,8 +26,8 @@ struct WelcomeView: View {
|
||||
.font(.largeTitle.monospaced())
|
||||
Spacer()
|
||||
}
|
||||
.padding(.vertical, 20)
|
||||
.padding(.leading, 20)
|
||||
.padding(.vertical, 16)
|
||||
.padding(.leading, 16)
|
||||
List {
|
||||
Section("How to use") {
|
||||
ListRow(number: 1, text: "Browse or search for an emoji")
|
||||
|
||||
@@ -142,7 +142,7 @@ struct TrieNodeView: View {
|
||||
.foregroundStyle(node.isEndOfWord ? .red : .primary)
|
||||
.frame(width: 20, height: 20)
|
||||
TrieNodeView(trie: trie, trieNode: node)
|
||||
.padding(.leading, 20)
|
||||
.padding(.leading, 16)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||