mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
swiftformat now enforces newlines for ifs
This commit is contained in:
@@ -105,7 +105,9 @@ class AppLockSetupFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
switch (fromState, event) {
|
||||
case (.initial, .start):
|
||||
if presentingFlow == .onboarding { return .createPIN(replacingExitingPIN: false) }
|
||||
if presentingFlow == .onboarding {
|
||||
return .createPIN(replacingExitingPIN: false)
|
||||
}
|
||||
return appLockService.isEnabled ? .unlock : .createPIN(replacingExitingPIN: false)
|
||||
case (.unlock, .pinEntered):
|
||||
return .settings
|
||||
|
||||
@@ -113,14 +113,20 @@ private func signPow(_ value: Float, _ exp: Float) -> Float {
|
||||
|
||||
private func linearTosRGB(_ value: Float) -> Int {
|
||||
let v = max(0, min(1, value))
|
||||
if v <= 0.0031308 { return Int(v * 12.92 * 255 + 0.5) }
|
||||
else { return Int((1.055 * pow(v, 1 / 2.4) - 0.055) * 255 + 0.5) }
|
||||
if v <= 0.0031308 {
|
||||
return Int(v * 12.92 * 255 + 0.5)
|
||||
} else {
|
||||
return Int((1.055 * pow(v, 1 / 2.4) - 0.055) * 255 + 0.5)
|
||||
}
|
||||
}
|
||||
|
||||
private func sRGBToLinear<Type: BinaryInteger>(_ value: Type) -> Float {
|
||||
let v = Float(Int64(value)) / 255
|
||||
if v <= 0.04045 { return v / 12.92 }
|
||||
else { return pow((v + 0.055) / 1.055, 2.4) }
|
||||
if v <= 0.04045 {
|
||||
return v / 12.92
|
||||
} else {
|
||||
return pow((v + 0.055) / 1.055, 2.4)
|
||||
}
|
||||
}
|
||||
|
||||
private let encodeCharacters: [String] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~".map { String($0) }
|
||||
|
||||
@@ -137,14 +137,20 @@ private func signPow(_ value: Float, _ exp: Float) -> Float {
|
||||
|
||||
private func linearTosRGB(_ value: Float) -> Int {
|
||||
let v = max(0, min(1, value))
|
||||
if v <= 0.0031308 { return Int(v * 12.92 * 255 + 0.5) }
|
||||
else { return Int((1.055 * pow(v, 1 / 2.4) - 0.055) * 255 + 0.5) }
|
||||
if v <= 0.0031308 {
|
||||
return Int(v * 12.92 * 255 + 0.5)
|
||||
} else {
|
||||
return Int((1.055 * pow(v, 1 / 2.4) - 0.055) * 255 + 0.5)
|
||||
}
|
||||
}
|
||||
|
||||
private func sRGBToLinear<Type: BinaryInteger>(_ value: Type) -> Float {
|
||||
let v = Float(Int64(value)) / 255
|
||||
if v <= 0.04045 { return v / 12.92 }
|
||||
else { return pow((v + 0.055) / 1.055, 2.4) }
|
||||
if v <= 0.04045 {
|
||||
return v / 12.92
|
||||
} else {
|
||||
return pow((v + 0.055) / 1.055, 2.4)
|
||||
}
|
||||
}
|
||||
|
||||
private let encodeCharacters: [String] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~".map { String($0) }
|
||||
|
||||
@@ -113,8 +113,12 @@ nonisolated extension String {
|
||||
let isStrongRTL = (0x0590...0x08FF).contains(value) ||
|
||||
(0xFB1D...0xFDFF).contains(value) ||
|
||||
(0xFE70...0xFEFF).contains(value)
|
||||
if isStrongRTL { return true }
|
||||
if scalar.properties.isAlphabetic { return false }
|
||||
if isStrongRTL {
|
||||
return true
|
||||
}
|
||||
if scalar.properties.isAlphabetic {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -43,7 +43,9 @@ struct PINTextField: View {
|
||||
|
||||
func sanitize(_ pinCode: String) -> String {
|
||||
var sanitized = pinCode
|
||||
if sanitized.count > maxLength { sanitized = String(pinCode.prefix(maxLength)) }
|
||||
if sanitized.count > maxLength {
|
||||
sanitized = String(pinCode.prefix(maxLength))
|
||||
}
|
||||
return sanitized.filter(\.isNumber)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,9 @@ extension HomeScreenRoom {
|
||||
|
||||
let callBadge = if summary.hasOngoingCall {
|
||||
summary.activeCallIntent == .audio ? CallBadgeType.voice : CallBadgeType.video
|
||||
} else { CallBadgeType.none }
|
||||
} else {
|
||||
CallBadgeType.none
|
||||
}
|
||||
|
||||
let type: HomeScreenRoom.RoomType = switch summary.joinRequestType {
|
||||
case .invite(let inviter): .invite(inviterDetails: inviter.map(RoomInviterDetails.init))
|
||||
|
||||
@@ -49,7 +49,9 @@ struct InviteUsersScreenViewState: BindableState {
|
||||
}
|
||||
|
||||
func isUserDisabled(_ user: UserProfileProxy) -> Bool {
|
||||
if isInviteeMandatory(user) { return true }
|
||||
if isInviteeMandatory(user) {
|
||||
return true
|
||||
}
|
||||
let membershipState = membershipState(user)
|
||||
return membershipState == .invite || membershipState == .join
|
||||
}
|
||||
|
||||
@@ -38,7 +38,11 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.appSettings = appSettings
|
||||
|
||||
let mandatoryInvitees: [UserProfileProxy] = if case .draft(let invitees) = roomType { invitees } else { [] }
|
||||
let mandatoryInvitees: [UserProfileProxy] = if case .draft(let invitees) = roomType {
|
||||
invitees
|
||||
} else {
|
||||
[]
|
||||
}
|
||||
|
||||
super.init(initialViewState: InviteUsersScreenViewState(selectedUsers: mandatoryInvitees,
|
||||
mandatoryInvitees: mandatoryInvitees,
|
||||
|
||||
@@ -30,7 +30,9 @@ enum LocationSharingInteractionMode: Hashable {
|
||||
case viewLive(sender: TimelineItemSender?, initialLiveLocationShare: LiveLocationShare?)
|
||||
|
||||
var isPicker: Bool {
|
||||
if case .picker = self { return true }
|
||||
if case .picker = self {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -97,7 +99,9 @@ struct LocationSharingScreenViewState: BindableState {
|
||||
case .viewLive:
|
||||
return liveLocationShares.compactMap { share in
|
||||
guard let geoURI = share.geoURI else { return nil }
|
||||
if share.userID == ownUserID, isStoppingLiveLocation { return nil }
|
||||
if share.userID == ownUserID, isStoppingLiveLocation {
|
||||
return nil
|
||||
}
|
||||
|
||||
let profile = userProfiles[share.userID] ?? UserProfileProxy(userID: share.userID)
|
||||
let kind = LocationMarkerKind.liveUser(profile)
|
||||
|
||||
@@ -145,8 +145,12 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
state.liveLocationShares = liveLocationsShares
|
||||
.filter { !(isStoppingLiveLocation && ownUserID == $0.userID) }
|
||||
.sorted { lhs, rhs in
|
||||
if lhs.userID == ownUserID { return true }
|
||||
if rhs.userID == ownUserID { return false }
|
||||
if lhs.userID == ownUserID {
|
||||
return true
|
||||
}
|
||||
if rhs.userID == ownUserID {
|
||||
return false
|
||||
}
|
||||
return lhs.timestamp > rhs.timestamp
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -271,8 +271,12 @@ private struct PreviewView: UIViewControllerRepresentable {
|
||||
|
||||
private func previewItemTitle(for url: URL) -> String? {
|
||||
guard let type = UTType(filenameExtension: url.pathExtension) else { return view.title }
|
||||
if type.conforms(to: .image) { return L10n.a11yPhotoPreview }
|
||||
if type.conforms(to: .movie) || type.conforms(to: .video) { return L10n.a11yVideoPreview }
|
||||
if type.conforms(to: .image) {
|
||||
return L10n.a11yPhotoPreview
|
||||
}
|
||||
if type.conforms(to: .movie) || type.conforms(to: .video) {
|
||||
return L10n.a11yVideoPreview
|
||||
}
|
||||
return view.title
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,9 @@ struct RoomScreen: View {
|
||||
.alert(item: $context.alertInfo)
|
||||
.timelineMediaPreview(viewModel: $context.mediaPreviewViewModel)
|
||||
.onChange(of: pillSourceButtonIsVisible) { _, isVisible in
|
||||
if !isVisible { dismissMarkAsReadPill() }
|
||||
if !isVisible {
|
||||
dismissMarkAsReadPill()
|
||||
}
|
||||
}
|
||||
.track(screen: .Room)
|
||||
.sentryTrace("\(Self.self)")
|
||||
|
||||
@@ -286,7 +286,9 @@ struct TimelineState {
|
||||
/// value to ``itemsDictionary``.
|
||||
mutating func recomputeReadMarkerUniqueID() {
|
||||
readMarkerUniqueID = itemsDictionary.first { _, viewState in
|
||||
if case .readMarker = viewState.type { return true }
|
||||
if case .readMarker = viewState.type {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}?.key
|
||||
}
|
||||
|
||||
@@ -103,7 +103,9 @@ class TimelineTableViewController: UIViewController {
|
||||
var isLive = true {
|
||||
didSet {
|
||||
// Update isScrolledToBottom when switching back to a live timeline.
|
||||
if isLive { scrollViewDidScroll(tableView) }
|
||||
if isLive {
|
||||
scrollViewDidScroll(tableView)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -113,7 +113,11 @@ struct TimelineItemMenuActionProvider {
|
||||
}
|
||||
|
||||
if canRedactItem(item) {
|
||||
let isMedia = if case .media = timelineKind { true } else { false }
|
||||
let isMedia = if case .media = timelineKind {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
secondaryActions.append(.redact(isMedia: isMedia))
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,9 @@ struct SessionVerificationViewModelTests {
|
||||
|
||||
let deferred = deferFulfillment(sessionVerificationController.actions
|
||||
.delay(for: .seconds(0.1), scheduler: DispatchQueue.main)) { callback in
|
||||
if case .finished = callback { return true }
|
||||
if case .finished = callback {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -92,7 +94,9 @@ struct SessionVerificationViewModelTests {
|
||||
|
||||
let deferred = deferFulfillment(sessionVerificationController.actions
|
||||
.delay(for: .seconds(0.1), scheduler: DispatchQueue.main)) { callback in
|
||||
if case .cancelled = callback { return true }
|
||||
if case .cancelled = callback {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,9 @@ public struct ListRowLabel<Icon: View>: View {
|
||||
|
||||
var iconForegroundColor: Color {
|
||||
guard isEnabled else { return .compound.iconTertiaryAlpha }
|
||||
if role == .destructive { return .compound.iconCriticalPrimary }
|
||||
if role == .destructive {
|
||||
return .compound.iconCriticalPrimary
|
||||
}
|
||||
if hideIconBackground {
|
||||
return .compound.iconTertiaryAlpha
|
||||
} else {
|
||||
@@ -111,7 +113,9 @@ public struct ListRowLabel<Icon: View>: View {
|
||||
}
|
||||
|
||||
var iconBackgroundColor: Color {
|
||||
if hideIconBackground { return .clear }
|
||||
if hideIconBackground {
|
||||
return .clear
|
||||
}
|
||||
if #available(iOS 26, *) {
|
||||
return .clear
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user