mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 20:54:51 +00:00
working on sharelink making (wip)
This commit is contained in:
2 files changed
+18
-1
No files matched your search
@@ -7,6 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
struct EmojiPack: Identifiable, Codable {
|
||||
var id: UUID
|
||||
@@ -35,6 +36,22 @@ struct EmojiPack: Identifiable, Codable {
|
||||
self.items.remove(at: index)
|
||||
}
|
||||
}
|
||||
|
||||
func shareLink() -> URL {
|
||||
let scheme = URL(string: "stickerslack://")!
|
||||
var url: URL = scheme.appendingPathComponent("pack", conformingTo: .directory)
|
||||
|
||||
let data = try! JSONEncoder().encode(items)
|
||||
let queries: [URLQueryItem] = [
|
||||
.init(name: "id", value: id.uuidString),
|
||||
.init(name: "name", value: name),
|
||||
.init(name: "description", value: description),
|
||||
.init(name: "items", value: data.base64EncodedString())
|
||||
]
|
||||
url = url.appending(queryItems: queries)
|
||||
print(url.path(percentEncoded: true))
|
||||
return url
|
||||
}
|
||||
}
|
||||
|
||||
extension EmojiPack {
|
||||
|
||||
@@ -165,7 +165,7 @@ struct EmojiPackDetailView: View {
|
||||
ToolbarSpacer()
|
||||
}
|
||||
ToolbarItem() {
|
||||
ShareLink(item: URL(string: "stickerslack://")!) {
|
||||
ShareLink(item: pack.shareLink()) {
|
||||
Image(systemName: "square.and.arrow.up")
|
||||
}
|
||||
}
|
||||
|
||||