mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 09:41:02 +00:00
SwiftFormat
This commit is contained in:
parent
2145bd5971
commit
8ff3e22d9f
55 changed files with 472 additions and 450 deletions
|
@ -10,11 +10,11 @@ extension IceCubesApp {
|
|||
}
|
||||
.keyboardShortcut("n", modifiers: .shift)
|
||||
Button("menu.new-post") {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
||||
#else
|
||||
sidebarRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
||||
#else
|
||||
sidebarRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
#endif
|
||||
}
|
||||
.keyboardShortcut("n", modifiers: .command)
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ extension IceCubesApp {
|
|||
}
|
||||
.defaultSize(width: 600, height: 800)
|
||||
.windowResizability(.contentMinSize)
|
||||
|
||||
|
||||
WindowGroup(for: WindowDestinationMedia.self) { destination in
|
||||
Group {
|
||||
switch destination.wrappedValue {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import Observation
|
||||
import SafariServices
|
||||
import SwiftUI
|
||||
import Models
|
||||
|
||||
extension View {
|
||||
@MainActor func withSafariRouter() -> some View {
|
||||
|
@ -43,9 +43,9 @@ private struct SafariRouter: ViewModifier {
|
|||
return .handled
|
||||
}
|
||||
}
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
guard preferences.preferredBrowser == .inAppSafari else { return .systemAction }
|
||||
#endif
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
guard preferences.preferredBrowser == .inAppSafari else { return .systemAction }
|
||||
#endif
|
||||
// SFSafariViewController only supports initial URLs with http:// or https:// schemes.
|
||||
guard let scheme = url.scheme, ["https", "http"].contains(scheme.lowercased()) else {
|
||||
return .systemAction
|
||||
|
|
|
@ -57,11 +57,11 @@ struct SideBarView<Content: View>: View {
|
|||
|
||||
private var postButton: some View {
|
||||
Button {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
||||
#else
|
||||
routerPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
||||
#else
|
||||
routerPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
#endif
|
||||
} label: {
|
||||
Image(systemName: "square.and.pencil")
|
||||
.resizable()
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import Account
|
||||
import DesignSystem
|
||||
import Env
|
||||
import SwiftUI
|
||||
import Account
|
||||
import Network
|
||||
import Models
|
||||
import Network
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct AboutView: View {
|
||||
|
@ -13,7 +13,7 @@ struct AboutView: View {
|
|||
|
||||
@State private var dimillianAccount: AccountsListRowViewModel?
|
||||
@State private var iceCubesAccount: AccountsListRowViewModel?
|
||||
|
||||
|
||||
let versionNumber: String
|
||||
|
||||
init() {
|
||||
|
@ -59,7 +59,6 @@ struct AboutView: View {
|
|||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
|
||||
|
||||
followAccountsSection
|
||||
|
||||
Section {
|
||||
|
@ -109,8 +108,7 @@ struct AboutView: View {
|
|||
routerPath.handle(url: url)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var followAccountsSection: some View {
|
||||
if let iceCubesAccount, let dimillianAccount {
|
||||
|
@ -132,18 +130,18 @@ struct AboutView: View {
|
|||
group.addTask {
|
||||
let viewModel = try await fetchAccountViewModel(account: "dimillian@mastodon.social")
|
||||
await MainActor.run {
|
||||
self.dimillianAccount = viewModel
|
||||
dimillianAccount = viewModel
|
||||
}
|
||||
}
|
||||
group.addTask {
|
||||
let viewModel = try await fetchAccountViewModel(account: "icecubesapp@mastodon.online")
|
||||
await MainActor.run {
|
||||
self.iceCubesAccount = viewModel
|
||||
iceCubesAccount = viewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func fetchAccountViewModel(account: String) async throws -> AccountsListRowViewModel {
|
||||
let dimillianAccount: Account = try await client.get(endpoint: Accounts.lookup(name: account))
|
||||
let rel: [Relationship] = try await client.get(endpoint: Accounts.relationships(ids: [dimillianAccount.id]))
|
||||
|
|
|
@ -218,7 +218,8 @@ struct AddAccountView: View {
|
|||
signInClient = .init(server: sanitizedName)
|
||||
if let oauthURL = try? await signInClient?.oauthURL(),
|
||||
let url = try? await webAuthenticationSession.authenticate(using: oauthURL,
|
||||
callbackURLScheme: AppInfo.scheme.replacingOccurrences(of: "://", with: "")){
|
||||
callbackURLScheme: AppInfo.scheme.replacingOccurrences(of: "://", with: ""))
|
||||
{
|
||||
await continueSignIn(url: url)
|
||||
} else {
|
||||
isSigninIn = false
|
||||
|
|
|
@ -212,7 +212,7 @@ struct DisplaySettingsView: View {
|
|||
Double(userPreferences.maxReplyIndentation)
|
||||
}, set: { newVal in
|
||||
userPreferences.maxReplyIndentation = UInt(newVal)
|
||||
}), in: 1...20, step: 1)
|
||||
}), in: 1 ... 20, step: 1)
|
||||
Text("settings.display.max-reply-indentation-\(String(userPreferences.maxReplyIndentation))")
|
||||
.font(.scaledBody)
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ struct IconSelectorView: View {
|
|||
static let items = [
|
||||
IconSelector(title: "settings.app.icon.official".localized, icons: [.primary, .alt1, .alt2, .alt3, .alt4, .alt5, .alt6, .alt7, .alt8,
|
||||
.alt9, .alt10, .alt11, .alt12, .alt13, .alt14,
|
||||
.alt15, .alt16, .alt17, .alt18, .alt19, .alt25,
|
||||
.alt15, .alt16, .alt17, .alt18, .alt19, .alt25,
|
||||
.alt43, .alt44, .alt45, .alt46, .alt47]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Albert Kinng", icons: [.alt20, .alt21, .alt22, .alt23, .alt24]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Dan van Moll", icons: [.alt26, .alt27, .alt28]),
|
||||
|
|
|
@ -29,7 +29,7 @@ struct SettingsTabs: View {
|
|||
@State private var timelineCache = TimelineCache()
|
||||
|
||||
@Binding var popToRootTab: Tab
|
||||
|
||||
|
||||
let isModal: Bool
|
||||
|
||||
@Query(sort: \LocalTimeline.creationDate, order: .reverse) var localTimelines: [LocalTimeline]
|
||||
|
@ -160,10 +160,10 @@ struct SettingsTabs: View {
|
|||
Label("settings.general.translate", systemImage: "captions.bubble")
|
||||
}
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
Link(destination: URL(string: UIApplication.openSettingsURLString)!) {
|
||||
Label("settings.system", systemImage: "gear")
|
||||
}
|
||||
.tint(theme.labelColor)
|
||||
Link(destination: URL(string: UIApplication.openSettingsURLString)!) {
|
||||
Label("settings.system", systemImage: "gear")
|
||||
}
|
||||
.tint(theme.labelColor)
|
||||
#endif
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
|
@ -173,24 +173,24 @@ struct SettingsTabs: View {
|
|||
private var otherSections: some View {
|
||||
@Bindable var preferences = preferences
|
||||
Section("settings.section.other") {
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
Picker(selection: $preferences.preferredBrowser) {
|
||||
ForEach(PreferredBrowser.allCases, id: \.rawValue) { browser in
|
||||
switch browser {
|
||||
case .inAppSafari:
|
||||
Text("settings.general.browser.in-app").tag(browser)
|
||||
case .safari:
|
||||
Text("settings.general.browser.system").tag(browser)
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
Picker(selection: $preferences.preferredBrowser) {
|
||||
ForEach(PreferredBrowser.allCases, id: \.rawValue) { browser in
|
||||
switch browser {
|
||||
case .inAppSafari:
|
||||
Text("settings.general.browser.in-app").tag(browser)
|
||||
case .safari:
|
||||
Text("settings.general.browser.system").tag(browser)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Label("settings.general.browser", systemImage: "network")
|
||||
}
|
||||
} label: {
|
||||
Label("settings.general.browser", systemImage: "network")
|
||||
}
|
||||
Toggle(isOn: $preferences.inAppBrowserReaderView) {
|
||||
Label("settings.general.browser.in-app.readerview", systemImage: "doc.plaintext")
|
||||
}
|
||||
.disabled(preferences.preferredBrowser != PreferredBrowser.inAppSafari)
|
||||
#endif
|
||||
Toggle(isOn: $preferences.inAppBrowserReaderView) {
|
||||
Label("settings.general.browser.in-app.readerview", systemImage: "doc.plaintext")
|
||||
}
|
||||
.disabled(preferences.preferredBrowser != PreferredBrowser.inAppSafari)
|
||||
#endif
|
||||
Toggle(isOn: $preferences.isOpenAIEnabled) {
|
||||
Label("settings.other.hide-openai", systemImage: "faxmachine")
|
||||
}
|
||||
|
@ -209,19 +209,19 @@ struct SettingsTabs: View {
|
|||
|
||||
private var appSection: some View {
|
||||
Section {
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
NavigationLink(destination: IconSelectorView()) {
|
||||
Label {
|
||||
Text("settings.app.icon")
|
||||
} icon: {
|
||||
let icon = IconSelectorView.Icon(string: UIApplication.shared.alternateIconName ?? "AppIcon")
|
||||
Image(uiImage: .init(named: icon.iconName)!)
|
||||
.resizable()
|
||||
.frame(width: 25, height: 25)
|
||||
.cornerRadius(4)
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
NavigationLink(destination: IconSelectorView()) {
|
||||
Label {
|
||||
Text("settings.app.icon")
|
||||
} icon: {
|
||||
let icon = IconSelectorView.Icon(string: UIApplication.shared.alternateIconName ?? "AppIcon")
|
||||
Image(uiImage: .init(named: icon.iconName)!)
|
||||
.resizable()
|
||||
.frame(width: 25, height: 25)
|
||||
.cornerRadius(4)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Link(destination: URL(string: "https://github.com/Dimillian/IceCubesApp")!) {
|
||||
Label("settings.app.source", systemImage: "link")
|
||||
|
|
|
@ -21,9 +21,9 @@ enum Tab: Int, Identifiable, Hashable {
|
|||
|
||||
static func loggedInTabs() -> [Tab] {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
return [.timeline, .trending, .federated, .local, .notifications, .mentions, .explore, .messages, .settings]
|
||||
[.timeline, .trending, .federated, .local, .notifications, .mentions, .explore, .messages, .settings]
|
||||
} else {
|
||||
return [.timeline, .notifications, .explore, .messages, .profile]
|
||||
[.timeline, .notifications, .explore, .messages, .profile]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ import Env
|
|||
import Models
|
||||
import Network
|
||||
import NukeUI
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
import SFSafeSymbols
|
||||
import Shimmer
|
||||
import SwiftData
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct EditTagGroupView: View {
|
||||
|
@ -53,8 +53,8 @@ struct EditTagGroupView: View {
|
|||
.formStyle(.grouped)
|
||||
.navigationTitle(
|
||||
isNewGroup
|
||||
? "timeline.filter.add-tag-groups"
|
||||
: "timeline.filter.edit-tag-groups"
|
||||
? "timeline.filter.add-tag-groups"
|
||||
: "timeline.filter.edit-tag-groups"
|
||||
)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.scrollContentBackground(.hidden)
|
||||
|
@ -76,9 +76,9 @@ struct EditTagGroupView: View {
|
|||
}
|
||||
|
||||
init(tagGroup: TagGroup = .emptyGroup(), onSaved: ((TagGroup) -> Void)? = nil) {
|
||||
self._tagGroup = State(wrappedValue: tagGroup)
|
||||
_tagGroup = State(wrappedValue: tagGroup)
|
||||
self.onSaved = onSaved
|
||||
self.isNewGroup = tagGroup.title.isEmpty
|
||||
isNewGroup = tagGroup.title.isEmpty
|
||||
}
|
||||
|
||||
private func save() {
|
||||
|
@ -320,7 +320,7 @@ private struct SymbolSearchResultsView: View {
|
|||
.onAppear {
|
||||
results = TagGroup.searchSymbol(for: symbolQuery, exclude: selectedSymbol)
|
||||
}
|
||||
case .invalid(let description):
|
||||
case let .invalid(description):
|
||||
Text(description)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
|
@ -335,6 +335,7 @@ private struct SymbolSearchResultsView: View {
|
|||
}
|
||||
|
||||
// MARK: search results validation
|
||||
|
||||
enum ValidationStatus: Equatable {
|
||||
case valid
|
||||
case invalid(description: LocalizedStringKey)
|
||||
|
@ -342,22 +343,23 @@ private struct SymbolSearchResultsView: View {
|
|||
|
||||
var validationStatus: ValidationStatus {
|
||||
if results.isEmpty {
|
||||
if symbolQuery == selectedSymbol
|
||||
&& !symbolQuery.isEmpty
|
||||
&& results.count == 0
|
||||
if symbolQuery == selectedSymbol,
|
||||
!symbolQuery.isEmpty,
|
||||
results.count == 0
|
||||
{
|
||||
return .invalid(description: "\(symbolQuery) add-tag-groups.edit.tags.field.warning.search-results.already-selected")
|
||||
.invalid(description: "\(symbolQuery) add-tag-groups.edit.tags.field.warning.search-results.already-selected")
|
||||
} else {
|
||||
return .invalid(description: "add-tag-groups.edit.tags.field.warning.search-results.no-symbol-found")
|
||||
.invalid(description: "add-tag-groups.edit.tags.field.warning.search-results.no-symbol-found")
|
||||
}
|
||||
} else {
|
||||
return .valid
|
||||
.valid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension TagGroup {
|
||||
// MARK: title validation
|
||||
|
||||
enum TitleValidationStatus: Equatable {
|
||||
case valid
|
||||
case invalid(description: LocalizedStringKey)
|
||||
|
@ -365,11 +367,12 @@ extension TagGroup {
|
|||
|
||||
var titleValidationStatus: TitleValidationStatus {
|
||||
title.isEmpty
|
||||
? .invalid(description: "add-tag-groups.edit.title.field.warning.empty-title")
|
||||
: .valid
|
||||
? .invalid(description: "add-tag-groups.edit.title.field.warning.empty-title")
|
||||
: .valid
|
||||
}
|
||||
|
||||
// MARK: symbolName validation
|
||||
|
||||
enum SymbolNameValidationStatus: Equatable {
|
||||
case valid
|
||||
case invalid(description: LocalizedStringKey)
|
||||
|
@ -386,6 +389,7 @@ extension TagGroup {
|
|||
}
|
||||
|
||||
// MARK: tags validation
|
||||
|
||||
enum TagsValidationStatus: Equatable {
|
||||
case valid
|
||||
case invalid(description: LocalizedStringKey)
|
||||
|
@ -399,19 +403,22 @@ extension TagGroup {
|
|||
}
|
||||
|
||||
// MARK: TagGroup validation
|
||||
|
||||
var isValid: Bool {
|
||||
titleValidationStatus == .valid
|
||||
&& symbolNameValidationStatus == .valid
|
||||
&& tagsValidationStatus == .valid
|
||||
&& symbolNameValidationStatus == .valid
|
||||
&& tagsValidationStatus == .valid
|
||||
}
|
||||
|
||||
// MARK: format
|
||||
|
||||
func format() {
|
||||
title = title.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
tags = tags.map { $0.lowercased() }
|
||||
}
|
||||
|
||||
// MARK: static members
|
||||
|
||||
static func emptyGroup() -> TagGroup {
|
||||
TagGroup(title: "", symbolName: "", tags: [])
|
||||
}
|
||||
|
@ -419,9 +426,9 @@ extension TagGroup {
|
|||
static func searchSymbol(for query: String, exclude excludedSymbol: String) -> [String] {
|
||||
guard !query.isEmpty else { return [] }
|
||||
|
||||
return Self.allSymbols.filter {
|
||||
return allSymbols.filter {
|
||||
$0.contains(query) &&
|
||||
$0 != excludedSymbol
|
||||
$0 != excludedSymbol
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -432,7 +439,7 @@ extension TagGroup {
|
|||
|
||||
extension Text {
|
||||
func warningLabel() -> Text {
|
||||
self.font(.caption)
|
||||
font(.caption)
|
||||
.foregroundStyle(.red)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,13 +81,14 @@ struct AccountDetailHeaderView: View {
|
|||
return
|
||||
}
|
||||
let attachement = MediaAttachment.imageWith(url: account.header)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationMedia.mediaViewer(
|
||||
attachments: [attachement],
|
||||
selectedAttachment: attachement))
|
||||
#else
|
||||
selectedAttachment: attachement
|
||||
))
|
||||
#else
|
||||
quickLook.prepareFor(selectedMediaAttachment: attachement, mediaAttachments: [attachement])
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
.accessibilityElement(children: .combine)
|
||||
.accessibilityAddTraits([.isImage, .isButton])
|
||||
|
@ -117,12 +118,12 @@ struct AccountDetailHeaderView: View {
|
|||
return
|
||||
}
|
||||
let attachement = MediaAttachment.imageWith(url: account.avatar)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationMedia.mediaViewer(attachments: [attachement],
|
||||
selectedAttachment: attachement))
|
||||
#else
|
||||
quickLook.prepareFor(selectedMediaAttachment: attachement, mediaAttachments: [attachement])
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationMedia.mediaViewer(attachments: [attachement],
|
||||
selectedAttachment: attachement))
|
||||
#else
|
||||
quickLook.prepareFor(selectedMediaAttachment: attachement, mediaAttachments: [attachement])
|
||||
#endif
|
||||
}
|
||||
.accessibilityElement(children: .combine)
|
||||
.accessibilityAddTraits([.isImage, .isButton])
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import Env
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
|
@ -16,7 +16,7 @@ public struct EditAccountView: View {
|
|||
public init() {}
|
||||
|
||||
public var body: some View {
|
||||
NavigationStack{
|
||||
NavigationStack {
|
||||
Form {
|
||||
if viewModel.isLoading {
|
||||
loadingSection
|
||||
|
|
|
@ -6,21 +6,21 @@ public extension Font {
|
|||
// See https://gist.github.com/zacwest/916d31da5d03405809c4 for iOS values
|
||||
// Custom values for Mac
|
||||
private static let title = 28.0
|
||||
#if targetEnvironment(macCatalyst)
|
||||
private static let headline = 20.0
|
||||
private static let body = 19.0
|
||||
private static let callout = 17.0
|
||||
private static let subheadline = 16.0
|
||||
private static let footnote = 15.0
|
||||
private static let caption = 14.0
|
||||
#else
|
||||
private static let headline = 17.0
|
||||
private static let body = 17.0
|
||||
private static let callout = 16.0
|
||||
private static let subheadline = 15.0
|
||||
private static let footnote = 13.0
|
||||
private static let caption = 12.0
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
private static let headline = 20.0
|
||||
private static let body = 19.0
|
||||
private static let callout = 17.0
|
||||
private static let subheadline = 16.0
|
||||
private static let footnote = 15.0
|
||||
private static let caption = 14.0
|
||||
#else
|
||||
private static let headline = 17.0
|
||||
private static let body = 17.0
|
||||
private static let callout = 16.0
|
||||
private static let subheadline = 15.0
|
||||
private static let footnote = 13.0
|
||||
private static let caption = 12.0
|
||||
#endif
|
||||
|
||||
private static func customFont(size: CGFloat, relativeTo textStyle: TextStyle) -> Font {
|
||||
if let chosenFont = Theme.shared.chosenFont {
|
||||
|
|
|
@ -6,14 +6,14 @@ public class SceneDelegate: NSObject, UIWindowSceneDelegate, Sendable {
|
|||
public var window: UIWindow?
|
||||
public private(set) var windowWidth: CGFloat = UIScreen.main.bounds.size.width
|
||||
public private(set) var windowHeight: CGFloat = UIScreen.main.bounds.size.height
|
||||
|
||||
|
||||
public func scene(_ scene: UIScene,
|
||||
willConnectTo _: UISceneSession,
|
||||
options _: UIScene.ConnectionOptions)
|
||||
{
|
||||
guard let windowScene = scene as? UIWindowScene else { return }
|
||||
window = windowScene.keyWindow
|
||||
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
if let titlebar = windowScene.titlebar {
|
||||
titlebar.titleVisibility = .hidden
|
||||
|
@ -22,10 +22,10 @@ public class SceneDelegate: NSObject, UIWindowSceneDelegate, Sendable {
|
|||
#endif
|
||||
}
|
||||
|
||||
public override init() {
|
||||
override public init() {
|
||||
super.init()
|
||||
self.windowWidth = self.window?.bounds.size.width ?? UIScreen.main.bounds.size.width
|
||||
self.windowHeight = self.window?.bounds.size.height ?? UIScreen.main.bounds.size.height
|
||||
windowWidth = window?.bounds.size.width ?? UIScreen.main.bounds.size.width
|
||||
windowHeight = window?.bounds.size.height ?? UIScreen.main.bounds.size.height
|
||||
Self.observedSceneDelegate.insert(self)
|
||||
_ = Self.observer // just for activating the lazy static property
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import Env
|
||||
import Models
|
||||
import Nuke
|
||||
import NukeUI
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
import Models
|
||||
|
||||
struct AccountPopoverView: View {
|
||||
let account: Account
|
||||
|
@ -36,7 +36,7 @@ struct AccountPopoverView: View {
|
|||
}
|
||||
.frame(height: adaptiveConfig.height / 2, alignment: .bottom)
|
||||
|
||||
EmojiTextApp(.init(stringValue: account.safeDisplayName ), emojis: account.emojis)
|
||||
EmojiTextApp(.init(stringValue: account.safeDisplayName), emojis: account.emojis)
|
||||
.font(.headline)
|
||||
.foregroundColor(theme.labelColor)
|
||||
.emojiSize(Font.scaledHeadlineFont.emojiSize)
|
||||
|
@ -122,11 +122,10 @@ struct AccountPopoverView: View {
|
|||
}
|
||||
|
||||
private var adaptiveConfig: AvatarView.FrameConfig {
|
||||
var cornerRadius: CGFloat
|
||||
if config == .badge || theme.avatarShape == .circle {
|
||||
cornerRadius = config.width / 2
|
||||
var cornerRadius: CGFloat = if config == .badge || theme.avatarShape == .circle {
|
||||
config.width / 2
|
||||
} else {
|
||||
cornerRadius = config.cornerRadius
|
||||
config.cornerRadius
|
||||
}
|
||||
return AvatarView.FrameConfig(width: config.width, height: config.height, cornerRadius: cornerRadius)
|
||||
}
|
||||
|
@ -142,7 +141,7 @@ extension VerticalAlignment {
|
|||
static let bottomAvatar = VerticalAlignment(BottomAvatarAlignment.self)
|
||||
}
|
||||
|
||||
public struct AccountPopoverModifier : ViewModifier {
|
||||
public struct AccountPopoverModifier: ViewModifier {
|
||||
@Environment(Theme.self) private var theme
|
||||
@Environment(UserPreferences.self) private var userPreferences
|
||||
|
||||
|
@ -156,7 +155,7 @@ public struct AccountPopoverModifier : ViewModifier {
|
|||
if !userPreferences.showAccountPopover {
|
||||
return AnyView(content)
|
||||
}
|
||||
|
||||
|
||||
return AnyView(content
|
||||
.onHover { hovering in
|
||||
if hovering {
|
||||
|
@ -191,8 +190,8 @@ public struct AccountPopoverModifier : ViewModifier {
|
|||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
public func accountPopover(_ account: Account) -> some View {
|
||||
public extension View {
|
||||
func accountPopover(_ account: Account) -> some View {
|
||||
modifier(AccountPopoverModifier(account))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import Models
|
||||
import Nuke
|
||||
import NukeUI
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
import Models
|
||||
|
||||
@MainActor
|
||||
public struct AvatarView: View {
|
||||
|
@ -21,11 +21,10 @@ public struct AvatarView: View {
|
|||
}
|
||||
|
||||
private var adaptiveConfig: FrameConfig {
|
||||
var cornerRadius: CGFloat
|
||||
if config == .badge || theme.avatarShape == .circle {
|
||||
cornerRadius = config.width / 2
|
||||
var cornerRadius: CGFloat = if config == .badge || theme.avatarShape == .circle {
|
||||
config.width / 2
|
||||
} else {
|
||||
cornerRadius = config.cornerRadius
|
||||
config.cornerRadius
|
||||
}
|
||||
return FrameConfig(width: config.width, height: config.height, cornerRadius: cornerRadius)
|
||||
}
|
||||
|
@ -42,16 +41,16 @@ public struct AvatarView: View {
|
|||
let cornerRadius: CGFloat
|
||||
|
||||
init(width: CGFloat, height: CGFloat, cornerRadius: CGFloat = 4) {
|
||||
self.size = CGSize(width: width, height: height)
|
||||
size = CGSize(width: width, height: height)
|
||||
self.cornerRadius = cornerRadius
|
||||
}
|
||||
|
||||
public static let account = FrameConfig(width: 80, height: 80)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
public static let status = FrameConfig(width: 48, height: 48)
|
||||
#else
|
||||
public static let status = FrameConfig(width: 40, height: 40)
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
public static let status = FrameConfig(width: 48, height: 48)
|
||||
#else
|
||||
public static let status = FrameConfig(width: 40, height: 40)
|
||||
#endif
|
||||
public static let embed = FrameConfig(width: 34, height: 34)
|
||||
public static let badge = FrameConfig(width: 28, height: 28, cornerRadius: 14)
|
||||
public static let list = FrameConfig(width: 20, height: 20, cornerRadius: 10)
|
||||
|
@ -77,10 +76,10 @@ struct PreviewWrapper: View {
|
|||
Toggle("Avatar Shape", isOn: $isCircleAvatar)
|
||||
}
|
||||
.onChange(of: isCircleAvatar) {
|
||||
Theme.shared.avatarShape = self.isCircleAvatar ? .circle : .rounded
|
||||
Theme.shared.avatarShape = isCircleAvatar ? .circle : .rounded
|
||||
}
|
||||
.onAppear {
|
||||
Theme.shared.avatarShape = self.isCircleAvatar ? .circle : .rounded
|
||||
Theme.shared.avatarShape = isCircleAvatar ? .circle : .rounded
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +102,8 @@ struct PreviewWrapper: View {
|
|||
url: URL(string: "https://nondot.org/sabre/")!,
|
||||
source: nil,
|
||||
bot: false,
|
||||
discoverable: true)
|
||||
discoverable: true
|
||||
)
|
||||
}
|
||||
|
||||
struct AvatarImage: View {
|
||||
|
|
|
@ -26,12 +26,12 @@ public struct StatusEditorToolbarItem: ToolbarContent {
|
|||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
Task { @MainActor in
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: visibility))
|
||||
#else
|
||||
routerPath.presentedSheet = .newStatusEditor(visibility: visibility)
|
||||
HapticManager.shared.fireHaptic(.buttonPress)
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: visibility))
|
||||
#else
|
||||
routerPath.presentedSheet = .newStatusEditor(visibility: visibility)
|
||||
HapticManager.shared.fireHaptic(.buttonPress)
|
||||
#endif
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "square.and.pencil")
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
import SwiftUI
|
||||
import Charts
|
||||
import Models
|
||||
import SwiftUI
|
||||
|
||||
public struct TagChartView: View {
|
||||
@State private var sortedHistory: [Tag.History] = []
|
||||
|
||||
|
||||
public init(tag: Tag) {
|
||||
_sortedHistory = .init(initialValue: tag.history.sorted {
|
||||
Int($0.day) ?? 0 < Int($1.day) ?? 0
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
public var body: some View {
|
||||
Chart(sortedHistory) { data in
|
||||
AreaMark(x: .value("day", sortedHistory.firstIndex(where: { $0.id == data.id }) ?? 0),
|
||||
y: .value("uses", Int(data.uses) ?? 0))
|
||||
.interpolationMethod(.catmullRom)
|
||||
.interpolationMethod(.catmullRom)
|
||||
}
|
||||
.chartLegend(.hidden)
|
||||
.chartXAxis(.hidden)
|
||||
|
|
|
@ -87,7 +87,7 @@ import Observation
|
|||
tags = []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func deleteList(list: Models.List) async {
|
||||
guard let client else { return }
|
||||
lists.removeAll(where: { $0.id == list.id })
|
||||
|
|
|
@ -68,7 +68,7 @@ public extension EnvironmentValues {
|
|||
get { self[IndentationLevel.self] }
|
||||
set { self[IndentationLevel.self] = newValue }
|
||||
}
|
||||
|
||||
|
||||
var isHomeTimeline: Bool {
|
||||
get { self[IsHomeTimeline.self] }
|
||||
set { self[IsHomeTimeline.self] = newValue }
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import DesignSystem
|
||||
import EmojiText
|
||||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import SwiftUI
|
||||
import Env
|
||||
|
||||
@MainActor
|
||||
public struct ListCreateView: View {
|
||||
|
@ -11,13 +11,13 @@ public struct ListCreateView: View {
|
|||
@Environment(Theme.self) private var theme
|
||||
@Environment(Client.self) private var client
|
||||
@Environment(CurrentAccount.self) private var currentAccount
|
||||
|
||||
|
||||
@State private var title = ""
|
||||
@State private var repliesPolicy: Models.List.RepliesPolicy = .list
|
||||
@State private var isExclusive: Bool = false
|
||||
@State private var isSaving: Bool = false
|
||||
|
||||
public init() { }
|
||||
public init() {}
|
||||
|
||||
public var body: some View {
|
||||
NavigationStack {
|
||||
|
@ -25,7 +25,8 @@ public struct ListCreateView: View {
|
|||
Section("lists.edit.settings") {
|
||||
TextField("list.edit.title", text: $title)
|
||||
Picker("list.edit.repliesPolicy",
|
||||
selection: $repliesPolicy) {
|
||||
selection: $repliesPolicy)
|
||||
{
|
||||
ForEach(Models.List.RepliesPolicy.allCases) { policy in
|
||||
Text(policy.title)
|
||||
.tag(policy)
|
||||
|
@ -43,8 +44,8 @@ public struct ListCreateView: View {
|
|||
Task {
|
||||
isSaving = true
|
||||
let _: Models.List = try await client.post(endpoint: Lists.createList(title: title,
|
||||
repliesPolicy: repliesPolicy,
|
||||
exclusive: isExclusive ))
|
||||
repliesPolicy: repliesPolicy,
|
||||
exclusive: isExclusive))
|
||||
await currentAccount.fetchLists()
|
||||
isSaving = false
|
||||
dismiss()
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import Account
|
||||
import DesignSystem
|
||||
import EmojiText
|
||||
import Models
|
||||
import Network
|
||||
import SwiftUI
|
||||
import Account
|
||||
|
||||
@MainActor
|
||||
public struct ListEditView: View {
|
||||
|
@ -22,10 +22,11 @@ public struct ListEditView: View {
|
|||
Form {
|
||||
Section("lists.edit.settings") {
|
||||
TextField("list.edit.title", text: $viewModel.title) {
|
||||
Task { await viewModel.update() }
|
||||
Task { await viewModel.update() }
|
||||
}
|
||||
Picker("list.edit.repliesPolicy",
|
||||
selection: $viewModel.repliesPolicy) {
|
||||
selection: $viewModel.repliesPolicy)
|
||||
{
|
||||
ForEach(Models.List.RepliesPolicy.allCases) { policy in
|
||||
Text(policy.title)
|
||||
.tag(policy)
|
||||
|
@ -41,7 +42,7 @@ public struct ListEditView: View {
|
|||
.onChange(of: viewModel.isExclusive) { _, _ in
|
||||
Task { await viewModel.update() }
|
||||
}
|
||||
|
||||
|
||||
Section("lists.edit.users-in-list") {
|
||||
HStack {
|
||||
TextField("lists.edit.users-search",
|
||||
|
@ -91,7 +92,7 @@ public struct ListEditView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var loadingView: some View {
|
||||
HStack {
|
||||
Spacer()
|
||||
|
@ -100,7 +101,7 @@ public struct ListEditView: View {
|
|||
}
|
||||
.id(UUID())
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var searchAccountsView: some View {
|
||||
if viewModel.isSearching {
|
||||
|
@ -138,15 +139,15 @@ public struct ListEditView: View {
|
|||
relationship: relationship,
|
||||
shouldDisplayNotify: false,
|
||||
relationshipUpdated: { relationship in
|
||||
viewModel.searchedRelationships[account.id] = relationship
|
||||
}))
|
||||
viewModel.searchedRelationships[account.id] = relationship
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var listAccountsView: some View {
|
||||
if viewModel.isLoadingAccounts {
|
||||
|
@ -176,5 +177,4 @@ public struct ListEditView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import Combine
|
||||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import Observation
|
||||
import SwiftUI
|
||||
import Env
|
||||
|
||||
@MainActor
|
||||
@Observable public class ListEditViewModel {
|
||||
|
@ -13,13 +13,13 @@ import Env
|
|||
|
||||
var isLoadingAccounts: Bool = true
|
||||
var accounts: [Account] = []
|
||||
|
||||
|
||||
var title: String
|
||||
var repliesPolicy: Models.List.RepliesPolicy
|
||||
var isExclusive: Bool
|
||||
|
||||
|
||||
var isUpdating: Bool = false
|
||||
|
||||
|
||||
var searchUserQuery: String = ""
|
||||
var searchedAccounts: [Account] = []
|
||||
var searchedRelationships: [String: Relationship] = [:]
|
||||
|
@ -27,9 +27,9 @@ import Env
|
|||
|
||||
init(list: Models.List) {
|
||||
self.list = list
|
||||
self.title = list.title
|
||||
self.repliesPolicy = list.repliesPolicy ?? .list
|
||||
self.isExclusive = list.exclusive ?? false
|
||||
title = list.title
|
||||
repliesPolicy = list.repliesPolicy ?? .list
|
||||
isExclusive = list.exclusive ?? false
|
||||
}
|
||||
|
||||
func fetchAccounts() async {
|
||||
|
@ -42,27 +42,27 @@ import Env
|
|||
isLoadingAccounts = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func update() async {
|
||||
guard let client else { return }
|
||||
do {
|
||||
isUpdating = true
|
||||
let list: Models.List = try await client.put(endpoint:
|
||||
Lists.updateList(id: list.id,
|
||||
title: title,
|
||||
repliesPolicy: repliesPolicy,
|
||||
exclusive: isExclusive ))
|
||||
Lists.updateList(id: list.id,
|
||||
title: title,
|
||||
repliesPolicy: repliesPolicy,
|
||||
exclusive: isExclusive))
|
||||
self.list = list
|
||||
self.title = list.title
|
||||
self.repliesPolicy = list.repliesPolicy ?? .list
|
||||
self.isExclusive = list.exclusive ?? false
|
||||
self.isUpdating = false
|
||||
title = list.title
|
||||
repliesPolicy = list.repliesPolicy ?? .list
|
||||
isExclusive = list.exclusive ?? false
|
||||
isUpdating = false
|
||||
await CurrentAccount.shared.fetchLists()
|
||||
} catch {
|
||||
isUpdating = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func add(account: Account) async {
|
||||
guard let client else { return }
|
||||
do {
|
||||
|
@ -76,7 +76,7 @@ import Env
|
|||
isUpdating = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func delete(account: Account) async {
|
||||
guard let client else { return }
|
||||
do {
|
||||
|
@ -90,7 +90,7 @@ import Env
|
|||
isUpdating = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func searchUsers() async {
|
||||
guard let client, !searchUserQuery.isEmpty else { return }
|
||||
do {
|
||||
|
@ -107,7 +107,7 @@ import Env
|
|||
}
|
||||
searchedAccounts = results.accounts
|
||||
isSearching = false
|
||||
} catch { }
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,11 +115,11 @@ extension Models.List.RepliesPolicy {
|
|||
var title: LocalizedStringKey {
|
||||
switch self {
|
||||
case .followed:
|
||||
return "list.repliesPolicy.followed"
|
||||
"list.repliesPolicy.followed"
|
||||
case .list:
|
||||
return "list.repliesPolicy.list"
|
||||
"list.repliesPolicy.list"
|
||||
case .none:
|
||||
return "list.repliesPolicy.none"
|
||||
"list.repliesPolicy.none"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public struct MediaUIView: View, @unchecked Sendable {
|
|||
data = attachments.compactMap { DisplayData(from: $0) }
|
||||
initialItem = DisplayData(from: selectedAttachment)
|
||||
}
|
||||
|
||||
|
||||
private func scrollToPrevious() {
|
||||
if let scrolledItem, let index = data.firstIndex(of: scrolledItem), index > 0 {
|
||||
withAnimation {
|
||||
|
@ -62,9 +62,9 @@ public struct MediaUIView: View, @unchecked Sendable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func scrollToNext() {
|
||||
if let scrolledItem, let index = data.firstIndex(of: scrolledItem), index < data.count - 1{
|
||||
if let scrolledItem, let index = data.firstIndex(of: scrolledItem), index < data.count - 1 {
|
||||
withAnimation {
|
||||
self.scrolledItem = data[index + 1]
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ public struct List: Codable, Identifiable, Equatable, Hashable {
|
|||
public let title: String
|
||||
public let repliesPolicy: RepliesPolicy?
|
||||
public let exclusive: Bool?
|
||||
|
||||
|
||||
public enum RepliesPolicy: String, Sendable, Codable, CaseIterable, Identifiable {
|
||||
public var id: String {
|
||||
rawValue
|
||||
}
|
||||
|
||||
case followed, list, `none`
|
||||
case followed, list, none
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ public struct Tag: Codable, Identifiable, Equatable, Hashable {
|
|||
public var id: String {
|
||||
day
|
||||
}
|
||||
|
||||
public let day: String
|
||||
public let accounts: String
|
||||
public let uses: String
|
||||
|
|
|
@ -14,7 +14,7 @@ public enum Apps: Endpoint {
|
|||
public func queryItems() -> [URLQueryItem]? {
|
||||
switch self {
|
||||
case .registerApp:
|
||||
return [
|
||||
[
|
||||
.init(name: "client_name", value: AppInfo.clientName),
|
||||
.init(name: "redirect_uris", value: AppInfo.scheme),
|
||||
.init(name: "scopes", value: AppInfo.scopes),
|
||||
|
|
|
@ -35,14 +35,14 @@ public enum Oauth: Endpoint {
|
|||
public func queryItems() -> [URLQueryItem]? {
|
||||
switch self {
|
||||
case let .authorize(clientId):
|
||||
return [
|
||||
[
|
||||
.init(name: "response_type", value: "code"),
|
||||
.init(name: "client_id", value: clientId),
|
||||
.init(name: "redirect_uri", value: AppInfo.scheme),
|
||||
.init(name: "scope", value: AppInfo.scopes),
|
||||
]
|
||||
default:
|
||||
return nil
|
||||
nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ public enum ServerFilters: Endpoint {
|
|||
public func queryItems() -> [URLQueryItem]? {
|
||||
switch self {
|
||||
case let .addKeyword(_, keyword, wholeWord):
|
||||
return [.init(name: "keyword", value: keyword),
|
||||
.init(name: "whole_word", value: wholeWord ? "true" : "false")]
|
||||
[.init(name: "keyword", value: keyword),
|
||||
.init(name: "whole_word", value: wholeWord ? "true" : "false")]
|
||||
default:
|
||||
return nil
|
||||
nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,18 +35,19 @@ public struct OpenAIClient {
|
|||
self.temperature = temperature
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public struct VisionRequest: OpenAIRequest {
|
||||
public struct Message: Encodable {
|
||||
public struct MessageContent: Encodable {
|
||||
public struct ImageUrl: Encodable {
|
||||
public let url: URL
|
||||
}
|
||||
|
||||
public let type: String
|
||||
public let text: String?
|
||||
public let imageUrl: ImageUrl?
|
||||
}
|
||||
|
||||
|
||||
public let role = "user"
|
||||
public let content: [MessageContent]
|
||||
}
|
||||
|
@ -77,8 +78,8 @@ public struct OpenAIClient {
|
|||
case let .emphasize(input):
|
||||
ChatRequest(content: "Make this text catchy, more fun: \(input)", temperature: 1)
|
||||
case let .imageDescription(image):
|
||||
VisionRequest(messages: [.init(content: [.init(type: "text", text: "What’s in this image? Be brief, it's for image alt description on a social network. Don't write in the first person.", imageUrl: nil)
|
||||
, .init(type: "image_url", text: nil, imageUrl: .init(url: image))])])
|
||||
VisionRequest(messages: [.init(content: [.init(type: "text", text: "What’s in this image? Be brief, it's for image alt description on a social network. Don't write in the first person.", imageUrl: nil),
|
||||
.init(type: "image_url", text: nil, imageUrl: .init(url: image))])])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@ import SwiftUI
|
|||
}
|
||||
|
||||
func loadSelectedType() {
|
||||
self.client = client
|
||||
|
||||
client = client
|
||||
|
||||
guard let value = UserDefaults.standard.string(forKey: filterKey)
|
||||
else {
|
||||
selectedType = nil
|
||||
|
|
|
@ -114,7 +114,8 @@ import SwiftUI
|
|||
indentationLevelPreviousCache = [:]
|
||||
for status in statuses {
|
||||
if let inReplyToId = status.inReplyToId,
|
||||
let prevIndent = indentationLevelPreviousCache[inReplyToId] {
|
||||
let prevIndent = indentationLevelPreviousCache[inReplyToId]
|
||||
{
|
||||
indentationLevelPreviousCache[status.id] = prevIndent + 1
|
||||
} else {
|
||||
indentationLevelPreviousCache[status.id] = 0
|
||||
|
@ -137,14 +138,14 @@ import SwiftUI
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getIndentationLevel(id: String, maxIndent: UInt) -> (indentationLevel: UInt, extraInset: Double) {
|
||||
|
||||
func getIndentationLevel(id: String, maxIndent: UInt) -> (indentationLevel: UInt, extraInset: Double) {
|
||||
let level = min(indentationLevelPreviousCache[id] ?? 0, maxIndent)
|
||||
|
||||
|
||||
let barSize = Double(level) * 2
|
||||
let spaceBetween = (Double(level) - 1) * 3
|
||||
let size = barSize + spaceBetween + 8
|
||||
|
||||
|
||||
return (level, size)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
import SwiftUI
|
||||
import GiphyUISDK
|
||||
import UIKit
|
||||
import DesignSystem
|
||||
import GiphyUISDK
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
struct GifPickerView: UIViewControllerRepresentable {
|
||||
@Environment(Theme.self) private var theme
|
||||
|
||||
var completion: ((String) -> Void)
|
||||
|
||||
var completion: (String) -> Void
|
||||
var onShouldDismissGifPicker: () -> Void
|
||||
|
||||
|
||||
func makeUIViewController(context: Context) -> GiphyViewController {
|
||||
Giphy.configure(apiKey: "MIylJkNX57vcUNZxmSODKU9dQKBgXCkV")
|
||||
|
||||
|
||||
let controller = GiphyViewController()
|
||||
controller.swiftUIEnabled = true
|
||||
controller.mediaTypeConfig = [.gifs, .stickers, .recents]
|
||||
controller.delegate = context.coordinator
|
||||
controller.navigationController?.isNavigationBarHidden = true
|
||||
controller.navigationController?.setNavigationBarHidden(true, animated: false)
|
||||
|
||||
|
||||
GiphyViewController.trayHeightMultiplier = 1.0
|
||||
|
||||
|
||||
controller.theme = GPHTheme(type: theme.selectedScheme == .dark ? .darkBlur : .lightBlur)
|
||||
|
||||
|
||||
return controller
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { }
|
||||
|
||||
|
||||
func updateUIViewController(_: UIViewControllerType, context _: Context) {}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
GifPickerView.Coordinator(parent: self)
|
||||
}
|
||||
|
||||
|
||||
class Coordinator: NSObject, GiphyDelegate {
|
||||
var parent: GifPickerView
|
||||
|
||||
|
||||
init(parent: GifPickerView) {
|
||||
self.parent = parent
|
||||
}
|
||||
|
||||
func didDismiss(controller: GiphyViewController?) {
|
||||
self.parent.onShouldDismissGifPicker()
|
||||
|
||||
func didDismiss(controller _: GiphyViewController?) {
|
||||
parent.onShouldDismissGifPicker()
|
||||
}
|
||||
|
||||
func didSelectMedia(giphyViewController: GiphyViewController, media: GPHMedia) {
|
||||
|
||||
func didSelectMedia(giphyViewController _: GiphyViewController, media: GPHMedia) {
|
||||
let url = media.url(rendition: .fixedWidth, fileType: .gif)
|
||||
parent.completion(url ?? "")
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import GiphyUISDK
|
||||
import Models
|
||||
import NukeUI
|
||||
import PhotosUI
|
||||
import SwiftUI
|
||||
import GiphyUISDK
|
||||
|
||||
@MainActor
|
||||
struct StatusEditorAccessoryView: View {
|
||||
|
@ -41,19 +41,19 @@ struct StatusEditorAccessoryView: View {
|
|||
} label: {
|
||||
Label("status.editor.photo-library", systemImage: "photo")
|
||||
}
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
Button {
|
||||
isCameraPickerPresented = true
|
||||
} label: {
|
||||
Label("status.editor.camera-picker", systemImage: "camera")
|
||||
}
|
||||
#endif
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
Button {
|
||||
isCameraPickerPresented = true
|
||||
} label: {
|
||||
Label("status.editor.camera-picker", systemImage: "camera")
|
||||
}
|
||||
#endif
|
||||
Button {
|
||||
isFileImporterPresented = true
|
||||
} label: {
|
||||
Label("status.editor.browse-file", systemImage: "folder")
|
||||
}
|
||||
|
||||
|
||||
Button {
|
||||
isGIFPickerPresented = true
|
||||
} label: {
|
||||
|
@ -70,8 +70,7 @@ struct StatusEditorAccessoryView: View {
|
|||
selection: $viewModel.mediaPickers,
|
||||
maxSelectionCount: 4,
|
||||
matching: .any(of: [.images, .videos]),
|
||||
photoLibrary: .shared()
|
||||
)
|
||||
photoLibrary: .shared())
|
||||
.fileImporter(isPresented: $isFileImporterPresented,
|
||||
allowedContentTypes: [.image, .video],
|
||||
allowsMultipleSelection: true)
|
||||
|
@ -92,7 +91,7 @@ struct StatusEditorAccessoryView: View {
|
|||
})
|
||||
.sheet(isPresented: $isGIFPickerPresented, content: {
|
||||
GifPickerView { url in
|
||||
GPHCache.shared.downloadAssetData(url) { data, error in
|
||||
GPHCache.shared.downloadAssetData(url) { data, _ in
|
||||
guard let data else { return }
|
||||
viewModel.processGIFData(data: data)
|
||||
}
|
||||
|
@ -109,7 +108,7 @@ struct StatusEditorAccessoryView: View {
|
|||
// all SEVM have the same visibility value
|
||||
followUpSEVMs.append(StatusEditorViewModel(mode: .new(visibility: focusedSEVM.visibility)))
|
||||
} label: {
|
||||
Image(systemName: "arrowshape.turn.up.left.circle.fill")
|
||||
Image(systemName: "arrowshape.turn.up.left.circle.fill")
|
||||
}
|
||||
.disabled(!canAddNewSEVM)
|
||||
|
||||
|
@ -213,8 +212,8 @@ struct StatusEditorAccessoryView: View {
|
|||
private var canAddNewSEVM: Bool {
|
||||
guard followUpSEVMs.count < 5 else { return false }
|
||||
|
||||
if followUpSEVMs.isEmpty, // there is only mainSEVM on the editor
|
||||
!focusedSEVM.statusText.string.isEmpty // focusedSEVM is also mainSEVM
|
||||
if followUpSEVMs.isEmpty, // there is only mainSEVM on the editor
|
||||
!focusedSEVM.statusText.string.isEmpty // focusedSEVM is also mainSEVM
|
||||
{ return true }
|
||||
|
||||
if let lastSEVMs = followUpSEVMs.last,
|
||||
|
|
|
@ -2,7 +2,7 @@ import Foundation
|
|||
import Models
|
||||
|
||||
struct StatusEditorCategorizedEmojiContainer: Identifiable, Equatable {
|
||||
let id = UUID().uuidString
|
||||
let categoryName: String
|
||||
var emojis: [Emoji]
|
||||
let id = UUID().uuidString
|
||||
let categoryName: String
|
||||
var emojis: [Emoji]
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
import Network
|
||||
|
||||
@MainActor
|
||||
struct StatusEditorMediaEditView: View {
|
||||
|
@ -11,7 +11,7 @@ struct StatusEditorMediaEditView: View {
|
|||
@Environment(Theme.self) private var theme
|
||||
@Environment(CurrentInstance.self) private var currentInstance
|
||||
@Environment(UserPreferences.self) private var preferences
|
||||
|
||||
|
||||
var viewModel: StatusEditorViewModel
|
||||
let container: StatusEditorMediaContainer
|
||||
|
||||
|
@ -22,7 +22,7 @@ struct StatusEditorMediaEditView: View {
|
|||
|
||||
@State private var didAppear: Bool = false
|
||||
@State private var isGeneratingDescription: Bool = false
|
||||
|
||||
|
||||
@State private var showTranslateButton: Bool = false
|
||||
@State private var isTranslating: Bool = false
|
||||
|
||||
|
@ -108,7 +108,7 @@ struct StatusEditorMediaEditView: View {
|
|||
.preferredColorScheme(theme.selectedScheme == .dark ? .dark : .light)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var generateButton: some View {
|
||||
if let url = container.mediaAttachment?.url, preferences.isOpenAIEnabled {
|
||||
|
@ -133,7 +133,7 @@ struct StatusEditorMediaEditView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var translateButton: some View {
|
||||
if showTranslateButton {
|
||||
|
@ -153,10 +153,9 @@ struct StatusEditorMediaEditView: View {
|
|||
Text("status.action.translate")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func generateDescription(url: URL) async -> String? {
|
||||
isGeneratingDescription = true
|
||||
let client = OpenAIClient()
|
||||
|
@ -164,7 +163,7 @@ struct StatusEditorMediaEditView: View {
|
|||
isGeneratingDescription = false
|
||||
return response?.trimmedText
|
||||
}
|
||||
|
||||
|
||||
private func translateDescription() async -> String? {
|
||||
isTranslating = true
|
||||
let userAPIKey = DeepLUserAPIHandler.readIfAllowed()
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import AVKit
|
||||
import DesignSystem
|
||||
import Env
|
||||
import MediaUI
|
||||
import Models
|
||||
import NukeUI
|
||||
import SwiftUI
|
||||
import MediaUI
|
||||
|
||||
@MainActor
|
||||
struct StatusEditorMediaView: View {
|
||||
|
@ -49,17 +49,17 @@ struct StatusEditorMediaView: View {
|
|||
private let containerHeight: CGFloat = 300
|
||||
private var containerWidth: CGFloat { containerHeight / 1.5 }
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
private var showsScrollIndicators : Bool { count > 1 }
|
||||
private var scrollBottomPadding : CGFloat? = nil
|
||||
#else
|
||||
private var showsScrollIndicators : Bool = false
|
||||
private var scrollBottomPadding : CGFloat? = 0
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
private var showsScrollIndicators: Bool { count > 1 }
|
||||
private var scrollBottomPadding: CGFloat?
|
||||
#else
|
||||
private var showsScrollIndicators: Bool = false
|
||||
private var scrollBottomPadding: CGFloat? = 0
|
||||
#endif
|
||||
|
||||
init(viewModel: StatusEditorViewModel, editingMediaContainer: Binding<StatusEditorMediaContainer?>) {
|
||||
self.viewModel = viewModel
|
||||
self._editingMediaContainer = editingMediaContainer
|
||||
_editingMediaContainer = editingMediaContainer
|
||||
}
|
||||
|
||||
private func pixel(at index: Int) -> some View {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import SwiftUI
|
||||
import Models
|
||||
import Env
|
||||
import DesignSystem
|
||||
import Accounts
|
||||
import AppAccount
|
||||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct StatusEditorCoreView: View {
|
||||
|
@ -22,11 +22,11 @@ struct StatusEditorCoreView: View {
|
|||
@Environment(CurrentAccount.self) private var currentAccount
|
||||
@Environment(AppAccountsManager.self) private var appAccounts
|
||||
@Environment(Client.self) private var client
|
||||
#if targetEnvironment(macCatalyst)
|
||||
@Environment(\.dismissWindow) private var dismissWindow
|
||||
#else
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
@Environment(\.dismissWindow) private var dismissWindow
|
||||
#else
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
#endif
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
|
@ -145,11 +145,11 @@ struct StatusEditorCoreView: View {
|
|||
viewModel.preferences = preferences
|
||||
viewModel.prepareStatusText()
|
||||
if !client.isAuth {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
dismissWindow()
|
||||
#else
|
||||
dismiss()
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
dismissWindow()
|
||||
#else
|
||||
dismiss()
|
||||
#endif
|
||||
NotificationCenter.default.post(name: .shareSheetClose, object: nil)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import SwiftUI
|
||||
import Models
|
||||
import SwiftUI
|
||||
|
||||
struct StatusEditorPrivacyMenu: View {
|
||||
@Binding var visibility: Models.Visibility
|
||||
|
@ -8,7 +8,7 @@ struct StatusEditorPrivacyMenu: View {
|
|||
var body: some View {
|
||||
Menu {
|
||||
ForEach(Models.Visibility.allCases, id: \.self) { vis in
|
||||
Button { self.visibility = vis } label: {
|
||||
Button { visibility = vis } label: {
|
||||
Label(vis.title, systemImage: vis.iconName)
|
||||
}
|
||||
}
|
||||
|
@ -29,4 +29,3 @@ struct StatusEditorPrivacyMenu: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import SwiftUI
|
||||
import Env
|
||||
import Models
|
||||
import StoreKit
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct StatusEditorToolbarItems: ToolbarContent {
|
||||
|
@ -12,11 +12,11 @@ struct StatusEditorToolbarItems: ToolbarContent {
|
|||
|
||||
@Environment(\.modelContext) private var context
|
||||
@Environment(UserPreferences.self) private var preferences
|
||||
#if targetEnvironment(macCatalyst)
|
||||
@Environment(\.dismissWindow) private var dismissWindow
|
||||
#else
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
@Environment(\.dismissWindow) private var dismissWindow
|
||||
#else
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
#endif
|
||||
|
||||
var body: some ToolbarContent {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
|
@ -81,18 +81,18 @@ struct StatusEditorToolbarItems: ToolbarContent {
|
|||
private func postStatus(with model: StatusEditorViewModel, isMainPost: Bool) async -> Status? {
|
||||
let status = await model.postStatus()
|
||||
|
||||
if status != nil && isMainPost {
|
||||
if status != nil, isMainPost {
|
||||
close()
|
||||
SoundEffectManager.shared.playSound(.tootSent)
|
||||
NotificationCenter.default.post(name: .shareSheetClose, object: nil)
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
if !mainSEVM.mode.isInShareExtension, !preferences.requestedReview {
|
||||
if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
|
||||
SKStoreReviewController.requestReview(in: scene)
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
if !mainSEVM.mode.isInShareExtension, !preferences.requestedReview {
|
||||
if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
|
||||
SKStoreReviewController.requestReview(in: scene)
|
||||
}
|
||||
preferences.requestedReview = true
|
||||
}
|
||||
preferences.requestedReview = true
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
return status
|
||||
|
@ -109,11 +109,11 @@ struct StatusEditorToolbarItems: ToolbarContent {
|
|||
}
|
||||
}
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
private func close() { dismissWindow() }
|
||||
#else
|
||||
private func close() { dismiss() }
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
private func close() { dismissWindow() }
|
||||
#else
|
||||
private func close() { dismiss() }
|
||||
#endif
|
||||
|
||||
@ViewBuilder
|
||||
private var languageConfirmationDialog: some View {
|
||||
|
|
|
@ -24,7 +24,7 @@ public struct StatusEditorView: View {
|
|||
@State private var scrollID: UUID?
|
||||
|
||||
@FocusState private var editorFocusState: StatusEditorFocusState?
|
||||
|
||||
|
||||
private var focusedSEVM: StatusEditorViewModel {
|
||||
if case let .followUp(id) = editorFocusState,
|
||||
let sevm = followUpSEVMs.first(where: { $0.id == id })
|
||||
|
@ -38,7 +38,7 @@ public struct StatusEditorView: View {
|
|||
}
|
||||
|
||||
public var body: some View {
|
||||
@Bindable var focusedSEVM = self.focusedSEVM
|
||||
@Bindable var focusedSEVM = focusedSEVM
|
||||
|
||||
NavigationStack {
|
||||
ScrollView {
|
||||
|
@ -54,7 +54,7 @@ public struct StatusEditorView: View {
|
|||
)
|
||||
.id(mainSEVM.id)
|
||||
|
||||
ForEach(followUpSEVMs) { sevm in
|
||||
ForEach(followUpSEVMs) { sevm in
|
||||
@Bindable var sevm: StatusEditorViewModel = sevm
|
||||
|
||||
StatusEditorCoreView(
|
||||
|
@ -93,7 +93,8 @@ public struct StatusEditorView: View {
|
|||
Button("OK") {}
|
||||
}, message: {
|
||||
Text(mainSEVM.postingError ?? "")
|
||||
})
|
||||
}
|
||||
)
|
||||
.interactiveDismissDisabled(mainSEVM.shouldDisplayDismissWarning)
|
||||
.onChange(of: appAccounts.currentClient) { _, newValue in
|
||||
if mainSEVM.mode.isInShareExtension {
|
||||
|
|
|
@ -10,7 +10,7 @@ import SwiftUI
|
|||
@MainActor
|
||||
@Observable public class StatusEditorViewModel: NSObject, Identifiable {
|
||||
public let id = UUID()
|
||||
|
||||
|
||||
var mode: Mode
|
||||
|
||||
var client: Client?
|
||||
|
@ -94,7 +94,7 @@ import SwiftUI
|
|||
|
||||
let removedIDs = oldValue
|
||||
.filter { !mediaPickers.contains($0) }
|
||||
.compactMap { $0.itemIdentifier }
|
||||
.compactMap(\.itemIdentifier)
|
||||
mediaContainers.removeAll { removedIDs.contains($0.id) }
|
||||
|
||||
let newPickerItems = mediaPickers.filter { !oldValue.contains($0) }
|
||||
|
@ -297,7 +297,8 @@ import SwiftUI
|
|||
movieTransferable: nil,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: $0,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
}
|
||||
case let .quote(status):
|
||||
embeddedStatus = status
|
||||
|
@ -384,7 +385,7 @@ import SwiftUI
|
|||
.compactMap { NSItemProvider(contentsOf: $0) }
|
||||
processItemsProvider(items: items)
|
||||
}
|
||||
|
||||
|
||||
func processGIFData(data: Data) {
|
||||
isMediasLoading = true
|
||||
let url = URL.temporaryDirectory.appending(path: "\(UUID().uuidString).gif")
|
||||
|
@ -405,7 +406,8 @@ import SwiftUI
|
|||
movieTransferable: nil,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: nil,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
prepareToPost(for: container)
|
||||
}
|
||||
|
||||
|
@ -428,7 +430,8 @@ import SwiftUI
|
|||
movieTransferable: nil,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: nil,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
prepareToPost(for: container)
|
||||
} else if let content = content as? ImageFileTranseferable,
|
||||
let compressedData = await compressor.compressImageFrom(url: content.url),
|
||||
|
@ -440,7 +443,8 @@ import SwiftUI
|
|||
movieTransferable: nil,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: nil,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
prepareToPost(for: container)
|
||||
} else if let video = content as? MovieFileTranseferable {
|
||||
let container = StatusEditorMediaContainer(
|
||||
|
@ -449,7 +453,8 @@ import SwiftUI
|
|||
movieTransferable: video,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: nil,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
prepareToPost(for: container)
|
||||
} else if let gif = content as? GifFileTranseferable {
|
||||
let container = StatusEditorMediaContainer(
|
||||
|
@ -458,7 +463,8 @@ import SwiftUI
|
|||
movieTransferable: nil,
|
||||
gifTransferable: gif,
|
||||
mediaAttachment: nil,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
prepareToPost(for: container)
|
||||
}
|
||||
} catch {
|
||||
|
@ -619,7 +625,8 @@ import SwiftUI
|
|||
movieTransferable: nil,
|
||||
gifTransferable: gifFile,
|
||||
mediaAttachment: nil,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
}
|
||||
|
||||
private static func makeMovieContainer(from pickerItem: PhotosPickerItem) async -> StatusEditorMediaContainer? {
|
||||
|
@ -631,7 +638,8 @@ import SwiftUI
|
|||
movieTransferable: movieFile,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: nil,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
}
|
||||
|
||||
private static func makeImageContainer(from pickerItem: PhotosPickerItem) async -> StatusEditorMediaContainer? {
|
||||
|
@ -649,7 +657,8 @@ import SwiftUI
|
|||
movieTransferable: nil,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: nil,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
}
|
||||
|
||||
func upload(container: StatusEditorMediaContainer) async {
|
||||
|
@ -662,7 +671,8 @@ import SwiftUI
|
|||
movieTransferable: originalContainer.movieTransferable,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: nil,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
mediaContainers[index] = newContainer
|
||||
do {
|
||||
let compressor = StatusEditorCompressor()
|
||||
|
@ -676,7 +686,8 @@ import SwiftUI
|
|||
movieTransferable: nil,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: uploadedMedia,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
}
|
||||
if let uploadedMedia, uploadedMedia.url == nil {
|
||||
scheduleAsyncMediaRefresh(mediaAttachement: uploadedMedia)
|
||||
|
@ -693,7 +704,8 @@ import SwiftUI
|
|||
movieTransferable: originalContainer.movieTransferable,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: uploadedMedia,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
}
|
||||
if let uploadedMedia, uploadedMedia.url == nil {
|
||||
scheduleAsyncMediaRefresh(mediaAttachement: uploadedMedia)
|
||||
|
@ -707,7 +719,8 @@ import SwiftUI
|
|||
movieTransferable: nil,
|
||||
gifTransferable: originalContainer.gifTransferable,
|
||||
mediaAttachment: uploadedMedia,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
}
|
||||
if let uploadedMedia, uploadedMedia.url == nil {
|
||||
scheduleAsyncMediaRefresh(mediaAttachement: uploadedMedia)
|
||||
|
@ -721,7 +734,8 @@ import SwiftUI
|
|||
movieTransferable: nil,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: nil,
|
||||
error: error)
|
||||
error: error
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -747,7 +761,8 @@ import SwiftUI
|
|||
movieTransferable: oldContainer.movieTransferable,
|
||||
gifTransferable: oldContainer.gifTransferable,
|
||||
mediaAttachment: newAttachement,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
}
|
||||
} catch {
|
||||
print(error.localizedDescription)
|
||||
|
@ -770,7 +785,8 @@ import SwiftUI
|
|||
movieTransferable: nil,
|
||||
gifTransferable: nil,
|
||||
mediaAttachment: media,
|
||||
error: nil)
|
||||
error: nil
|
||||
)
|
||||
} catch { print(error) }
|
||||
}
|
||||
}
|
||||
|
@ -815,9 +831,9 @@ import SwiftUI
|
|||
|
||||
return dict
|
||||
}.sorted(by: { lhs, rhs in
|
||||
if rhs.key == "Uncategorized" { return false }
|
||||
else if lhs.key == "Uncategorized" { return true }
|
||||
else { return lhs.key < rhs.key }
|
||||
if rhs.key == "Uncategorized" { false }
|
||||
else if lhs.key == "Uncategorized" { true }
|
||||
else { lhs.key < rhs.key }
|
||||
}).forEach { key, value in
|
||||
emojiContainers.append(.init(categoryName: key, emojis: value))
|
||||
}
|
||||
|
|
|
@ -45,10 +45,9 @@ extension TextView.Representable {
|
|||
textView.allowsEditingTextAttributes = false
|
||||
textView.returnKeyType = .default
|
||||
textView.allowsEditingTextAttributes = true
|
||||
#if targetEnvironment(macCatalyst)
|
||||
textView.inlinePredictionType = .no
|
||||
#endif
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
textView.inlinePredictionType = .no
|
||||
#endif
|
||||
|
||||
self.getTextView?(textView)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public struct StatusRowView: View {
|
|||
HStack(spacing: 0) {
|
||||
if !isCompact {
|
||||
HStack(spacing: 3) {
|
||||
ForEach(0..<indentationLevel, id: \.self) { level in
|
||||
ForEach(0 ..< indentationLevel, id: \.self) { level in
|
||||
Rectangle()
|
||||
.fill(theme.tintColor)
|
||||
.frame(width: 2)
|
||||
|
@ -225,13 +225,14 @@ public struct StatusRowView: View {
|
|||
Button("accessibility.status.media-viewer-action.label") {
|
||||
HapticManager.shared.fireHaptic(.notification(.success))
|
||||
let attachments = viewModel.finalStatus.mediaAttachments
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationMedia.mediaViewer(
|
||||
attachments: attachments,
|
||||
selectedAttachment: attachments[0]))
|
||||
#else
|
||||
quickLook.prepareFor(selectedMediaAttachment: attachments[0], mediaAttachments: attachments)
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationMedia.mediaViewer(
|
||||
attachments: attachments,
|
||||
selectedAttachment: attachments[0]
|
||||
))
|
||||
#else
|
||||
quickLook.prepareFor(selectedMediaAttachment: attachments[0], mediaAttachments: attachments)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ import SwiftUI
|
|||
var isLoadingRemoteContent: Bool = false
|
||||
var localStatusId: String?
|
||||
var localStatus: Status?
|
||||
|
||||
|
||||
private var scrollToId = nil as Binding<String?>?
|
||||
|
||||
// The relationship our user has to the author of this post, if available
|
||||
|
@ -199,9 +199,9 @@ import SwiftUI
|
|||
routerPath.navigate(to: .accountDetail(id: mention.id))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func goToParent() {
|
||||
guard let id = status.inReplyToId else {return}
|
||||
guard let id = status.inReplyToId else { return }
|
||||
if let _ = scrollToId {
|
||||
scrollToId?.wrappedValue = id
|
||||
} else {
|
||||
|
|
|
@ -205,11 +205,11 @@ struct StatusRowActionsView: View {
|
|||
switch action {
|
||||
case .respond:
|
||||
SoundEffectManager.shared.playSound(.share)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.localStatus ?? viewModel.status))
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.localStatus ?? viewModel.status)
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.localStatus ?? viewModel.status))
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.localStatus ?? viewModel.status)
|
||||
#endif
|
||||
case .favorite:
|
||||
SoundEffectManager.shared.playSound(.favorite)
|
||||
await statusDataController.toggleFavorite(remoteStatus: viewModel.localStatusId)
|
||||
|
|
|
@ -5,6 +5,7 @@ import NukeUI
|
|||
import Shimmer
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
public struct StatusRowCardView: View {
|
||||
@Environment(\.openURL) private var openURL
|
||||
@Environment(\.isInCaptureMode) private var isInCaptureMode: Bool
|
||||
|
@ -46,7 +47,7 @@ public struct StatusRowCardView: View {
|
|||
} label: {
|
||||
if let title = card.title, let url = URL(string: card.url) {
|
||||
VStack(alignment: .leading) {
|
||||
let sitesWithIcons = [ "apps.apple.com", "music.apple.com", "open.spotify.com" ]
|
||||
let sitesWithIcons = ["apps.apple.com", "music.apple.com", "open.spotify.com"]
|
||||
if let host = url.host(), sitesWithIcons.contains(host) {
|
||||
iconLinkPreview(title, url)
|
||||
} else {
|
||||
|
@ -83,56 +84,53 @@ public struct StatusRowCardView: View {
|
|||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@ViewBuilder
|
||||
private func defaultLinkPreview(_ title: String, _ url: URL) -> some View {
|
||||
Group {
|
||||
if let imageURL = card.image, !isInCaptureMode {
|
||||
LazyResizableImage(url: imageURL) { state, proxy in
|
||||
let width = imageWidthFor(proxy: proxy)
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(height: imageHeight)
|
||||
.frame(maxWidth: width)
|
||||
.clipped()
|
||||
} else if state.isLoading {
|
||||
Rectangle()
|
||||
.fill(Color.gray)
|
||||
.frame(height: imageHeight)
|
||||
}
|
||||
if let imageURL = card.image, !isInCaptureMode {
|
||||
LazyResizableImage(url: imageURL) { state, proxy in
|
||||
let width = imageWidthFor(proxy: proxy)
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(height: imageHeight)
|
||||
.frame(maxWidth: width)
|
||||
.clipped()
|
||||
} else if state.isLoading {
|
||||
Rectangle()
|
||||
.fill(Color.gray)
|
||||
.frame(height: imageHeight)
|
||||
}
|
||||
// This image is decorative
|
||||
.accessibilityHidden(true)
|
||||
.frame(height: imageHeight)
|
||||
}
|
||||
HStack {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text(title)
|
||||
.font(.scaledHeadline)
|
||||
.lineLimit(3)
|
||||
if let description = card.description, !description.isEmpty {
|
||||
Text(description)
|
||||
.font(.scaledBody)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(3)
|
||||
}
|
||||
Text(url.host() ?? url.absoluteString)
|
||||
.font(.scaledFootnote)
|
||||
.foregroundColor(theme.tintColor)
|
||||
.lineLimit(1)
|
||||
}
|
||||
Spacer()
|
||||
}.padding(16)
|
||||
// This image is decorative
|
||||
.accessibilityHidden(true)
|
||||
.frame(height: imageHeight)
|
||||
}
|
||||
HStack {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text(title)
|
||||
.font(.scaledHeadline)
|
||||
.lineLimit(3)
|
||||
if let description = card.description, !description.isEmpty {
|
||||
Text(description)
|
||||
.font(.scaledBody)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(3)
|
||||
}
|
||||
Text(url.host() ?? url.absoluteString)
|
||||
.font(.scaledFootnote)
|
||||
.foregroundColor(theme.tintColor)
|
||||
.lineLimit(1)
|
||||
}
|
||||
Spacer()
|
||||
}.padding(16)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func iconLinkPreview(_ title: String, _ url: URL) -> some View {
|
||||
// ..where the image is known to be a square icon
|
||||
HStack {
|
||||
if let imageURL = card.image, !isInCaptureMode {
|
||||
LazyResizableImage(url: imageURL) { state, proxy in
|
||||
LazyResizableImage(url: imageURL) { state, _ in
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizable()
|
||||
|
@ -149,7 +147,7 @@ public struct StatusRowCardView: View {
|
|||
.accessibilityHidden(true)
|
||||
.frame(width: imageHeight, height: imageHeight)
|
||||
}
|
||||
|
||||
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text(title)
|
||||
.font(.scaledHeadline)
|
||||
|
|
|
@ -55,20 +55,20 @@ struct StatusRowContextMenu: View {
|
|||
systemImage: "bookmark")
|
||||
}
|
||||
Button {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.status))
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.status))
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
||||
#endif
|
||||
} label: {
|
||||
Label("status.action.reply", systemImage: "arrowshape.turn.up.left")
|
||||
}
|
||||
Button {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.quoteStatusEditor(status: viewModel.status))
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .quoteStatusEditor(status: viewModel.status)
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.quoteStatusEditor(status: viewModel.status))
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .quoteStatusEditor(status: viewModel.status)
|
||||
#endif
|
||||
} label: {
|
||||
Label("status.action.quote", systemImage: "quote.bubble")
|
||||
}
|
||||
|
@ -171,11 +171,11 @@ struct StatusRowContextMenu: View {
|
|||
}
|
||||
if currentInstance.isEditSupported {
|
||||
Button {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.editStatusEditor(status: viewModel.status.reblogAsAsStatus ?? viewModel.status))
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .editStatusEditor(status: viewModel.status.reblogAsAsStatus ?? viewModel.status)
|
||||
#endif
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.editStatusEditor(status: viewModel.status.reblogAsAsStatus ?? viewModel.status))
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .editStatusEditor(status: viewModel.status.reblogAsAsStatus ?? viewModel.status)
|
||||
#endif
|
||||
} label: {
|
||||
Label("status.action.edit", systemImage: "pencil")
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ struct SelectTextView: View {
|
|||
struct SelectableText: UIViewRepresentable {
|
||||
let content: AttributedString
|
||||
|
||||
func makeUIView(context: Context) -> UITextView {
|
||||
func makeUIView(context _: Context) -> UITextView {
|
||||
let attributedText = NSMutableAttributedString(content)
|
||||
attributedText.addAttribute(
|
||||
.font,
|
||||
|
@ -323,6 +323,6 @@ struct SelectableText: UIViewRepresentable {
|
|||
return textView
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: UITextView, context: Context) {}
|
||||
func makeCoordinator() -> Void {}
|
||||
func updateUIView(_: UITextView, context _: Context) {}
|
||||
func makeCoordinator() {}
|
||||
}
|
||||
|
|
|
@ -55,13 +55,13 @@ struct StatusRowHeaderView: View {
|
|||
Group {
|
||||
EmojiTextApp(.init(stringValue: viewModel.finalStatus.account.safeDisplayName),
|
||||
emojis: viewModel.finalStatus.account.emojis)
|
||||
.font(.scaledSubheadline)
|
||||
.foregroundColor(theme.labelColor)
|
||||
.emojiSize(Font.scaledSubheadlineFont.emojiSize)
|
||||
.emojiBaselineOffset(Font.scaledSubheadlineFont.emojiBaselineOffset)
|
||||
.fontWeight(.semibold)
|
||||
.lineLimit(1)
|
||||
.accountPopover(viewModel.finalStatus.account)
|
||||
.font(.scaledSubheadline)
|
||||
.foregroundColor(theme.labelColor)
|
||||
.emojiSize(Font.scaledSubheadlineFont.emojiSize)
|
||||
.emojiBaselineOffset(Font.scaledSubheadlineFont.emojiBaselineOffset)
|
||||
.fontWeight(.semibold)
|
||||
.lineLimit(1)
|
||||
.accountPopover(viewModel.finalStatus.account)
|
||||
|
||||
accountBadgeView
|
||||
.font(.footnote)
|
||||
|
|
|
@ -102,19 +102,19 @@ public struct StatusRowMediaPreviewView: View {
|
|||
}
|
||||
|
||||
private func tabAction(for index: Int) {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(
|
||||
value: WindowDestinationMedia.mediaViewer(
|
||||
attachments: attachments,
|
||||
selectedAttachment: attachments[index]
|
||||
)
|
||||
)
|
||||
#else
|
||||
#else
|
||||
quickLook.prepareFor(
|
||||
selectedMediaAttachment: attachments[index],
|
||||
mediaAttachments: attachments
|
||||
)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
private static func accessibilityLabel(for attachment: MediaAttachment) -> Text {
|
||||
|
@ -137,10 +137,10 @@ private struct MediaPreview: View {
|
|||
@Environment(\.isCompact) private var isCompact: Bool
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { proxy in
|
||||
GeometryReader { _ in
|
||||
switch displayData.type {
|
||||
case .image:
|
||||
LazyResizableImage(url: displayData.previewUrl) { state, proxy in
|
||||
LazyResizableImage(url: displayData.previewUrl) { state, _ in
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizable()
|
||||
|
@ -247,7 +247,7 @@ private struct FeaturedImagePreView: View {
|
|||
let boxWidth = availableWidth - appLayoutWidth
|
||||
let boxHeight = availableHeight * 0.8 // use only 80% of window height to leave room for text
|
||||
|
||||
if from.width <= boxWidth && from.height <= boxHeight {
|
||||
if from.width <= boxWidth, from.height <= boxHeight {
|
||||
// intrinsic size of image fits just fine
|
||||
return from
|
||||
}
|
||||
|
|
|
@ -7,30 +7,30 @@ struct StatusRowReplyView: View {
|
|||
var body: some View {
|
||||
Group {
|
||||
if let accountId = viewModel.status.inReplyToAccountId {
|
||||
Group {
|
||||
if let mention = viewModel.status.mentions.first(where: { $0.id == accountId }) {
|
||||
HStack(spacing: 2) {
|
||||
Image(systemName: "arrowshape.turn.up.left.fill")
|
||||
Text("status.row.was-reply \(mention.username)")
|
||||
}
|
||||
.accessibilityElement(children: .combine)
|
||||
.accessibilityLabel(
|
||||
Text("status.row.was-reply \(mention.username)")
|
||||
)
|
||||
} else if viewModel.isThread && accountId == viewModel.status.account.id {
|
||||
HStack(spacing: 2) {
|
||||
Image(systemName: "quote.opening")
|
||||
Text("status.row.is-thread")
|
||||
}
|
||||
.accessibilityElement(children: .combine)
|
||||
.accessibilityLabel(
|
||||
Text("status.row.is-thread")
|
||||
)
|
||||
}
|
||||
}
|
||||
.onTapGesture {
|
||||
viewModel.goToParent()
|
||||
Group {
|
||||
if let mention = viewModel.status.mentions.first(where: { $0.id == accountId }) {
|
||||
HStack(spacing: 2) {
|
||||
Image(systemName: "arrowshape.turn.up.left.fill")
|
||||
Text("status.row.was-reply \(mention.username)")
|
||||
}
|
||||
.accessibilityElement(children: .combine)
|
||||
.accessibilityLabel(
|
||||
Text("status.row.was-reply \(mention.username)")
|
||||
)
|
||||
} else if viewModel.isThread, accountId == viewModel.status.account.id {
|
||||
HStack(spacing: 2) {
|
||||
Image(systemName: "quote.opening")
|
||||
Text("status.row.is-thread")
|
||||
}
|
||||
.accessibilityElement(children: .combine)
|
||||
.accessibilityLabel(
|
||||
Text("status.row.is-thread")
|
||||
)
|
||||
}
|
||||
}
|
||||
.onTapGesture {
|
||||
viewModel.goToParent()
|
||||
}
|
||||
}
|
||||
}
|
||||
.font(.scaledFootnote)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import DesignSystem
|
||||
import SwiftUI
|
||||
import Env
|
||||
import SwiftUI
|
||||
|
||||
struct StatusRowTagView: View {
|
||||
@Environment(CurrentAccount.self) private var currentAccount
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import Charts
|
||||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
|
@ -7,7 +8,6 @@ import Status
|
|||
import SwiftData
|
||||
import SwiftUI
|
||||
import SwiftUIIntrospect
|
||||
import Charts
|
||||
|
||||
@MainActor
|
||||
public struct TimelineView: View {
|
||||
|
@ -157,7 +157,7 @@ public struct TimelineView: View {
|
|||
HStack {
|
||||
TagChartView(tag: tag)
|
||||
.padding(.top, 12)
|
||||
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("#\(tag.name)")
|
||||
.font(.scaledHeadline)
|
||||
|
|
|
@ -202,7 +202,7 @@ extension TimelineViewModel: StatusesFetcher {
|
|||
// Else we fetch top most page from the API.
|
||||
if let cachedStatuses = await getCachedStatuses(),
|
||||
!cachedStatuses.isEmpty,
|
||||
timeline == .home && !UserPreferences.shared.fastRefreshEnabled
|
||||
timeline == .home, !UserPreferences.shared.fastRefreshEnabled
|
||||
{
|
||||
await datasource.set(cachedStatuses)
|
||||
if let latestSeenId = await cache.getLatestSeenStatus(for: client)?.last,
|
||||
|
|
Loading…
Reference in a new issue