Swiftformat .

This commit is contained in:
Thomas Ricouard 2023-02-22 19:09:39 +01:00
parent 4af78478ba
commit a4910037b8
18 changed files with 67 additions and 70 deletions

View file

@ -112,7 +112,7 @@ struct IceCubesApp: App {
popToRootTab: $popToRootTab,
tabs: availableTabs,
routerPath: sidebarRouterPath) {
GeometryReader { proxy in
GeometryReader { _ in
HStack(spacing: 0) {
ZStack {
if selectedTab == .profile {

View file

@ -68,8 +68,8 @@ extension AppQLPreviewController: QLPreviewControllerDelegate {
func previewControllerWillDismiss(_: QLPreviewController) {
dismiss(animated: true)
}
func previewControllerDidDismiss(_ controller: QLPreviewController) {
func previewControllerDidDismiss(_: QLPreviewController) {
dismiss(animated: true)
}
}

View file

@ -86,7 +86,7 @@ struct NotificationsTab: View {
routerPath.path = []
}
}
private func clearNotifications() {
if isSecondaryColumn {
if let token = appAccount.currentAccount.oauthToken {

View file

@ -9,37 +9,36 @@ struct SwipeActionsSettingsView: View {
var body: some View {
Form {
Section {
Label("settings.swipeactions.status.leading", systemImage: "arrow.right")
.foregroundColor(.secondary)
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusLeadingLeft,
label: "settings.swipeactions.primary")
label: "settings.swipeactions.primary")
.onChange(of: userPreferences.swipeActionsStatusLeadingLeft) { action in
if action == .none {
userPreferences.swipeActionsStatusLeadingRight = .none;
userPreferences.swipeActionsStatusLeadingRight = .none
}
}
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusLeadingRight,
label: "settings.swipeactions.secondary")
.disabled(userPreferences.swipeActionsStatusLeadingLeft == .none)
label: "settings.swipeactions.secondary")
.disabled(userPreferences.swipeActionsStatusLeadingLeft == .none)
Label("settings.swipeactions.status.trailing", systemImage: "arrow.left")
.foregroundColor(.secondary)
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusTrailingRight,
label: "settings.swipeactions.primary")
label: "settings.swipeactions.primary")
.onChange(of: userPreferences.swipeActionsStatusTrailingRight) { action in
if action == .none {
userPreferences.swipeActionsStatusTrailingLeft = .none;
userPreferences.swipeActionsStatusTrailingLeft = .none
}
}
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusTrailingLeft,
label: "settings.swipeactions.secondary")
label: "settings.swipeactions.secondary")
.disabled(userPreferences.swipeActionsStatusTrailingRight == .none)
} header: {
Text("settings.swipeactions.status")
} footer: {
@ -82,5 +81,4 @@ struct SwipeActionsSettingsView: View {
}
}
}
}

View file

@ -197,7 +197,7 @@ struct AccountDetailHeaderView: View {
if account.bot {
Text("🤖")
}
if account.locked{
if account.locked {
Text("🔒")
}
Image(systemName: "calendar")

View file

@ -127,7 +127,7 @@ struct ConversationMessageView: View {
private func makeImageRequest(for url: URL, size: CGSize) -> ImageRequest {
ImageRequest(url: url, processors: [.resize(size: size)])
}
private func mediaWidth(proxy: GeometryProxy) -> CGFloat {
var width = proxy.frame(in: .local).width
if UIDevice.current.userInterfaceIdiom == .pad {
@ -135,7 +135,7 @@ struct ConversationMessageView: View {
}
return width
}
private func makeMediaView(_ attachement: MediaAttachment) -> some View {
GeometryReader { proxy in
let width = mediaWidth(proxy: proxy)

View file

@ -42,7 +42,7 @@ public struct SecondaryColumnToolbarItem: ToolbarContent {
@EnvironmentObject private var preferences: UserPreferences
public init() {}
public var body: some ToolbarContent {
ToolbarItem(placement: isSecondaryColumn ? .navigationBarLeading : .navigationBarTrailing) {
Button {

View file

@ -19,7 +19,7 @@ public enum StatusAction: String, CaseIterable, Identifiable {
if privateBoost {
return isReblogged ? "status.action.unboost" : "status.action.boost-to-followers"
}
return isReblogged ? "status.action.unboost" : "settings.swipeactions.status.action.boost"
case .favorite:
return isFavorited ? "status.action.unfavorite" : "settings.swipeactions.status.action.favorite"
@ -40,7 +40,7 @@ public enum StatusAction: String, CaseIterable, Identifiable {
if privateBoost {
return isReblogged ? "arrow.left.arrow.right.circle.fill" : "lock.rotation"
}
return isReblogged ? "arrow.left.arrow.right.circle.fill" : "arrow.left.arrow.right.circle"
case .favorite:
return isFavorited ? "star.fill" : "star"

View file

@ -3,17 +3,17 @@ import Foundation
public final class Account: Codable, Identifiable, Hashable, Sendable, Equatable {
public static func == (lhs: Account, rhs: Account) -> Bool {
lhs.id == rhs.id &&
lhs.username == rhs.username &&
lhs.note.asRawText == rhs.note.asRawText &&
lhs.statusesCount == rhs.statusesCount &&
lhs.followersCount == rhs.followersCount &&
lhs.followingCount == rhs.followingCount &&
lhs.acct == rhs.acct &&
lhs.displayName == rhs.displayName &&
lhs.fields == rhs.fields &&
lhs.lastStatusAt == rhs.lastStatusAt &&
lhs.discoverable == rhs.discoverable &&
lhs.bot == rhs.bot
lhs.username == rhs.username &&
lhs.note.asRawText == rhs.note.asRawText &&
lhs.statusesCount == rhs.statusesCount &&
lhs.followersCount == rhs.followersCount &&
lhs.followingCount == rhs.followingCount &&
lhs.acct == rhs.acct &&
lhs.displayName == rhs.displayName &&
lhs.fields == rhs.fields &&
lhs.lastStatusAt == rhs.lastStatusAt &&
lhs.discoverable == rhs.discoverable &&
lhs.bot == rhs.bot
}
public func hash(into hasher: inout Hasher) {

View file

@ -13,7 +13,7 @@ struct StatusEditorMediaEditView: View {
@State private var imageDescription: String = ""
@FocusState private var isFieldFocused: Bool
@State private var isUpdating: Bool = false
var body: some View {
@ -23,7 +23,7 @@ struct StatusEditorMediaEditView: View {
TextField("status.editor.media.image-description",
text: $imageDescription,
axis: .vertical)
.focused($isFieldFocused)
.focused($isFieldFocused)
}
.listRowBackground(theme.primaryBackgroundColor)
Section {

View file

@ -1,6 +1,6 @@
import UIKit
import SwiftUI
import DesignSystem
import SwiftUI
import UIKit
extension ButtonStyle where Self == StatusActionButtonStyle {
static func statusAction(isOn: Bool = false, tintColor: Color? = nil) -> Self {
@ -98,14 +98,14 @@ struct StatusActionButtonStyle: ButtonStyle {
static func generateCells() -> [Cell] {
let cellCount = 16
let velocityRange = 0.6...1.0
let scaleRange = 0.5...1.0
let alphaRange = 0.6...1.0
let velocityRange = 0.6 ... 1.0
let scaleRange = 0.5 ... 1.0
let alphaRange = 0.6 ... 1.0
let spacing = 2 * .pi/(1.618 + Double(arc4random() % 200) / 10000)
let spacing = 2 * .pi / (1.618 + Double(arc4random() % 200) / 10000)
let initialSpacing = deg2rad(Double(arc4random() % 360))
return (0..<cellCount).map { index in
return Cell(
return (0 ..< cellCount).map { index in
Cell(
id: index,
angle: initialSpacing + spacing * Double(index),
velocity: random(within: velocityRange),
@ -116,13 +116,11 @@ struct StatusActionButtonStyle: ButtonStyle {
}
static func random(within range: ClosedRange<Double>) -> Double {
Double(arc4random()) / 0xFFFFFFFF * (range.upperBound - range.lowerBound) + range.lowerBound
Double(arc4random()) / 0xFFFF_FFFF * (range.upperBound - range.lowerBound) + range.lowerBound
}
static func deg2rad(_ number: Double) -> Double {
return number * .pi / 180
return number * .pi / 180
}
}
}

View file

@ -70,7 +70,7 @@ public struct StatusRowView: View {
.accessibilityAction {
viewModel.navigateToDetail()
}
if viewModel.showActions, (viewModel.isFocused || theme.statusActionsDisplay != .none), !isInCaptureMode {
if viewModel.showActions, viewModel.isFocused || theme.statusActionsDisplay != .none, !isInCaptureMode {
StatusRowActionsView(viewModel: viewModel)
.padding(.top, 8)
.tint(viewModel.isFocused ? theme.tintColor : .gray)

View file

@ -37,7 +37,7 @@ struct StatusRowActionsView: View {
}
func count(viewModel: StatusRowViewModel, theme: Theme) -> Int? {
if theme.statusActionsDisplay == .discret && !viewModel.isFocused {
if theme.statusActionsDisplay == .discret && !viewModel.isFocused {
return nil
}
switch self {
@ -116,7 +116,7 @@ struct StatusRowActionsView: View {
)
)
.disabled(action == .boost &&
(viewModel.status.visibility == .direct || viewModel.status.visibility == .priv && viewModel.status.account.id != currentAccount.account?.id))
(viewModel.status.visibility == .direct || viewModel.status.visibility == .priv && viewModel.status.account.id != currentAccount.account?.id))
if let count = action.count(viewModel: viewModel, theme: theme), !viewModel.isRemote {
Text("\(count)")
.foregroundColor(Color(UIColor.secondaryLabel))

View file

@ -10,27 +10,27 @@ public struct StatusRowCardView: View {
@Environment(\.isInCaptureMode) private var isInCaptureMode: Bool
@EnvironmentObject private var theme: Theme
let card: Card
public init(card: Card) {
self.card = card
}
private var maxWidth: CGFloat? {
if theme.statusDisplayStyle == .medium {
return 300
}
return nil
}
private func imageWidthFor(proxy: GeometryProxy) -> CGFloat {
if theme.statusDisplayStyle == .medium, let maxWidth {
return maxWidth
}
return proxy.frame(in: .local).width
}
private var imageHeight: CGFloat {
if theme.statusDisplayStyle == .medium {
return 100

View file

@ -145,7 +145,7 @@ struct StatusRowContextMenu: View {
await viewModel.translate(userLang: lang)
}
} label: {
Label("status.action.translate", systemImage: "captions.bubble")
Label("status.action.translate", systemImage: "captions.bubble")
}
}

View file

@ -27,7 +27,8 @@ public struct StatusRowMediaPreviewView: View {
var availableWidth: CGFloat {
if UIDevice.current.userInterfaceIdiom == .phone &&
(UIDevice.current.orientation == .landscapeLeft || UIDevice.current.orientation == .landscapeRight) || theme.statusDisplayStyle == .medium {
(UIDevice.current.orientation == .landscapeLeft || UIDevice.current.orientation == .landscapeRight) || theme.statusDisplayStyle == .medium
{
return sceneDelegate.windowWidth * 0.80
}
return sceneDelegate.windowWidth
@ -38,7 +39,7 @@ public struct StatusRowMediaPreviewView: View {
var sidebarWidth: CGFloat = 0
var secondaryColumnWidth: CGFloat = 0
let layoutPading: CGFloat = .layoutPadding * 2
if UIDevice.current.userInterfaceIdiom == .pad {
if UIDevice.current.userInterfaceIdiom == .pad {
sidebarWidth = .sidebarWidth
if preferences.showiPadSecondaryColumn {
secondaryColumnWidth = .secondaryColumnWidth

View file

@ -11,7 +11,7 @@ struct StatusRowSwipeView: View {
enum Mode {
case leading, trailing
}
func privateBoost() -> Bool {
return viewModel.status.visibility == .priv && viewModel.status.account.id == currentAccount.account?.id
}

View file

@ -25,15 +25,15 @@ struct StatusRowTranslateView: View {
}
}
private func getLocalizedString(langCode: String, provider: String) -> String {
if let localizedLanguage = Locale.current.localizedString(forLanguageCode: langCode) {
let format = NSLocalizedString("status.action.translated-label-from-%@-%@", comment: "")
return String.localizedStringWithFormat(format, localizedLanguage, provider)
} else {
return "status.action.translated-label-\(provider)"
}
private func getLocalizedString(langCode: String, provider: String) -> String {
if let localizedLanguage = Locale.current.localizedString(forLanguageCode: langCode) {
let format = NSLocalizedString("status.action.translated-label-from-%@-%@", comment: "")
return String.localizedStringWithFormat(format, localizedLanguage, provider)
} else {
return "status.action.translated-label-\(provider)"
}
}
var body: some View {
if !isInCaptureMode,
let userLang = preferences.serverPreferences?.postLanguage,
@ -47,7 +47,7 @@ struct StatusRowTranslateView: View {
if viewModel.isLoadingTranslation {
ProgressView()
} else {
Text("status.action.translate")
Text("status.action.translate")
}
}
.buttonStyle(.borderless)
@ -58,7 +58,7 @@ struct StatusRowTranslateView: View {
VStack(alignment: .leading, spacing: 4) {
Text(translation.content.asSafeMarkdownAttributedString)
.font(.scaledBody)
Text(getLocalizedString(langCode: translation.detectedSourceLanguage, provider: translation.provider))
Text(getLocalizedString(langCode: translation.detectedSourceLanguage, provider: translation.provider))
.font(.footnote)
.foregroundColor(.gray)
}