From 58dae8d392896e620461f2ccb9740f0d83a5aaac Mon Sep 17 00:00:00 2001 From: lumaa-dev Date: Sat, 5 Oct 2024 14:11:53 +0200 Subject: [PATCH] Small improvements --- Bubble/Components/Post/PostMenu.swift | 54 ++++++++++++++------------- Bubble/Data/AppInfo.swift | 4 ++ Bubble/Data/URLNavigator.swift | 1 + Bubble/Views/Settings/ShopView.swift | 12 ++++++ 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/Bubble/Components/Post/PostMenu.swift b/Bubble/Components/Post/PostMenu.swift index 6bf5f47..3c361ee 100644 --- a/Bubble/Components/Post/PostMenu.swift +++ b/Bubble/Components/Post/PostMenu.swift @@ -40,30 +40,6 @@ struct PostMenu: View { } Divider() - - Menu { - Button { - openURL(URL(string: AltClients.IvoryApp.createPost(status.reblogAsAsStatus?.content.asRawText ?? status.content.asRawText))!) - } label: { - Text(AltClients.IvoryApp.name) - } - - Button { - openURL(URL(string: AltClients.ThreadsApp.createPost(status.reblogAsAsStatus?.content.asRawText ?? status.content.asRawText))!) - } label: { - Text(AltClients.ThreadsApp.name) - } - - Button { - openURL(URL(string: AltClients.XApp.createPost(status.reblogAsAsStatus?.content.asRawText ?? status.content.asRawText))!) - } label: { - Text(AltClients.XApp.name) - } - } label: { - Label("status.cross-post.alts", systemImage: "shuffle") - } - - Divider() } Menu { @@ -86,6 +62,10 @@ struct PostMenu: View { } label: { Label("status.menu.copy-text", systemImage: "list.clipboard") } + + if isOwner { + altClients + } } label: { Label("status.menu.share", systemImage: "paperplane") } @@ -98,7 +78,31 @@ struct PostMenu: View { Label("status.menu.report", systemImage: "exclamationmark.triangle.fill") } } - + + private var altClients: some View { + Menu { + Button { + openURL(URL(string: AltClients.IvoryApp.createPost(status.reblogAsAsStatus?.content.asRawText ?? status.content.asRawText))!) + } label: { + Text(AltClients.IvoryApp.name) + } + + Button { + openURL(URL(string: AltClients.ThreadsApp.createPost(status.reblogAsAsStatus?.content.asRawText ?? status.content.asRawText))!) + } label: { + Text(AltClients.ThreadsApp.name) + } + + Button { + openURL(URL(string: AltClients.XApp.createPost(status.reblogAsAsStatus?.content.asRawText ?? status.content.asRawText))!) + } label: { + Text(AltClients.XApp.name) + } + } label: { + Label("status.cross-post.alts", systemImage: "shuffle") + } + } + @MainActor private func createImage() { let view = HStack { diff --git a/Bubble/Data/AppInfo.swift b/Bubble/Data/AppInfo.swift index 85fd9b9..74bbb4a 100644 --- a/Bubble/Data/AppInfo.swift +++ b/Bubble/Data/AppInfo.swift @@ -1,6 +1,7 @@ //Made by Lumaa import Foundation +import SwiftUI public enum AppInfo { public static let scopes = "read write follow push" @@ -20,6 +21,7 @@ extension AppInfo { case contentFilter case downloadAttachment case moreAccounts + case subClub case experimentalSettings case vip @@ -36,6 +38,8 @@ extension AppInfo { return .init("shop.features.download-atchmnt", description: "shop.features.download-atchmnt.description", systemImage: "photo.badge.arrow.down") case .moreAccounts: return .init("shop.features.more-accounts", description: "shop.features.more-accounts.description", systemImage: "person.fill.badge.plus") + case .subClub: + return .init(LocalizedStringKey(String("sub.club")), description: "info.subclub.description", systemImage: "person.crop.square.filled.and.at.rectangle.fill") case .experimentalSettings: return .init("shop.features.experimental", description: "shop.features.experimental.description", systemImage: "gearshape.fill") case .vip: diff --git a/Bubble/Data/URLNavigator.swift b/Bubble/Data/URLNavigator.swift index 3c71fef..8f78c38 100644 --- a/Bubble/Data/URLNavigator.swift +++ b/Bubble/Data/URLNavigator.swift @@ -84,6 +84,7 @@ extension Navigator { } } else { print("deeplink detected") + // available: update, new?text, plus let actions: [String] = path.split(separator: /\/+/).map({ $0.lowercased().replacing(/\?(.)+$/, with: "") }) if !actions.isEmpty, let mainAction: String = actions.first { if mainAction == "update" { diff --git a/Bubble/Views/Settings/ShopView.swift b/Bubble/Views/Settings/ShopView.swift index 3ed9d68..a64da21 100644 --- a/Bubble/Views/Settings/ShopView.swift +++ b/Bubble/Views/Settings/ShopView.swift @@ -447,6 +447,18 @@ extension ShopView { } } +extension LocalizedStringKey { + func toString() -> String { + let mirror = Mirror(reflecting: self) + for child in mirror.children { + if let value = child.value as? String { + return value + } + } + return "" + } +} + #Preview { ShopView() .environment(AppDelegate())