mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Run SwiftFormat.
This commit is contained in:
@@ -81,7 +81,7 @@ private extension [Bit] {
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
|
||||
mutating func takeBits16(_ count: Int) throws(BitError) -> UInt16 {
|
||||
guard count <= 16 else { throw .moreThan16BitsTaken }
|
||||
|
||||
@@ -92,7 +92,7 @@ private extension [Bit] {
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
|
||||
mutating func takeUInt8() throws(BitError) -> UInt8 {
|
||||
try takeBits(8)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ extension View {
|
||||
})
|
||||
return alert(item.wrappedValue?.title ?? "", isPresented: binding, presenting: item.wrappedValue, actions: actions, message: message)
|
||||
}
|
||||
|
||||
|
||||
// periphery: ignore - not used yet but might be useful
|
||||
func alert<Item: AlertProtocol, Actions: View>(item: Binding<Item?>, @ViewBuilder actions: (Item) -> Actions) -> some View {
|
||||
let binding = Binding<Bool>(get: {
|
||||
@@ -51,7 +51,7 @@ struct AlertInfo<T: Hashable>: Identifiable, AlertProtocol {
|
||||
var role: ButtonRole?
|
||||
let action: (() -> Void)?
|
||||
}
|
||||
|
||||
|
||||
struct AlertTextField: Identifiable {
|
||||
let id = UUID()
|
||||
let placeholder: String
|
||||
@@ -59,7 +59,7 @@ struct AlertInfo<T: Hashable>: Identifiable, AlertProtocol {
|
||||
let autoCapitalization: TextInputAutocapitalization
|
||||
let autoCorrectionDisabled: Bool
|
||||
}
|
||||
|
||||
|
||||
/// An identifier that can be used to distinguish one error from another.
|
||||
let id: T
|
||||
/// The alert's title.
|
||||
@@ -86,7 +86,7 @@ extension AlertInfo {
|
||||
title = L10n.commonError
|
||||
message = L10n.errorUnknown
|
||||
}
|
||||
|
||||
|
||||
// periphery: ignore - might be useful in the future
|
||||
/// Initialises the type with the title from an `Error`'s localised description along with the default Ok button.
|
||||
///
|
||||
@@ -109,7 +109,7 @@ extension View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if let textFields = item.textFields {
|
||||
VStack(spacing: 24) {
|
||||
ForEach(textFields) { textField in
|
||||
@@ -119,12 +119,12 @@ extension View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Button(item.primaryButton.title, role: item.primaryButton.role) {
|
||||
item.primaryButton.action?()
|
||||
}
|
||||
.accessibilityIdentifier(A11yIdentifiers.alertInfo.primaryButton)
|
||||
|
||||
|
||||
if let secondaryButton = item.secondaryButton {
|
||||
Button(secondaryButton.title, role: secondaryButton.role) {
|
||||
secondaryButton.action?()
|
||||
|
||||
@@ -36,7 +36,7 @@ extension AttributedString {
|
||||
case (false, false):
|
||||
.plainText
|
||||
}
|
||||
|
||||
|
||||
components.append(AttributedStringBuilderComponent(id: String(attributedString.characters),
|
||||
attributedString: attributedString,
|
||||
type: componentType))
|
||||
|
||||
@@ -28,9 +28,9 @@ public extension Bundle {
|
||||
/// Overrides `Bundle.app.preferredLocalizations` for testing translations since this is
|
||||
/// only for testing, and is changed at runtime only in tests, it's fine to keep as `nonisolated(unsafe)`
|
||||
nonisolated(unsafe) static var overrideLocalizations: [String]?
|
||||
|
||||
|
||||
private static let cachedBundles = Mutex<[String: Bundle]>([:])
|
||||
|
||||
|
||||
/// Get an lproj language bundle from the receiver bundle.
|
||||
/// - Parameter language: The language to try to load.
|
||||
/// - Returns: The lproj bundle if found otherwise nil.
|
||||
@@ -38,24 +38,24 @@ public extension Bundle {
|
||||
if let bundle = cachedValue(forKey: language) {
|
||||
return bundle
|
||||
}
|
||||
|
||||
|
||||
guard let lprojURL = Bundle.app.url(forResource: language, withExtension: "lproj") else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
let bundle = Bundle(url: lprojURL)
|
||||
|
||||
|
||||
cacheValue(bundle, forKey: language)
|
||||
|
||||
|
||||
return bundle
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
||||
private static func cacheValue(_ value: Bundle?, forKey key: String) {
|
||||
cachedBundles.withLock { $0[key] = value }
|
||||
}
|
||||
|
||||
|
||||
private static func cachedValue(forKey key: String) -> Bundle? {
|
||||
cachedBundles.withLock { $0[key] }
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ extension ClientBuilder {
|
||||
.enableShareHistoryOnInvite(enableShareHistoryOnInvite: true)
|
||||
.autoEnableBackups(autoEnableBackups: true)
|
||||
}
|
||||
|
||||
|
||||
// Set recipient strategy and trust requirement even if `setupEncryption` is false to ensure messages
|
||||
// from insecure devices aren't displayed in push notifications.
|
||||
// See https://github.com/element-hq/element-x-ios/issues/4702.
|
||||
|
||||
@@ -25,7 +25,7 @@ extension View {
|
||||
})
|
||||
return confirmationDialog(item.wrappedValue?.title ?? "", isPresented: binding, titleVisibility: titleVisibility, presenting: item.wrappedValue, actions: actions)
|
||||
}
|
||||
|
||||
|
||||
// periphery: ignore - not used yet but might be useful
|
||||
func confirmationDialog<Item: ConfirmationDialogProtocol, Actions: View, Message: View>(item: Binding<Item?>,
|
||||
titleVisibility: Visibility = .automatic,
|
||||
|
||||
@@ -18,7 +18,7 @@ extension Encodable {
|
||||
}
|
||||
return json
|
||||
}
|
||||
|
||||
|
||||
func toJsonString(_ encoder: JSONEncoder = JSONEncoder()) throws -> String? {
|
||||
try toJsonDictionary(encoder).jsonString
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ extension FileManager {
|
||||
}
|
||||
return isDirectory.boolValue
|
||||
}
|
||||
|
||||
|
||||
func createDirectoryIfNeeded(at url: URL, withIntermediateDirectories: Bool = true) throws {
|
||||
guard !directoryExists(at: url) else {
|
||||
return
|
||||
@@ -36,7 +36,7 @@ extension FileManager {
|
||||
|
||||
return newURL
|
||||
}
|
||||
|
||||
|
||||
@discardableResult
|
||||
func writeDataToTemporaryDirectory(data: Data, fileName: String, withinAppGroupContainer: Bool = false) throws -> URL {
|
||||
let baseURL: URL = withinAppGroupContainer ? .appGroupTemporaryDirectory : .temporaryDirectory
|
||||
@@ -59,7 +59,7 @@ extension FileManager {
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
|
||||
func sizeForDirectory(at url: URL) throws -> UInt {
|
||||
guard let enumerator = enumerator(at: url, includingPropertiesForKeys: [.fileSizeKey, .isDirectoryKey]) else {
|
||||
throw FileManagerError.invalidFileSize
|
||||
|
||||
@@ -16,7 +16,7 @@ extension ImageCache {
|
||||
result.diskStorage.config.sizeLimit = 1
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
static var onlyOnDisk: ImageCache {
|
||||
let result = ImageCache.default
|
||||
result.memoryStorage.config.totalCostLimit = 1
|
||||
|
||||
@@ -133,7 +133,7 @@ extension NSItemProvider {
|
||||
guard registeredContentTypes.contains(where: { $0.conforms(to: .fileURL) }) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
for type in registeredContentTypes {
|
||||
if let fileExtension = type.preferredFilenameExtension {
|
||||
return .init(type: type, fileExtension: fileExtension)
|
||||
|
||||
@@ -17,7 +17,7 @@ extension ProcessInfo {
|
||||
false
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/// Flag indicating whether the app is running the UI tests.
|
||||
static var isRunningUITests: Bool {
|
||||
#if DEBUG
|
||||
@@ -42,7 +42,7 @@ extension ProcessInfo {
|
||||
false
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/// Flag indicating whether the app is running the UI tests or unit tests.
|
||||
static var isRunningTests: Bool {
|
||||
isRunningUITests || isRunningUnitTests || isRunningIntegrationTests || isRunningAccessibilityTests
|
||||
|
||||
@@ -11,7 +11,7 @@ import SwiftUI
|
||||
|
||||
struct SnapshotPrecisionPreferenceKey: PreferenceKey {
|
||||
static var defaultValue: Float = 1.0
|
||||
|
||||
|
||||
static func reduce(value: inout Float, nextValue: () -> Float) {
|
||||
value = nextValue()
|
||||
}
|
||||
@@ -19,7 +19,7 @@ struct SnapshotPrecisionPreferenceKey: PreferenceKey {
|
||||
|
||||
struct SnapshotPerceptualPrecisionPreferenceKey: PreferenceKey {
|
||||
static var defaultValue: Float = 0.98
|
||||
|
||||
|
||||
static func reduce(value: inout Float, nextValue: () -> Float) {
|
||||
value = nextValue()
|
||||
}
|
||||
@@ -27,7 +27,7 @@ struct SnapshotPerceptualPrecisionPreferenceKey: PreferenceKey {
|
||||
|
||||
struct SnapshotFulfillmentPreferenceKey: PreferenceKey {
|
||||
static var defaultValue: Wrapper?
|
||||
|
||||
|
||||
static func reduce(value: inout Wrapper?, nextValue: () -> Wrapper?) {
|
||||
value = nextValue()
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public extension Task where Success == Never, Failure == Never {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Dispatches the given throwing closure onto the given queue, wrapped within
|
||||
/// a continuation to make it non-blocking and awaitable.
|
||||
///
|
||||
@@ -59,7 +59,7 @@ extension Task {
|
||||
func store(in cancellables: inout Set<AnyCancellable>) {
|
||||
asCancellable().store(in: &cancellables)
|
||||
}
|
||||
|
||||
|
||||
func asCancellable() -> AnyCancellable {
|
||||
AnyCancellable(cancel)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ extension UIDevice {
|
||||
var isPhone: Bool {
|
||||
userInterfaceIdiom == .phone
|
||||
}
|
||||
|
||||
|
||||
var initialDeviceName: String {
|
||||
L10n.loginInitialDeviceNameIos(InfoPlistReader.main.bundleDisplayName)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ extension UNNotificationContent {
|
||||
@objc var receiverID: String? {
|
||||
userInfo[NotificationConstants.UserInfoKey.receiverIdentifier] as? String
|
||||
}
|
||||
|
||||
|
||||
@objc var roomID: String? {
|
||||
userInfo[NotificationConstants.UserInfoKey.roomIdentifier] as? String
|
||||
}
|
||||
@@ -21,7 +21,7 @@ extension UNNotificationContent {
|
||||
@objc var eventID: String? {
|
||||
userInfo[NotificationConstants.UserInfoKey.eventIdentifier] as? String
|
||||
}
|
||||
|
||||
|
||||
@objc var pusherNotificationClientIdentifier: String? {
|
||||
userInfo[NotificationConstants.UserInfoKey.pusherNotificationClientIdentifier] as? String
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@ extension URL {
|
||||
.appending(component: "Logs", directoryHint: .isDirectory)
|
||||
.appending(component: InfoPlistReader.main.baseBundleIdentifier, directoryHint: .isDirectory)
|
||||
}
|
||||
|
||||
|
||||
/// The base directory where all session data is stored.
|
||||
static var sessionsBaseDirectory: URL {
|
||||
let applicationSupportSessionsURL = applicationSupportBaseDirectory.appending(component: "Sessions", directoryHint: .isDirectory)
|
||||
|
||||
try? FileManager.default.createDirectoryIfNeeded(at: applicationSupportSessionsURL)
|
||||
|
||||
|
||||
return applicationSupportSessionsURL
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ extension URL {
|
||||
.appending(component: "Library", directoryHint: .isDirectory)
|
||||
.appending(component: "Application Support", directoryHint: .isDirectory)
|
||||
.appending(component: InfoPlistReader.main.baseBundleIdentifier, directoryHint: .isDirectory)
|
||||
|
||||
|
||||
try? FileManager.default.createDirectoryIfNeeded(at: url)
|
||||
|
||||
do {
|
||||
@@ -57,7 +57,7 @@ extension URL {
|
||||
} catch {
|
||||
MXLog.error("Failed excluding Application Support from backups")
|
||||
}
|
||||
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
@@ -68,12 +68,12 @@ extension URL {
|
||||
.appending(component: "Caches", directoryHint: .isDirectory)
|
||||
.appending(component: InfoPlistReader.main.baseBundleIdentifier, directoryHint: .isDirectory)
|
||||
.appending(component: "Sessions", directoryHint: .isDirectory)
|
||||
|
||||
|
||||
try? FileManager.default.createDirectoryIfNeeded(at: url)
|
||||
|
||||
// Caches are excluded from backups automatically.
|
||||
// https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
|
||||
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
@@ -84,12 +84,12 @@ extension URL {
|
||||
static var appGroupTemporaryDirectory: URL {
|
||||
let url = appGroupContainerDirectory
|
||||
.appending(component: "tmp", directoryHint: .isDirectory)
|
||||
|
||||
|
||||
try? FileManager.default.createDirectoryIfNeeded(at: url)
|
||||
|
||||
// Temporary files are excluded from backups automatically.
|
||||
// https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
|
||||
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ extension URL {
|
||||
|
||||
MXLog.info("Found \(String(describing: proxies?.count)) proxies, using the first one.")
|
||||
MXLog.info("Proxy type is \(proxyType)")
|
||||
|
||||
|
||||
guard let host = firstProxy[kCFProxyHostNameKey] as? String else {
|
||||
MXLog.error("Found proxy with invalid host name")
|
||||
return nil
|
||||
@@ -138,23 +138,23 @@ extension URL {
|
||||
static var mockMXCAudio: URL {
|
||||
"mxc://matrix.org/1234567890AuDiO"
|
||||
}
|
||||
|
||||
|
||||
static var mockMXCFile: URL {
|
||||
"mxc://matrix.org/1234567890FiLe"
|
||||
}
|
||||
|
||||
|
||||
static var mockMXCImage: URL {
|
||||
"mxc://matrix.org/1234567890ImAgE"
|
||||
}
|
||||
|
||||
|
||||
static var mockMXCVideo: URL {
|
||||
"mxc://matrix.org/1234567890ViDeO"
|
||||
}
|
||||
|
||||
|
||||
static var mockMXCAvatar: URL {
|
||||
"mxc://matrix.org/1234567890AvAtAr"
|
||||
}
|
||||
|
||||
|
||||
static var mockMXCUserAvatar: URL {
|
||||
"mxc://matrix.org/1234567890AvAtArUsEr"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user