mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-29 03:31: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)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
||||
#else
|
||||
#else
|
||||
sidebarRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
.keyboardShortcut("n", modifiers: .command)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
guard preferences.preferredBrowser == .inAppSafari else { return .systemAction }
|
||||
#endif
|
||||
#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)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
||||
#else
|
||||
#else
|
||||
routerPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
#endif
|
||||
#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 {
|
||||
|
@ -59,7 +59,6 @@ struct AboutView: View {
|
|||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
|
||||
|
||||
followAccountsSection
|
||||
|
||||
Section {
|
||||
|
@ -110,7 +109,6 @@ struct AboutView: View {
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var followAccountsSection: some View {
|
||||
if let iceCubesAccount, let dimillianAccount {
|
||||
|
@ -132,13 +130,13 @@ 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ struct SettingsTabs: View {
|
|||
private var otherSections: some View {
|
||||
@Bindable var preferences = preferences
|
||||
Section("settings.section.other") {
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
Picker(selection: $preferences.preferredBrowser) {
|
||||
ForEach(PreferredBrowser.allCases, id: \.rawValue) { browser in
|
||||
switch browser {
|
||||
|
@ -190,7 +190,7 @@ struct SettingsTabs: View {
|
|||
Label("settings.general.browser.in-app.readerview", systemImage: "doc.plaintext")
|
||||
}
|
||||
.disabled(preferences.preferredBrowser != PreferredBrowser.inAppSafari)
|
||||
#endif
|
||||
#endif
|
||||
Toggle(isOn: $preferences.isOpenAIEnabled) {
|
||||
Label("settings.other.hide-openai", systemImage: "faxmachine")
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ struct SettingsTabs: View {
|
|||
|
||||
private var appSection: some View {
|
||||
Section {
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
NavigationLink(destination: IconSelectorView()) {
|
||||
Label {
|
||||
Text("settings.app.icon")
|
||||
|
@ -221,7 +221,7 @@ struct SettingsTabs: View {
|
|||
.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 {
|
||||
|
@ -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)
|
||||
|
@ -370,6 +372,7 @@ extension TagGroup {
|
|||
}
|
||||
|
||||
// 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,6 +403,7 @@ extension TagGroup {
|
|||
}
|
||||
|
||||
// MARK: TagGroup validation
|
||||
|
||||
var isValid: Bool {
|
||||
titleValidationStatus == .valid
|
||||
&& symbolNameValidationStatus == .valid
|
||||
|
@ -406,12 +411,14 @@ extension TagGroup {
|
|||
}
|
||||
|
||||
// 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,7 +426,7 @@ 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
|
||||
}
|
||||
|
@ -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)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationMedia.mediaViewer(attachments: [attachement],
|
||||
selectedAttachment: attachement))
|
||||
#else
|
||||
#else
|
||||
quickLook.prepareFor(selectedMediaAttachment: attachement, mediaAttachments: [attachement])
|
||||
#endif
|
||||
#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)
|
||||
#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
|
||||
#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
|
||||
#endif
|
||||
|
||||
private static func customFont(size: CGFloat, relativeTo textStyle: TextStyle) -> Font {
|
||||
if let chosenFont = Theme.shared.chosenFont {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
public static let status = FrameConfig(width: 48, height: 48)
|
||||
#else
|
||||
#else
|
||||
public static let status = FrameConfig(width: 40, height: 40)
|
||||
#endif
|
||||
#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)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: visibility))
|
||||
#else
|
||||
#else
|
||||
routerPath.presentedSheet = .newStatusEditor(visibility: visibility)
|
||||
HapticManager.shared.fireHaptic(.buttonPress)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "square.and.pencil")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import SwiftUI
|
||||
import Charts
|
||||
import Models
|
||||
import SwiftUI
|
||||
|
||||
public struct TagChartView: View {
|
||||
@State private var sortedHistory: [Tag.History] = []
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import DesignSystem
|
||||
import EmojiText
|
||||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import SwiftUI
|
||||
import Env
|
||||
|
||||
@MainActor
|
||||
public struct ListCreateView: View {
|
||||
|
@ -17,7 +17,7 @@ public struct ListCreateView: View {
|
|||
@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)
|
||||
|
@ -44,7 +45,7 @@ public struct ListCreateView: View {
|
|||
isSaving = true
|
||||
let _: Models.List = try await client.post(endpoint: Lists.createList(title: title,
|
||||
repliesPolicy: repliesPolicy,
|
||||
exclusive: isExclusive ))
|
||||
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 {
|
||||
|
@ -25,7 +25,8 @@ public struct ListEditView: View {
|
|||
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)
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -51,12 +51,12 @@ import Env
|
|||
Lists.updateList(id: list.id,
|
||||
title: title,
|
||||
repliesPolicy: repliesPolicy,
|
||||
exclusive: isExclusive ))
|
||||
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
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ 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]
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ public struct List: Codable, Identifiable, Equatable, Hashable {
|
|||
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: "keyword", value: keyword),
|
||||
.init(name: "whole_word", value: wholeWord ? "true" : "false")]
|
||||
default:
|
||||
return nil
|
||||
nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ public struct OpenAIClient {
|
|||
public struct ImageUrl: Encodable {
|
||||
public let url: URL
|
||||
}
|
||||
|
||||
public let type: String
|
||||
public let text: String?
|
||||
public let imageUrl: ImageUrl?
|
||||
|
@ -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,7 +54,7 @@ import SwiftUI
|
|||
}
|
||||
|
||||
func loadSelectedType() {
|
||||
self.client = client
|
||||
client = client
|
||||
|
||||
guard let value = UserDefaults.standard.string(forKey: filterKey)
|
||||
else {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
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 {
|
||||
|
@ -26,7 +26,7 @@ struct GifPickerView: UIViewControllerRepresentable {
|
|||
return controller
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { }
|
||||
func updateUIViewController(_: UIViewControllerType, context _: Context) {}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
GifPickerView.Coordinator(parent: self)
|
||||
|
@ -39,11 +39,11 @@ struct GifPickerView: UIViewControllerRepresentable {
|
|||
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,13 +41,13 @@ struct StatusEditorAccessoryView: View {
|
|||
} label: {
|
||||
Label("status.editor.photo-library", systemImage: "photo")
|
||||
}
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
Button {
|
||||
isCameraPickerPresented = true
|
||||
} label: {
|
||||
Label("status.editor.camera-picker", systemImage: "camera")
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Button {
|
||||
isFileImporterPresented = 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)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
import Network
|
||||
|
||||
@MainActor
|
||||
struct StatusEditorMediaEditView: View {
|
||||
|
@ -153,7 +153,6 @@ struct StatusEditorMediaEditView: View {
|
|||
Text("status.action.translate")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
@Environment(\.dismissWindow) private var dismissWindow
|
||||
#else
|
||||
#else
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
#endif
|
||||
#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)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
dismissWindow()
|
||||
#else
|
||||
#else
|
||||
dismiss()
|
||||
#endif
|
||||
#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)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
@Environment(\.dismissWindow) private var dismissWindow
|
||||
#else
|
||||
#else
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
#endif
|
||||
#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 !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
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
return status
|
||||
|
@ -109,11 +109,11 @@ struct StatusEditorToolbarItems: ToolbarContent {
|
|||
}
|
||||
}
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
private func close() { dismissWindow() }
|
||||
#else
|
||||
#else
|
||||
private func close() { dismiss() }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ViewBuilder
|
||||
private var languageConfirmationDialog: some View {
|
||||
|
|
|
@ -38,7 +38,7 @@ public struct StatusEditorView: View {
|
|||
}
|
||||
|
||||
public var body: some View {
|
||||
@Bindable var focusedSEVM = self.focusedSEVM
|
||||
@Bindable var focusedSEVM = focusedSEVM
|
||||
|
||||
NavigationStack {
|
||||
ScrollView {
|
||||
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
@ -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)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
textView.inlinePredictionType = .no
|
||||
#endif
|
||||
|
||||
#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)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationMedia.mediaViewer(
|
||||
attachments: attachments,
|
||||
selectedAttachment: attachments[0]))
|
||||
#else
|
||||
selectedAttachment: attachments[0]
|
||||
))
|
||||
#else
|
||||
quickLook.prepareFor(selectedMediaAttachment: attachments[0], mediaAttachments: attachments)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ import SwiftUI
|
|||
}
|
||||
|
||||
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)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.localStatus ?? viewModel.status))
|
||||
#else
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.localStatus ?? viewModel.status)
|
||||
#endif
|
||||
#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,9 +84,8 @@ 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)
|
||||
|
@ -125,14 +125,12 @@ public struct StatusRowCardView: View {
|
|||
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()
|
||||
|
|
|
@ -55,20 +55,20 @@ struct StatusRowContextMenu: View {
|
|||
systemImage: "bookmark")
|
||||
}
|
||||
Button {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.status))
|
||||
#else
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
||||
#endif
|
||||
#endif
|
||||
} label: {
|
||||
Label("status.action.reply", systemImage: "arrowshape.turn.up.left")
|
||||
}
|
||||
Button {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.quoteStatusEditor(status: viewModel.status))
|
||||
#else
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .quoteStatusEditor(status: viewModel.status)
|
||||
#endif
|
||||
#endif
|
||||
} label: {
|
||||
Label("status.action.quote", systemImage: "quote.bubble")
|
||||
}
|
||||
|
@ -171,11 +171,11 @@ struct StatusRowContextMenu: View {
|
|||
}
|
||||
if currentInstance.isEditSupported {
|
||||
Button {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.editStatusEditor(status: viewModel.status.reblogAsAsStatus ?? viewModel.status))
|
||||
#else
|
||||
#else
|
||||
viewModel.routerPath.presentedSheet = .editStatusEditor(status: viewModel.status.reblogAsAsStatus ?? viewModel.status)
|
||||
#endif
|
||||
#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() {}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ struct StatusRowReplyView: View {
|
|||
.accessibilityLabel(
|
||||
Text("status.row.was-reply \(mention.username)")
|
||||
)
|
||||
} else if viewModel.isThread && accountId == viewModel.status.account.id {
|
||||
} else if viewModel.isThread, accountId == viewModel.status.account.id {
|
||||
HStack(spacing: 2) {
|
||||
Image(systemName: "quote.opening")
|
||||
Text("status.row.is-thread")
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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