mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
Update files following swiftformat upgrade
This commit is contained in:
committed by
Stefan Ceriu
parent
fe189fcfed
commit
23062901c0
@@ -56,7 +56,9 @@ enum A11yIdentifiers {
|
||||
}
|
||||
|
||||
struct AppLockScreen {
|
||||
func numpad(_ digit: Int) -> String { "app_lock-numpad_\(digit)" }
|
||||
func numpad(_ digit: Int) -> String {
|
||||
"app_lock-numpad_\(digit)"
|
||||
}
|
||||
}
|
||||
|
||||
struct AppLockSetupBiometricsScreen {
|
||||
|
||||
@@ -15,7 +15,6 @@ struct ScreenTrackerViewModifier: ViewModifier {
|
||||
|
||||
let screen: AnalyticsEvent.MobileScreen.ScreenName
|
||||
|
||||
@ViewBuilder
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.onAppear {
|
||||
|
||||
@@ -13,7 +13,7 @@ enum Avatars {
|
||||
enum Size {
|
||||
case user(on: UserAvatarSizeOnScreen)
|
||||
case room(on: RoomAvatarSizeOnScreen)
|
||||
// custom
|
||||
/// custom
|
||||
case custom(CGFloat)
|
||||
|
||||
/// Value in UIKit points
|
||||
|
||||
@@ -102,11 +102,9 @@ private func decodeAC(_ value: Int, maximumValue: Float) -> (Float, Float, Float
|
||||
let quantG = (value / 19) % 19
|
||||
let quantB = value % 19
|
||||
|
||||
let rgb = (signPow((Float(quantR) - 9) / 9, 2) * maximumValue,
|
||||
signPow((Float(quantG) - 9) / 9, 2) * maximumValue,
|
||||
signPow((Float(quantB) - 9) / 9, 2) * maximumValue)
|
||||
|
||||
return rgb
|
||||
return (signPow((Float(quantR) - 9) / 9, 2) * maximumValue,
|
||||
signPow((Float(quantG) - 9) / 9, 2) * maximumValue,
|
||||
signPow((Float(quantB) - 9) / 9, 2) * maximumValue)
|
||||
}
|
||||
|
||||
private func signPow(_ value: Float, _ exp: Float) -> Float {
|
||||
|
||||
@@ -39,14 +39,12 @@ struct CollapsibleReactionLayout: Layout {
|
||||
rows: collapsedRows,
|
||||
collapseButton: subviewsByType.collapseButton,
|
||||
addMoreButton: subviewsByType.addMoreButton)
|
||||
let size = sizeThatFits(rows: collapsedRowsWithButtons)
|
||||
return size
|
||||
return sizeThatFits(rows: collapsedRowsWithButtons)
|
||||
} else {
|
||||
// Show all subviews with the button at the end
|
||||
var rowsWithButtons = calculateRows(proposal: proposal, subviews: Array(subviews))
|
||||
ensureCollapseAndAddMoreButtonsAreOnTheSameRow(&rowsWithButtons)
|
||||
let size = sizeThatFits(rows: rowsWithButtons)
|
||||
return size
|
||||
return sizeThatFits(rows: rowsWithButtons)
|
||||
}
|
||||
} else {
|
||||
// Otherwise we are just calculating the size of all items without the button
|
||||
|
||||
@@ -21,7 +21,7 @@ struct CurrentValuePublisher<Output, Failure: Error>: Publisher {
|
||||
self.init(CurrentValueSubject(value))
|
||||
}
|
||||
|
||||
func receive<S>(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input {
|
||||
func receive<S: Subscriber>(subscriber: S) where Failure == S.Failure, Output == S.Input {
|
||||
subject.receive(subscriber: subscriber)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ protocol AlertProtocol {
|
||||
}
|
||||
|
||||
extension View {
|
||||
func alert<Item, Actions, Message>(item: Binding<Item?>, @ViewBuilder actions: (Item) -> Actions, @ViewBuilder message: (Item) -> Message) -> some View where Item: AlertProtocol, Actions: View, Message: View {
|
||||
func alert<Item: AlertProtocol, Actions: View, Message: View>(item: Binding<Item?>, @ViewBuilder actions: (Item) -> Actions, @ViewBuilder message: (Item) -> Message) -> some View {
|
||||
let binding = Binding<Bool>(get: {
|
||||
item.wrappedValue != nil
|
||||
}, set: { newValue in
|
||||
@@ -25,7 +25,7 @@ extension View {
|
||||
}
|
||||
|
||||
// periphery: ignore - not used yet but might be useful
|
||||
func alert<Item, Actions>(item: Binding<Item?>, @ViewBuilder actions: (Item) -> Actions) -> some View where Item: AlertProtocol, Actions: View {
|
||||
func alert<Item: AlertProtocol, Actions: View>(item: Binding<Item?>, @ViewBuilder actions: (Item) -> Actions) -> some View {
|
||||
let binding = Binding<Bool>(get: {
|
||||
item.wrappedValue != nil
|
||||
}, set: { newValue in
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
extension AttributedString {
|
||||
// faster than doing `String(characters)`: https://forums.swift.org/t/attributedstring-to-string/61667
|
||||
/// faster than doing `String(characters)`: https://forums.swift.org/t/attributedstring-to-string/61667
|
||||
var string: String {
|
||||
String(characters[...])
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ protocol ConfirmationDialogProtocol {
|
||||
}
|
||||
|
||||
extension View {
|
||||
func confirmationDialog<Item, Actions>(item: Binding<Item?>,
|
||||
titleVisibility: Visibility = .automatic,
|
||||
@ViewBuilder actions: (Item) -> Actions) -> some View where Item: ConfirmationDialogProtocol, Actions: View {
|
||||
func confirmationDialog<Item: ConfirmationDialogProtocol, Actions: View>(item: Binding<Item?>,
|
||||
titleVisibility: Visibility = .automatic,
|
||||
@ViewBuilder actions: (Item) -> Actions) -> some View {
|
||||
let binding = Binding<Bool>(get: {
|
||||
item.wrappedValue != nil
|
||||
}, set: { newValue in
|
||||
@@ -27,10 +27,10 @@ extension View {
|
||||
}
|
||||
|
||||
// periphery: ignore - not used yet but might be useful
|
||||
func confirmationDialog<Item, Actions, Message>(item: Binding<Item?>,
|
||||
titleVisibility: Visibility = .automatic,
|
||||
@ViewBuilder actions: (Item) -> Actions,
|
||||
@ViewBuilder message: (Item) -> Message) -> some View where Item: ConfirmationDialogProtocol, Actions: View, Message: View {
|
||||
func confirmationDialog<Item: ConfirmationDialogProtocol, Actions: View, Message: View>(item: Binding<Item?>,
|
||||
titleVisibility: Visibility = .automatic,
|
||||
@ViewBuilder actions: (Item) -> Actions,
|
||||
@ViewBuilder message: (Item) -> Message) -> some View {
|
||||
let binding = Binding<Bool>(get: {
|
||||
item.wrappedValue != nil
|
||||
}, set: { newValue in
|
||||
|
||||
@@ -67,8 +67,8 @@ extension Date {
|
||||
}
|
||||
|
||||
private extension DateFormatter {
|
||||
// There doesn't appear to be a way to get "Today" out of
|
||||
// `Date.RelativeFormatStyle` so use the old way instead 😐
|
||||
/// There doesn't appear to be a way to get "Today" out of
|
||||
/// `Date.RelativeFormatStyle` so use the old way instead 😐
|
||||
static let relative: DateFormatter = {
|
||||
let formatter = DateFormatter()
|
||||
formatter.doesRelativeDateFormatting = true
|
||||
|
||||
@@ -197,5 +197,7 @@ extension NSItemProvider {
|
||||
}
|
||||
|
||||
private extension NSString {
|
||||
var hasPathExtension: Bool { !pathExtension.isEmpty }
|
||||
var hasPathExtension: Bool {
|
||||
!pathExtension.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
import OrderedCollections
|
||||
|
||||
extension OrderedSet {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import SwiftUI
|
||||
|
||||
extension Section where Parent == Color, Content == EmptyView, Footer == EmptyView {
|
||||
// An empty section whose purpose is to keep Form's background color when there is no content into it.
|
||||
/// An empty section whose purpose is to keep Form's background color when there is no content into it.
|
||||
static var empty: some View {
|
||||
Section {
|
||||
EmptyView()
|
||||
|
||||
@@ -135,12 +135,29 @@ extension URL {
|
||||
|
||||
// MARK: Mocks
|
||||
|
||||
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" }
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
@@ -96,7 +96,7 @@ extension XCTestCase {
|
||||
timeout: TimeInterval = 10,
|
||||
message: String? = nil) -> DeferredFulfillment<P.Output> {
|
||||
var expectedOrder = transitionValues
|
||||
let deferred = deferFulfillment(publisher, timeout: timeout, message: message) { value in
|
||||
return deferFulfillment(publisher, timeout: timeout, message: message) { value in
|
||||
let receivedValue = value[keyPath: keyPath]
|
||||
if let index = expectedOrder.firstIndex(where: { $0 == receivedValue }), index == 0 {
|
||||
expectedOrder.remove(at: index)
|
||||
@@ -104,8 +104,6 @@ extension XCTestCase {
|
||||
|
||||
return expectedOrder.isEmpty
|
||||
}
|
||||
|
||||
return deferred
|
||||
}
|
||||
|
||||
/// XCTest utility that assists in subscribing to an async sequence and deferring the fulfilment and results until some other actions have been performed.
|
||||
@@ -120,15 +118,13 @@ extension XCTestCase {
|
||||
timeout: TimeInterval = 10,
|
||||
message: String? = nil) -> DeferredFulfillment<Value> {
|
||||
var expectedOrder = transitionValues
|
||||
let deferred = deferFulfillment(asyncSequence, timeout: timeout, message: message) { value in
|
||||
return deferFulfillment(asyncSequence, timeout: timeout, message: message) { value in
|
||||
if let index = expectedOrder.firstIndex(where: { $0 == value }), index == 0 {
|
||||
expectedOrder.remove(at: index)
|
||||
}
|
||||
|
||||
return expectedOrder.isEmpty
|
||||
}
|
||||
|
||||
return deferred
|
||||
}
|
||||
|
||||
/// XCTest utility that assists in subscribing to a publisher and deferring the failure for a particular value until some other actions have been performed.
|
||||
|
||||
@@ -72,13 +72,13 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
return result
|
||||
}
|
||||
|
||||
// Do not use the default HTML renderer of NSAttributedString because this method
|
||||
// runs on the UI thread which we want to avoid because renderHTMLString is called
|
||||
// most of the time from a background thread.
|
||||
// Use DTCoreText HTML renderer instead.
|
||||
// Using DTCoreText, which renders static string, helps to avoid code injection attacks
|
||||
// that could happen with the default HTML renderer of NSAttributedString which is a
|
||||
// webview.
|
||||
/// Do not use the default HTML renderer of NSAttributedString because this method
|
||||
/// runs on the UI thread which we want to avoid because renderHTMLString is called
|
||||
/// most of the time from a background thread.
|
||||
/// Use DTCoreText HTML renderer instead.
|
||||
/// Using DTCoreText, which renders static string, helps to avoid code injection attacks
|
||||
/// that could happen with the default HTML renderer of NSAttributedString which is a
|
||||
/// webview.
|
||||
func fromHTML(_ htmlString: String?) -> AttributedString? {
|
||||
guard let originalHTMLString = htmlString else {
|
||||
return nil
|
||||
|
||||
@@ -89,7 +89,9 @@ extension AttributeScopes {
|
||||
let uiKit: UIKitAttributes
|
||||
}
|
||||
|
||||
var elementX: ElementXAttributes.Type { ElementXAttributes.self }
|
||||
var elementX: ElementXAttributes.Type {
|
||||
ElementXAttributes.self
|
||||
}
|
||||
}
|
||||
|
||||
// periphery: ignore - required to make NSAttributedString to AttributedString conversion even if not used directly
|
||||
|
||||
@@ -26,7 +26,9 @@ enum Tracing {
|
||||
/// This basically only affects ``logFiles``, and doesn't inform the SDK to write
|
||||
/// the logs to a different directory, which should be done before setting this.
|
||||
static var logsDirectoryOverride: URL?
|
||||
static var legacyLogsDirectory: URL { .appGroupContainerDirectory }
|
||||
static var legacyLogsDirectory: URL {
|
||||
.appGroupContainerDirectory
|
||||
}
|
||||
|
||||
static let fileExtension = "log"
|
||||
|
||||
@@ -60,7 +62,9 @@ enum Tracing {
|
||||
}
|
||||
|
||||
/// A list of all log file URLs, sorted chronologically.
|
||||
static var logFiles: [URL] { logFiles(in: logsDirectory) }
|
||||
static var logFiles: [URL] {
|
||||
logFiles(in: logsDirectory)
|
||||
}
|
||||
|
||||
/// Collect all of the logs in the given directory, sorting them chronologically.
|
||||
private static func logFiles(in directory: URL) -> [URL] {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/*
|
||||
/**
|
||||
Behavior mode of the current user's location, can be hidden, only shown and shown following the user
|
||||
*/
|
||||
enum ShowUserLocationMode {
|
||||
|
||||
@@ -114,7 +114,9 @@ struct MapLibreStaticMapView_Previews: PreviewProvider, TestablePreview {
|
||||
}
|
||||
|
||||
private struct MapTilerURLBuilderMock: MapTilerURLBuilderProtocol {
|
||||
func interactiveMapURL(for style: MapTilerStyle) -> URL? { nil }
|
||||
func interactiveMapURL(for style: MapTilerStyle) -> URL? {
|
||||
nil
|
||||
}
|
||||
|
||||
func staticMapTileImageURL(for style: MapTilerStyle,
|
||||
coordinates: CLLocationCoordinate2D,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
// https://spec.matrix.org/latest/appendices/#identifier-grammar
|
||||
/// https://spec.matrix.org/latest/appendices/#identifier-grammar
|
||||
enum MatrixEntityRegex: String {
|
||||
case homeserver
|
||||
case userID
|
||||
|
||||
@@ -22,7 +22,7 @@ final class MessageTextView: UITextView, PillAttachmentViewProviderDelegate, UIG
|
||||
super.addGestureRecognizer(gestureRecognizer)
|
||||
}
|
||||
|
||||
// This prevents the magnifying glass from showing up
|
||||
/// This prevents the magnifying glass from showing up
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
if otherGestureRecognizer is UILongPressGestureRecognizer {
|
||||
return false
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
import SwiftUI
|
||||
import SwiftUIIntrospect
|
||||
import UIKit
|
||||
|
||||
import WysiwygComposer
|
||||
|
||||
protocol PillAttachmentViewProviderDelegate: AnyObject {
|
||||
|
||||
@@ -29,7 +29,6 @@ struct PillView: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var mainContent: some View {
|
||||
Text(context.viewState.displayText)
|
||||
.font(.compound.bodyLGSemibold)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
// In the future we might use this to do some customisation in what is plain text used to represent mentions.
|
||||
/// In the future we might use this to do some customisation in what is plain text used to represent mentions.
|
||||
struct PlainMentionBuilder: MentionBuilderProtocol {
|
||||
func handleEventOnRoomAliasMention(for attributedString: NSMutableAttributedString, in range: NSRange, url: URL, eventID: String, roomAlias: String) { }
|
||||
|
||||
|
||||
@@ -26,123 +26,177 @@ final class SDKListener<T> {
|
||||
// MARK: QRCodeLoginService
|
||||
|
||||
extension SDKListener: QrLoginProgressListener where T == QrLoginProgress {
|
||||
func onUpdate(state: QrLoginProgress) { onUpdateClosure(state) }
|
||||
func onUpdate(state: QrLoginProgress) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: GrantQrLoginProgressListener where T == GrantQrLoginProgress {
|
||||
func onUpdate(state: GrantQrLoginProgress) { onUpdateClosure(state) }
|
||||
func onUpdate(state: GrantQrLoginProgress) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: GrantGeneratedQrLoginProgressListener where T == GrantGeneratedQrLoginProgress {
|
||||
func onUpdate(state: GrantGeneratedQrLoginProgress) { onUpdateClosure(state) }
|
||||
func onUpdate(state: GrantGeneratedQrLoginProgress) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: ClientProxy
|
||||
|
||||
extension SDKListener: MediaPreviewConfigListener where T == MediaPreviewConfig? {
|
||||
func onChange(mediaPreviewConfig: MediaPreviewConfig?) { onUpdateClosure(mediaPreviewConfig) }
|
||||
func onChange(mediaPreviewConfig: MediaPreviewConfig?) {
|
||||
onUpdateClosure(mediaPreviewConfig)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SyncServiceStateObserver where T == SyncServiceState {
|
||||
func onUpdate(state: SyncServiceState) { onUpdateClosure(state) }
|
||||
func onUpdate(state: SyncServiceState) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: RoomListServiceStateListener where T == RoomListServiceState {
|
||||
func onUpdate(state: RoomListServiceState) { onUpdateClosure(state) }
|
||||
func onUpdate(state: RoomListServiceState) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: RoomListServiceSyncIndicatorListener where T == RoomListServiceSyncIndicator {
|
||||
func onUpdate(syncIndicator: RoomListServiceSyncIndicator) { onUpdateClosure(syncIndicator) }
|
||||
func onUpdate(syncIndicator: RoomListServiceSyncIndicator) {
|
||||
onUpdateClosure(syncIndicator)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: VerificationStateListener where T == VerificationState {
|
||||
func onUpdate(status: VerificationState) { onUpdateClosure(status) }
|
||||
func onUpdate(status: VerificationState) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: IgnoredUsersListener where T == [String] {
|
||||
func call(ignoredUserIds: [String]) { onUpdateClosure(ignoredUserIds) }
|
||||
func call(ignoredUserIds: [String]) {
|
||||
onUpdateClosure(ignoredUserIds)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SendQueueRoomErrorListener where T == (String, ClientError) {
|
||||
func onError(roomId: String, error: ClientError) { onUpdateClosure((roomId, error)) }
|
||||
func onError(roomId: String, error: ClientError) {
|
||||
onUpdateClosure((roomId, error))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: SecureBackupController
|
||||
|
||||
extension SDKListener: BackupStateListener where T == BackupState {
|
||||
func onUpdate(status: BackupState) { onUpdateClosure(status) }
|
||||
func onUpdate(status: BackupState) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: RecoveryStateListener where T == RecoveryState {
|
||||
func onUpdate(status: RecoveryState) { onUpdateClosure(status) }
|
||||
func onUpdate(status: RecoveryState) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: EnableRecoveryProgressListener where T == EnableRecoveryProgress {
|
||||
func onUpdate(status: EnableRecoveryProgress) { onUpdateClosure(status) }
|
||||
func onUpdate(status: EnableRecoveryProgress) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: BackupSteadyStateListener where T == BackupUploadState {
|
||||
func onUpdate(status: BackupUploadState) { onUpdateClosure(status) }
|
||||
func onUpdate(status: BackupUploadState) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: RoomSummaryProvider
|
||||
|
||||
extension SDKListener: RoomListEntriesListener where T == [RoomListEntriesUpdate] {
|
||||
func onUpdate(roomEntriesUpdate: [RoomListEntriesUpdate]) { onUpdateClosure(roomEntriesUpdate) }
|
||||
func onUpdate(roomEntriesUpdate: [RoomListEntriesUpdate]) {
|
||||
onUpdateClosure(roomEntriesUpdate)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: RoomListLoadingStateListener where T == RoomListLoadingState {
|
||||
func onUpdate(state: RoomListLoadingState) { onUpdateClosure(state) }
|
||||
func onUpdate(state: RoomListLoadingState) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Spaces
|
||||
|
||||
extension SDKListener: SpaceServiceJoinedSpacesListener where T == [SpaceListUpdate] {
|
||||
func onUpdate(rooms: [SpaceListUpdate]) { onUpdateClosure(rooms) }
|
||||
func onUpdate(rooms: [SpaceListUpdate]) {
|
||||
onUpdateClosure(rooms)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SpaceRoomListEntriesListener where T == [SpaceListUpdate] {
|
||||
func onUpdate(roomUpdates: [SpaceListUpdate]) { onUpdateClosure(roomUpdates) }
|
||||
func onUpdate(roomUpdates: [SpaceListUpdate]) {
|
||||
onUpdateClosure(roomUpdates)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SpaceRoomListPaginationStateListener where T == SpaceRoomListPaginationState {
|
||||
func onUpdate(paginationState: SpaceRoomListPaginationState) { onUpdateClosure(paginationState) }
|
||||
func onUpdate(paginationState: SpaceRoomListPaginationState) {
|
||||
onUpdateClosure(paginationState)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SpaceRoomListSpaceListener where T == SpaceRoom? {
|
||||
func onUpdate(space: SpaceRoom?) { onUpdateClosure(space) }
|
||||
func onUpdate(space: SpaceRoom?) {
|
||||
onUpdateClosure(space)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SpaceServiceSpaceFiltersListener where T == [SpaceFilterUpdate] {
|
||||
func onUpdate(filterUpdates: [SpaceFilterUpdate]) { onUpdateClosure(filterUpdates) }
|
||||
func onUpdate(filterUpdates: [SpaceFilterUpdate]) {
|
||||
onUpdateClosure(filterUpdates)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Room
|
||||
|
||||
extension SDKListener: RoomInfoListener where T == RoomInfo {
|
||||
func call(roomInfo: RoomInfo) { onUpdateClosure(roomInfo) }
|
||||
func call(roomInfo: RoomInfo) {
|
||||
onUpdateClosure(roomInfo)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: CallDeclineListener where T == String {
|
||||
func call(declinerUserId: String) { onUpdateClosure(declinerUserId) }
|
||||
func call(declinerUserId: String) {
|
||||
onUpdateClosure(declinerUserId)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: TypingNotificationsListener where T == [String] {
|
||||
func call(typingUserIds: [String]) { onUpdateClosure(typingUserIds) }
|
||||
func call(typingUserIds: [String]) {
|
||||
onUpdateClosure(typingUserIds)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: IdentityStatusChangeListener where T == [IdentityStatusChange] {
|
||||
func call(identityStatusChange: [IdentityStatusChange]) { onUpdateClosure(identityStatusChange) }
|
||||
func call(identityStatusChange: [IdentityStatusChange]) {
|
||||
onUpdateClosure(identityStatusChange)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: KnockRequestsListener where T == [KnockRequest] {
|
||||
func call(joinRequests: [KnockRequest]) { onUpdateClosure(joinRequests) }
|
||||
func call(joinRequests: [KnockRequest]) {
|
||||
onUpdateClosure(joinRequests)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: TimelineProxy
|
||||
|
||||
extension SDKListener: PaginationStatusListener where T == RoomPaginationStatus {
|
||||
func onUpdate(status: RoomPaginationStatus) { onUpdateClosure(status) }
|
||||
func onUpdate(status: RoomPaginationStatus) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: ProgressWatcher where T == Double {
|
||||
@@ -156,11 +210,15 @@ extension SDKListener: ProgressWatcher where T == Double {
|
||||
// MARK: TimelineItemProvider
|
||||
|
||||
extension SDKListener: TimelineListener where T == [TimelineDiff] {
|
||||
func onUpdate(diff: [TimelineDiff]) { onUpdateClosure(diff) }
|
||||
func onUpdate(diff: [TimelineDiff]) {
|
||||
onUpdateClosure(diff)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: RoomDirectorySearchProxy
|
||||
|
||||
extension SDKListener: RoomDirectorySearchEntriesListener where T == [RoomDirectorySearchEntryUpdate] {
|
||||
func onUpdate(roomEntriesUpdate: [RoomDirectorySearchEntryUpdate]) { onUpdateClosure(roomEntriesUpdate) }
|
||||
func onUpdate(roomEntriesUpdate: [RoomDirectorySearchEntryUpdate]) {
|
||||
onUpdateClosure(roomEntriesUpdate)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public extension Animation {
|
||||
return animation.disabledIfReduceMotionEnabled()
|
||||
}
|
||||
|
||||
// `noAnimation` if running tests, otherwise `self` if `UIAccessibility.isReduceMotionEnabled` is false
|
||||
/// `noAnimation` if running tests, otherwise `self` if `UIAccessibility.isReduceMotionEnabled` is false
|
||||
func disabledDuringTests() -> Self {
|
||||
let animation: Animation = ProcessInfo.isRunningTests ? .noAnimation : self
|
||||
return animation.disabledIfReduceMotionEnabled()
|
||||
|
||||
@@ -10,7 +10,9 @@ import SwiftUI
|
||||
|
||||
extension ButtonStyle where Self == MenuSheetButtonStyle {
|
||||
/// A button style for buttons that are within a menu that is being presented as a sheet.
|
||||
static var menuSheet: Self { MenuSheetButtonStyle() }
|
||||
static var menuSheet: Self {
|
||||
MenuSheetButtonStyle()
|
||||
}
|
||||
}
|
||||
|
||||
/// The style used for buttons that are part of a menu that's presented as
|
||||
|
||||
@@ -31,7 +31,6 @@ extension View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
func mediaGalleryTimelineAspectRatio(imageInfo: ImageInfoProxy?) -> some View {
|
||||
aspectRatio(imageInfo?.aspectRatio, contentMode: .fill)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ private struct SearchControllerModifier: ViewModifier {
|
||||
/// is `false`, checking if this value is `false` is pretty much meaningless.
|
||||
@State private var isSearching = false
|
||||
|
||||
@ViewBuilder
|
||||
func body(content: Content) -> some View {
|
||||
let text: Text? = if let placeholder {
|
||||
Text(placeholder)
|
||||
@@ -191,7 +190,9 @@ private struct SearchController: UIViewControllerRepresentable {
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) { fatalError() }
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
override func willMove(toParent parent: UIViewController?) {
|
||||
parent?.navigationItem.searchController = searchController
|
||||
|
||||
@@ -135,9 +135,7 @@ private struct LoadableImageContent<TransformerView: View, PlaceholderView: View
|
||||
ZStack {
|
||||
switch (contentLoader.content, shouldRender) {
|
||||
case (.image(let image), true):
|
||||
transformer(
|
||||
AnyView(Image(uiImage: image).resizable())
|
||||
)
|
||||
transformer(AnyView(Image(uiImage: image).resizable()))
|
||||
case (.gifData, true):
|
||||
transformer(AnyView(KFAnimatedImage(source: .provider(self))))
|
||||
case (.none, _), (_, false):
|
||||
@@ -170,7 +168,7 @@ private struct LoadableImageContent<TransformerView: View, PlaceholderView: View
|
||||
}
|
||||
}
|
||||
|
||||
// Note: Returns `AnyView` as this is what `transformer` expects.
|
||||
/// Note: Returns `AnyView` as this is what `transformer` expects.
|
||||
var blurHashView: AnyView? {
|
||||
if let blurhash,
|
||||
// Build a small blurhash image so that it's fast
|
||||
@@ -387,7 +385,10 @@ struct LoadableImage_Previews: PreviewProvider, TestablePreview {
|
||||
}
|
||||
}
|
||||
|
||||
static func placeholder() -> some View { Color.compound._bgBubbleIncoming }
|
||||
static func placeholder() -> some View {
|
||||
Color.compound._bgBubbleIncoming
|
||||
}
|
||||
|
||||
static func transformer(_ view: AnyView) -> some View {
|
||||
view.overlay {
|
||||
Image(systemSymbol: .playCircleFill)
|
||||
|
||||
@@ -17,7 +17,9 @@ struct UserProfileListRow: View {
|
||||
|
||||
let kind: ListRow<LoadableAvatarImage, EmptyView, EmptyView, Bool>.Kind<EmptyView, Bool>
|
||||
|
||||
var isUnknownProfile: Bool { !user.isVerified && membership == nil }
|
||||
var isUnknownProfile: Bool {
|
||||
!user.isVerified && membership == nil
|
||||
}
|
||||
|
||||
private var subtitle: String? {
|
||||
guard !isUnknownProfile else { return L10n.commonInviteUnknownProfile }
|
||||
|
||||
@@ -58,12 +58,10 @@ private struct VisualListItemLabelStyle: LabelStyle {
|
||||
struct VisualListItem_Previews: PreviewProvider, TestablePreview {
|
||||
static let strings = AnalyticsPromptScreenStrings(termsURL: ServiceLocator.shared.settings.analyticsTermsURL)
|
||||
|
||||
@ViewBuilder
|
||||
static var testImage1: some View {
|
||||
Image(systemName: "circle")
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static var testImage2: some View {
|
||||
Image(systemName: "square")
|
||||
}
|
||||
|
||||
@@ -13,8 +13,13 @@ enum UserIndicatorType: Equatable {
|
||||
case toast(progress: UserIndicator.Progress?)
|
||||
case modal(progress: UserIndicator.Progress?, interactiveDismissDisabled: Bool, allowsInteraction: Bool)
|
||||
|
||||
static var toast: Self { .toast(progress: .none) }
|
||||
static var modal: Self { .modal(progress: .indeterminate, interactiveDismissDisabled: false, allowsInteraction: false) }
|
||||
static var toast: Self {
|
||||
.toast(progress: .none)
|
||||
}
|
||||
|
||||
static var modal: Self {
|
||||
.modal(progress: .indeterminate, interactiveDismissDisabled: false, allowsInteraction: false)
|
||||
}
|
||||
}
|
||||
|
||||
struct UserIndicator: Equatable, Identifiable {
|
||||
|
||||
@@ -76,28 +76,24 @@ struct UserIndicatorModalView_Previews: PreviewProvider, TestablePreview {
|
||||
VStack(spacing: 0) {
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
|
||||
title: "Successfully logged in",
|
||||
iconName: "checkmark")
|
||||
)
|
||||
iconName: "checkmark"))
|
||||
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal(progress: .published(CurrentValueSubject<Double, Never>(0.5).asCurrentValuePublisher()),
|
||||
interactiveDismissDisabled: false,
|
||||
allowsInteraction: false),
|
||||
title: "Successfully logged in",
|
||||
iconName: "checkmark")
|
||||
)
|
||||
iconName: "checkmark"))
|
||||
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal(progress: .none,
|
||||
interactiveDismissDisabled: false,
|
||||
allowsInteraction: false),
|
||||
title: "Successfully logged in",
|
||||
iconName: "checkmark")
|
||||
)
|
||||
iconName: "checkmark"))
|
||||
|
||||
UserIndicatorModalView(indicator: UserIndicator(type: .modal,
|
||||
title: "Successfully logged in",
|
||||
message: "You can now be happy.",
|
||||
iconName: "checkmark")
|
||||
)
|
||||
iconName: "checkmark"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ struct UserIndicatorPresenter: View {
|
||||
.animation(.elementDefault, value: userIndicatorController.activeIndicator)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func indicatorViewFor(indicator: UserIndicator?) -> some View {
|
||||
ZStack { // Need a container to properly animate transitions
|
||||
if let indicator {
|
||||
|
||||
@@ -83,10 +83,8 @@ private struct VoiceMessageButtonStyle: ButtonStyle {
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
configuration.label
|
||||
.foregroundColor(isEnabled ? .compound.textSecondary.opacity(configuration.isPressed ? 0.6 : 1) : .compound.iconDisabled)
|
||||
.background(
|
||||
Circle()
|
||||
.foregroundColor(configuration.isPressed ? .compound.bgSubtlePrimary : .compound.bgCanvasDefault)
|
||||
)
|
||||
.background(Circle()
|
||||
.foregroundColor(configuration.isPressed ? .compound.bgSubtlePrimary : .compound.bgCanvasDefault))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@ private struct WaveformInteractionModifier: ViewModifier {
|
||||
isDragging = true
|
||||
let progress = dragGesture.location.x / geometry.size.width
|
||||
onSeek(max(0, min(progress, 1.0)))
|
||||
}
|
||||
)
|
||||
})
|
||||
.offset(x: -cursorInteractiveSize / 2, y: 0)
|
||||
}
|
||||
.gesture(SpatialTapGesture()
|
||||
|
||||
Reference in New Issue
Block a user