SwiftFormat

This commit is contained in:
Thomas Ricouard 2023-12-18 08:22:59 +01:00
parent 2145bd5971
commit 8ff3e22d9f
55 changed files with 472 additions and 450 deletions

View file

@ -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 {

View file

@ -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
}
}
}

View file

@ -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

View file

@ -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]
}
}

View file

@ -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)
}
}

View file

@ -84,7 +84,8 @@ struct AccountDetailHeaderView: View {
#if targetEnvironment(macCatalyst)
openWindow(value: WindowDestinationMedia.mediaViewer(
attachments: [attachement],
selectedAttachment: attachement))
selectedAttachment: attachement
))
#else
quickLook.prepareFor(selectedMediaAttachment: attachement, mediaAttachments: [attachement])
#endif

View file

@ -1,7 +1,7 @@
import DesignSystem
import Env
import Models
import Network
import Env
import SwiftUI
@MainActor

View file

@ -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
}

View file

@ -1,9 +1,9 @@
import Env
import Models
import Nuke
import NukeUI
import Shimmer
import SwiftUI
import Models
struct AccountPopoverView: View {
let account: Account
@ -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)
}
@ -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))
}
}

View file

@ -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,7 +41,7 @@ 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
}
@ -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 {

View file

@ -1,6 +1,6 @@
import SwiftUI
import Charts
import Models
import SwiftUI
public struct TagChartView: View {
@State private var sortedHistory: [Tag.History] = []

View file

@ -1,9 +1,9 @@
import DesignSystem
import EmojiText
import Env
import Models
import Network
import SwiftUI
import Env
@MainActor
public struct ListCreateView: View {
@ -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)

View file

@ -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 {
}
}
}
}

View file

@ -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 {
@ -53,10 +53,10 @@ import Env
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
@ -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"
}
}
}

View file

@ -11,7 +11,7 @@ public struct List: Codable, Identifiable, Equatable, Hashable {
rawValue
}
case followed, list, `none`
case followed, list, none
}
}

View file

@ -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

View file

@ -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),

View file

@ -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
}
}
}

View file

@ -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
}
}

View file

@ -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: "Whats 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: "Whats 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))])])
}
}
}

View file

@ -54,7 +54,7 @@ import SwiftUI
}
func loadSelectedType() {
self.client = client
client = client
guard let value = UserDefaults.standard.string(forKey: filterKey)
else {

View file

@ -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

View file

@ -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 ?? "")
}

View file

@ -1,10 +1,10 @@
import DesignSystem
import Env
import GiphyUISDK
import Models
import NukeUI
import PhotosUI
import SwiftUI
import GiphyUISDK
@MainActor
struct StatusEditorAccessoryView: View {
@ -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)
}

View file

@ -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")
}
}
}
}

View file

@ -1,10 +1,10 @@
import AVKit
import DesignSystem
import Env
import MediaUI
import Models
import NukeUI
import SwiftUI
import MediaUI
@MainActor
struct StatusEditorMediaView: View {
@ -51,7 +51,7 @@ struct StatusEditorMediaView: View {
#if targetEnvironment(macCatalyst)
private var showsScrollIndicators: Bool { count > 1 }
private var scrollBottomPadding : CGFloat? = nil
private var scrollBottomPadding: CGFloat?
#else
private var showsScrollIndicators: Bool = false
private var scrollBottomPadding: CGFloat? = 0
@ -59,7 +59,7 @@ struct StatusEditorMediaView: View {
init(viewModel: StatusEditorViewModel, editingMediaContainer: Binding<StatusEditorMediaContainer?>) {
self.viewModel = viewModel
self._editingMediaContainer = editingMediaContainer
_editingMediaContainer = editingMediaContainer
}
private func pixel(at index: Int) -> some View {

View file

@ -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 {

View file

@ -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 {
}
}
}

View file

@ -1,7 +1,7 @@
import SwiftUI
import Env
import Models
import StoreKit
import SwiftUI
@MainActor
struct StatusEditorToolbarItems: ToolbarContent {
@ -81,7 +81,7 @@ 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)

View file

@ -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 {

View file

@ -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))
}

View file

@ -49,7 +49,6 @@ extension TextView.Representable {
textView.inlinePredictionType = .no
#endif
self.getTextView?(textView)
}

View file

@ -228,7 +228,8 @@ public struct StatusRowView: View {
#if targetEnvironment(macCatalyst)
openWindow(value: WindowDestinationMedia.mediaViewer(
attachments: attachments,
selectedAttachment: attachments[0]))
selectedAttachment: attachments[0]
))
#else
quickLook.prepareFor(selectedMediaAttachment: attachments[0], mediaAttachments: attachments)
#endif

View file

@ -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
@ -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()

View file

@ -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() {}
}

View file

@ -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
}

View file

@ -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")

View file

@ -1,6 +1,6 @@
import DesignSystem
import SwiftUI
import Env
import SwiftUI
struct StatusRowTagView: View {
@Environment(CurrentAccount.self) private var currentAccount

View file

@ -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 {

View file

@ -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,