swiftformat now enforces newlines for ifs

This commit is contained in:
Mauro Romito
2026-06-19 13:46:46 +02:00
committed by Mauro
parent f32b9eeb26
commit 3aedd0ccff
17 changed files with 87 additions and 29 deletions
@@ -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
}
@@ -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)
}
}
}
@@ -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))
}