mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:11:45 +00:00
Swift format enforce isEmpty rule (#5843)
* swift format enforce isEmpty rule * revert scheme * use trailing closure
This commit is contained in:
@@ -75,7 +75,7 @@ extension UIImage {
|
||||
hash += sizeFlag.encode83(length: 1)
|
||||
|
||||
let maximumValue: Float
|
||||
if ac.count > 0 {
|
||||
if !ac.isEmpty {
|
||||
let actualMaximumValue = ac.map { max(abs($0.0), abs($0.1), abs($0.2)) }.max()!
|
||||
let quantisedMaximumValue = Int(max(0, min(82, floor(actualMaximumValue * 166 - 0.5))))
|
||||
maximumValue = Float(quantisedMaximumValue + 1) / 166
|
||||
|
||||
@@ -24,7 +24,7 @@ nonisolated struct CollapsibleReactionLayout: Layout {
|
||||
var rowsBeforeCollapsible: Int?
|
||||
|
||||
func sizeThatFits(proposal: ProposedViewSize, subviews: some FlowLayoutSubviews, cache: inout ()) -> CGSize {
|
||||
guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), subviewsByType.reactions.count > 0 else {
|
||||
guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), !subviewsByType.reactions.isEmpty else {
|
||||
return .zero
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ nonisolated struct CollapsibleReactionLayout: Layout {
|
||||
}
|
||||
|
||||
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: some FlowLayoutSubviews, cache: inout ()) {
|
||||
guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), subviewsByType.reactions.count > 0 else {
|
||||
guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), !subviewsByType.reactions.isEmpty else {
|
||||
subviews.forEach { subview in
|
||||
subview.place(at: Self.pointOffscreen, anchor: .leading, proposal: .zero)
|
||||
}
|
||||
@@ -119,7 +119,7 @@ nonisolated struct CollapsibleReactionLayout: Layout {
|
||||
currentRow.append(subview)
|
||||
}
|
||||
// If there are items in the current row remember to append it to the returned value
|
||||
if currentRow.count > 0 {
|
||||
if !currentRow.isEmpty {
|
||||
rows.append(currentRow)
|
||||
}
|
||||
return rows
|
||||
@@ -243,7 +243,7 @@ nonisolated struct CollapsibleReactionLayout: Layout {
|
||||
addMoreButton = subview
|
||||
}
|
||||
}
|
||||
guard let collapseButton, let addMoreButton, reactions.count > 0 else {
|
||||
guard let collapseButton, let addMoreButton, !reactions.isEmpty else {
|
||||
return nil
|
||||
}
|
||||
return ReactionSubviews(reactions: reactions, collapseButton: collapseButton, addMoreButton: addMoreButton)
|
||||
|
||||
@@ -40,7 +40,7 @@ extension XCUIApplication {
|
||||
/// app instance anyway, and some of our tests assert that a default focus has been set on the text field,
|
||||
/// so having a method that would set the focus and show the keyboard isn't always desirable.
|
||||
func showKeyboardIfNeeded() {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad, keyboards.count == 0 {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad, keyboards.isEmpty {
|
||||
buttons["Keyboard"].tap()
|
||||
buttons["Show Keyboard"].tap()
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ nonisolated struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
TextParsingMatch(type: .atRoom, range: match.range)
|
||||
})
|
||||
|
||||
guard matches.count > 0 else {
|
||||
guard !matches.isEmpty else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ struct RoomAvatarImage: View {
|
||||
onTap: onAvatarTap)
|
||||
case .heroes(let users):
|
||||
// We will expand upon this with more stack sizes in the future.
|
||||
if users.count == 0 {
|
||||
if users.isEmpty {
|
||||
let _ = assertionFailure("We should never pass empty heroes here.")
|
||||
PlaceholderAvatarImage(name: nil, contentID: "")
|
||||
} else if users.count == 2 {
|
||||
|
||||
Reference in New Issue
Block a user