From 04053ae69bb92f7df9e471ae386171e0ae73a586 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Tue, 27 Jan 2026 08:47:03 +0200 Subject: [PATCH] Update files following swiftformat upgrade --- Dangerfile.swift | 6 +- .../AccessibilityTestsAppCoordinator.swift | 4 +- .../AppHooks/Hooks/AppSettingsHook.swift | 4 +- .../AppHooks/Hooks/BugReportHook.swift | 4 +- .../AppHooks/Hooks/ClientBuilderHook.swift | 4 +- .../Hooks/DeveloperOptionsScreenHook.swift | 4 +- .../AppHooks/Hooks/RoomScreenHook.swift | 4 +- .../Sources/Application/AppCoordinator.swift | 32 ++- .../Sources/Application/AppMediator.swift | 2 +- .../Application/FlowCoordinatorProtocol.swift | 9 +- .../Navigation/NavigationTabCoordinator.swift | 9 +- .../Application/Settings/AppSettings.swift | 16 +- .../Settings/MapTilerConfiguration.swift | 4 +- .../Settings/RemotePreference.swift | 9 +- .../Application/Settings/UserPreference.swift | 15 +- .../ChatsTabFlowCoordinator.swift | 4 +- .../MediaEventsTimelineFlowCoordinator.swift | 4 +- .../PinnedEventsTimelineFlowCoordinator.swift | 4 +- .../RoomFlowCoordinator.swift | 4 +- .../SpaceSettingsFlowCoordinator.swift | 2 +- .../UserSessionFlowCoordinator.swift | 16 +- .../Sources/Mocks/RoomMemberProxyMock.swift | 2 +- ElementX/Sources/Mocks/UserProfile+Mock.swift | 2 +- .../Other/AccessibilityIdentifiers.swift | 4 +- .../Analytics/ScreenTrackerViewModifier.swift | 1 - ElementX/Sources/Other/Avatars.swift | 2 +- ElementX/Sources/Other/BlurHashDecode.swift | 8 +- .../CollapsibleReactionLayout.swift | 6 +- .../Sources/Other/CurrentValuePublisher.swift | 2 +- ElementX/Sources/Other/Extensions/Alert.swift | 4 +- .../Other/Extensions/AttributedString.swift | 2 +- .../Other/Extensions/ConfirmationDialog.swift | 14 +- ElementX/Sources/Other/Extensions/Date.swift | 4 +- .../Other/Extensions/NSItemProvider.swift | 4 +- .../Sources/Other/Extensions/OrderedSet.swift | 1 - .../Sources/Other/Extensions/Section.swift | 2 +- ElementX/Sources/Other/Extensions/URL.swift | 29 ++- .../Sources/Other/Extensions/XCTestCase.swift | 8 +- .../HTMLParsing/AttributedStringBuilder.swift | 14 +- .../HTMLParsing/ElementXAttributeScope.swift | 4 +- ElementX/Sources/Other/Logging/Tracing.swift | 8 +- .../Other/MapLibre/MapLibreModels.swift | 2 +- .../MapLibre/MapLibreStaticMapView.swift | 4 +- .../Sources/Other/MatrixEntityRegex.swift | 2 +- .../Sources/Other/Pills/MessageText.swift | 2 +- .../Pills/PillAttachmentViewProvider.swift | 1 - ElementX/Sources/Other/Pills/PillView.swift | 1 - .../Other/Pills/PlainMentionBuilder.swift | 2 +- ElementX/Sources/Other/SDKListener.swift | 116 ++++++--- .../SwiftUI/Animation/ElementAnimations.swift | 2 +- .../SwiftUI/Layout/MenuSheetLabelStyle.swift | 4 +- .../SwiftUI/Layout/TimelineMediaFrame.swift | 1 - ElementX/Sources/Other/SwiftUI/Search.swift | 5 +- .../Other/SwiftUI/Views/LoadableImage.swift | 11 +- .../SwiftUI/Views/UserProfileListRow.swift | 4 +- .../Other/SwiftUI/Views/VisualListItem.swift | 2 - .../Other/UserIndicator/UserIndicator.swift | 9 +- .../UserIndicatorModalView.swift | 12 +- .../UserIndicatorPresenter.swift | 1 - .../VoiceMessage/VoiceMessageButton.swift | 6 +- .../WaveformInteractionModifier.swift | 3 +- .../AppLockScreen/AppLockScreenModels.swift | 10 +- .../AppLockScreen/View/AppLockScreen.swift | 2 +- .../View/AppLockScreenPINKeypad.swift | 4 +- .../AppLockSetupBiometricsScreenModels.swift | 14 +- .../AppLockSetupPINScreenModels.swift | 5 +- .../AppLockSetupSettingsScreenModels.swift | 9 +- .../LoginScreen/LoginScreenCoordinator.swift | 6 +- .../LoginScreen/LoginScreenModels.swift | 4 +- .../OIDCAuthenticationPresenter.swift | 4 +- .../View/ServerConfirmationScreen.swift | 6 +- .../ServerSelectionScreenCoordinator.swift | 6 +- .../SoftLogoutScreenCoordinator.swift | 7 +- .../SoftLogoutScreenModels.swift | 4 +- .../View/AuthenticationStartLogo.swift | 4 +- .../BugReportScreenCoordinator.swift | 10 +- .../View/BugReportScreen.swift | 10 +- .../CallScreen/CallScreenViewModel.swift | 2 +- .../Screens/CallScreen/View/CallScreen.swift | 4 +- .../View/EncryptionResetPasswordScreen.swift | 1 - .../View/EncryptionResetScreen.swift | 1 - .../InteractiveQuickLook.swift | 13 +- .../TimelineMediaPreviewDataSource.swift | 9 +- .../TimelineMediaPreviewModels.swift | 5 +- .../TimelineMediaPreviewModifier.swift | 8 +- .../TimelineMediaPreviewViewModel.swift | 4 +- .../View/TimelineMediaPreviewController.swift | 30 ++- ...TimelineMediaPreviewFileExportPicker.swift | 4 +- ...neMediaPreviewRedactConfirmationView.swift | 1 - .../Screens/HomeScreen/HomeScreenModels.swift | 2 +- .../HomeScreen/View/BloomModifier.swift | 14 +- .../View/Filters/RoomListFilterModels.swift | 1 - .../View/Filters/RoomListFiltersView.swift | 4 +- .../View/HomeScreenInviteCell.swift | 1 - .../View/HomeScreenKnockedCell.swift | 1 - .../HomeScreen/View/HomeScreenRoomCell.swift | 2 - .../HomeScreen/View/HomeScreenRoomList.swift | 1 - .../JoinRoomScreen/View/JoinRoomScreen.swift | 3 - .../KnockRequestsListScreenModels.swift | 4 +- .../View/KnockRequestCell.swift | 5 +- .../StaticLocationScreenViewModel.swift | 4 +- .../View/MediaEventsTimelineScreen.swift | 18 +- .../View/MediaUploadPreviewScreen.swift | 9 +- .../View/AnalyticsPromptScreen.swift | 1 - .../View/IdentityConfirmationScreen.swift | 2 - .../View/IdentityConfirmedScreen.swift | 2 - .../View/SessionVerificationScreen.swift | 2 - .../View/QRCodeLoginScreen.swift | 10 +- .../ReportContentScreenCoordinator.swift | 10 +- .../View/RoomChangeRolesScreen.swift | 4 +- .../View/RoomDetailsScreen.swift | 1 - .../View/RoomDirectorySearchScreen.swift | 2 +- .../RoomMemberDetailsScreenViewModel.swift | 9 +- .../RoomMembersListScreenModels.swift | 4 +- .../View/RoomPollsHistoryScreen.swift | 15 +- .../ComposerToolbarModels.swift | 8 +- .../ComposerToolbarViewModel.swift | 4 +- .../View/CompletionSuggestionView.swift | 2 +- .../View/ComposerToolbar.swift | 1 - .../View/RoomAttachmentPicker.swift | 4 +- .../View/VoiceMessageRecordingButton.swift | 4 +- .../Screens/RoomScreen/RoomScreenModels.swift | 6 +- .../PinnedItemsBannerView.swift | 1 - .../Screens/RoomScreen/View/RoomScreen.swift | 2 - .../RoomScreen/View/SwipeRightAction.swift | 13 +- ...SecureBackupLogoutConfirmationScreen.swift | 1 - .../View/SecureBackupRecoveryKeyScreen.swift | 2 - .../View/SecureBackupScreen.swift | 1 - .../OIDCAccountSettingsPresenter.swift | 4 +- .../NotificationSettingsScreenModels.swift | 6 +- .../Screens/Spaces/Common/SpaceRoomCell.swift | 9 +- .../LeaveSpace/LeaveSpaceViewModel.swift | 18 +- .../SpaceAddRoomsScreenViewModel.swift | 9 +- .../SpaceScreen/SpaceScreenViewModel.swift | 9 +- .../Spaces/SpaceScreen/View/SpaceScreen.swift | 4 +- .../SpacesScreen/SpacesScreenViewModel.swift | 4 +- .../SpacesScreen/View/SpacesScreen.swift | 10 +- .../View/JoinRoomByAddressView.swift | 11 +- .../View/StartChatScreen.swift | 11 +- .../Screens/Timeline/TimelineModels.swift | 6 +- .../TimelineTableViewController.swift | 7 +- .../ItemMenu/TimelineItemMenuAction.swift | 8 +- .../Timeline/View/Polls/PollView.swift | 5 +- .../ReadReceiptsSummaryView.swift | 23 +- .../View/Style/LongPressWithFeedback.swift | 17 +- .../Timeline/View/Style/ThreadDecorator.swift | 3 +- .../TimelineItemAccessibilityModifier.swift | 1 - .../Style/TimelineItemBubbledStylerView.swift | 11 +- .../Style/TimelineItemSendInfoLabel.swift | 1 - .../Timeline/View/Style/TimelineStyler.swift | 16 +- .../Timeline/View/TimelineItemDebugView.swift | 1 - .../CallNotificationRoomTimelineView.swift | 6 +- .../TimelineItemViews/FormattedBodyText.swift | 3 +- .../ImageRoomTimelineView.swift | 4 +- .../TextRoomTimelineView.swift | 3 +- .../VideoRoomTimelineView.swift | 4 +- .../Screens/Timeline/View/TimelineView.swift | 7 +- .../UserProfileScreenViewModel.swift | 9 +- .../Analytics/PostHogAnalyticsClient.swift | 4 +- .../Services/Analytics/Signposter.swift | 6 +- .../Services/AppLock/AppLockService.swift | 12 +- .../Services/AppLock/LAContextMock.swift | 8 +- .../Audio/Player/AudioPlayerProtocol.swift | 6 +- .../AuthenticationService.swift | 5 +- .../Authentication/LinkNewDeviceService.swift | 10 +- .../Services/BugReport/BugReportService.swift | 5 +- .../Sources/Services/Client/ClientProxy.swift | 3 +- .../Services/Client/ClientProxyProtocol.swift | 2 +- .../ComposerDraftServiceProtocol.swift | 1 - .../ElementCall/ElementCallService.swift | 2 +- .../Keychain/KeychainControllerMock.swift | 9 +- .../MediaPlayer/MediaPlayerProvider.swift | 4 +- .../Services/Room/JoinedRoomProxy.swift | 14 +- .../Sources/Services/Room/RoomInfoProxy.swift | 225 ++++++++++++++---- .../Room/RoomMember/RoomMemberProxy.swift | 28 ++- .../RoomMember/RoomMemberProxyProtocol.swift | 4 +- .../Services/Room/RoomPermissions.swift | 14 +- .../Services/Room/RoomProxyProtocol.swift | 2 +- .../Room/RoomSummary/RoomSummary.swift | 38 ++- .../RoomDirectorySearchProxy.swift | 1 - .../Spaces/LeaveSpaceHandleProxy.swift | 9 +- .../Services/Spaces/SpaceRoomListProxy.swift | 4 +- .../Spaces/SpaceServiceProxyProtocol.swift | 2 +- .../Sources/Services/Timeline/GeoURI.swift | 2 +- .../Timeline/IntentionalMentions.swift | 1 - .../MockTimelineController.swift | 5 +- .../TimelineController.swift | 18 +- .../TimelineItemContent/ReadReceipt.swift | 4 +- .../RoomTimelineItemProperties.swift | 6 +- .../RoomTimelineItemFactory.swift | 2 +- .../RoomTimelineItemFactoryProtocol.swift | 1 - .../TimelineItems/RoomTimelineItemView.swift | 4 +- .../UserSession/SessionDirectories.swift | 9 +- .../UserSession/UserSessionStore.swift | 13 +- .../Services/Users/UserProfileProxy.swift | 4 +- .../Sources/UITests/UITestsSignalling.swift | 4 +- Enterprise | 2 +- IntegrationTests/Sources/Common.swift | 4 +- IntegrationTests/Sources/UserFlowTests.swift | 2 +- NSE/Sources/NotificationContentBuilder.swift | 7 +- .../NotificationItemProxy.swift | 48 +++- .../NotificationServiceExtension.swift | 4 +- PreviewTests/Sources/PreviewTests.swift | 16 +- .../Unit/TemplateScreenViewModelTests.swift | 5 +- Tools/Sources/Commands/OutdatedPackages.swift | 4 +- Tools/Sources/Extensions/URL.swift | 14 +- UITests/Sources/AppLockSetupTests.swift | 4 +- .../AuthenticationFlowCoordinatorTests.swift | 6 +- UITests/Sources/UserSessionScreenTests.swift | 2 +- ...hineReadableCodeObjectExtensionsTest.swift | 3 +- ...nalyticsSettingsScreenViewModelTests.swift | 3 +- UnitTests/Sources/AnalyticsTests.swift | 16 +- .../AppLock/AppLockScreenViewModelTests.swift | 7 +- .../Sources/AppLock/AppLockServiceTests.swift | 3 +- .../AppLockSettingsScreenViewModelTests.swift | 3 +- ...kSetupBiometricsScreenViewModelTests.swift | 7 +- .../AppLockSetupPINScreenViewModelTests.swift | 7 +- .../Sources/AppLock/AppLockTimerTests.swift | 22 +- .../Sources/AppLock/PINTextFieldTests.swift | 3 +- .../Sources/AppRouteURLParserTests.swift | 3 +- UnitTests/Sources/ArrayTests.swift | 6 +- .../AttributedStringBuilderTests.swift | 2 +- UnitTests/Sources/AudioPlayerStateTests.swift | 8 +- .../Sources/AudioRecorderStateTests.swift | 6 +- .../Sources/AuthenticationServiceTests.swift | 3 +- ...henticationStartScreenViewModelTests.swift | 7 +- .../BlockedUsersScreenViewModelTests.swift | 3 +- .../BugReportScreenViewModelTests.swift | 7 +- UnitTests/Sources/BugReportServiceTests.swift | 10 +- .../Sources/CallScreenViewModelTests.swift | 3 +- .../ChatsTabFlowCoordinatorTests.swift | 12 +- .../CompletionSuggestionServiceTests.swift | 3 +- .../ComposerToolbarViewModelTests.swift | 17 +- .../Sources/CreateRoomViewModelTests.swift | 5 +- UnitTests/Sources/DateTests.swift | 28 +-- ...eactivateAccountScreenViewModelTests.swift | 3 +- .../DeclineAndBlockScreenViewModelTests.swift | 3 +- ...DeveloperOptionsScreenViewModelTests.swift | 3 +- .../EditRoomAddressScreenViewModelTests.swift | 9 +- .../Sources/ElementCallServiceTests.swift | 5 +- .../EmojiPickerScreenViewModelTests.swift | 7 +- UnitTests/Sources/EmojiProviderTests.swift | 11 +- .../Sources/ExpiringTaskRunnerTests.swift | 6 +- UnitTests/Sources/GeoURITests.swift | 2 +- .../GlobalSearchScreenViewModelTests.swift | 3 +- UnitTests/Sources/HomeScreenRoomTests.swift | 3 +- .../Sources/HomeScreenViewModelTests.swift | 15 +- .../Sources/InviteUsersViewModelTests.swift | 3 +- .../JoinRoomScreenViewModelTests.swift | 5 +- ...nockRequestsListScreenViewModelTests.swift | 3 +- ...LegalInformationScreenViewModelTests.swift | 3 +- UnitTests/Sources/LoggingTests.swift | 6 +- .../Sources/LoginScreenViewModelTests.swift | 9 +- .../ManageRoomMemberSheetViewModelTests.swift | 3 +- .../Sources/MatrixEntityRegexTests.swift | 6 +- .../Sources/MediaPlayerProviderTests.swift | 6 +- .../MediaProvider/MediaProviderTests.swift | 5 +- ...diaUploadPreviewScreenViewModelTests.swift | 27 ++- .../MediaUploadingPreprocessorTests.swift | 3 +- ...essageForwardingScreenViewModelTests.swift | 3 +- .../NavigationRootCoordinatorTests.swift | 3 +- .../NavigationSplitCoordinatorTests.swift | 3 +- .../NavigationStackCoordinatorTests.swift | 3 +- .../NavigationTabCoordinatorTests.swift | 3 +- .../NotificationContentBuilderTests.swift | 3 +- .../NotificationManager/MockCoder.swift | 9 +- .../NotificationManagerTests.swift | 23 +- ...tionSettingsEditScreenViewModelTests.swift | 3 +- ...ficationSettingsScreenViewModelTests.swift | 3 +- UnitTests/Sources/PillContextTests.swift | 7 +- .../PinnedEventsBannerStateTests.swift | 3 +- .../PollFormScreenViewModelTests.swift | 7 +- .../QRCodeLoginScreenViewModelTests.swift | 7 +- UnitTests/Sources/RemotePreferenceTests.swift | 3 +- .../ReportRoomScreenViewModelTests.swift | 3 +- ...dUserSendFailureScreenViewModelTests.swift | 7 +- UnitTests/Sources/RestorationTokenTests.swift | 3 +- ...hangePermissionsScreenViewModelTests.swift | 9 +- .../RoomChangeRolesScreenViewModelTests.swift | 3 +- .../RoomDetailsEditScreenViewModelTests.swift | 5 +- .../RoomDetailsScreenViewModelTests.swift | 10 +- ...torySearchScreenScreenViewModelTests.swift | 3 +- .../Sources/RoomFlowCoordinatorTests.swift | 3 +- .../Sources/RoomListFiltersStateTests.swift | 5 +- .../RoomMemberDetailsViewModelTests.swift | 7 +- .../RoomMembersFlowCoordinatorTests.swift | 3 +- .../RoomMembersListScreenViewModelTests.swift | 3 +- ...ficationSettingsScreenViewModelTests.swift | 3 +- UnitTests/Sources/RoomPermissionsTests.swift | 3 +- ...RoomPollsHistoryScreenViewModelTests.swift | 3 +- ...esAndPermissionsScreenViewModelTests.swift | 3 +- .../Sources/RoomScreenViewModelTests.swift | 3 +- .../Sources/RoomSummaryProviderTests.swift | 3 +- UnitTests/Sources/RoomSummaryTests.swift | 3 +- UnitTests/Sources/RoomTests.swift | 5 +- ...eBackupKeyBackupScreenViewModelTests.swift | 3 +- ...goutConfirmationScreenViewModelTests.swift | 7 +- ...ackupRecoveryKeyScreenViewModelTests.swift | 3 +- .../SecureBackupScreenViewModelTests.swift | 3 +- ...curityAndPrivacyScreenViewModelTests.swift | 3 +- ...verConfigurationScreenViewStateTests.swift | 3 +- ...rverConfirmationScreenViewModelTests.swift | 7 +- .../ServerSelectionScreenViewModelTests.swift | 7 +- .../Sources/SessionDirectoriesTests.swift | 17 +- ...SessionVerificationStateMachineTests.swift | 3 +- .../SessionVerificationViewModelTests.swift | 3 +- .../SettingsScreenViewModelTests.swift | 3 +- .../SoftLogoutScreenViewModelTests.swift | 3 +- .../SpaceAddRoomsScreenViewModelTests.swift | 7 +- .../SpaceListScreenViewModelTests.swift | 3 +- .../Sources/SpaceScreenViewModelTests.swift | 5 +- .../Sources/StartChatViewModelTests.swift | 5 +- .../StaticLocationScreenViewModelTests.swift | 17 +- UnitTests/Sources/StringTests.swift | 3 +- .../Sources/TimelineItemFactoryTests.swift | 3 +- .../TimelineMediaPreviewViewModelTests.swift | 8 +- .../Sources/TimelineViewModelTests.swift | 11 +- UnitTests/Sources/URLComponentsTests.swift | 3 +- UnitTests/Sources/URLTests.swift | 3 +- UnitTests/Sources/UserAgentBuilderTests.swift | 3 +- .../UserDetailsEditScreenViewModelTests.swift | 3 +- .../UserDiscoveryServiceTest.swift | 7 +- .../UserIndicatorControllerTests.swift | 6 +- UnitTests/Sources/UserPreferenceTests.swift | 14 +- .../UserProfileScreenViewModelTests.swift | 7 +- .../UserSessionFlowCoordinatorTests.swift | 24 +- .../Sources/VoiceMessageCacheTests.swift | 8 +- .../Sources/VoiceMessageRecorderTests.swift | 28 +-- .../Sources/CompoundInspectorApp.swift | 9 +- .../Sources/Compound/Buttons/SendButton.swift | 4 +- .../Compound/Colors/CompoundColors.swift | 8 +- .../Compound/Colors/CompoundGradients.swift | 44 ++-- .../Compound/Colors/CompoundUIColors.swift | 4 +- .../Compound/List/ListInlinePicker.swift | 4 +- .../Sources/Compound/List/ListRow.swift | 8 +- .../Compound/List/ListRowAccessory.swift | 5 +- .../Sources/Compound/List/ListRowLabel.swift | 4 +- .../List/ListRowTrailingSection.swift | 4 +- .../Text Field Styles/SearchFieldStyle.swift | 1 - .../CompoundTests/AvatarColorsTests.swift | 5 +- .../Tests/CompoundTests/FontSizeTests.swift | 2 +- .../CompoundTests/OverrideColorTests.swift | 3 +- .../Tests/CompoundTests/PreviewTests.swift | 16 +- 343 files changed, 1502 insertions(+), 1048 deletions(-) diff --git a/Dangerfile.swift b/Dangerfile.swift index 137165c1f..33e538359 100644 --- a/Dangerfile.swift +++ b/Dangerfile.swift @@ -11,7 +11,7 @@ SwiftLint.lint(.modifiedAndCreatedFiles(directory: nil), let danger = Danger() -// All of the new and modified files together. +/// All of the new and modified files together. let editedFiles = danger.git.modifiedFiles + danger.git.createdFiles // Warn when there is a big PR @@ -24,7 +24,7 @@ if danger.github.pullRequest.body?.isEmpty ?? true { warn("Please provide a description for this PR.") } -// Check for screenshots on view changes +/// Check for screenshots on view changes let hasChangedViews = !editedFiles.filter { $0.lowercased().contains("/view") }.isEmpty if hasChangedViews { if (danger.github.pullRequest.body?.contains("user-attachments") ?? false) == false { @@ -32,7 +32,7 @@ if hasChangedViews { } } -// Check for pngs on resources +/// Check for pngs on resources let hasPngs = !editedFiles.filter { $0.lowercased().contains(".xcassets") && $0.lowercased().hasSuffix(".png") }.isEmpty if hasPngs { warn("You seem to have made changes to some resource images. Please consider using an SVG or PDF.") diff --git a/ElementX/Sources/AccessibilityTests/AccessibilityTestsAppCoordinator.swift b/ElementX/Sources/AccessibilityTests/AccessibilityTestsAppCoordinator.swift index b601f3d7b..79909acba 100644 --- a/ElementX/Sources/AccessibilityTests/AccessibilityTestsAppCoordinator.swift +++ b/ElementX/Sources/AccessibilityTests/AccessibilityTestsAppCoordinator.swift @@ -118,7 +118,9 @@ struct PreviewsWrapperView: View { private let name: String private let previews: [_Preview] private(set) var currentIndex = -1 - var currentPreview: _Preview { previews[currentIndex] } + var currentPreview: _Preview { + previews[currentIndex] + } private(set) var isDone = false diff --git a/ElementX/Sources/AppHooks/Hooks/AppSettingsHook.swift b/ElementX/Sources/AppHooks/Hooks/AppSettingsHook.swift index 373a60dc0..ad25bb043 100644 --- a/ElementX/Sources/AppHooks/Hooks/AppSettingsHook.swift +++ b/ElementX/Sources/AppHooks/Hooks/AppSettingsHook.swift @@ -13,5 +13,7 @@ protocol AppSettingsHookProtocol { } struct DefaultAppSettingsHook: AppSettingsHookProtocol { - func configure(_ appSettings: AppSettings) -> AppSettings { appSettings } + func configure(_ appSettings: AppSettings) -> AppSettings { + appSettings + } } diff --git a/ElementX/Sources/AppHooks/Hooks/BugReportHook.swift b/ElementX/Sources/AppHooks/Hooks/BugReportHook.swift index ba68c513a..92231b5aa 100644 --- a/ElementX/Sources/AppHooks/Hooks/BugReportHook.swift +++ b/ElementX/Sources/AppHooks/Hooks/BugReportHook.swift @@ -13,5 +13,7 @@ protocol BugReportHookProtocol { } struct DefaultBugReportHook: BugReportHookProtocol { - func update(_ bugReport: BugReport) -> BugReport { bugReport } + func update(_ bugReport: BugReport) -> BugReport { + bugReport + } } diff --git a/ElementX/Sources/AppHooks/Hooks/ClientBuilderHook.swift b/ElementX/Sources/AppHooks/Hooks/ClientBuilderHook.swift index b871b401b..f936f0ecd 100644 --- a/ElementX/Sources/AppHooks/Hooks/ClientBuilderHook.swift +++ b/ElementX/Sources/AppHooks/Hooks/ClientBuilderHook.swift @@ -13,5 +13,7 @@ protocol ClientBuilderHookProtocol { } struct DefaultClientBuilderHook: ClientBuilderHookProtocol { - func configure(_ builder: ClientBuilder) -> ClientBuilder { builder } + func configure(_ builder: ClientBuilder) -> ClientBuilder { + builder + } } diff --git a/ElementX/Sources/AppHooks/Hooks/DeveloperOptionsScreenHook.swift b/ElementX/Sources/AppHooks/Hooks/DeveloperOptionsScreenHook.swift index e31b390b4..3470db21a 100644 --- a/ElementX/Sources/AppHooks/Hooks/DeveloperOptionsScreenHook.swift +++ b/ElementX/Sources/AppHooks/Hooks/DeveloperOptionsScreenHook.swift @@ -12,5 +12,7 @@ protocol DeveloperOptionsScreenHookProtocol { } struct DefaultDeveloperOptionsScreenHook: DeveloperOptionsScreenHookProtocol { - func generalSectionRows() -> AnyView? { nil } + func generalSectionRows() -> AnyView? { + nil + } } diff --git a/ElementX/Sources/AppHooks/Hooks/RoomScreenHook.swift b/ElementX/Sources/AppHooks/Hooks/RoomScreenHook.swift index cbb4aa0f7..5eba9c507 100644 --- a/ElementX/Sources/AppHooks/Hooks/RoomScreenHook.swift +++ b/ElementX/Sources/AppHooks/Hooks/RoomScreenHook.swift @@ -15,5 +15,7 @@ protocol RoomScreenHookProtocol { struct DefaultRoomScreenHook: RoomScreenHookProtocol { func configure(with userSession: UserSessionProtocol?) async { } - func update(_ viewState: RoomScreenViewState) -> RoomScreenViewState { viewState } + func update(_ viewState: RoomScreenViewState) -> RoomScreenViewState { + viewState + } } diff --git a/ElementX/Sources/Application/AppCoordinator.swift b/ElementX/Sources/Application/AppCoordinator.swift index 362399af2..3adfefd81 100644 --- a/ElementX/Sources/Application/AppCoordinator.swift +++ b/ElementX/Sources/Application/AppCoordinator.swift @@ -198,18 +198,16 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg } func toPresentable() -> AnyView { - AnyView( - navigationRootCoordinator.toPresentable() - .environment(\.analyticsService, ServiceLocator.shared.analytics) - .onReceive(appSettings.$appAppearance) { [weak self] appAppearance in - guard let self else { return } + AnyView(navigationRootCoordinator.toPresentable() + .environment(\.analyticsService, ServiceLocator.shared.analytics) + .onReceive(appSettings.$appAppearance) { [weak self] appAppearance in + guard let self else { return } - windowManager.windows.forEach { window in - // Unfortunately .preferredColorScheme doesn't propagate properly throughout the app when changed - window.overrideUserInterfaceStyle = appAppearance.interfaceStyle - } + windowManager.windows.forEach { window in + // Unfortunately .preferredColorScheme doesn't propagate properly throughout the app when changed + window.overrideUserInterfaceStyle = appAppearance.interfaceStyle } - ) + }) } func handlePotentialPhishingAttempt(url: URL, openURLAction: @escaping (URL) -> Void) -> Bool { @@ -450,7 +448,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg userSessionMigrationsOldVersion = nil } - // This could be removed once the adoption of 25.06.x is widespread. + /// This could be removed once the adoption of 25.06.x is widespread. private func performSettingsToAccountDataMigration(userSession: UserSessionProtocol) { guard let userDefaults = UserDefaults(suiteName: InfoPlistReader.main.appGroupIdentifier) else { return @@ -1200,12 +1198,12 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg // This is important for the app to keep refreshing in the background scheduleBackgroundAppRefresh() - /// We have a lot of crashes stemming here which we previously believed are caused by stopSync not being async - /// on the client proxy side (see the comment on that method). We have now realised that will likely not fix anything but - /// we also noticed this does not crash on the main thread, even though the whole AppCoordinator is on the Main actor. - /// As such, we introduced a MainActor conformance on the expirationHandler but we are also assuming main actor - /// isolated in the `stopSync` method above. - /// https://sentry.tools.element.io/organizations/element/issues/4477794/ + // We have a lot of crashes stemming here which we previously believed are caused by stopSync not being async + // on the client proxy side (see the comment on that method). We have now realised that will likely not fix anything but + // we also noticed this does not crash on the main thread, even though the whole AppCoordinator is on the Main actor. + // As such, we introduced a MainActor conformance on the expirationHandler but we are also assuming main actor + // isolated in the `stopSync` method above. + // https://sentry.tools.element.io/organizations/element/issues/4477794/ task.expirationHandler = { @Sendable [weak self] in MXLog.info("Background app refresh task is about to expire.") diff --git a/ElementX/Sources/Application/AppMediator.swift b/ElementX/Sources/Application/AppMediator.swift index 095e0f66d..b8016fda4 100644 --- a/ElementX/Sources/Application/AppMediator.swift +++ b/ElementX/Sources/Application/AppMediator.swift @@ -18,7 +18,7 @@ class AppMediator: AppMediatorProtocol { self.networkMonitor = networkMonitor } - // UIApplication.State won't update if we store this e.g. in the constructor + /// UIApplication.State won't update if we store this e.g. in the constructor private var application: UIApplication { UIApplication.shared } diff --git a/ElementX/Sources/Application/FlowCoordinatorProtocol.swift b/ElementX/Sources/Application/FlowCoordinatorProtocol.swift index 95f67590c..dcbecff45 100644 --- a/ElementX/Sources/Application/FlowCoordinatorProtocol.swift +++ b/ElementX/Sources/Application/FlowCoordinatorProtocol.swift @@ -41,6 +41,11 @@ struct CommonFlowParameters { let notificationManager: NotificationManagerProtocol let stateMachineFactory: StateMachineFactoryProtocol - var windowManager: WindowManagerProtocol { appMediator.windowManager } - var ongoingCallRoomIDPublisher: CurrentValuePublisher { elementCallService.ongoingCallRoomIDPublisher } + var windowManager: WindowManagerProtocol { + appMediator.windowManager + } + + var ongoingCallRoomIDPublisher: CurrentValuePublisher { + elementCallService.ongoingCallRoomIDPublisher + } } diff --git a/ElementX/Sources/Application/Navigation/NavigationTabCoordinator.swift b/ElementX/Sources/Application/Navigation/NavigationTabCoordinator.swift index 67e8b0227..361b73a9e 100644 --- a/ElementX/Sources/Application/Navigation/NavigationTabCoordinator.swift +++ b/ElementX/Sources/Application/Navigation/NavigationTabCoordinator.swift @@ -57,8 +57,13 @@ import SwiftUI let module: NavigationModule let details: TabDetails - var id: ObjectIdentifier { module.id } - @MainActor var coordinator: CoordinatorProtocol? { module.coordinator } + var id: ObjectIdentifier { + module.id + } + + @MainActor var coordinator: CoordinatorProtocol? { + module.coordinator + } } fileprivate var tabModules = [TabModule]() { diff --git a/ElementX/Sources/Application/Settings/AppSettings.swift b/ElementX/Sources/Application/Settings/AppSettings.swift index 55c016b58..2bb054d53 100644 --- a/ElementX/Sources/Application/Settings/AppSettings.swift +++ b/ElementX/Sources/Application/Settings/AppSettings.swift @@ -13,7 +13,7 @@ import EmbeddedElementCall import Foundation import SwiftUI -// Common settings between app and NSE +/// Common settings between app and NSE protocol CommonSettingsProtocol { var logLevel: LogLevel { get } var traceLogPacks: Set { get } @@ -265,7 +265,9 @@ final class AppSettings { } private(set) var pushGatewayBaseURL: URL = "https://matrix.org" - var pushGatewayNotifyEndpoint: URL { pushGatewayBaseURL.appending(path: "_matrix/push/v1/notify") } + var pushGatewayNotifyEndpoint: URL { + pushGatewayBaseURL.appending(path: "_matrix/push/v1/notify") + } @UserPreference(key: UserDefaultsKeys.enableNotifications, defaultValue: true, storageType: .userDefaults(store)) var enableNotifications @@ -305,7 +307,9 @@ final class AppSettings { /// The URL to open with more information about analytics terms. When this is `nil` the "Learn more" link will be hidden. private(set) var analyticsTermsURL: URL? = "https://element.io/cookie-policy" /// Whether or not there the app is able ask for user consent to enable analytics or sentry reporting. - var canPromptForAnalytics: Bool { analyticsConfiguration != nil || bugReportSentryURL != nil } + var canPromptForAnalytics: Bool { + analyticsConfiguration != nil || bugReportSentryURL != nil + } private static func makeAnalyticsConfiguration() -> AnalyticsConfiguration? { guard let host = Secrets.postHogHost, let apiKey = Secrets.postHogAPIKey else { return nil } @@ -364,7 +368,7 @@ final class AppSettings { // MARK: - Maps - // maptiler base url + /// maptiler base url private(set) var mapTilerConfiguration = MapTilerConfiguration(baseURL: "https://api.maptiler.com/maps", apiKey: Secrets.mapLibreAPIKey, lightStyleID: "9bc819c8-e627-474a-a348-ec144fe3d810", @@ -377,14 +381,14 @@ final class AppSettings { // MARK: - Feature Flags - // Spaces + /// Spaces @UserPreference(key: UserDefaultsKeys.spaceSettingsEnabled, defaultValue: false, storageType: .userDefaults(store)) var spaceSettingsEnabled @UserPreference(key: UserDefaultsKeys.createSpaceEnabled, defaultValue: false, storageType: .userDefaults(store)) var createSpaceEnabled - // Others + /// Others @UserPreference(key: UserDefaultsKeys.publicSearchEnabled, defaultValue: false, storageType: .userDefaults(store)) var publicSearchEnabled diff --git a/ElementX/Sources/Application/Settings/MapTilerConfiguration.swift b/ElementX/Sources/Application/Settings/MapTilerConfiguration.swift index beeea3b75..0671b7de1 100644 --- a/ElementX/Sources/Application/Settings/MapTilerConfiguration.swift +++ b/ElementX/Sources/Application/Settings/MapTilerConfiguration.swift @@ -22,5 +22,7 @@ struct MapTilerConfiguration { /// A MapLibre style ID for a dark-mode map. let darkStyleID: String - var isEnabled: Bool { apiKey != nil } + var isEnabled: Bool { + apiKey != nil + } } diff --git a/ElementX/Sources/Application/Settings/RemotePreference.swift b/ElementX/Sources/Application/Settings/RemotePreference.swift index 736c5826c..0b14b5c85 100644 --- a/ElementX/Sources/Application/Settings/RemotePreference.swift +++ b/ElementX/Sources/Application/Settings/RemotePreference.swift @@ -16,8 +16,13 @@ import Combine class RemotePreference { private let defaultValue: T private let subject: CurrentValueSubject - var publisher: CurrentValuePublisher { subject.asCurrentValuePublisher() } - var isRemotelyConfigured: Bool { subject.value != defaultValue } + var publisher: CurrentValuePublisher { + subject.asCurrentValuePublisher() + } + + var isRemotelyConfigured: Bool { + subject.value != defaultValue + } init(_ defaultValue: T) { self.defaultValue = defaultValue diff --git a/ElementX/Sources/Application/Settings/UserPreference.swift b/ElementX/Sources/Application/Settings/UserPreference.swift index 84271b58a..87a1d9a2a 100644 --- a/ElementX/Sources/Application/Settings/UserPreference.swift +++ b/ElementX/Sources/Application/Settings/UserPreference.swift @@ -24,14 +24,17 @@ final class UserPreference { } private let key: String - private var remoteKey: String { "\(Self.remotePrefix)\(key)" } + private var remoteKey: String { + "\(Self.remotePrefix)\(key)" + } + private var keyedStorage: any KeyedStorage private let defaultValue: T private let subject: PassthroughSubject = .init() private let mode: Mode - // This can be used to check if is still possible for the user to change the value or not - // Can only be accessed by using `_preferenceName.isLockedToRemote` + /// This can be used to check if is still possible for the user to change the value or not + /// Can only be accessed by using `_preferenceName.isLockedToRemote` var isLockedToRemote: Bool { mode == .remoteOverLocal && remoteValue != nil } @@ -53,7 +56,7 @@ final class UserPreference { self.mode = mode } - // The wrapped value is supposed to be the one updated by the user so it can only control the local value + /// The wrapped value is supposed to be the one updated by the user so it can only control the local value var wrappedValue: T { get { switch mode { @@ -69,8 +72,8 @@ final class UserPreference { } } - // This is supposed to be the value that is set by the remote settings - // So it can only be accessed by doing `AppSettings._preferenceName.remoteValue` + /// This is supposed to be the value that is set by the remote settings + /// So it can only be accessed by doing `AppSettings._preferenceName.remoteValue` var remoteValue: T? { get { keyedStorage[remoteKey] diff --git a/ElementX/Sources/FlowCoordinators/ChatsTabFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/ChatsTabFlowCoordinator.swift index 9209aa1a9..cea87b7c7 100644 --- a/ElementX/Sources/FlowCoordinators/ChatsTabFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/ChatsTabFlowCoordinator.swift @@ -25,7 +25,9 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol { private let navigationSplitCoordinator: NavigationSplitCoordinator private let flowParameters: CommonFlowParameters - private var userSession: UserSessionProtocol { flowParameters.userSession } + private var userSession: UserSessionProtocol { + flowParameters.userSession + } private let stateMachine: ChatsTabFlowCoordinatorStateMachine diff --git a/ElementX/Sources/FlowCoordinators/MediaEventsTimelineFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/MediaEventsTimelineFlowCoordinator.swift index d0e9f75d4..c79668c73 100644 --- a/ElementX/Sources/FlowCoordinators/MediaEventsTimelineFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/MediaEventsTimelineFlowCoordinator.swift @@ -20,7 +20,9 @@ class MediaEventsTimelineFlowCoordinator: FlowCoordinatorProtocol { private let navigationStackCoordinator: NavigationStackCoordinator private let flowParameters: CommonFlowParameters - private var userSession: UserSessionProtocol { flowParameters.userSession } + private var userSession: UserSessionProtocol { + flowParameters.userSession + } private let actionsSubject: PassthroughSubject = .init() var actionsPublisher: AnyPublisher { diff --git a/ElementX/Sources/FlowCoordinators/PinnedEventsTimelineFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/PinnedEventsTimelineFlowCoordinator.swift index e45c014f4..2996631f6 100644 --- a/ElementX/Sources/FlowCoordinators/PinnedEventsTimelineFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/PinnedEventsTimelineFlowCoordinator.swift @@ -21,7 +21,9 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol { private let navigationStackCoordinator: NavigationStackCoordinator private let flowParameters: CommonFlowParameters - private var userSession: UserSessionProtocol { flowParameters.userSession } + private var userSession: UserSessionProtocol { + flowParameters.userSession + } private let actionsSubject: PassthroughSubject = .init() var actionsPublisher: AnyPublisher { diff --git a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift index 023aaf6c4..8936eae25 100644 --- a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift @@ -67,7 +67,9 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { private let navigationStackCoordinator: NavigationStackCoordinator private let flowParameters: CommonFlowParameters - private var userSession: UserSessionProtocol { flowParameters.userSession } + private var userSession: UserSessionProtocol { + flowParameters.userSession + } private var roomProxy: JoinedRoomProxyProtocol! diff --git a/ElementX/Sources/FlowCoordinators/SpaceSettingsFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/SpaceSettingsFlowCoordinator.swift index cfa316526..905655608 100644 --- a/ElementX/Sources/FlowCoordinators/SpaceSettingsFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/SpaceSettingsFlowCoordinator.swift @@ -28,7 +28,7 @@ final class SpaceSettingsFlowCoordinator: FlowCoordinatorProtocol { /// The edit address screen case editAddress - // Other flows + /// Other flows /// The roles and permissions screen case rolesAndPermissionsFlow /// The members flow screen diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift index 743e6b586..67a435d3e 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift @@ -27,7 +27,9 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { private let appLockService: AppLockServiceProtocol private let flowParameters: CommonFlowParameters - private var userSession: UserSessionProtocol { flowParameters.userSession } + private var userSession: UserSessionProtocol { + flowParameters.userSession + } private let onboardingFlowCoordinator: OnboardingFlowCoordinator private let onboardingStackCoordinator: NavigationStackCoordinator @@ -145,12 +147,12 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { chatsTabFlowCoordinator.clearRoute(animated: animated) } - // Clearing routes is more complicated than it first seems. When passing routes - // to the chats flow we can't clear all routes as e.g. childRoom/childEvent etc - // expect to push into the existing stack. But we do need to hide any sheets that - // might cover up the presented route. BUT! We probably shouldn't dismiss onboarding - // or verification flows until they're complete… This needs more thought before we - // codify it all into the state machine. + /// Clearing routes is more complicated than it first seems. When passing routes + /// to the chats flow we can't clear all routes as e.g. childRoom/childEvent etc + /// expect to push into the existing stack. But we do need to hide any sheets that + /// might cover up the presented route. BUT! We probably shouldn't dismiss onboarding + /// or verification flows until they're complete… This needs more thought before we + /// codify it all into the state machine. private func clearPresentedSheets(animated: Bool) { switch stateMachine.state { case .initial, .tabBar: diff --git a/ElementX/Sources/Mocks/RoomMemberProxyMock.swift b/ElementX/Sources/Mocks/RoomMemberProxyMock.swift index 0014ce2e9..f803e28a5 100644 --- a/ElementX/Sources/Mocks/RoomMemberProxyMock.swift +++ b/ElementX/Sources/Mocks/RoomMemberProxyMock.swift @@ -38,7 +38,7 @@ extension RoomMemberProxyMock { powerLevel = configuration.powerLevel } - // Mocks + /// Mocks static var mockMe: RoomMemberProxyMock { RoomMemberProxyMock(with: .init(userID: "@me:matrix.org", displayName: "Me", diff --git a/ElementX/Sources/Mocks/UserProfile+Mock.swift b/ElementX/Sources/Mocks/UserProfile+Mock.swift index 8e0198f01..27a8b8ecf 100644 --- a/ElementX/Sources/Mocks/UserProfile+Mock.swift +++ b/ElementX/Sources/Mocks/UserProfile+Mock.swift @@ -9,7 +9,7 @@ import Foundation extension UserProfileProxy { - // Mocks + /// Mocks static var mockAlice: UserProfileProxy { .init(userID: "@alice:matrix.org", displayName: "Alice", avatarURL: "mxc://matrix.org/UcCimidcvpFvWkPzvjXMQPHA") } diff --git a/ElementX/Sources/Other/AccessibilityIdentifiers.swift b/ElementX/Sources/Other/AccessibilityIdentifiers.swift index 0058e6108..3db68bd2d 100644 --- a/ElementX/Sources/Other/AccessibilityIdentifiers.swift +++ b/ElementX/Sources/Other/AccessibilityIdentifiers.swift @@ -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 { diff --git a/ElementX/Sources/Other/Analytics/ScreenTrackerViewModifier.swift b/ElementX/Sources/Other/Analytics/ScreenTrackerViewModifier.swift index 8efc5c141..b8c3355ac 100644 --- a/ElementX/Sources/Other/Analytics/ScreenTrackerViewModifier.swift +++ b/ElementX/Sources/Other/Analytics/ScreenTrackerViewModifier.swift @@ -15,7 +15,6 @@ struct ScreenTrackerViewModifier: ViewModifier { let screen: AnalyticsEvent.MobileScreen.ScreenName - @ViewBuilder func body(content: Content) -> some View { content .onAppear { diff --git a/ElementX/Sources/Other/Avatars.swift b/ElementX/Sources/Other/Avatars.swift index 8f182bcd5..69f687150 100644 --- a/ElementX/Sources/Other/Avatars.swift +++ b/ElementX/Sources/Other/Avatars.swift @@ -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 diff --git a/ElementX/Sources/Other/BlurHashDecode.swift b/ElementX/Sources/Other/BlurHashDecode.swift index c96e9fd1c..7aa6e169c 100644 --- a/ElementX/Sources/Other/BlurHashDecode.swift +++ b/ElementX/Sources/Other/BlurHashDecode.swift @@ -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 { diff --git a/ElementX/Sources/Other/CollapsibleFlowLayout/CollapsibleReactionLayout.swift b/ElementX/Sources/Other/CollapsibleFlowLayout/CollapsibleReactionLayout.swift index e40b90a9b..6a2bf4d00 100644 --- a/ElementX/Sources/Other/CollapsibleFlowLayout/CollapsibleReactionLayout.swift +++ b/ElementX/Sources/Other/CollapsibleFlowLayout/CollapsibleReactionLayout.swift @@ -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 diff --git a/ElementX/Sources/Other/CurrentValuePublisher.swift b/ElementX/Sources/Other/CurrentValuePublisher.swift index f23e090b6..e2b6dfcd4 100644 --- a/ElementX/Sources/Other/CurrentValuePublisher.swift +++ b/ElementX/Sources/Other/CurrentValuePublisher.swift @@ -21,7 +21,7 @@ struct CurrentValuePublisher: Publisher { self.init(CurrentValueSubject(value)) } - func receive(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input { + func receive(subscriber: S) where Failure == S.Failure, Output == S.Input { subject.receive(subscriber: subscriber) } diff --git a/ElementX/Sources/Other/Extensions/Alert.swift b/ElementX/Sources/Other/Extensions/Alert.swift index 65200799d..f175163ce 100644 --- a/ElementX/Sources/Other/Extensions/Alert.swift +++ b/ElementX/Sources/Other/Extensions/Alert.swift @@ -13,7 +13,7 @@ protocol AlertProtocol { } extension View { - func alert(item: Binding, @ViewBuilder actions: (Item) -> Actions, @ViewBuilder message: (Item) -> Message) -> some View where Item: AlertProtocol, Actions: View, Message: View { + func alert(item: Binding, @ViewBuilder actions: (Item) -> Actions, @ViewBuilder message: (Item) -> Message) -> some View { let binding = Binding(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: Binding, @ViewBuilder actions: (Item) -> Actions) -> some View where Item: AlertProtocol, Actions: View { + func alert(item: Binding, @ViewBuilder actions: (Item) -> Actions) -> some View { let binding = Binding(get: { item.wrappedValue != nil }, set: { newValue in diff --git a/ElementX/Sources/Other/Extensions/AttributedString.swift b/ElementX/Sources/Other/Extensions/AttributedString.swift index 708786077..9e087cd84 100644 --- a/ElementX/Sources/Other/Extensions/AttributedString.swift +++ b/ElementX/Sources/Other/Extensions/AttributedString.swift @@ -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[...]) } diff --git a/ElementX/Sources/Other/Extensions/ConfirmationDialog.swift b/ElementX/Sources/Other/Extensions/ConfirmationDialog.swift index 4bc8fef4f..ccdc8bfb6 100644 --- a/ElementX/Sources/Other/Extensions/ConfirmationDialog.swift +++ b/ElementX/Sources/Other/Extensions/ConfirmationDialog.swift @@ -13,9 +13,9 @@ protocol ConfirmationDialogProtocol { } extension View { - func confirmationDialog(item: Binding, - titleVisibility: Visibility = .automatic, - @ViewBuilder actions: (Item) -> Actions) -> some View where Item: ConfirmationDialogProtocol, Actions: View { + func confirmationDialog(item: Binding, + titleVisibility: Visibility = .automatic, + @ViewBuilder actions: (Item) -> Actions) -> some View { let binding = Binding(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: Binding, - titleVisibility: Visibility = .automatic, - @ViewBuilder actions: (Item) -> Actions, - @ViewBuilder message: (Item) -> Message) -> some View where Item: ConfirmationDialogProtocol, Actions: View, Message: View { + func confirmationDialog(item: Binding, + titleVisibility: Visibility = .automatic, + @ViewBuilder actions: (Item) -> Actions, + @ViewBuilder message: (Item) -> Message) -> some View { let binding = Binding(get: { item.wrappedValue != nil }, set: { newValue in diff --git a/ElementX/Sources/Other/Extensions/Date.swift b/ElementX/Sources/Other/Extensions/Date.swift index b7d6bc5ba..a41b52131 100644 --- a/ElementX/Sources/Other/Extensions/Date.swift +++ b/ElementX/Sources/Other/Extensions/Date.swift @@ -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 diff --git a/ElementX/Sources/Other/Extensions/NSItemProvider.swift b/ElementX/Sources/Other/Extensions/NSItemProvider.swift index 464f2b5b3..3e17d8e64 100644 --- a/ElementX/Sources/Other/Extensions/NSItemProvider.swift +++ b/ElementX/Sources/Other/Extensions/NSItemProvider.swift @@ -197,5 +197,7 @@ extension NSItemProvider { } private extension NSString { - var hasPathExtension: Bool { !pathExtension.isEmpty } + var hasPathExtension: Bool { + !pathExtension.isEmpty + } } diff --git a/ElementX/Sources/Other/Extensions/OrderedSet.swift b/ElementX/Sources/Other/Extensions/OrderedSet.swift index 06ef34e5f..8dd530c0f 100644 --- a/ElementX/Sources/Other/Extensions/OrderedSet.swift +++ b/ElementX/Sources/Other/Extensions/OrderedSet.swift @@ -7,7 +7,6 @@ // import Foundation - import OrderedCollections extension OrderedSet { diff --git a/ElementX/Sources/Other/Extensions/Section.swift b/ElementX/Sources/Other/Extensions/Section.swift index 3b82e9eee..6135e3e6a 100644 --- a/ElementX/Sources/Other/Extensions/Section.swift +++ b/ElementX/Sources/Other/Extensions/Section.swift @@ -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() diff --git a/ElementX/Sources/Other/Extensions/URL.swift b/ElementX/Sources/Other/Extensions/URL.swift index 8c0cb1fd1..8b1c39392 100644 --- a/ElementX/Sources/Other/Extensions/URL.swift +++ b/ElementX/Sources/Other/Extensions/URL.swift @@ -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 diff --git a/ElementX/Sources/Other/Extensions/XCTestCase.swift b/ElementX/Sources/Other/Extensions/XCTestCase.swift index e9e2ec07c..590d3e856 100644 --- a/ElementX/Sources/Other/Extensions/XCTestCase.swift +++ b/ElementX/Sources/Other/Extensions/XCTestCase.swift @@ -96,7 +96,7 @@ extension XCTestCase { timeout: TimeInterval = 10, message: String? = nil) -> DeferredFulfillment { 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 { 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. diff --git a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift index 147a9e47a..01ff640e2 100644 --- a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift +++ b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift @@ -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 diff --git a/ElementX/Sources/Other/HTMLParsing/ElementXAttributeScope.swift b/ElementX/Sources/Other/HTMLParsing/ElementXAttributeScope.swift index 74f72bd62..f372451f9 100644 --- a/ElementX/Sources/Other/HTMLParsing/ElementXAttributeScope.swift +++ b/ElementX/Sources/Other/HTMLParsing/ElementXAttributeScope.swift @@ -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 diff --git a/ElementX/Sources/Other/Logging/Tracing.swift b/ElementX/Sources/Other/Logging/Tracing.swift index 43ebb4bf4..6c61f6ba1 100644 --- a/ElementX/Sources/Other/Logging/Tracing.swift +++ b/ElementX/Sources/Other/Logging/Tracing.swift @@ -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] { diff --git a/ElementX/Sources/Other/MapLibre/MapLibreModels.swift b/ElementX/Sources/Other/MapLibre/MapLibreModels.swift index a5dd154ed..681a22266 100644 --- a/ElementX/Sources/Other/MapLibre/MapLibreModels.swift +++ b/ElementX/Sources/Other/MapLibre/MapLibreModels.swift @@ -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 { diff --git a/ElementX/Sources/Other/MapLibre/MapLibreStaticMapView.swift b/ElementX/Sources/Other/MapLibre/MapLibreStaticMapView.swift index e30aa479e..289d69124 100644 --- a/ElementX/Sources/Other/MapLibre/MapLibreStaticMapView.swift +++ b/ElementX/Sources/Other/MapLibre/MapLibreStaticMapView.swift @@ -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, diff --git a/ElementX/Sources/Other/MatrixEntityRegex.swift b/ElementX/Sources/Other/MatrixEntityRegex.swift index cdc6d5548..b592a5b1e 100644 --- a/ElementX/Sources/Other/MatrixEntityRegex.swift +++ b/ElementX/Sources/Other/MatrixEntityRegex.swift @@ -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 diff --git a/ElementX/Sources/Other/Pills/MessageText.swift b/ElementX/Sources/Other/Pills/MessageText.swift index 6de78d490..478b06743 100644 --- a/ElementX/Sources/Other/Pills/MessageText.swift +++ b/ElementX/Sources/Other/Pills/MessageText.swift @@ -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 diff --git a/ElementX/Sources/Other/Pills/PillAttachmentViewProvider.swift b/ElementX/Sources/Other/Pills/PillAttachmentViewProvider.swift index a2ae71452..5b72d031d 100644 --- a/ElementX/Sources/Other/Pills/PillAttachmentViewProvider.swift +++ b/ElementX/Sources/Other/Pills/PillAttachmentViewProvider.swift @@ -9,7 +9,6 @@ import SwiftUI import SwiftUIIntrospect import UIKit - import WysiwygComposer protocol PillAttachmentViewProviderDelegate: AnyObject { diff --git a/ElementX/Sources/Other/Pills/PillView.swift b/ElementX/Sources/Other/Pills/PillView.swift index 3b4779861..28d49fd0b 100644 --- a/ElementX/Sources/Other/Pills/PillView.swift +++ b/ElementX/Sources/Other/Pills/PillView.swift @@ -29,7 +29,6 @@ struct PillView: View { } } - @ViewBuilder private var mainContent: some View { Text(context.viewState.displayText) .font(.compound.bodyLGSemibold) diff --git a/ElementX/Sources/Other/Pills/PlainMentionBuilder.swift b/ElementX/Sources/Other/Pills/PlainMentionBuilder.swift index 674163163..d33c3478f 100644 --- a/ElementX/Sources/Other/Pills/PlainMentionBuilder.swift +++ b/ElementX/Sources/Other/Pills/PlainMentionBuilder.swift @@ -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) { } diff --git a/ElementX/Sources/Other/SDKListener.swift b/ElementX/Sources/Other/SDKListener.swift index 2bdf6beaa..a4bba795e 100644 --- a/ElementX/Sources/Other/SDKListener.swift +++ b/ElementX/Sources/Other/SDKListener.swift @@ -26,123 +26,177 @@ final class SDKListener { // 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) + } } diff --git a/ElementX/Sources/Other/SwiftUI/Animation/ElementAnimations.swift b/ElementX/Sources/Other/SwiftUI/Animation/ElementAnimations.swift index 7d8965aa7..fd47373b7 100644 --- a/ElementX/Sources/Other/SwiftUI/Animation/ElementAnimations.swift +++ b/ElementX/Sources/Other/SwiftUI/Animation/ElementAnimations.swift @@ -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() diff --git a/ElementX/Sources/Other/SwiftUI/Layout/MenuSheetLabelStyle.swift b/ElementX/Sources/Other/SwiftUI/Layout/MenuSheetLabelStyle.swift index 13cd216bf..4678c80cd 100644 --- a/ElementX/Sources/Other/SwiftUI/Layout/MenuSheetLabelStyle.swift +++ b/ElementX/Sources/Other/SwiftUI/Layout/MenuSheetLabelStyle.swift @@ -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 diff --git a/ElementX/Sources/Other/SwiftUI/Layout/TimelineMediaFrame.swift b/ElementX/Sources/Other/SwiftUI/Layout/TimelineMediaFrame.swift index 1069a7464..e93a6a17f 100644 --- a/ElementX/Sources/Other/SwiftUI/Layout/TimelineMediaFrame.swift +++ b/ElementX/Sources/Other/SwiftUI/Layout/TimelineMediaFrame.swift @@ -31,7 +31,6 @@ extension View { } } - @ViewBuilder func mediaGalleryTimelineAspectRatio(imageInfo: ImageInfoProxy?) -> some View { aspectRatio(imageInfo?.aspectRatio, contentMode: .fill) } diff --git a/ElementX/Sources/Other/SwiftUI/Search.swift b/ElementX/Sources/Other/SwiftUI/Search.swift index 0ac57ce7b..a05c45ee1 100644 --- a/ElementX/Sources/Other/SwiftUI/Search.swift +++ b/ElementX/Sources/Other/SwiftUI/Search.swift @@ -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 diff --git a/ElementX/Sources/Other/SwiftUI/Views/LoadableImage.swift b/ElementX/Sources/Other/SwiftUI/Views/LoadableImage.swift index dcb2cecfe..0904e9042 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/LoadableImage.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/LoadableImage.swift @@ -135,9 +135,7 @@ private struct LoadableImageContent 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) diff --git a/ElementX/Sources/Other/SwiftUI/Views/UserProfileListRow.swift b/ElementX/Sources/Other/SwiftUI/Views/UserProfileListRow.swift index 2c2649cdb..8a8b3a48d 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/UserProfileListRow.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/UserProfileListRow.swift @@ -17,7 +17,9 @@ struct UserProfileListRow: View { let kind: ListRow.Kind - var isUnknownProfile: Bool { !user.isVerified && membership == nil } + var isUnknownProfile: Bool { + !user.isVerified && membership == nil + } private var subtitle: String? { guard !isUnknownProfile else { return L10n.commonInviteUnknownProfile } diff --git a/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift b/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift index 40ebe83ae..08d98abd6 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift @@ -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") } diff --git a/ElementX/Sources/Other/UserIndicator/UserIndicator.swift b/ElementX/Sources/Other/UserIndicator/UserIndicator.swift index a76d6c206..4329d576b 100644 --- a/ElementX/Sources/Other/UserIndicator/UserIndicator.swift +++ b/ElementX/Sources/Other/UserIndicator/UserIndicator.swift @@ -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 { diff --git a/ElementX/Sources/Other/UserIndicator/UserIndicatorModalView.swift b/ElementX/Sources/Other/UserIndicator/UserIndicatorModalView.swift index a9a69f795..80b5a2c58 100644 --- a/ElementX/Sources/Other/UserIndicator/UserIndicatorModalView.swift +++ b/ElementX/Sources/Other/UserIndicator/UserIndicatorModalView.swift @@ -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(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")) } } } diff --git a/ElementX/Sources/Other/UserIndicator/UserIndicatorPresenter.swift b/ElementX/Sources/Other/UserIndicator/UserIndicatorPresenter.swift index e43c904c3..fe5158ea6 100644 --- a/ElementX/Sources/Other/UserIndicator/UserIndicatorPresenter.swift +++ b/ElementX/Sources/Other/UserIndicator/UserIndicatorPresenter.swift @@ -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 { diff --git a/ElementX/Sources/Other/VoiceMessage/VoiceMessageButton.swift b/ElementX/Sources/Other/VoiceMessage/VoiceMessageButton.swift index 57a670b48..4e14fb082 100644 --- a/ElementX/Sources/Other/VoiceMessage/VoiceMessageButton.swift +++ b/ElementX/Sources/Other/VoiceMessage/VoiceMessageButton.swift @@ -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)) } } diff --git a/ElementX/Sources/Other/VoiceMessage/WaveformInteractionModifier.swift b/ElementX/Sources/Other/VoiceMessage/WaveformInteractionModifier.swift index e0c79b5d1..c8fb7cabb 100644 --- a/ElementX/Sources/Other/VoiceMessage/WaveformInteractionModifier.swift +++ b/ElementX/Sources/Other/VoiceMessage/WaveformInteractionModifier.swift @@ -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() diff --git a/ElementX/Sources/Screens/AppLock/AppLockScreen/AppLockScreenModels.swift b/ElementX/Sources/Screens/AppLock/AppLockScreen/AppLockScreenModels.swift index b82aac0ca..497713567 100644 --- a/ElementX/Sources/Screens/AppLock/AppLockScreen/AppLockScreenModels.swift +++ b/ElementX/Sources/Screens/AppLock/AppLockScreen/AppLockScreenModels.swift @@ -27,9 +27,15 @@ struct AppLockScreenViewState: BindableState { var bindings: AppLockScreenViewStateBindings /// The number of digits the user has entered so far. - var numberOfDigitsEntered: Int { bindings.pinCode.count } + var numberOfDigitsEntered: Int { + bindings.pinCode.count + } + /// Whether the subtitle is in a warning state or not. - var isSubtitleWarning: Bool { numberOfPINAttempts > 0 } + var isSubtitleWarning: Bool { + numberOfPINAttempts > 0 + } + /// The string shown in the screen's subtitle. var subtitle: String { if !isSubtitleWarning { diff --git a/ElementX/Sources/Screens/AppLock/AppLockScreen/View/AppLockScreen.swift b/ElementX/Sources/Screens/AppLock/AppLockScreen/View/AppLockScreen.swift index efd30e1f9..a20b61482 100644 --- a/ElementX/Sources/Screens/AppLock/AppLockScreen/View/AppLockScreen.swift +++ b/ElementX/Sources/Screens/AppLock/AppLockScreen/View/AppLockScreen.swift @@ -78,7 +78,7 @@ struct AppLockScreen: View { /// The row of dots showing how many digits have been entered. var pinInputField: some View { HStack(spacing: 24) { - /// The size of each dot within the PIN input field. + // The size of each dot within the PIN input field. let pinDotSize: CGFloat = 14 Circle() .fill(context.viewState.numberOfDigitsEntered > 0 ? .compound.iconPrimary : .compound.bgSubtlePrimary) diff --git a/ElementX/Sources/Screens/AppLock/AppLockScreen/View/AppLockScreenPINKeypad.swift b/ElementX/Sources/Screens/AppLock/AppLockScreen/View/AppLockScreenPINKeypad.swift index 366e35678..7d6d50dea 100644 --- a/ElementX/Sources/Screens/AppLock/AppLockScreen/View/AppLockScreenPINKeypad.swift +++ b/ElementX/Sources/Screens/AppLock/AppLockScreen/View/AppLockScreenPINKeypad.swift @@ -117,7 +117,9 @@ struct AppLockScreenPINKeypad_Previews: PreviewProvider { @StateObject var model = PreviewModel() class PreviewModel: ObservableObject { @Published var pinCode = "" - var output: String { pinCode.isEmpty ? "Enter code" : pinCode } + var output: String { + pinCode.isEmpty ? "Enter code" : pinCode + } } var body: some View { diff --git a/ElementX/Sources/Screens/AppLock/AppLockSetupBiometricsScreen/AppLockSetupBiometricsScreenModels.swift b/ElementX/Sources/Screens/AppLock/AppLockSetupBiometricsScreen/AppLockSetupBiometricsScreenModels.swift index 789b4d151..08af4e403 100644 --- a/ElementX/Sources/Screens/AppLock/AppLockSetupBiometricsScreen/AppLockSetupBiometricsScreenModels.swift +++ b/ElementX/Sources/Screens/AppLock/AppLockSetupBiometricsScreen/AppLockSetupBiometricsScreenModels.swift @@ -17,9 +17,17 @@ struct AppLockSetupBiometricsScreenViewState: BindableState { /// The supported biometry type on this device. let biometryType: LABiometryType - var icon: SFSymbol { biometryType.systemSymbol } - var title: String { L10n.screenAppLockSetupBiometricUnlockAllowTitle(biometryType.localizedString) } - var subtitle: String { L10n.screenAppLockSetupBiometricUnlockSubtitle(biometryType.localizedString) } + var icon: SFSymbol { + biometryType.systemSymbol + } + + var title: String { + L10n.screenAppLockSetupBiometricUnlockAllowTitle(biometryType.localizedString) + } + + var subtitle: String { + L10n.screenAppLockSetupBiometricUnlockSubtitle(biometryType.localizedString) + } } enum AppLockSetupBiometricsScreenViewAction { diff --git a/ElementX/Sources/Screens/AppLock/AppLockSetupPINScreen/AppLockSetupPINScreenModels.swift b/ElementX/Sources/Screens/AppLock/AppLockSetupPINScreen/AppLockSetupPINScreenModels.swift index c6bb12e13..e7d038156 100644 --- a/ElementX/Sources/Screens/AppLock/AppLockSetupPINScreen/AppLockSetupPINScreenModels.swift +++ b/ElementX/Sources/Screens/AppLock/AppLockSetupPINScreen/AppLockSetupPINScreenModels.swift @@ -50,7 +50,10 @@ struct AppLockSetupPINScreenViewState: BindableState { } /// Whether the subtitle is in a warning state or not. - var isSubtitleWarning: Bool { mode == .unlock && numberOfUnlockAttempts > 0 } + var isSubtitleWarning: Bool { + mode == .unlock && numberOfUnlockAttempts > 0 + } + var subtitle: String { guard mode == .unlock else { return L10n.screenAppLockSetupPinContext(InfoPlistReader.main.bundleDisplayName) } if !isSubtitleWarning { diff --git a/ElementX/Sources/Screens/AppLock/AppLockSetupSettingsScreen/AppLockSetupSettingsScreenModels.swift b/ElementX/Sources/Screens/AppLock/AppLockSetupSettingsScreen/AppLockSetupSettingsScreenModels.swift index 0c6e3a0c1..edb2fc270 100644 --- a/ElementX/Sources/Screens/AppLock/AppLockSetupSettingsScreen/AppLockSetupSettingsScreenModels.swift +++ b/ElementX/Sources/Screens/AppLock/AppLockSetupSettingsScreen/AppLockSetupSettingsScreenModels.swift @@ -22,8 +22,13 @@ struct AppLockSetupSettingsScreenViewState: BindableState { let biometryType: LABiometryType var bindings: AppLockSetupSettingsScreenViewStateBindings - var supportsBiometrics: Bool { biometryType != .none } - var enableBiometricsTitle: String { L10n.screenAppLockSetupBiometricUnlockAllowTitle(biometryType.localizedString) } + var supportsBiometrics: Bool { + biometryType != .none + } + + var enableBiometricsTitle: String { + L10n.screenAppLockSetupBiometricUnlockAllowTitle(biometryType.localizedString) + } } struct AppLockSetupSettingsScreenViewStateBindings { diff --git a/ElementX/Sources/Screens/Authentication/LoginScreen/LoginScreenCoordinator.swift b/ElementX/Sources/Screens/Authentication/LoginScreen/LoginScreenCoordinator.swift index b33c720cc..baa44f891 100644 --- a/ElementX/Sources/Screens/Authentication/LoginScreen/LoginScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Authentication/LoginScreen/LoginScreenCoordinator.swift @@ -26,12 +26,14 @@ enum LoginScreenCoordinatorAction { case signedIn(UserSessionProtocol) } -// Note: This code was brought over from Riot, we should move the authentication service logic into the view model. +/// Note: This code was brought over from Riot, we should move the authentication service logic into the view model. final class LoginScreenCoordinator: CoordinatorProtocol { private let parameters: LoginScreenCoordinatorParameters private var viewModel: LoginScreenViewModelProtocol - private var authenticationService: AuthenticationServiceProtocol { parameters.authenticationService } + private var authenticationService: AuthenticationServiceProtocol { + parameters.authenticationService + } private let actionsSubject: PassthroughSubject = .init() private var cancellables = Set() diff --git a/ElementX/Sources/Screens/Authentication/LoginScreen/LoginScreenModels.swift b/ElementX/Sources/Screens/Authentication/LoginScreen/LoginScreenModels.swift index 955f5037a..6096794a9 100644 --- a/ElementX/Sources/Screens/Authentication/LoginScreen/LoginScreenModels.swift +++ b/ElementX/Sources/Screens/Authentication/LoginScreen/LoginScreenModels.swift @@ -31,7 +31,9 @@ struct LoginScreenViewState: BindableState { var bindings = LoginScreenBindings() /// The types of login supported by the homeserver. - var loginMode: LoginMode { homeserver.loginMode } + var loginMode: LoginMode { + homeserver.loginMode + } /// `true` if the username and password are ready to be submitted. var hasValidCredentials: Bool { diff --git a/ElementX/Sources/Screens/Authentication/OIDCAuthenticationPresenter.swift b/ElementX/Sources/Screens/Authentication/OIDCAuthenticationPresenter.swift index f78bc2c05..db27f3f14 100644 --- a/ElementX/Sources/Screens/Authentication/OIDCAuthenticationPresenter.swift +++ b/ElementX/Sources/Screens/Authentication/OIDCAuthenticationPresenter.swift @@ -103,7 +103,9 @@ class OIDCAuthenticationPresenter: NSObject { // MARK: ASWebAuthenticationPresentationContextProviding extension OIDCAuthenticationPresenter: ASWebAuthenticationPresentationContextProviding { - func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor { presentationAnchor } + func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor { + presentationAnchor + } } extension ASWebAuthenticationSession.Callback { diff --git a/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift b/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift index 21b2099ad..47e2ec144 100644 --- a/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift +++ b/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift @@ -103,9 +103,9 @@ struct ServerConfirmationScreen: View { } } -// This is such a hack. I hate it! -// But… We're not in a List/Form, the compound picker doesn't -// support icons and this screen's design might change so 🤷‍♂️. +/// This is such a hack. I hate it! +/// But… We're not in a List/Form, the compound picker doesn't +/// support icons and this screen's design might change so 🤷‍♂️. private struct FakeInlinePicker: View { let items: [String] let icon: KeyPath diff --git a/ElementX/Sources/Screens/Authentication/ServerSelectionScreen/ServerSelectionScreenCoordinator.swift b/ElementX/Sources/Screens/Authentication/ServerSelectionScreen/ServerSelectionScreenCoordinator.swift index 4a81fdc53..e5baec76e 100644 --- a/ElementX/Sources/Screens/Authentication/ServerSelectionScreen/ServerSelectionScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Authentication/ServerSelectionScreen/ServerSelectionScreenCoordinator.swift @@ -22,12 +22,14 @@ enum ServerSelectionScreenCoordinatorAction { case dismiss } -// Note: This code was brought over from Riot, we should move the authentication service logic into the view model. +/// Note: This code was brought over from Riot, we should move the authentication service logic into the view model. final class ServerSelectionScreenCoordinator: CoordinatorProtocol { private let parameters: ServerSelectionScreenCoordinatorParameters private let userIndicatorController: UserIndicatorControllerProtocol private var viewModel: ServerSelectionScreenViewModelProtocol - private var authenticationService: AuthenticationServiceProtocol { parameters.authenticationService } + private var authenticationService: AuthenticationServiceProtocol { + parameters.authenticationService + } private let actionsSubject: PassthroughSubject = .init() private var cancellables = Set() diff --git a/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/SoftLogoutScreenCoordinator.swift b/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/SoftLogoutScreenCoordinator.swift index 61a393183..d2916eb00 100644 --- a/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/SoftLogoutScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/SoftLogoutScreenCoordinator.swift @@ -34,14 +34,17 @@ enum SoftLogoutScreenCoordinatorResult: CustomStringConvertible { } } -// Note: This code was brought over from Riot, we should move the authentication service logic into the view model. +/// Note: This code was brought over from Riot, we should move the authentication service logic into the view model. final class SoftLogoutScreenCoordinator: CoordinatorProtocol { private let parameters: SoftLogoutScreenCoordinatorParameters private var viewModel: SoftLogoutScreenViewModelProtocol private let actionsSubject: PassthroughSubject = .init() private var cancellables = Set() - private var authenticationService: AuthenticationServiceProtocol { parameters.authenticationService } + private var authenticationService: AuthenticationServiceProtocol { + parameters.authenticationService + } + private var oidcPresenter: OIDCAuthenticationPresenter? var actions: AnyPublisher { diff --git a/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/SoftLogoutScreenModels.swift b/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/SoftLogoutScreenModels.swift index 1e348d62a..1e2e00bc3 100644 --- a/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/SoftLogoutScreenModels.swift +++ b/ElementX/Sources/Screens/Authentication/SoftLogoutScreen/SoftLogoutScreenModels.swift @@ -54,7 +54,9 @@ struct SoftLogoutScreenViewState: BindableState { var bindings: SoftLogoutScreenBindings /// The types of login supported by the homeserver. - var loginMode: LoginMode { homeserver.loginMode } + var loginMode: LoginMode { + homeserver.loginMode + } /// The presentation anchor used for OIDC authentication. var window: UIWindow? diff --git a/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationStartLogo.swift b/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationStartLogo.swift index bc5d9c28f..8d5eea263 100644 --- a/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationStartLogo.swift +++ b/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationStartLogo.swift @@ -20,7 +20,9 @@ struct AuthenticationStartLogo: View { /// The shape that the logo is composed on top of. private let outerShape = RoundedRectangle(cornerRadius: 44) private let outerShapeShadowColor = Color(red: 0.11, green: 0.11, blue: 0.13) - private var isLight: Bool { colorScheme == .light } + private var isLight: Bool { + colorScheme == .light + } var body: some View { if hideBrandChrome { diff --git a/ElementX/Sources/Screens/BugReportScreen/BugReportScreenCoordinator.swift b/ElementX/Sources/Screens/BugReportScreen/BugReportScreenCoordinator.swift index d5b08c4d8..6f5a37f92 100644 --- a/ElementX/Sources/Screens/BugReportScreen/BugReportScreenCoordinator.swift +++ b/ElementX/Sources/Screens/BugReportScreen/BugReportScreenCoordinator.swift @@ -83,12 +83,10 @@ final class BugReportScreenCoordinator: CoordinatorProtocol { private static let loadingIndicatorIdentifier = "\(BugReportScreenCoordinator.self)-Loading" private func startLoading(label: String = L10n.commonLoading, progressPublisher: CurrentValuePublisher) { - parameters.userIndicatorController?.submitIndicator( - UserIndicator(id: Self.loadingIndicatorIdentifier, - type: .modal(progress: .published(progressPublisher), interactiveDismissDisabled: false, allowsInteraction: true), - title: label, - persistent: true) - ) + parameters.userIndicatorController?.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier, + type: .modal(progress: .published(progressPublisher), interactiveDismissDisabled: false, allowsInteraction: true), + title: label, + persistent: true)) } private func stopLoading() { diff --git a/ElementX/Sources/Screens/BugReportScreen/View/BugReportScreen.swift b/ElementX/Sources/Screens/BugReportScreen/View/BugReportScreen.swift index 6dd12179e..b9546424b 100644 --- a/ElementX/Sources/Screens/BugReportScreen/View/BugReportScreen.swift +++ b/ElementX/Sources/Screens/BugReportScreen/View/BugReportScreen.swift @@ -15,8 +15,13 @@ struct BugReportScreen: View { @Bindable var context: BugReportScreenViewModel.Context - var canSendLogFiles: Bool { context.viewState.canSendLogFiles } - var photosPickerTitle: String { context.viewState.screenshot == nil ? L10n.screenBugReportAttachScreenshot : L10n.screenBugReportEditScreenshot } + var canSendLogFiles: Bool { + context.viewState.canSendLogFiles + } + + var photosPickerTitle: String { + context.viewState.screenshot == nil ? L10n.screenBugReportAttachScreenshot : L10n.screenBugReportEditScreenshot + } var body: some View { Form { @@ -89,7 +94,6 @@ struct BugReportScreen: View { } } - @ViewBuilder private var attachScreenshotSection: some View { Section { ListRow(kind: .custom { diff --git a/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift b/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift index 40e3cfa87..e7c16472b 100644 --- a/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift +++ b/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift @@ -225,7 +225,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol } } - // This should always match the web app value + /// This should always match the web app value private static let earpieceID = "earpiece-id" private func handleOutputDeviceSelected(deviceID: String) { diff --git a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift index 9a2c0f296..c7e9826e6 100644 --- a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift +++ b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift @@ -197,8 +197,8 @@ private struct CallView: UIViewRepresentable { } } - // This function is called by the webview output routing button - // it allows to open the OS output selector using the hidden button. + /// This function is called by the webview output routing button + /// it allows to open the OS output selector using the hidden button. private func tapRoutePickerView() { guard let button = routePickerView.subviews.first(where: { $0 is UIButton }) as? UIButton else { return diff --git a/ElementX/Sources/Screens/EncryptionReset/EncryptionResetPasswordScreen/View/EncryptionResetPasswordScreen.swift b/ElementX/Sources/Screens/EncryptionReset/EncryptionResetPasswordScreen/View/EncryptionResetPasswordScreen.swift index b0d18235f..ef1d7056c 100644 --- a/ElementX/Sources/Screens/EncryptionReset/EncryptionResetPasswordScreen/View/EncryptionResetPasswordScreen.swift +++ b/ElementX/Sources/Screens/EncryptionReset/EncryptionResetPasswordScreen/View/EncryptionResetPasswordScreen.swift @@ -45,7 +45,6 @@ struct EncryptionResetPasswordScreen: View { .onAppear { textFieldFocus = true } } - @ViewBuilder private var passwordSection: some View { VStack(alignment: .leading, spacing: 8) { Text(L10n.commonPassword) diff --git a/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/View/EncryptionResetScreen.swift b/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/View/EncryptionResetScreen.swift index bfd1d4a4a..f797ee992 100644 --- a/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/View/EncryptionResetScreen.swift +++ b/ElementX/Sources/Screens/EncryptionReset/EncryptionResetScreen/View/EncryptionResetScreen.swift @@ -70,7 +70,6 @@ struct EncryptionResetScreen: View { .environment(\.backgroundStyle, AnyShapeStyle(.compound.bgSubtleSecondary)) } - @ViewBuilder private func checkMarkItem(title: String, position: ListPosition, positive: Bool) -> some View { VisualListItem(title: title, position: position) { CompoundIcon(positive ? \.check : \.info) diff --git a/ElementX/Sources/Screens/FilePreviewScreen/InteractiveQuickLook.swift b/ElementX/Sources/Screens/FilePreviewScreen/InteractiveQuickLook.swift index 7216e51b9..ffa2725b6 100644 --- a/ElementX/Sources/Screens/FilePreviewScreen/InteractiveQuickLook.swift +++ b/ElementX/Sources/Screens/FilePreviewScreen/InteractiveQuickLook.swift @@ -106,10 +106,10 @@ private struct MediaPreviewViewController: UIViewControllerRepresentable { ]) } - // Don't use viewWillAppear due to the following warning: - // Presenting view controller from detached view controller is not supported, - // and may result in incorrect safe area insets and a corrupt root presentation. Make sure is in - // the view controller hierarchy before presenting from it. Will become a hard exception in a future release. + /// Don't use viewWillAppear due to the following warning: + /// Presenting view controller from detached view controller is not supported, + /// and may result in incorrect safe area insets and a corrupt root presentation. Make sure is in + /// the view controller hierarchy before presenting from it. Will become a hard exception in a future release. override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) @@ -153,7 +153,10 @@ private struct MediaPreviewViewController: UIViewControllerRepresentable { class MediaPreviewItem: NSObject, QLPreviewItem { let file: MediaFileHandleProxy - var previewItemURL: URL? { file.url } + var previewItemURL: URL? { + file.url + } + let previewItemTitle: String? init(file: MediaFileHandleProxy, title: String?) { diff --git a/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewDataSource.swift b/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewDataSource.swift index e626251c5..0f7da106c 100644 --- a/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewDataSource.swift +++ b/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewDataSource.swift @@ -114,8 +114,13 @@ class TimelineMediaPreviewDataSource: NSObject, QLPreviewControllerDataSource { // MARK: - QLPreviewControllerDataSource - var firstPreviewItemIndex: Int { backwardPadding } - var lastPreviewItemIndex: Int { backwardPadding + previewItems.count - 1 } + var firstPreviewItemIndex: Int { + backwardPadding + } + + var lastPreviewItemIndex: Int { + backwardPadding + previewItems.count - 1 + } func numberOfPreviewItems(in controller: QLPreviewController) -> Int { previewItems.count + backwardPadding + forwardPadding diff --git a/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewModels.swift b/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewModels.swift index d19bf9b4c..1b3ac160e 100644 --- a/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewModels.swift +++ b/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewModels.swift @@ -56,7 +56,10 @@ struct TimelineMediaPreviewViewState: BindableState { var dataSource: TimelineMediaPreviewDataSource /// The media item that is currently being previewed. - var currentItem: TimelineMediaPreviewItem { dataSource.currentItem } + var currentItem: TimelineMediaPreviewItem { + dataSource.currentItem + } + /// All of the available actions for the current item. var currentItemActions: TimelineItemMenuActions? diff --git a/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewModifier.swift b/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewModifier.swift index 68d66c146..2014054cb 100644 --- a/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewModifier.swift +++ b/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewModifier.swift @@ -101,10 +101,10 @@ private struct MediaPreviewViewController: UIViewControllerRepresentable { ]) } - // Don't use viewWillAppear due to the following warning: - // Presenting view controller from detached view controller is not supported, - // and may result in incorrect safe area insets and a corrupt root presentation. Make sure is in - // the view controller hierarchy before presenting from it. Will become a hard exception in a future release. + /// Don't use viewWillAppear due to the following warning: + /// Presenting view controller from detached view controller is not supported, + /// and may result in incorrect safe area insets and a corrupt root presentation. Make sure is in + /// the view controller hierarchy before presenting from it. Will become a hard exception in a future release. override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) diff --git a/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewViewModel.swift b/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewViewModel.swift index 1b91cef21..74a297cc4 100644 --- a/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewViewModel.swift +++ b/ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewViewModel.swift @@ -236,5 +236,7 @@ class TimelineMediaPreviewViewModel: TimelineMediaPreviewViewModelType { title: L10n.screenMediaDetailsNoMoreMediaToShow)) } - private var statusIndicatorID: String { "\(Self.self)-Status" } + private var statusIndicatorID: String { + "\(Self.self)-Status" + } } diff --git a/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewController.swift b/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewController.swift index 8f6c07af5..ce10aadf7 100644 --- a/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewController.swift +++ b/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewController.swift @@ -24,7 +24,10 @@ class TimelineMediaPreviewController: QLPreviewController { private var cancellables: Set = [] - private var navigationBar: UINavigationBar? { view.subviews.first?.subviews.first { $0 is UINavigationBar } as? UINavigationBar } + private var navigationBar: UINavigationBar? { + view.subviews.first?.subviews.first { $0 is UINavigationBar } as? UINavigationBar + } + private var bottomBarItemsContainer: UIView? { if #available(iOS 26, *) { view.subviews.first?.subviews.last?.subviews.first @@ -33,8 +36,13 @@ class TimelineMediaPreviewController: QLPreviewController { } } - private var pageScrollView: UIScrollView? { view.firstScrollView() } - private var captionView: UIView { captionHostingController.view } + private var pageScrollView: UIScrollView? { + view.firstScrollView() + } + + private var captionView: UIView { + captionHostingController.view + } override var overrideUserInterfaceStyle: UIUserInterfaceStyle { get { .dark } @@ -255,7 +263,9 @@ class TimelineMediaPreviewController: QLPreviewController { private struct HeaderView: View { @ObservedObject var context: TimelineMediaPreviewViewModel.Context - private var currentItem: TimelineMediaPreviewItem { context.viewState.currentItem } + private var currentItem: TimelineMediaPreviewItem { + context.viewState.currentItem + } var body: some View { switch currentItem { @@ -281,7 +291,9 @@ private struct HeaderView: View { private struct DetailsButton: View { @ObservedObject var context: TimelineMediaPreviewViewModel.Context - private var currentItem: TimelineMediaPreviewItem { context.viewState.currentItem } + private var currentItem: TimelineMediaPreviewItem { + context.viewState.currentItem + } var isHidden: Bool { switch currentItem { @@ -301,7 +313,9 @@ private struct DetailsButton: View { private struct CaptionView: View { @ObservedObject var context: TimelineMediaPreviewViewModel.Context - private var currentItem: TimelineMediaPreviewItem { context.viewState.currentItem } + private var currentItem: TimelineMediaPreviewItem { + context.viewState.currentItem + } var body: some View { if case let .media(mediaItem) = currentItem, let caption = mediaItem.caption { @@ -323,7 +337,9 @@ private struct CaptionView: View { private struct DownloadIndicatorView: View { @ObservedObject var context: TimelineMediaPreviewViewModel.Context - private var currentItem: TimelineMediaPreviewItem { context.viewState.currentItem } + private var currentItem: TimelineMediaPreviewItem { + context.viewState.currentItem + } private var shouldShowDownloadIndicator: Bool { switch currentItem { diff --git a/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewFileExportPicker.swift b/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewFileExportPicker.swift index afb88087c..ef6e41fb1 100644 --- a/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewFileExportPicker.swift +++ b/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewFileExportPicker.swift @@ -11,7 +11,9 @@ import SwiftUI struct TimelineMediaPreviewFileExportPicker: UIViewControllerRepresentable { struct File: Identifiable { let url: URL - var id: String { url.absoluteString } + var id: String { + url.absoluteString + } } let file: File diff --git a/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewRedactConfirmationView.swift b/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewRedactConfirmationView.swift index da9942d76..d7eab8b4d 100644 --- a/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewRedactConfirmationView.swift +++ b/ElementX/Sources/Screens/FilePreviewScreen/View/TimelineMediaPreviewRedactConfirmationView.swift @@ -57,7 +57,6 @@ struct TimelineMediaPreviewRedactConfirmationView: View { .padding(.horizontal, 24) } - @ViewBuilder private var preview: some View { HStack(spacing: 12) { if let mediaSource = item.thumbnailMediaSource { diff --git a/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift b/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift index d3d4431fd..99fdfee76 100644 --- a/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift +++ b/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift @@ -130,7 +130,7 @@ struct HomeScreenViewState: BindableState { } } - // Used to hide all the rooms when the search field is focused and the query is empty + /// Used to hide all the rooms when the search field is focused and the query is empty var shouldHideRoomList: Bool { bindings.isSearchFieldFocused && bindings.searchQuery.isEmpty } diff --git a/ElementX/Sources/Screens/HomeScreen/View/BloomModifier.swift b/ElementX/Sources/Screens/HomeScreen/View/BloomModifier.swift index 9e93563af..9302eb310 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/BloomModifier.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/BloomModifier.swift @@ -29,7 +29,9 @@ private struct BloomModifier: ViewModifier { @State private var height = CGFloat.zero - private var endPointY: CGFloat { hasSearchBar ? 0.35 : 0.55 } + private var endPointY: CGFloat { + hasSearchBar ? 0.35 : 0.55 + } func body(content: Content) -> some View { content @@ -102,7 +104,9 @@ private struct OldBloomModifier: ViewModifier { return bloom } - private var endPointY: CGFloat { hasSearchBar ? 0.5 : 0.7 } + private var endPointY: CGFloat { + hasSearchBar ? 0.5 : 0.7 + } private var bloomGradient: some View { LinearGradient(gradient: .compound.subtle, @@ -117,9 +121,9 @@ private struct OldBloomModifier: ViewModifier { bloom.colorScheme == colorScheme && bloom.baseColor == .compound.gradientSubtleStop1 } - // This is a class to avoid a "Modifying state during view update" warning when storing - // the result on the same run-loop - we want to avoid dispatching that to the next loop as - // that can result in further (unnecessary) renders being made. + /// This is a class to avoid a "Modifying state during view update" warning when storing + /// the result on the same run-loop - we want to avoid dispatching that to the next loop as + /// that can result in further (unnecessary) renders being made. class Bloom { var image: UIImage? var colorScheme: ColorScheme? diff --git a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFilterModels.swift b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFilterModels.swift index 8bc2f4e5f..fcd4db338 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFilterModels.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFilterModels.swift @@ -8,7 +8,6 @@ import Combine import Foundation - import MatrixRustSDK import OrderedCollections diff --git a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift index 77ad167ae..0c1e52d99 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift @@ -15,7 +15,9 @@ struct RoomListFiltersView: View { /// When you connect a mouse on macOS the scrollbars aren't hidden. This is some extra padding /// applied to the scroll view content to make sure the bars don't overlap the filters. - private var macScrollBarPadding: CGFloat { ProcessInfo.processInfo.isiOSAppOnMac ? 16 : 0 } + private var macScrollBarPadding: CGFloat { + ProcessInfo.processInfo.isiOSAppOnMac ? 16 : 0 + } var body: some View { ScrollViewReader { proxy in diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift index 45a395342..3d36593d3 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift @@ -92,7 +92,6 @@ struct HomeScreenInviteCell: View { } } - @ViewBuilder private var textualContent: some View { VStack(alignment: .leading, spacing: 0) { Text(title) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift index e9e11319d..71c04c50f 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift @@ -65,7 +65,6 @@ struct HomeScreenKnockedCell: View { } } - @ViewBuilder private var textualContent: some View { VStack(alignment: .leading, spacing: 0) { Text(title) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift index 5dc29b168..b8abbad69 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift @@ -76,7 +76,6 @@ struct HomeScreenRoomCell: View { } } - @ViewBuilder private var header: some View { HStack(alignment: .top, spacing: 16) { Text(room.name) @@ -93,7 +92,6 @@ struct HomeScreenRoomCell: View { } } - @ViewBuilder private var footer: some View { HStack(alignment: .firstTextBaseline, spacing: 0) { ZStack(alignment: .topLeading) { diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomList.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomList.swift index 743eb8861..5263a81c2 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomList.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomList.swift @@ -20,7 +20,6 @@ struct HomeScreenRoomList: View { } } - @ViewBuilder private var content: some View { ForEach(context.viewState.visibleRooms) { room in switch room.type { diff --git a/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift b/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift index a16c3fea8..16d13de27 100644 --- a/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift +++ b/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift @@ -56,7 +56,6 @@ struct JoinRoomScreen: View { } } - @ViewBuilder private var defaultView: some View { VStack(spacing: 16) { RoomAvatarImage(avatar: context.viewState.avatar ?? .room(id: "", name: nil, avatarURL: nil), @@ -140,7 +139,6 @@ struct JoinRoomScreen: View { } } - @ViewBuilder private var knockedView: some View { VStack(spacing: 16) { BigIcon(icon: \.checkCircleSolid, style: .successSolid) @@ -157,7 +155,6 @@ struct JoinRoomScreen: View { } } - @ViewBuilder private var knockMessage: some View { VStack(alignment: .leading, spacing: 12) { HStack(spacing: 0) { diff --git a/ElementX/Sources/Screens/KnockRequestsListScreen/KnockRequestsListScreenModels.swift b/ElementX/Sources/Screens/KnockRequestsListScreen/KnockRequestsListScreenModels.swift index a23d035a5..b0a626444 100644 --- a/ElementX/Sources/Screens/KnockRequestsListScreen/KnockRequestsListScreenModels.swift +++ b/ElementX/Sources/Screens/KnockRequestsListScreen/KnockRequestsListScreenModels.swift @@ -36,8 +36,8 @@ struct KnockRequestsListScreenViewState: BindableState { var isKnockableRoom = true var handledEventIDs: Set = [] - // If all the permissions are denied or the join rule changes while we are in the view - // we want to stop displaying any request + /// If all the permissions are denied or the join rule changes while we are in the view + /// we want to stop displaying any request var shouldDisplayRequests: Bool { !displayedRequests.isEmpty && isKnockableRoom && (canAccept || canDecline || canBan) } diff --git a/ElementX/Sources/Screens/KnockRequestsListScreen/View/KnockRequestCell.swift b/ElementX/Sources/Screens/KnockRequestsListScreen/View/KnockRequestCell.swift index db650be74..4ff2f0467 100644 --- a/ElementX/Sources/Screens/KnockRequestsListScreen/View/KnockRequestCell.swift +++ b/ElementX/Sources/Screens/KnockRequestsListScreen/View/KnockRequestCell.swift @@ -80,7 +80,6 @@ struct KnockRequestCell: View { } } - @ViewBuilder private var actions: some View { VStack(spacing: 16) { if onDecline != nil || onAccept != nil { @@ -174,7 +173,9 @@ private struct DisclosableText: View { } extension KnockRequestCellInfo: Identifiable { - var id: String { eventID } + var id: String { + eventID + } } struct KnockRequestCell_Previews: PreviewProvider, TestablePreview { diff --git a/ElementX/Sources/Screens/LocationSharing/StaticLocationScreenViewModel.swift b/ElementX/Sources/Screens/LocationSharing/StaticLocationScreenViewModel.swift index 5ad99dd6d..3a71da4ae 100644 --- a/ElementX/Sources/Screens/LocationSharing/StaticLocationScreenViewModel.swift +++ b/ElementX/Sources/Screens/LocationSharing/StaticLocationScreenViewModel.swift @@ -84,5 +84,7 @@ class StaticLocationScreenViewModel: StaticLocationScreenViewModelType, StaticLo iconName: "xmark")) } - private var statusIndicatorID: String { "\(Self.self)-Status" } + private var statusIndicatorID: String { + "\(Self.self)-Status" + } } diff --git a/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift b/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift index 6806f3333..1cfe0612e 100644 --- a/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift +++ b/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift @@ -37,12 +37,12 @@ struct MediaEventsTimelineScreen: View { } } - // The scale effects do the following: - // * flip the scrollView vertically to keep the items - // at the bottom and have pagination working properly - // * flip the grid vertically to counteract the scroll view - // but also horizontally to preserve the correct item order - // * flip the items on both axes have them render correctly + /// The scale effects do the following: + /// * flip the scrollView vertically to keep the items + /// at the bottom and have pagination working properly + /// * flip the grid vertically to counteract the scroll view + /// but also horizontally to preserve the correct item order + /// * flip the items on both axes have them render correctly @ViewBuilder private var mainContent: some View { if context.viewState.shouldShowEmptyState { @@ -99,7 +99,6 @@ struct MediaEventsTimelineScreen: View { .scaleEffect(.init(width: -1, height: 1)) } - @ViewBuilder private var filesContent: some View { LazyVStack(alignment: .center, spacing: 16) { ForEach(context.viewState.groups) { group in @@ -174,7 +173,6 @@ struct MediaEventsTimelineScreen: View { } } - @ViewBuilder private var emptyState: some View { FullscreenDialog(topPadding: UIConstants.iconTopPaddingToNavigationBar, background: .gradient) { VStack(spacing: 16) { @@ -260,7 +258,9 @@ struct MediaEventsTimelineScreen: View { } extension TimelineMediaPreviewViewModel: Identifiable { - var id: UUID { instanceID } + var id: UUID { + instanceID + } } // MARK: - Previews diff --git a/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift b/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift index 257032e83..ede0eb9e3 100644 --- a/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift +++ b/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift @@ -21,8 +21,13 @@ struct MediaUploadPreviewScreen: View { @State private var currentIndex = 0 @FocusState private var isComposerFocussed - private var title: String { ProcessInfo.processInfo.isiOSAppOnMac ? context.viewState.title ?? "" : "" } - private var colorSchemeOverride: ColorScheme { ProcessInfo.processInfo.isiOSAppOnMac ? colorScheme : .dark } + private var title: String { + ProcessInfo.processInfo.isiOSAppOnMac ? context.viewState.title ?? "" : "" + } + + private var colorSchemeOverride: ColorScheme { + ProcessInfo.processInfo.isiOSAppOnMac ? colorScheme : .dark + } var body: some View { mainContent diff --git a/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift b/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift index 6b6fddf21..aef362555 100644 --- a/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift +++ b/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift @@ -64,7 +64,6 @@ struct AnalyticsPromptScreen: View { .environment(\.backgroundStyle, AnyShapeStyle(.compound.bgSubtleSecondary)) } - @ViewBuilder private func checkMarkItem(title: String, position: ListPosition) -> some View { VisualListItem(title: title, position: position) { CompoundIcon(\.checkCircle, size: .small, relativeTo: .body) diff --git a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift index 8715498ca..7e8929ed9 100644 --- a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift +++ b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift @@ -35,7 +35,6 @@ struct IdentityConfirmationScreen: View { // MARK: - Private - @ViewBuilder private var screenHeader: some View { VStack(spacing: 0) { BigIcon(icon: \.lockSolid) @@ -60,7 +59,6 @@ struct IdentityConfirmationScreen: View { } } - @ViewBuilder private var actionButtons: some View { VStack(spacing: 16) { if let availableActions = context.viewState.availableActions { diff --git a/ElementX/Sources/Screens/Onboarding/IdentityConfirmedScreen/View/IdentityConfirmedScreen.swift b/ElementX/Sources/Screens/Onboarding/IdentityConfirmedScreen/View/IdentityConfirmedScreen.swift index f6e176acd..c49dd8414 100644 --- a/ElementX/Sources/Screens/Onboarding/IdentityConfirmedScreen/View/IdentityConfirmedScreen.swift +++ b/ElementX/Sources/Screens/Onboarding/IdentityConfirmedScreen/View/IdentityConfirmedScreen.swift @@ -27,7 +27,6 @@ struct IdentityConfirmedScreen: View { // MARK: - Private - @ViewBuilder private var screenHeader: some View { VStack(spacing: 0) { BigIcon(icon: \.checkCircle, style: .successSolid) @@ -46,7 +45,6 @@ struct IdentityConfirmedScreen: View { } } - @ViewBuilder private var actionButtons: some View { Button(L10n.actionContinue) { context.send(viewAction: .done) diff --git a/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift b/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift index 53476a298..bb9dd271d 100644 --- a/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift +++ b/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift @@ -54,7 +54,6 @@ struct SessionVerificationScreen: View { } } - @ViewBuilder private var screenHeader: some View { VStack(spacing: 0) { BigIcon(icon: context.viewState.headerIcon.keyPath, @@ -109,7 +108,6 @@ struct SessionVerificationScreen: View { } } - @ViewBuilder private func emojisPanel(with emojis: [SessionVerificationEmoji]) -> some View { VStack(spacing: 32) { HStack(spacing: 16) { diff --git a/ElementX/Sources/Screens/QRCodeLoginScreen/View/QRCodeLoginScreen.swift b/ElementX/Sources/Screens/QRCodeLoginScreen/View/QRCodeLoginScreen.swift index f60cb51fe..62e842d94 100644 --- a/ElementX/Sources/Screens/QRCodeLoginScreen/View/QRCodeLoginScreen.swift +++ b/ElementX/Sources/Screens/QRCodeLoginScreen/View/QRCodeLoginScreen.swift @@ -202,9 +202,7 @@ struct QRCodeLoginScreen: View { .frame(maxWidth: 312) .readFrame($qrFrame) .background(.compound.bgCanvasDefault) - .overlay( - QRScannerViewOverlay(length: qrFrame.height) - ) + .overlay(QRScannerViewOverlay(length: qrFrame.height)) } @ViewBuilder @@ -324,7 +322,7 @@ struct QRCodeLoginScreen_Previews: PreviewProvider, TestablePreview { static let loginInstructionsStateViewModel = QRCodeLoginScreenViewModel.mock(state: .loginInstructions) static let linkInstructionsStateViewModel = QRCodeLoginScreenViewModel.mock(state: .linkDesktopInstructions) - // Scanning + /// Scanning static let scanningStateViewModel = QRCodeLoginScreenViewModel.mock(state: .scan(.scanning)) static let connectingStateViewModel = QRCodeLoginScreenViewModel.mock(state: .scan(.connecting)) @@ -337,7 +335,7 @@ struct QRCodeLoginScreen_Previews: PreviewProvider, TestablePreview { static let deviceNotSignedInStateViewModel = QRCodeLoginScreenViewModel.mock(state: .scan(.scanFailed(.deviceNotSignedIn))) - // Showing + /// Showing static let showingStateViewModel = QRCodeLoginScreenViewModel.mock(state: .displayQR(LinkNewDeviceServiceMock.mockQRCodeImage)) // Displaying codes @@ -348,7 +346,7 @@ struct QRCodeLoginScreen_Previews: PreviewProvider, TestablePreview { static let confirmCodeEnteredStateViewModel = QRCodeLoginScreenViewModel.mock(state: .confirmCode(.inputCode(CheckCodeSenderProxy(underlyingSender: CheckCodeSenderSDKMock()))), checkCodeInput: "12") static let confirmCodeInvalidStateViewModel = QRCodeLoginScreenViewModel.mock(state: .confirmCode(.invalidCode)) - // Errors (no need to test them all QRCodeErrorView covers that). + /// Errors (no need to test them all QRCodeErrorView covers that). static let errorStateViewModel = QRCodeLoginScreenViewModel.mock(state: .error(.declined)) static var previews: some View { diff --git a/ElementX/Sources/Screens/ReportContentScreen/ReportContentScreenCoordinator.swift b/ElementX/Sources/Screens/ReportContentScreen/ReportContentScreenCoordinator.swift index b722630d1..fca2c7146 100644 --- a/ElementX/Sources/Screens/ReportContentScreen/ReportContentScreenCoordinator.swift +++ b/ElementX/Sources/Screens/ReportContentScreen/ReportContentScreenCoordinator.swift @@ -77,12 +77,10 @@ final class ReportContentScreenCoordinator: CoordinatorProtocol { private static let loadingIndicatorIdentifier = "\(ReportContentScreenCoordinator.self)-Loading" private func startLoading() { - parameters.userIndicatorController.submitIndicator( - UserIndicator(id: Self.loadingIndicatorIdentifier, - type: .modal, - title: L10n.commonSending, - persistent: true) - ) + parameters.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier, + type: .modal, + title: L10n.commonSending, + persistent: true)) } private func stopLoading() { diff --git a/ElementX/Sources/Screens/RoomChangeRolesScreen/View/RoomChangeRolesScreen.swift b/ElementX/Sources/Screens/RoomChangeRolesScreen/View/RoomChangeRolesScreen.swift index 3f3b29f00..81152839d 100644 --- a/ElementX/Sources/Screens/RoomChangeRolesScreen/View/RoomChangeRolesScreen.swift +++ b/ElementX/Sources/Screens/RoomChangeRolesScreen/View/RoomChangeRolesScreen.swift @@ -12,7 +12,9 @@ import SwiftUI struct RoomChangeRolesScreen: View { @Bindable var context: RoomChangeRolesScreenViewModel.Context - var showTopSection: Bool { !context.viewState.membersWithRole.isEmpty } + var showTopSection: Bool { + !context.viewState.membersWithRole.isEmpty + } var body: some View { mainContent diff --git a/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift b/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift index e48f8740e..ed3af509e 100644 --- a/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift +++ b/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift @@ -74,7 +74,6 @@ struct RoomDetailsScreen: View { .accessibilityIdentifier(A11yIdentifiers.roomDetailsScreen.avatar) } - @ViewBuilder private var headerSectionShortcuts: some View { HStack(spacing: 8) { ForEach(context.viewState.shortcuts, id: \.self) { shortcut in diff --git a/ElementX/Sources/Screens/RoomDirectorySearchScreen/View/RoomDirectorySearchScreen.swift b/ElementX/Sources/Screens/RoomDirectorySearchScreen/View/RoomDirectorySearchScreen.swift index a5edd6c83..71d3d67f4 100644 --- a/ElementX/Sources/Screens/RoomDirectorySearchScreen/View/RoomDirectorySearchScreen.swift +++ b/ElementX/Sources/Screens/RoomDirectorySearchScreen/View/RoomDirectorySearchScreen.swift @@ -60,7 +60,7 @@ struct RoomDirectorySearchScreen: View { } } - // The greedy size of Rectangle can create an issue with the navigation bar when the search is highlighted, so is best to use a fixed frame instead of hidden() or EmptyView() + /// The greedy size of Rectangle can create an issue with the navigation bar when the search is highlighted, so is best to use a fixed frame instead of hidden() or EmptyView() private var emptyRectangle: some View { Rectangle() .frame(width: 0, height: 0) diff --git a/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenViewModel.swift b/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenViewModel.swift index e45d53aa6..e9624e3f2 100644 --- a/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenViewModel.swift @@ -235,8 +235,13 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro // MARK: User Indicators - private var loadingIndicatorIdentifier: String { "\(Self.self)-Loading" } - private var statusIndicatorIdentifier: String { "\(Self.self)-Status" } + private var loadingIndicatorIdentifier: String { + "\(Self.self)-Loading" + } + + private var statusIndicatorIdentifier: String { + "\(Self.self)-Status" + } private func showMemberLoadingIndicator() { userIndicatorController.submitIndicator(UserIndicator(id: loadingIndicatorIdentifier, diff --git a/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenModels.swift b/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenModels.swift index c325fde1c..c249721c4 100644 --- a/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenModels.swift +++ b/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenModels.swift @@ -41,7 +41,9 @@ struct RoomMembersListScreenViewState: BindableState { private var bannedMembers: [RoomMemberListScreenEntry] let joinedMembersCount: Int - var bannedMembersCount: Int { bannedMembers.count } + var bannedMembersCount: Int { + bannedMembers.count + } var canInviteUsers = false var canKickUsers = false diff --git a/ElementX/Sources/Screens/RoomPollsHistoryScreen/View/RoomPollsHistoryScreen.swift b/ElementX/Sources/Screens/RoomPollsHistoryScreen/View/RoomPollsHistoryScreen.swift index 07138b13b..6a2db15b3 100644 --- a/ElementX/Sources/Screens/RoomPollsHistoryScreen/View/RoomPollsHistoryScreen.swift +++ b/ElementX/Sources/Screens/RoomPollsHistoryScreen/View/RoomPollsHistoryScreen.swift @@ -118,10 +118,9 @@ struct RoomPollsHistoryScreen_Previews: PreviewProvider, TestablePreview { let timelineController = MockTimelineController() timelineController.timelineItems = [] let roomProxyMockConfiguration = JoinedRoomProxyMockConfiguration(name: "Polls") - let viewModel = RoomPollsHistoryScreenViewModel(pollInteractionHandler: PollInteractionHandlerMock(), - timelineController: timelineController, - userIndicatorController: UserIndicatorControllerMock()) - return viewModel + return RoomPollsHistoryScreenViewModel(pollInteractionHandler: PollInteractionHandlerMock(), + timelineController: timelineController, + userIndicatorController: UserIndicatorControllerMock()) }() static let viewModel: RoomPollsHistoryScreenViewModel = { @@ -140,11 +139,9 @@ struct RoomPollsHistoryScreen_Previews: PreviewProvider, TestablePreview { } let roomProxyMockConfiguration = JoinedRoomProxyMockConfiguration(name: "Polls", timelineStartReached: true) - let viewModel = RoomPollsHistoryScreenViewModel(pollInteractionHandler: PollInteractionHandlerMock(), - timelineController: timelineController, - userIndicatorController: UserIndicatorControllerMock()) - - return viewModel + return RoomPollsHistoryScreenViewModel(pollInteractionHandler: PollInteractionHandlerMock(), + timelineController: timelineController, + userIndicatorController: UserIndicatorControllerMock()) }() static var previews: some View { diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarModels.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarModels.swift index bae953546..a03fe9ec7 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarModels.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarModels.swift @@ -172,11 +172,15 @@ enum FormatType { } extension FormatType: CaseIterable, Identifiable { - var id: Self { self } + var id: Self { + self + } } extension FormatItem: Identifiable { - var id: FormatType { type } + var id: FormatType { + type + } } extension FormatItem { diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift index dee6e6bba..46e58f3f7 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift @@ -782,12 +782,12 @@ private final class ComposerMentionReplacer: MentionReplacer { self.replacementForMentionClosure = replacementForMentionClosure } - // There is no internal Markdown to RTE switch implemented yet in the room so this one is never called + /// There is no internal Markdown to RTE switch implemented yet in the room so this one is never called func postProcessMarkdown(in attributedString: NSAttributedString) -> NSAttributedString { attributedString } - // There is no internal RTE to Markdown switch implemented yet in the room so this one is never called + /// There is no internal RTE to Markdown switch implemented yet in the room so this one is never called func restoreMarkdown(in attributedString: NSAttributedString) -> String { attributedString.string } diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/CompletionSuggestionView.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/CompletionSuggestionView.swift index ba589bf00..936549db1 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/CompletionSuggestionView.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/CompletionSuggestionView.swift @@ -20,7 +20,7 @@ struct CompletionSuggestionView: View { // added by the list itself when presenting the divider static let listItemSpacing: CGFloat = 4.0 static let leadingPadding: CGFloat = 16.0 - // To make the scrolling more apparent we show a factional amount + /// To make the scrolling more apparent we show a factional amount static let maxVisibleRows: CGFloat = 4.5 } diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift index d455e04ce..89587cbc4 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift @@ -114,7 +114,6 @@ struct ComposerToolbar: View { HStackLayout(alignment: .bottom, spacing: 5) } - @ViewBuilder private var mainTopBarContent: some View { ZStack(alignment: .bottom) { topBarLayout { diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift index 20c01998f..edfe52a50 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift @@ -23,9 +23,7 @@ struct RoomAttachmentPicker: View { } label: { CompoundIcon(asset: Asset.Images.composerAttachment, size: .custom(30), relativeTo: .compound.headingLG) .scaledPadding(7, relativeTo: .compound.headingLG) - .foregroundColor( - isEnabled ? .compound.iconPrimary : .compound.iconDisabled - ) + .foregroundColor(isEnabled ? .compound.iconPrimary : .compound.iconDisabled) } .buttonStyle(RoomAttachmentPickerButtonStyle()) .accessibilityLabel(L10n.actionAddToTimeline) diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/VoiceMessageRecordingButton.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/VoiceMessageRecordingButton.swift index 5706fae35..799f53127 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/VoiceMessageRecordingButton.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/VoiceMessageRecordingButton.swift @@ -36,9 +36,7 @@ struct VoiceMessageRecordingButton: View { switch mode { case .idle: CompoundIcon(\.micOn, size: .medium, relativeTo: .compound.headingLG) - .foregroundColor( - isEnabled ? .compound.iconSecondary : .compound.iconDisabled - ) + .foregroundColor(isEnabled ? .compound.iconSecondary : .compound.iconDisabled) .scaledPadding(10, relativeTo: .compound.headingLG) case .recording: CompoundIcon(asset: Asset.Images.stopRecording, size: .medium, relativeTo: .compound.headingLG) diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenModels.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenModels.swift index 6f70de9a2..720e5d726 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenModels.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenModels.swift @@ -190,9 +190,9 @@ enum PinnedEventsBannerState: Equatable { } } - // Note that if we are setting this value, this is definitely sent from the pinned events timeline - // so we can assume that the pinned events timeline is already loaded and we only need to set the - // selection for the loaded state + /// Note that if we are setting this value, this is definitely sent from the pinned events timeline + /// so we can assume that the pinned events timeline is already loaded and we only need to set the + /// selection for the loaded state mutating func setSelectedPinnedEventID(_ eventID: String) { switch self { case .loaded(var state): diff --git a/ElementX/Sources/Screens/RoomScreen/View/PinnedItemsBanner/PinnedItemsBannerView.swift b/ElementX/Sources/Screens/RoomScreen/View/PinnedItemsBanner/PinnedItemsBannerView.swift index 3edf32e64..ff843187c 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/PinnedItemsBanner/PinnedItemsBannerView.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/PinnedItemsBanner/PinnedItemsBannerView.swift @@ -46,7 +46,6 @@ struct PinnedItemsBannerView: View { .accessibilityElement(children: .contain) } - @ViewBuilder private var viewAllButton: some View { Button { onViewAllButtonTap() } label: { Text(state.isLoading ? "" : L10n.screenRoomPinnedBannerViewAllButtonTitle) diff --git a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift index f26f288c2..cc2f8942a 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift @@ -72,14 +72,12 @@ struct RoomScreen: View { .sentryTrace("\(Self.self)") } - @ViewBuilder private var pinnedItemsBanner: some View { PinnedItemsBannerView(state: context.viewState.pinnedEventsBannerState, onMainButtonTap: { context.send(viewAction: .tappedPinnedEventsBanner) }, onViewAllButtonTap: { context.send(viewAction: .viewAllPins) }) } - @ViewBuilder private var knockRequestsBanner: some View { KnockRequestsBannerView(requests: context.viewState.displayedKnockRequests, onDismiss: dismissKnockRequestsBanner, diff --git a/ElementX/Sources/Screens/RoomScreen/View/SwipeRightAction.swift b/ElementX/Sources/Screens/RoomScreen/View/SwipeRightAction.swift index 702334cd8..7bcbc1a83 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/SwipeRightAction.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/SwipeRightAction.swift @@ -49,7 +49,6 @@ struct SwipeRightAction: ViewModifier { } } - @ViewBuilder private func mainContent(content: Content) -> some View { content .offset(x: xOffset, y: 0.0) @@ -164,7 +163,9 @@ extension View { } struct SwipeRightAction_Previews: PreviewProvider, TestablePreview { - static var previews: some View { Preview() } + static var previews: some View { + Preview() + } struct Preview: View { @State private var isPresentingSheet = false @@ -196,12 +197,14 @@ struct SwipeRightAction_Previews: PreviewProvider, TestablePreview { } } -// Fixes the issue on iOS 18 where DragGesture conflicts with the scroll view -// https://github.com/feedback-assistant/reports/issues/542#issuecomment-2581322968 +/// Fixes the issue on iOS 18 where DragGesture conflicts with the scroll view +/// https://github.com/feedback-assistant/reports/issues/542#issuecomment-2581322968 private struct PanGestureRepresentable: UIGestureRecognizerRepresentable { var handle: (UIPanGestureRecognizer) -> Void - func makeCoordinator(converter: CoordinateSpaceConverter) -> Coordinator { .init() } + func makeCoordinator(converter: CoordinateSpaceConverter) -> Coordinator { + .init() + } func makeUIGestureRecognizer(context: Context) -> UIPanGestureRecognizer { let gesture = UIPanGestureRecognizer() diff --git a/ElementX/Sources/Screens/SecureBackup/SecureBackupLogoutConfirmationScreen/View/SecureBackupLogoutConfirmationScreen.swift b/ElementX/Sources/Screens/SecureBackup/SecureBackupLogoutConfirmationScreen/View/SecureBackupLogoutConfirmationScreen.swift index e55ea5487..a34b60040 100644 --- a/ElementX/Sources/Screens/SecureBackup/SecureBackupLogoutConfirmationScreen/View/SecureBackupLogoutConfirmationScreen.swift +++ b/ElementX/Sources/Screens/SecureBackup/SecureBackupLogoutConfirmationScreen/View/SecureBackupLogoutConfirmationScreen.swift @@ -56,7 +56,6 @@ struct SecureBackupLogoutConfirmationScreen: View { } } - @ViewBuilder private var footer: some View { VStack(spacing: 16.0) { if case .saveRecoveryKey = context.viewState.mode { diff --git a/ElementX/Sources/Screens/SecureBackup/SecureBackupRecoveryKeyScreen/View/SecureBackupRecoveryKeyScreen.swift b/ElementX/Sources/Screens/SecureBackup/SecureBackupRecoveryKeyScreen/View/SecureBackupRecoveryKeyScreen.swift index d2070fc47..f4d176e66 100644 --- a/ElementX/Sources/Screens/SecureBackup/SecureBackupRecoveryKeyScreen/View/SecureBackupRecoveryKeyScreen.swift +++ b/ElementX/Sources/Screens/SecureBackup/SecureBackupRecoveryKeyScreen/View/SecureBackupRecoveryKeyScreen.swift @@ -35,7 +35,6 @@ struct SecureBackupRecoveryKeyScreen: View { .alert(item: $context.alertInfo) } - @ViewBuilder private var mainContent: some View { VStack(spacing: 48) { switch context.viewState.mode { @@ -178,7 +177,6 @@ struct SecureBackupRecoveryKeyScreen: View { context.viewState.mode == .setupRecovery ? L10n.screenRecoveryKeySetupGenerateKey : L10n.screenRecoveryKeyChangeGenerateKey } - @ViewBuilder private var confirmRecoveryKeySection: some View { VStack(alignment: .leading, spacing: 8) { Text(L10n.commonRecoveryKey) diff --git a/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/View/SecureBackupScreen.swift b/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/View/SecureBackupScreen.swift index cd9b80ead..ec0228697 100644 --- a/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/View/SecureBackupScreen.swift +++ b/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/View/SecureBackupScreen.swift @@ -36,7 +36,6 @@ struct SecureBackupScreen: View { // MARK: - Private - @ViewBuilder private var keyBackupSection: some View { Section { ListRow(kind: .custom { diff --git a/ElementX/Sources/Screens/Settings/AccountSettings/OIDCAccountSettingsPresenter.swift b/ElementX/Sources/Screens/Settings/AccountSettings/OIDCAccountSettingsPresenter.swift index 5ccd77818..e706c27d5 100644 --- a/ElementX/Sources/Screens/Settings/AccountSettings/OIDCAccountSettingsPresenter.swift +++ b/ElementX/Sources/Screens/Settings/AccountSettings/OIDCAccountSettingsPresenter.swift @@ -60,5 +60,7 @@ class OIDCAccountSettingsPresenter: NSObject { // MARK: ASWebAuthenticationPresentationContextProviding extension OIDCAccountSettingsPresenter: ASWebAuthenticationPresentationContextProviding { - func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor { presentationAnchor } + func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor { + presentationAnchor + } } diff --git a/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenModels.swift b/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenModels.swift index 22b7ad989..bd5f90789 100644 --- a/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenModels.swift +++ b/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenModels.swift @@ -20,7 +20,7 @@ struct NotificationSettingsScreenViewState: BindableState { let isModallyPresented: Bool var isUserPermissionGranted: Bool? var fixingConfigurationMismatch = false - // Hide calls settings until calls are available in El-X + /// Hide calls settings until calls are available in El-X let showCallsSettings = false var showSystemNotificationsAlert: Bool { @@ -45,8 +45,8 @@ struct NotificationSettingsScreenSettings { let roomMentionsEnabled: Bool? let callsEnabled: Bool? let invitationsEnabled: Bool? - // Old clients were having specific settings for encrypted and unencrypted rooms, - // so it's possible for `group chats` and `direct chats` settings to be inconsistent (e.g. encrypted `direct chats` can have a different mode that unencrypted `direct chats`) + /// Old clients were having specific settings for encrypted and unencrypted rooms, + /// so it's possible for `group chats` and `direct chats` settings to be inconsistent (e.g. encrypted `direct chats` can have a different mode that unencrypted `direct chats`) let inconsistentSettings: [NotificationSettingsScreenInvalidSetting] } diff --git a/ElementX/Sources/Screens/Spaces/Common/SpaceRoomCell.swift b/ElementX/Sources/Screens/Spaces/Common/SpaceRoomCell.swift index eba106bd0..86aeb1f2b 100644 --- a/ElementX/Sources/Screens/Spaces/Common/SpaceRoomCell.swift +++ b/ElementX/Sources/Screens/Spaces/Common/SpaceRoomCell.swift @@ -25,8 +25,13 @@ struct SpaceRoomCell: View { private let verticalInsets = 12.0 private let horizontalInsets = 16.0 - private var isEditModeActive: Bool { editMode?.wrappedValue ?? .inactive != .inactive } - private var isHighlighted: Bool { isSelected && !isEditModeActive } + private var isEditModeActive: Bool { + editMode?.wrappedValue ?? .inactive != .inactive + } + + private var isHighlighted: Bool { + isSelected && !isEditModeActive + } private var subtitle: String { if spaceServiceRoom.isSpace { diff --git a/ElementX/Sources/Screens/Spaces/LeaveSpace/LeaveSpaceViewModel.swift b/ElementX/Sources/Screens/Spaces/LeaveSpace/LeaveSpaceViewModel.swift index 3c092465d..34791d76b 100644 --- a/ElementX/Sources/Screens/Spaces/LeaveSpace/LeaveSpaceViewModel.swift +++ b/ElementX/Sources/Screens/Spaces/LeaveSpace/LeaveSpaceViewModel.swift @@ -12,7 +12,10 @@ typealias LeaveSpaceViewModelType = StateStoreViewModelV2() - var actions: AnyPublisher { actionsSubject.eraseToAnyPublisher() } + var actions: AnyPublisher { + actionsSubject.eraseToAnyPublisher() + } + private let userIndicatorController: UserIndicatorControllerProtocol private let mediaProvider: MediaProviderProtocol @@ -53,8 +56,13 @@ class LeaveSpaceViewModel: LeaveSpaceViewModelType { } } - private static var leavingIndicatorID: String { "\(Self.self)-Leaving" } - private static var failureIndicatorID: String { "\(Self.self)-Failure" } + private static var leavingIndicatorID: String { + "\(Self.self)-Leaving" + } + + private static var failureIndicatorID: String { + "\(Self.self)-Failure" + } private func showLeavingIndicator() { userIndicatorController.submitIndicator(UserIndicator(id: Self.leavingIndicatorID, @@ -75,5 +83,7 @@ class LeaveSpaceViewModel: LeaveSpaceViewModelType { } extension LeaveSpaceViewModel: Identifiable { - var id: String { state.leaveHandle.id } + var id: String { + state.leaveHandle.id + } } diff --git a/ElementX/Sources/Screens/Spaces/SpaceAddRoomsScreen/SpaceAddRoomsScreenViewModel.swift b/ElementX/Sources/Screens/Spaces/SpaceAddRoomsScreen/SpaceAddRoomsScreenViewModel.swift index 18a43286b..b8fefaf40 100644 --- a/ElementX/Sources/Screens/Spaces/SpaceAddRoomsScreen/SpaceAddRoomsScreenViewModel.swift +++ b/ElementX/Sources/Screens/Spaces/SpaceAddRoomsScreen/SpaceAddRoomsScreenViewModel.swift @@ -161,8 +161,13 @@ class SpaceAddRoomsScreenViewModel: SpaceAddRoomsScreenViewModelType, SpaceAddRo // MARK: User Indicators - private var savingIndicatorID: String { "\(Self.self)-Saving" } - private var failureIndicatorID: String { "\(Self.self)-Failure" } + private var savingIndicatorID: String { + "\(Self.self)-Saving" + } + + private var failureIndicatorID: String { + "\(Self.self)-Failure" + } private func showSavingIndicator() { userIndicatorController.submitIndicator(UserIndicator(id: savingIndicatorID, diff --git a/ElementX/Sources/Screens/Spaces/SpaceScreen/SpaceScreenViewModel.swift b/ElementX/Sources/Screens/Spaces/SpaceScreen/SpaceScreenViewModel.swift index afc4591c4..d269fceeb 100644 --- a/ElementX/Sources/Screens/Spaces/SpaceScreen/SpaceScreenViewModel.swift +++ b/ElementX/Sources/Screens/Spaces/SpaceScreen/SpaceScreenViewModel.swift @@ -270,8 +270,13 @@ class SpaceScreenViewModel: SpaceScreenViewModelType, SpaceScreenViewModelProtoc // MARK: - Indicators - private static var removingIndicatorID: String { "\(Self.self)-Removing" } - private static var failureIndicatorID: String { "\(Self.self)-Failure" } + private static var removingIndicatorID: String { + "\(Self.self)-Removing" + } + + private static var failureIndicatorID: String { + "\(Self.self)-Failure" + } private func showRemovingIndicator() { userIndicatorController.submitIndicator(UserIndicator(id: Self.removingIndicatorID, diff --git a/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift b/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift index a0a40834a..cb40fae8d 100644 --- a/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift +++ b/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift @@ -12,7 +12,9 @@ import SwiftUI struct SpaceScreen: View { @Bindable var context: SpaceScreenViewModel.Context - private var isEditModeActive: Bool { context.viewState.editMode != .inactive } + private var isEditModeActive: Bool { + context.viewState.editMode != .inactive + } var body: some View { ScrollView { diff --git a/ElementX/Sources/Screens/Spaces/SpacesScreen/SpacesScreenViewModel.swift b/ElementX/Sources/Screens/Spaces/SpacesScreen/SpacesScreenViewModel.swift index cde1dc26a..8b019a92e 100644 --- a/ElementX/Sources/Screens/Spaces/SpacesScreen/SpacesScreenViewModel.swift +++ b/ElementX/Sources/Screens/Spaces/SpacesScreen/SpacesScreenViewModel.swift @@ -97,7 +97,9 @@ class SpacesScreenViewModel: SpacesScreenViewModelType, SpacesScreenViewModelPro // MARK: - Indicators - private static var failureIndicatorID: String { "\(Self.self)-Failure" } + private static var failureIndicatorID: String { + "\(Self.self)-Failure" + } private func showFailureIndicator() { userIndicatorController.submitIndicator(UserIndicator(id: Self.failureIndicatorID, diff --git a/ElementX/Sources/Screens/Spaces/SpacesScreen/View/SpacesScreen.swift b/ElementX/Sources/Screens/Spaces/SpacesScreen/View/SpacesScreen.swift index 2a48f7a3a..ab47b1a0c 100644 --- a/ElementX/Sources/Screens/Spaces/SpacesScreen/View/SpacesScreen.swift +++ b/ElementX/Sources/Screens/Spaces/SpacesScreen/View/SpacesScreen.swift @@ -158,11 +158,9 @@ struct SpacesScreen_Previews: PreviewProvider, TestablePreview { let clientProxy = ClientProxyMock(.init()) clientProxy.spaceService = SpaceServiceProxyMock(.init(topLevelSpaces: isEmpty ? [] : .mockJoinedSpaces)) - let viewModel = SpacesScreenViewModel(userSession: UserSessionMock(.init(clientProxy: clientProxy)), - selectedSpacePublisher: .init(nil), - appSettings: appSettings, - userIndicatorController: UserIndicatorControllerMock()) - - return viewModel + return SpacesScreenViewModel(userSession: UserSessionMock(.init(clientProxy: clientProxy)), + selectedSpacePublisher: .init(nil), + appSettings: appSettings, + userIndicatorController: UserIndicatorControllerMock()) } } diff --git a/ElementX/Sources/Screens/StartChatScreen/View/JoinRoomByAddressView.swift b/ElementX/Sources/Screens/StartChatScreen/View/JoinRoomByAddressView.swift index d44ec3897..9579e72d2 100644 --- a/ElementX/Sources/Screens/StartChatScreen/View/JoinRoomByAddressView.swift +++ b/ElementX/Sources/Screens/StartChatScreen/View/JoinRoomByAddressView.swift @@ -82,12 +82,11 @@ struct JoinRoomByAddressView_Previews: PreviewProvider, TestablePreview { let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com")))) let userDiscoveryService = UserDiscoveryServiceMock() userDiscoveryService.searchProfilesWithReturnValue = .success([.mockAlice]) - let viewModel = StartChatScreenViewModel(userSession: userSession, - analytics: ServiceLocator.shared.analytics, - userIndicatorController: UserIndicatorControllerMock(), - userDiscoveryService: userDiscoveryService, - appSettings: ServiceLocator.shared.settings) - return viewModel + return StartChatScreenViewModel(userSession: userSession, + analytics: ServiceLocator.shared.analytics, + userIndicatorController: UserIndicatorControllerMock(), + userDiscoveryService: userDiscoveryService, + appSettings: ServiceLocator.shared.settings) }() static var previews: some View { diff --git a/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift b/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift index 3ba91ff41..aece5f449 100644 --- a/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift +++ b/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift @@ -160,12 +160,11 @@ struct StartChatScreen_Previews: PreviewProvider, TestablePreview { let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com")))) let userDiscoveryService = UserDiscoveryServiceMock() userDiscoveryService.searchProfilesWithReturnValue = .success([.mockAlice]) - let viewModel = StartChatScreenViewModel(userSession: userSession, - analytics: ServiceLocator.shared.analytics, - userIndicatorController: UserIndicatorControllerMock(), - userDiscoveryService: userDiscoveryService, - appSettings: appSettings) - return viewModel + return StartChatScreenViewModel(userSession: userSession, + analytics: ServiceLocator.shared.analytics, + userIndicatorController: UserIndicatorControllerMock(), + userDiscoveryService: userDiscoveryService, + appSettings: appSettings) }() static var previews: some View { diff --git a/ElementX/Sources/Screens/Timeline/TimelineModels.swift b/ElementX/Sources/Screens/Timeline/TimelineModels.swift index 3926ac886..94069b646 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineModels.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineModels.swift @@ -117,8 +117,8 @@ struct TimelineViewState: BindableState { let hasPredecessor: Bool - // The `pinnedEventIDs` are used only to determine if an item is already pinned or not. - // It's updated from the room info, so it's faster than using the timeline + /// The `pinnedEventIDs` are used only to determine if an item is already pinned or not. + /// It's updated from the room info, so it's faster than using the timeline var pinnedEventIDs: Set = [] /// A closure providing the associated audio player state for an item in the timeline. @@ -234,7 +234,7 @@ struct TimelineState { /// A focussed event that was navigated to via a permalink. var focussedEvent: FocussedEvent? - // These can be removed when we have full swiftUI and moved as @State values in the view + /// These can be removed when we have full swiftUI and moved as @State values in the view var scrollToBottomPublisher = PassthroughSubject() var itemsDictionary = OrderedDictionary() diff --git a/ElementX/Sources/Screens/Timeline/TimelineTableViewController.swift b/ElementX/Sources/Screens/Timeline/TimelineTableViewController.swift index e8fb6abf6..18d3b0363 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineTableViewController.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineTableViewController.swift @@ -9,9 +9,8 @@ import Combine import Compound import MatrixRustSDK -import SwiftUI - import OrderedCollections +import SwiftUI /// A table view cell that displays a timeline item in a room. The cell is intended /// to be configured to display a SwiftUI view and not use any UIKit. @@ -238,7 +237,9 @@ class TimelineTableViewController: UIViewController { } @available(*, unavailable) - required init?(coder: NSCoder) { fatalError("init(coder:) is not available.") } + required init?(coder: NSCoder) { + fatalError("init(coder:) is not available.") + } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) diff --git a/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenuAction.swift b/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenuAction.swift index c1e7eda86..b5c61bbee 100644 --- a/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenuAction.swift +++ b/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenuAction.swift @@ -48,8 +48,8 @@ struct TimelineItemMenuReaction: Hashable { let key: String let symbol: SFSymbol - // Frequently used emojis on the all use the same .heart SFSymbol. - // Override equatable so we can remove duplicates. + /// Frequently used emojis on the all use the same .heart SFSymbol. + /// Override equatable so we can remove duplicates. static func == (lhs: TimelineItemMenuReaction, rhs: TimelineItemMenuReaction) -> Bool { lhs.key == rhs.key } @@ -80,7 +80,9 @@ enum TimelineItemMenuAction: Identifiable, Hashable { case share case save - var id: Self { self } + var id: Self { + self + } /// Whether the item should cancel a reply/edit occurring in the composer. var switchToDefaultComposer: Bool { diff --git a/ElementX/Sources/Screens/Timeline/View/Polls/PollView.swift b/ElementX/Sources/Screens/Timeline/View/Polls/PollView.swift index 482fac9aa..98c766b7e 100644 --- a/ElementX/Sources/Screens/Timeline/View/Polls/PollView.swift +++ b/ElementX/Sources/Screens/Timeline/View/Polls/PollView.swift @@ -62,9 +62,10 @@ struct PollView: View { // MARK: - Private - private var senderString: String { poll.createdByAccountOwner ? L10n.commonYou : sender.disambiguatedDisplayName ?? sender.id } + private var senderString: String { + poll.createdByAccountOwner ? L10n.commonYou : sender.disambiguatedDisplayName ?? sender.id + } - @ViewBuilder private var accessibleQuestionView: some View { questionView .accessibilityRepresentation { diff --git a/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift b/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift index 6f070b886..7e55c9591 100644 --- a/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift +++ b/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift @@ -44,18 +44,17 @@ struct ReadReceiptsSummaryView_Previews: PreviewProvider, TestablePreview { .mockDan ] let roomProxyMock = JoinedRoomProxyMock(.init(name: "Room", members: members)) - let mock = TimelineViewModel(roomProxy: roomProxyMock, - timelineController: MockTimelineController(), - userSession: UserSessionMock(.init()), - mediaPlayerProvider: MediaPlayerProviderMock(), - userIndicatorController: UserIndicatorControllerMock(), - appMediator: AppMediatorMock.default, - appSettings: ServiceLocator.shared.settings, - analyticsService: ServiceLocator.shared.analytics, - emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings), - linkMetadataProvider: LinkMetadataProvider(), - timelineControllerFactory: TimelineControllerFactoryMock(.init())) - return mock + return TimelineViewModel(roomProxy: roomProxyMock, + timelineController: MockTimelineController(), + userSession: UserSessionMock(.init()), + mediaPlayerProvider: MediaPlayerProviderMock(), + userIndicatorController: UserIndicatorControllerMock(), + appMediator: AppMediatorMock.default, + appSettings: ServiceLocator.shared.settings, + analyticsService: ServiceLocator.shared.analytics, + emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings), + linkMetadataProvider: LinkMetadataProvider(), + timelineControllerFactory: TimelineControllerFactoryMock(.init())) }() static let orderedReadReceipts: [ReadReceipt] = [ diff --git a/ElementX/Sources/Screens/Timeline/View/Style/LongPressWithFeedback.swift b/ElementX/Sources/Screens/Timeline/View/Style/LongPressWithFeedback.swift index 4c1d81ac3..8a24cb8f9 100644 --- a/ElementX/Sources/Screens/Timeline/View/Style/LongPressWithFeedback.swift +++ b/ElementX/Sources/Screens/Timeline/View/Style/LongPressWithFeedback.swift @@ -31,8 +31,8 @@ struct LongPressWithFeedback: ViewModifier { }) } - // The gesture's minimum duration doesn't actually invoke the perform block when elapsed (thus - // the implementation below) but it does cancel other system gestures e.g. swipe to reply + /// The gesture's minimum duration doesn't actually invoke the perform block when elapsed (thus + /// the implementation below) but it does cancel other system gestures e.g. swipe to reply private func handleLongPress(isPressing: Bool) { isLongPressing = isPressing @@ -56,7 +56,6 @@ struct LongPressWithFeedback: ViewModifier { } } - @ViewBuilder private func mainContent(content: Content) -> some View { content .compositingGroup() // Apply the shadow to the view as a whole. @@ -76,7 +75,9 @@ extension View { } struct LongPressWithFeedback_Previews: PreviewProvider, TestablePreview { - static var previews: some View { Preview() } + static var previews: some View { + Preview() + } struct Preview: View { private let viewModel = TimelineViewModel.mock @@ -123,12 +124,14 @@ struct LongPressWithFeedback_Previews: PreviewProvider, TestablePreview { } } -// Fixes the issue on iOS 18 where LongPress conflicts with the scroll view -// https://github.com/feedback-assistant/reports/issues/542#issuecomment-2581322968 +/// Fixes the issue on iOS 18 where LongPress conflicts with the scroll view +/// https://github.com/feedback-assistant/reports/issues/542#issuecomment-2581322968 private struct LongPressGestureRepresentable: UIGestureRecognizerRepresentable { var handle: (UILongPressGestureRecognizer) -> Void - func makeCoordinator(converter: CoordinateSpaceConverter) -> Coordinator { .init() } + func makeCoordinator(converter: CoordinateSpaceConverter) -> Coordinator { + .init() + } func makeUIGestureRecognizer(context: Context) -> UILongPressGestureRecognizer { let gesture = UILongPressGestureRecognizer() diff --git a/ElementX/Sources/Screens/Timeline/View/Style/ThreadDecorator.swift b/ElementX/Sources/Screens/Timeline/View/Style/ThreadDecorator.swift index 95d9bac91..ea0241ed1 100644 --- a/ElementX/Sources/Screens/Timeline/View/Style/ThreadDecorator.swift +++ b/ElementX/Sources/Screens/Timeline/View/Style/ThreadDecorator.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import SwiftUI - import Compound +import SwiftUI struct ThreadDecorator: View { var body: some View { diff --git a/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemAccessibilityModifier.swift b/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemAccessibilityModifier.swift index 05a9cd078..3a7d8224c 100644 --- a/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemAccessibilityModifier.swift +++ b/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemAccessibilityModifier.swift @@ -12,7 +12,6 @@ private struct TimelineItemAccessibilityModifier: ViewModifier { let timelineItem: RoomTimelineItemProtocol let action: () -> Void - @ViewBuilder func body(content: Content) -> some View { switch timelineItem { case is PollRoomTimelineItem: diff --git a/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift b/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift index f88825f1d..f4e861974 100644 --- a/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift +++ b/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift @@ -18,8 +18,14 @@ struct TimelineItemBubbledStylerView: View { let adjustedDeliveryStatus: TimelineItemDeliveryStatus? @ViewBuilder let content: () -> Content - private var isDirectOneToOneRoom: Bool { context.viewState.isDirectOneToOneRoom } - private var isFocussed: Bool { focussedEventID != nil && timelineItem.id.eventID == focussedEventID } + private var isDirectOneToOneRoom: Bool { + context.viewState.isDirectOneToOneRoom + } + + private var isFocussed: Bool { + focussedEventID != nil && timelineItem.id.eventID == focussedEventID + } + private var isPinned: Bool { guard context.viewState.timelineKind != .pinned, let eventID = timelineItem.id.eventID else { @@ -179,7 +185,6 @@ struct TimelineItemBubbledStylerView: View { color: timelineItem.bubbleBackgroundColor) } - @ViewBuilder var contentWithReply: some View { TimelineBubbleLayout(spacing: 8) { if !context.viewState.timelineKind.isThread, timelineItem.properties.isThreaded { diff --git a/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemSendInfoLabel.swift b/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemSendInfoLabel.swift index 9fd3fbdb1..a635bf30d 100644 --- a/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemSendInfoLabel.swift +++ b/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemSendInfoLabel.swift @@ -96,7 +96,6 @@ private struct TimelineItemSendInfoLabel: View { } } - @ViewBuilder var content: some View { HStack(spacing: 4) { Text(sendInfo.localizedString) diff --git a/ElementX/Sources/Screens/Timeline/View/Style/TimelineStyler.swift b/ElementX/Sources/Screens/Timeline/View/Style/TimelineStyler.swift index b5fab2ea9..d842d2353 100644 --- a/ElementX/Sources/Screens/Timeline/View/Style/TimelineStyler.swift +++ b/ElementX/Sources/Screens/Timeline/View/Style/TimelineStyler.swift @@ -49,7 +49,6 @@ struct TimelineStyler: View { .animation(.elementDefault, value: adjustedDeliveryStatus) } - @ViewBuilder var mainContent: some View { TimelineItemBubbledStylerView(timelineItem: timelineItem, adjustedDeliveryStatus: adjustedDeliveryStatus, content: content) } @@ -99,14 +98,13 @@ struct TimelineItemStyler_Previews: PreviewProvider, TestablePreview { static let sentLast: TextRoomTimelineItem = { let id = viewModel.state.timelineState.uniqueIDs.last ?? .init(UUID().uuidString) - let result = TextRoomTimelineItem(id: .event(uniqueID: id, eventOrTransactionID: .eventID(UUID().uuidString)), - timestamp: .mock, - isOutgoing: true, - isEditable: false, - canBeRepliedTo: true, - sender: .test, - content: .init(body: "Test")) - return result + return TextRoomTimelineItem(id: .event(uniqueID: id, eventOrTransactionID: .eventID(UUID().uuidString)), + timestamp: .mock, + isOutgoing: true, + isEditable: false, + canBeRepliedTo: true, + sender: .test, + content: .init(body: "Test")) }() static let ltrString = TextRoomTimelineItem(id: .randomEvent, diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineItemDebugView.swift b/ElementX/Sources/Screens/Timeline/View/TimelineItemDebugView.swift index 06d040edb..353e9622e 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineItemDebugView.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineItemDebugView.swift @@ -67,7 +67,6 @@ struct TimelineItemDebugView: View { } } - @ViewBuilder var disclosureGroupContent: some View { VStack(alignment: .leading, spacing: 0) { Divider() diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/CallNotificationRoomTimelineView.swift b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/CallNotificationRoomTimelineView.swift index 9785df5d8..8203b34a4 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/CallNotificationRoomTimelineView.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/CallNotificationRoomTimelineView.swift @@ -45,10 +45,8 @@ struct CallNotificationRoomTimelineView: View { .foregroundColor(.compound.textSecondary) } .padding(12) - .overlay( - RoundedRectangle(cornerRadius: 8) - .stroke(.compound.borderInteractiveSecondary, lineWidth: 1) - ) + .overlay(RoundedRectangle(cornerRadius: 8) + .stroke(.compound.borderInteractiveSecondary, lineWidth: 1)) .padding(16) } } diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/FormattedBodyText.swift b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/FormattedBodyText.swift index c9f72d4c1..b086636b1 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/FormattedBodyText.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/FormattedBodyText.swift @@ -57,7 +57,7 @@ struct FormattedBodyText: View { boostFontSize: boostFontSize) } - // These is needed to create the slightly off inlined timestamp effect + /// These is needed to create the slightly off inlined timestamp effect private var additionalWhitespacesSuffix: String { .generateBreakableWhitespaceEnd(whitespaceCount: additionalWhitespacesCount, layoutDirection: layoutDirection) } @@ -68,7 +68,6 @@ struct FormattedBodyText: View { .accessibilityLabel(Text(attributedString)) } - @ViewBuilder var mainContent: some View { layout .tint(.compound.textLinkExternal) diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/ImageRoomTimelineView.swift b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/ImageRoomTimelineView.swift index 3fa4f3845..08f9e1ca8 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/ImageRoomTimelineView.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/ImageRoomTimelineView.swift @@ -13,7 +13,9 @@ struct ImageRoomTimelineView: View { @Environment(\.timelineContext) private var context let timelineItem: ImageRoomTimelineItem - var hasMediaCaption: Bool { timelineItem.content.caption != nil } + var hasMediaCaption: Bool { + timelineItem.content.caption != nil + } var body: some View { TimelineStyler(timelineItem: timelineItem) { diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/TextRoomTimelineView.swift b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/TextRoomTimelineView.swift index d788aa36b..20b64d2a5 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/TextRoomTimelineView.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/TextRoomTimelineView.swift @@ -7,9 +7,8 @@ // import Foundation -import SwiftUI - import OrderedCollections +import SwiftUI struct TextRoomTimelineView: View, TextBasedRoomTimelineViewProtocol { static let maxLinkPreviewsToRender = 2 diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/VideoRoomTimelineView.swift b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/VideoRoomTimelineView.swift index f1053894c..cc297ad5d 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/VideoRoomTimelineView.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/VideoRoomTimelineView.swift @@ -13,7 +13,9 @@ struct VideoRoomTimelineView: View { @Environment(\.timelineContext) private var context let timelineItem: VideoRoomTimelineItem - private var hasMediaCaption: Bool { timelineItem.content.caption != nil } + private var hasMediaCaption: Bool { + timelineItem.content.caption != nil + } var body: some View { TimelineStyler(timelineItem: timelineItem) { diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineView.swift b/ElementX/Sources/Screens/Timeline/View/TimelineView.swift index 6a2e1968b..a9ec59f91 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineView.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineView.swift @@ -81,10 +81,9 @@ struct TimelineViewRepresentable: UIViewControllerRepresentable { @EnvironmentObject private var viewModelContext: TimelineViewModel.Context func makeUIViewController(context: Context) -> TimelineTableViewController { - let tableViewController = TimelineTableViewController(coordinator: context.coordinator, - isScrolledToBottom: $viewModelContext.isScrolledToBottom, - scrollToBottomPublisher: viewModelContext.viewState.timelineState.scrollToBottomPublisher) - return tableViewController + TimelineTableViewController(coordinator: context.coordinator, + isScrolledToBottom: $viewModelContext.isScrolledToBottom, + scrollToBottomPublisher: viewModelContext.viewState.timelineState.scrollToBottomPublisher) } func updateUIViewController(_ uiViewController: TimelineTableViewController, context: Context) { diff --git a/ElementX/Sources/Screens/UserProfileScreen/UserProfileScreenViewModel.swift b/ElementX/Sources/Screens/UserProfileScreen/UserProfileScreenViewModel.swift index 0c75dd706..03de4d16a 100644 --- a/ElementX/Sources/Screens/UserProfileScreen/UserProfileScreenViewModel.swift +++ b/ElementX/Sources/Screens/UserProfileScreen/UserProfileScreenViewModel.swift @@ -154,8 +154,13 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr // MARK: User Indicators - private var loadingIndicatorIdentifier: String { "\(Self.self)-Loading" } - private var statusIndicatorIdentifier: String { "\(Self.self)-Status" } + private var loadingIndicatorIdentifier: String { + "\(Self.self)-Loading" + } + + private var statusIndicatorIdentifier: String { + "\(Self.self)-Status" + } private func showLoadingIndicator(allowsInteraction: Bool) { userIndicatorController.submitIndicator(UserIndicator(id: loadingIndicatorIdentifier, diff --git a/ElementX/Sources/Services/Analytics/PostHogAnalyticsClient.swift b/ElementX/Sources/Services/Analytics/PostHogAnalyticsClient.swift index 95408f9ab..1d13d409a 100644 --- a/ElementX/Sources/Services/Analytics/PostHogAnalyticsClient.swift +++ b/ElementX/Sources/Services/Analytics/PostHogAnalyticsClient.swift @@ -30,7 +30,9 @@ class PostHogAnalyticsClient: AnalyticsClientProtocol { /// Not persisted for now, should be set on start. private var superProperties: AnalyticsEvent.SuperProperties? - var isRunning: Bool { postHog != nil } + var isRunning: Bool { + postHog != nil + } func start(analyticsConfiguration: AnalyticsConfiguration) { // Only start if analytics have been configured in BuildSettings diff --git a/ElementX/Sources/Services/Analytics/Signposter.swift b/ElementX/Sources/Services/Analytics/Signposter.swift index e26c79306..b2ad21e36 100644 --- a/ElementX/Sources/Services/Analytics/Signposter.swift +++ b/ElementX/Sources/Services/Analytics/Signposter.swift @@ -36,9 +36,9 @@ class Signposter { private var appStartupTransaction: Span? - // We have a manual start method because we need to configure the ServiceLocator *before* we configure - // Sentry but this class is created in the AnalyticsService and so spans and transactions are dropped - // until Sentry has been configured. Therefore doing this in the init doesn't work. + /// We have a manual start method because we need to configure the ServiceLocator *before* we configure + /// Sentry but this class is created in the AnalyticsService and so spans and transactions are dropped + /// until Sentry has been configured. Therefore doing this in the init doesn't work. func start() { appStartupTransaction = SentrySDK.startTransaction(name: Name.appStartup, operation: Name.appStarted) } diff --git a/ElementX/Sources/Services/AppLock/AppLockService.swift b/ElementX/Sources/Services/AppLock/AppLockService.swift index c241bcd72..c2308dfd9 100644 --- a/ElementX/Sources/Services/AppLock/AppLockService.swift +++ b/ElementX/Sources/Services/AppLock/AppLockService.swift @@ -18,7 +18,9 @@ class AppLockService: AppLockServiceProtocol { private let timer: AppLockTimer private let unlockPolicy: LAPolicy = .deviceOwnerAuthenticationWithBiometrics - var isMandatory: Bool { appSettings.appLockIsMandatory } + var isMandatory: Bool { + appSettings.appLockIsMandatory + } var isEnabled: Bool { do { @@ -31,7 +33,9 @@ class AppLockService: AppLockServiceProtocol { } private var isEnabledSubject: PassthroughSubject = .init() - var isEnabledPublisher: AnyPublisher { isEnabledSubject.eraseToAnyPublisher() } + var isEnabledPublisher: AnyPublisher { + isEnabledSubject.eraseToAnyPublisher() + } var biometryType: LABiometryType { updateBiometrics() @@ -49,7 +53,9 @@ class AppLockService: AppLockServiceProtocol { return state == context.evaluatedPolicyDomainState } - var numberOfPINAttempts: AnyPublisher { appSettings.$appLockNumberOfPINAttempts } + var numberOfPINAttempts: AnyPublisher { + appSettings.$appLockNumberOfPINAttempts + } init(keychainController: KeychainControllerProtocol, appSettings: AppSettings, context: LAContext = .init()) { self.keychainController = keychainController diff --git a/ElementX/Sources/Services/AppLock/LAContextMock.swift b/ElementX/Sources/Services/AppLock/LAContextMock.swift index 921be890c..2ebc4ff8a 100644 --- a/ElementX/Sources/Services/AppLock/LAContextMock.swift +++ b/ElementX/Sources/Services/AppLock/LAContextMock.swift @@ -15,11 +15,15 @@ import LocalAuthentication class LAContextMock: LAContext { var biometryTypeValue: LABiometryType! private var internalBiometryTypeValue: LABiometryType! - override var biometryType: LABiometryType { internalBiometryTypeValue } + override var biometryType: LABiometryType { + internalBiometryTypeValue + } var evaluatedPolicyDomainStateValue: Data? private var internalEvaluatedPolicyDomainStateValue: Data? - override var evaluatedPolicyDomainState: Data? { internalEvaluatedPolicyDomainStateValue } + override var evaluatedPolicyDomainState: Data? { + internalEvaluatedPolicyDomainStateValue + } override func canEvaluatePolicy(_ policy: LAPolicy, error: NSErrorPointer) -> Bool { let result = super.canEvaluatePolicy(policy, error: error) diff --git a/ElementX/Sources/Services/Audio/Player/AudioPlayerProtocol.swift b/ElementX/Sources/Services/Audio/Player/AudioPlayerProtocol.swift index 40f7263de..3c00a01ac 100644 --- a/ElementX/Sources/Services/Audio/Player/AudioPlayerProtocol.swift +++ b/ElementX/Sources/Services/Audio/Player/AudioPlayerProtocol.swift @@ -13,9 +13,9 @@ enum AudioPlayerError: Error { case genericError } -// There used to be a MediaPlayerProtocol that AudioPlayerProtocol inherited from. -// This should be called something else but we already have an AudioPlayerState, -// AudioPlayerPlaybackState and InternalAudioPlayerState so who knows what to call this. +/// There used to be a MediaPlayerProtocol that AudioPlayerProtocol inherited from. +/// This should be called something else but we already have an AudioPlayerState, +/// AudioPlayerPlaybackState and InternalAudioPlayerState so who knows what to call this. enum MediaPlayerState { case loading case playing diff --git a/ElementX/Sources/Services/Authentication/AuthenticationService.swift b/ElementX/Sources/Services/Authentication/AuthenticationService.swift index 6a003a7dc..ffcc2313f 100644 --- a/ElementX/Sources/Services/Authentication/AuthenticationService.swift +++ b/ElementX/Sources/Services/Authentication/AuthenticationService.swift @@ -21,7 +21,10 @@ class AuthenticationService: AuthenticationServiceProtocol { private let appHooks: AppHooks private let homeserverSubject: CurrentValueSubject - var homeserver: CurrentValuePublisher { homeserverSubject.asCurrentValuePublisher() } + var homeserver: CurrentValuePublisher { + homeserverSubject.asCurrentValuePublisher() + } + private(set) var flow: AuthenticationFlow init(userSessionStore: UserSessionStoreProtocol, diff --git a/ElementX/Sources/Services/Authentication/LinkNewDeviceService.swift b/ElementX/Sources/Services/Authentication/LinkNewDeviceService.swift index 4caadf800..cdd471bb8 100644 --- a/ElementX/Sources/Services/Authentication/LinkNewDeviceService.swift +++ b/ElementX/Sources/Services/Authentication/LinkNewDeviceService.swift @@ -216,10 +216,12 @@ class CheckCodeSenderProxy: Equatable { try await underlyingSender.send(code: code) } - // Bypassed for now whilst we wait for an SDK update (however its worth noting that - // things should still fail if the wrong code is provided, just not necessarily with - // the right error being shown). https://github.com/matrix-org/matrix-rust-sdk/pull/5957 - func validate(checkCode: UInt8) -> Bool { true } + /// Bypassed for now whilst we wait for an SDK update (however its worth noting that + /// things should still fail if the wrong code is provided, just not necessarily with + /// the right error being shown). https://github.com/matrix-org/matrix-rust-sdk/pull/5957 + func validate(checkCode: UInt8) -> Bool { + true + } } extension UIImage { diff --git a/ElementX/Sources/Services/BugReport/BugReportService.swift b/ElementX/Sources/Services/BugReport/BugReportService.swift index 373477bfc..9bbc5093e 100644 --- a/ElementX/Sources/Services/BugReport/BugReportService.swift +++ b/ElementX/Sources/Services/BugReport/BugReportService.swift @@ -23,7 +23,10 @@ class BugReportService: NSObject, BugReportServiceProtocol { private let progressSubject = PassthroughSubject() private var cancellables = Set() - var isEnabled: Bool { rageshakeURL != .disabled } + var isEnabled: Bool { + rageshakeURL != .disabled + } + var lastCrashEventID: String? init(rageshakeURLPublisher: CurrentValuePublisher, diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 0b283cfca..d20a70c11 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -9,9 +9,8 @@ @preconcurrency import Combine import CryptoKit import Foundation -import OrderedCollections - import MatrixRustSDK +import OrderedCollections class ClientProxy: ClientProxyProtocol { private let client: ClientProtocol diff --git a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift index 2d328a3ae..904637c12 100644 --- a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift +++ b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift @@ -83,7 +83,7 @@ enum SessionVerificationState { case unverified } -// The `Decodable` conformance is just for the purpose of migration +/// The `Decodable` conformance is just for the purpose of migration enum TimelineMediaVisibility: Decodable { case always case privateOnly diff --git a/ElementX/Sources/Services/ComposerDraft/ComposerDraftServiceProtocol.swift b/ElementX/Sources/Services/ComposerDraft/ComposerDraftServiceProtocol.swift index 9b1986a7c..0f0c04041 100644 --- a/ElementX/Sources/Services/ComposerDraft/ComposerDraftServiceProtocol.swift +++ b/ElementX/Sources/Services/ComposerDraft/ComposerDraftServiceProtocol.swift @@ -7,7 +7,6 @@ // import Foundation - import MatrixRustSDK struct ComposerDraftProxy: Equatable { diff --git a/ElementX/Sources/Services/ElementCall/ElementCallService.swift b/ElementX/Sources/Services/ElementCall/ElementCallService.swift index 7aba4e57c..13935f716 100644 --- a/ElementX/Sources/Services/ElementCall/ElementCallService.swift +++ b/ElementX/Sources/Services/ElementCall/ElementCallService.swift @@ -14,7 +14,7 @@ import MatrixRustSDK import PushKit import UIKit -// Keep this class testable +/// Keep this class testable struct TimeProvider { var clock: any Clock var now: () -> Date diff --git a/ElementX/Sources/Services/Keychain/KeychainControllerMock.swift b/ElementX/Sources/Services/Keychain/KeychainControllerMock.swift index e5bb3debd..d38deb3d3 100644 --- a/ElementX/Sources/Services/Keychain/KeychainControllerMock.swift +++ b/ElementX/Sources/Services/Keychain/KeychainControllerMock.swift @@ -10,6 +10,11 @@ import MatrixRustSDK /// Adds the missing methods for conformance to the protocol. extension KeychainControllerMock { - func retrieveSessionFromKeychain(userId: String) throws -> Session { fatalError("Not implemented") } - func saveSessionInKeychain(session: Session) { fatalError("Not implemented") } + func retrieveSessionFromKeychain(userId: String) throws -> Session { + fatalError("Not implemented") + } + + func saveSessionInKeychain(session: Session) { + fatalError("Not implemented") + } } diff --git a/ElementX/Sources/Services/MediaPlayer/MediaPlayerProvider.swift b/ElementX/Sources/Services/MediaPlayer/MediaPlayerProvider.swift index b44f31332..80253b783 100644 --- a/ElementX/Sources/Services/MediaPlayer/MediaPlayerProvider.swift +++ b/ElementX/Sources/Services/MediaPlayer/MediaPlayerProvider.swift @@ -12,7 +12,9 @@ class MediaPlayerProvider: MediaPlayerProviderProtocol { private lazy var audioPlayer = AudioPlayer() private var audioPlayerStates: [String: AudioPlayerState] = [:] - var player: AudioPlayerProtocol { audioPlayer } + var player: AudioPlayerProtocol { + audioPlayer + } deinit { audioPlayerStates = [:] diff --git a/ElementX/Sources/Services/Room/JoinedRoomProxy.swift b/ElementX/Sources/Services/Room/JoinedRoomProxy.swift index 5f28d76fd..df183d8a8 100644 --- a/ElementX/Sources/Services/Room/JoinedRoomProxy.swift +++ b/ElementX/Sources/Services/Room/JoinedRoomProxy.swift @@ -30,17 +30,19 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { private var subscribedForUpdates = false - // A room identifier is constant and lazy stops it from being fetched - // multiple times over FFI + /// A room identifier is constant and lazy stops it from being fetched + /// multiple times over FFI lazy var id: String = room.id() - var ownUserID: String { room.ownUserId() } + var ownUserID: String { + room.ownUserId() + } - // The predecessor is set on room creation and never changes, so we lazily store it. + /// The predecessor is set on room creation and never changes, so we lazily store it. lazy var predecessorRoom = room.predecessorRoom() - // The successor may change over time, so we access it dynamically. - // It's suggested to observe it through the `infoPublisher` + /// The successor may change over time, so we access it dynamically. + /// It's suggested to observe it through the `infoPublisher` var successorRoom: SuccessorRoom? { room.successorRoom() } diff --git a/ElementX/Sources/Services/Room/RoomInfoProxy.swift b/ElementX/Sources/Services/Room/RoomInfoProxy.swift index 13b9d2ba4..f2055a45f 100644 --- a/ElementX/Sources/Services/Room/RoomInfoProxy.swift +++ b/ElementX/Sources/Services/Room/RoomInfoProxy.swift @@ -12,48 +12,139 @@ import MatrixRustSDK struct RoomInfoProxy: RoomInfoProxyProtocol { let roomInfo: RoomInfo - var id: String { roomInfo.id } - var creators: [String] { roomInfo.creators ?? [] } - var displayName: String? { roomInfo.displayName } - var rawName: String? { roomInfo.rawName } - var topic: String? { roomInfo.topic } - /// The room's avatar URL. Use this for editing and favour ``avatar`` for display. - var avatarURL: URL? { roomInfo.avatarUrl.flatMap(URL.init) } + var id: String { + roomInfo.id + } - // Here we're assuming unknown rooms are unencrypted. - // Fortunately https://github.com/matrix-org/matrix-rust-sdk/pull/4778 makes that very much of an edge case and we - // also automatically start a `latestEncryptionState` fetch if needed. - // In the worst case, even if we are to assume a room is unencrypted, the SDK will still determine the correct - // state before any message is sent. - var isEncrypted: Bool { roomInfo.encryptionState == .encrypted } + var creators: [String] { + roomInfo.creators ?? [] + } + + var displayName: String? { + roomInfo.displayName + } + + var rawName: String? { + roomInfo.rawName + } + + var topic: String? { + roomInfo.topic + } + + /// The room's avatar URL. Use this for editing and favour ``avatar`` for display. + var avatarURL: URL? { + roomInfo.avatarUrl.flatMap(URL.init) + } + + /// Here we're assuming unknown rooms are unencrypted. + /// Fortunately https://github.com/matrix-org/matrix-rust-sdk/pull/4778 makes that very much of an edge case and we + /// also automatically start a `latestEncryptionState` fetch if needed. + /// In the worst case, even if we are to assume a room is unencrypted, the SDK will still determine the correct + /// state before any message is sent. + var isEncrypted: Bool { + roomInfo.encryptionState == .encrypted + } - var isDirect: Bool { roomInfo.isDirect } - var isSpace: Bool { roomInfo.isSpace } + var isDirect: Bool { + roomInfo.isDirect + } + + var isSpace: Bool { + roomInfo.isSpace + } - var successor: SuccessorRoom? { roomInfo.successorRoom } - var isFavourite: Bool { roomInfo.isFavourite } - var canonicalAlias: String? { roomInfo.canonicalAlias } - var alternativeAliases: [String] { roomInfo.alternativeAliases } - var membership: Membership { roomInfo.membership } - var inviter: RoomMemberProxyProtocol? { roomInfo.inviter.map(RoomMemberProxy.init) } - var heroes: [RoomHero] { roomInfo.heroes } - var activeMembersCount: Int { Int(roomInfo.activeMembersCount) } - var invitedMembersCount: Int { Int(roomInfo.invitedMembersCount) } - var joinedMembersCount: Int { Int(roomInfo.joinedMembersCount) } - var highlightCount: Int { Int(roomInfo.highlightCount) } - var notificationCount: Int { Int(roomInfo.notificationCount) } - var cachedUserDefinedNotificationMode: RoomNotificationMode? { roomInfo.cachedUserDefinedNotificationMode } - var hasRoomCall: Bool { roomInfo.hasRoomCall } - var activeRoomCallParticipants: [String] { roomInfo.activeRoomCallParticipants } - var isMarkedUnread: Bool { roomInfo.isMarkedUnread } - var unreadMessagesCount: UInt { UInt(roomInfo.numUnreadMessages) } - var unreadNotificationsCount: UInt { UInt(roomInfo.numUnreadNotifications) } - var unreadMentionsCount: UInt { UInt(roomInfo.numUnreadMentions) } - var pinnedEventIDs: Set { Set(roomInfo.pinnedEventIds) } - var joinRule: JoinRule? { roomInfo.joinRule } - var historyVisibility: RoomHistoryVisibility { roomInfo.historyVisibility } + var successor: SuccessorRoom? { + roomInfo.successorRoom + } + + var isFavourite: Bool { + roomInfo.isFavourite + } + + var canonicalAlias: String? { + roomInfo.canonicalAlias + } + + var alternativeAliases: [String] { + roomInfo.alternativeAliases + } + + var membership: Membership { + roomInfo.membership + } + + var inviter: RoomMemberProxyProtocol? { + roomInfo.inviter.map(RoomMemberProxy.init) + } + + var heroes: [RoomHero] { + roomInfo.heroes + } + + var activeMembersCount: Int { + Int(roomInfo.activeMembersCount) + } + + var invitedMembersCount: Int { + Int(roomInfo.invitedMembersCount) + } + + var joinedMembersCount: Int { + Int(roomInfo.joinedMembersCount) + } + + var highlightCount: Int { + Int(roomInfo.highlightCount) + } + + var notificationCount: Int { + Int(roomInfo.notificationCount) + } + + var cachedUserDefinedNotificationMode: RoomNotificationMode? { + roomInfo.cachedUserDefinedNotificationMode + } + + var hasRoomCall: Bool { + roomInfo.hasRoomCall + } + + var activeRoomCallParticipants: [String] { + roomInfo.activeRoomCallParticipants + } + + var isMarkedUnread: Bool { + roomInfo.isMarkedUnread + } + + var unreadMessagesCount: UInt { + UInt(roomInfo.numUnreadMessages) + } + + var unreadNotificationsCount: UInt { + UInt(roomInfo.numUnreadNotifications) + } + + var unreadMentionsCount: UInt { + UInt(roomInfo.numUnreadMentions) + } + + var pinnedEventIDs: Set { + Set(roomInfo.pinnedEventIds) + } + + var joinRule: JoinRule? { + roomInfo.joinRule + } + + var historyVisibility: RoomHistoryVisibility { + roomInfo.historyVisibility + } - var powerLevels: RoomPowerLevelsProxyProtocol? { RoomPowerLevelsProxy(roomInfo.powerLevels) } + var powerLevels: RoomPowerLevelsProxyProtocol? { + RoomPowerLevelsProxy(roomInfo.powerLevels) + } } struct RoomPreviewInfoProxy: BaseRoomInfoProxyProtocol { @@ -61,17 +152,51 @@ struct RoomPreviewInfoProxy: BaseRoomInfoProxyProtocol { let successor: SuccessorRoom? = nil - var id: String { roomPreviewInfo.roomId } - var displayName: String? { roomPreviewInfo.name } - var heroes: [RoomHero] { roomPreviewInfo.heroes ?? [] } - var topic: String? { roomPreviewInfo.topic } - var canonicalAlias: String? { roomPreviewInfo.canonicalAlias } - var avatarURL: URL? { roomPreviewInfo.avatarUrl.flatMap(URL.init) } - var isDirect: Bool { roomPreviewInfo.isDirect ?? false } - var isSpace: Bool { roomPreviewInfo.roomType == .space } - var activeMembersCount: Int { Int(roomPreviewInfo.numActiveMembers ?? roomPreviewInfo.numJoinedMembers) } - var joinedMembersCount: Int { Int(roomPreviewInfo.numJoinedMembers) } + var id: String { + roomPreviewInfo.roomId + } + + var displayName: String? { + roomPreviewInfo.name + } + + var heroes: [RoomHero] { + roomPreviewInfo.heroes ?? [] + } + + var topic: String? { + roomPreviewInfo.topic + } + + var canonicalAlias: String? { + roomPreviewInfo.canonicalAlias + } + + var avatarURL: URL? { + roomPreviewInfo.avatarUrl.flatMap(URL.init) + } + + var isDirect: Bool { + roomPreviewInfo.isDirect ?? false + } + + var isSpace: Bool { + roomPreviewInfo.roomType == .space + } + + var activeMembersCount: Int { + Int(roomPreviewInfo.numActiveMembers ?? roomPreviewInfo.numJoinedMembers) + } + + var joinedMembersCount: Int { + Int(roomPreviewInfo.numJoinedMembers) + } - var joinRule: JoinRule? { roomPreviewInfo.joinRule } - var membership: Membership? { roomPreviewInfo.membership } + var joinRule: JoinRule? { + roomPreviewInfo.joinRule + } + + var membership: Membership? { + roomPreviewInfo.membership + } } diff --git a/ElementX/Sources/Services/Room/RoomMember/RoomMemberProxy.swift b/ElementX/Sources/Services/Room/RoomMember/RoomMemberProxy.swift index b829c57e4..69f56644f 100644 --- a/ElementX/Sources/Services/Room/RoomMember/RoomMemberProxy.swift +++ b/ElementX/Sources/Services/Room/RoomMember/RoomMemberProxy.swift @@ -16,9 +16,13 @@ final class RoomMemberProxy: RoomMemberProxyProtocol { self.member = member } - var userID: String { member.userId } + var userID: String { + member.userId + } - var displayName: String? { member.displayName } + var displayName: String? { + member.displayName + } var disambiguatedDisplayName: String? { guard let displayName else { @@ -28,13 +32,23 @@ final class RoomMemberProxy: RoomMemberProxyProtocol { return member.isNameAmbiguous ? "\(displayName) (\(userID))" : displayName } - var avatarURL: URL? { member.avatarUrl.flatMap(URL.init(string:)) } + var avatarURL: URL? { + member.avatarUrl.flatMap(URL.init(string:)) + } - var membership: MembershipState { member.membership } + var membership: MembershipState { + member.membership + } - var membershipChangeReason: String? { member.membershipChangeReason } + var membershipChangeReason: String? { + member.membershipChangeReason + } - var isIgnored: Bool { member.isIgnored } + var isIgnored: Bool { + member.isIgnored + } - var powerLevel: RoomPowerLevel { .init(rustPowerLevel: member.powerLevel) } + var powerLevel: RoomPowerLevel { + .init(rustPowerLevel: member.powerLevel) + } } diff --git a/ElementX/Sources/Services/Room/RoomMember/RoomMemberProxyProtocol.swift b/ElementX/Sources/Services/Room/RoomMember/RoomMemberProxyProtocol.swift index fecb51c5d..acbb26038 100644 --- a/ElementX/Sources/Services/Room/RoomMember/RoomMemberProxyProtocol.swift +++ b/ElementX/Sources/Services/Room/RoomMember/RoomMemberProxyProtocol.swift @@ -59,5 +59,7 @@ extension [RoomMemberProxyProtocol] { } extension RoomMemberProxyProtocol { - var role: RoomRole { .init(powerLevel: powerLevel) } + var role: RoomRole { + .init(powerLevel: powerLevel) + } } diff --git a/ElementX/Sources/Services/Room/RoomPermissions.swift b/ElementX/Sources/Services/Room/RoomPermissions.swift index 694c86f3f..cbe060155 100644 --- a/ElementX/Sources/Services/Room/RoomPermissions.swift +++ b/ElementX/Sources/Services/Room/RoomPermissions.swift @@ -13,7 +13,9 @@ struct RoomPermissionsSetting: Identifiable { static let allValues: [(title: String, tag: RoomRole)] = [(title: L10n.screenRoomChangePermissionsAdministrators, tag: .administrator), (title: L10n.screenRoomChangePermissionsModerators, tag: .moderator), (title: L10n.screenRoomChangePermissionsEveryone, tag: .user)] - var id: KeyPath { keyPath } + var id: KeyPath { + keyPath + } /// The title of this setting. let title: String @@ -69,16 +71,6 @@ struct RoomPermissionsSetting: Identifiable { Self.allValues.filter { $0.tag <= ownPowerLevel.role } } } - - init(title: String, - value: Int64, - ownPowerLevel: RoomPowerLevel, - keyPath: KeyPath) { - self.ownPowerLevel = ownPowerLevel - self.title = title - self.value = value - self.keyPath = keyPath - } } struct RoomPermissions { diff --git a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift index 04117706e..87583a736 100644 --- a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift +++ b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift @@ -214,7 +214,7 @@ extension JoinedRoomProxyProtocol { return membersPublisher.value } - // This is a horrible workaround for not having any server names available when using tombstone links with v12 room IDs. + /// This is a horrible workaround for not having any server names available when using tombstone links with v12 room IDs. func knownServerNames(maxCount: Int) -> any Sequence { membersPublisher.value .prefix(1000) // No need to go crazy here… diff --git a/ElementX/Sources/Services/Room/RoomSummary/RoomSummary.swift b/ElementX/Sources/Services/Room/RoomSummary/RoomSummary.swift index 2e22a95b2..cbc06a381 100644 --- a/ElementX/Sources/Services/Room/RoomSummary/RoomSummary.swift +++ b/ElementX/Sources/Services/Room/RoomSummary/RoomSummary.swift @@ -62,21 +62,33 @@ struct RoomSummary { let isFavourite: Bool let isTombstoned: Bool - var hasUnreadMessages: Bool { unreadMessagesCount > 0 } - var hasUnreadMentions: Bool { unreadMentionsCount > 0 } - var hasUnreadNotifications: Bool { unreadNotificationsCount > 0 } - var isMuted: Bool { notificationMode == .mute } + var hasUnreadMessages: Bool { + unreadMessagesCount > 0 + } + + var hasUnreadMentions: Bool { + unreadMentionsCount > 0 + } + + var hasUnreadNotifications: Bool { + unreadNotificationsCount > 0 + } + + var isMuted: Bool { + notificationMode == .mute + } } extension RoomSummary: CustomStringConvertible { - var description: String { """ - RoomSummary: - id: \(id) \ - - isDirect: \(isDirect) \ - - unreadMessagesCount: \(unreadMessagesCount) \ - - unreadMentionsCount: \(unreadMentionsCount) \ - - unreadNotificationsCount: \(unreadNotificationsCount) \ - - notificationMode: \(notificationMode?.rawValue ?? "nil") - """ + var description: String { + """ + RoomSummary: - id: \(id) \ + - isDirect: \(isDirect) \ + - unreadMessagesCount: \(unreadMessagesCount) \ + - unreadMentionsCount: \(unreadMentionsCount) \ + - unreadNotificationsCount: \(unreadNotificationsCount) \ + - notificationMode: \(notificationMode?.rawValue ?? "nil") + """ } /// Used where summaries are shown in a list e.g. message forwarding, @@ -135,7 +147,7 @@ extension RoomSummary { isTombstoned = false } - // This doesn't have to work properly for DM invites, the heroes are always empty + /// This doesn't have to work properly for DM invites, the heroes are always empty var avatar: RoomAvatar { guard !isTombstoned else { return .tombstoned diff --git a/ElementX/Sources/Services/RoomDirectorySearch/RoomDirectorySearchProxy.swift b/ElementX/Sources/Services/RoomDirectorySearch/RoomDirectorySearchProxy.swift index 563cbf678..7c6c13bb5 100644 --- a/ElementX/Sources/Services/RoomDirectorySearch/RoomDirectorySearchProxy.swift +++ b/ElementX/Sources/Services/RoomDirectorySearch/RoomDirectorySearchProxy.swift @@ -8,7 +8,6 @@ import Combine import Foundation - import MatrixRustSDK final class RoomDirectorySearchProxy: RoomDirectorySearchProxyProtocol { diff --git a/ElementX/Sources/Services/Spaces/LeaveSpaceHandleProxy.swift b/ElementX/Sources/Services/Spaces/LeaveSpaceHandleProxy.swift index 11734165e..540bda479 100644 --- a/ElementX/Sources/Services/Spaces/LeaveSpaceHandleProxy.swift +++ b/ElementX/Sources/Services/Spaces/LeaveSpaceHandleProxy.swift @@ -18,8 +18,13 @@ final class LeaveSpaceHandleProxy { private let leaveHandle: LeaveSpaceHandleProtocol - var canLeave: Bool { mode != .spaceNeedsNewOwner } - var selectedCount: Int { rooms.count { $0.isSelected } } + var canLeave: Bool { + mode != .spaceNeedsNewOwner + } + + var selectedCount: Int { + rooms.count { $0.isSelected } + } init(spaceID: String, leaveHandle: LeaveSpaceHandleProtocol) { id = spaceID diff --git a/ElementX/Sources/Services/Spaces/SpaceRoomListProxy.swift b/ElementX/Sources/Services/Spaces/SpaceRoomListProxy.swift index d7a33d684..4b7712c6c 100644 --- a/ElementX/Sources/Services/Spaces/SpaceRoomListProxy.swift +++ b/ElementX/Sources/Services/Spaces/SpaceRoomListProxy.swift @@ -10,7 +10,9 @@ import Combine import MatrixRustSDK class SpaceRoomListProxy: SpaceRoomListProxyProtocol { - var id: String { spaceServiceRoomPublisher.value.id } + var id: String { + spaceServiceRoomPublisher.value.id + } private let spaceRoomList: SpaceRoomListProtocol diff --git a/ElementX/Sources/Services/Spaces/SpaceServiceProxyProtocol.swift b/ElementX/Sources/Services/Spaces/SpaceServiceProxyProtocol.swift index 490a350b5..583950f82 100644 --- a/ElementX/Sources/Services/Spaces/SpaceServiceProxyProtocol.swift +++ b/ElementX/Sources/Services/Spaces/SpaceServiceProxyProtocol.swift @@ -31,7 +31,7 @@ struct SpaceServiceFilter: Identifiable, Equatable { descendants = Set(filter.descendants) } - // Same rooms might appear on multiple levels + /// Same rooms might appear on multiple levels var id: String { room.id + "\(level)" } diff --git a/ElementX/Sources/Services/Timeline/GeoURI.swift b/ElementX/Sources/Services/Timeline/GeoURI.swift index 9f54684e9..6a2ed5885 100644 --- a/ElementX/Sources/Services/Timeline/GeoURI.swift +++ b/ElementX/Sources/Services/Timeline/GeoURI.swift @@ -47,7 +47,7 @@ struct GeoURI: Hashable { // MARK: - Private - // Parse a geo URI string like "geo:53.99803101552848,-8.25347900390625;u=10" + /// Parse a geo URI string like "geo:53.99803101552848,-8.25347900390625;u=10" private static func parseGeoURI(from string: String) -> GeoURI? { guard let matchOutput = try? RegexGeoURI.standard.wholeMatch(in: string)?.output, diff --git a/ElementX/Sources/Services/Timeline/IntentionalMentions.swift b/ElementX/Sources/Services/Timeline/IntentionalMentions.swift index b84ad9759..dc2742a65 100644 --- a/ElementX/Sources/Services/Timeline/IntentionalMentions.swift +++ b/ElementX/Sources/Services/Timeline/IntentionalMentions.swift @@ -7,7 +7,6 @@ // import Foundation - import MatrixRustSDK import WysiwygComposer diff --git a/ElementX/Sources/Services/Timeline/TimelineController/MockTimelineController.swift b/ElementX/Sources/Services/Timeline/TimelineController/MockTimelineController.swift index 843e95b54..dc014c132 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/MockTimelineController.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/MockTimelineController.swift @@ -21,7 +21,10 @@ class MockTimelineController: TimelineControllerProtocol { var roomProxy: JoinedRoomProxyProtocol? var timelineProxy: TimelineProxyProtocol? - var roomID: String { roomProxy?.id ?? "MockRoomIdentifier" } + var roomID: String { + roomProxy?.id ?? "MockRoomIdentifier" + } + var timelineKind: TimelineKind let callbacks = PassthroughSubject() diff --git a/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift b/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift index 4fbc60a35..2aab0096a 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift @@ -250,8 +250,8 @@ class TimelineController: TimelineControllerProtocol { await activeTimeline.messageEventContent(for: timelineItemID) } - // Handle this parallel to the timeline items so we're not forced - // to bundle the Rust side objects within them + /// Handle this parallel to the timeline items so we're not forced + /// to bundle the Rust side objects within them func debugInfo(for itemID: TimelineItemIdentifier) -> TimelineItemDebugInfo { for timelineItemProxy in activeTimelineItemProvider.itemProxies { switch timelineItemProxy { @@ -428,14 +428,12 @@ class TimelineController: TimelineControllerProtocol { let isLastItem = index == collapsibleChunks.indices.last let items = collapsibleChunk.compactMap { itemProxy in - let timelineItem = self.buildTimelineItem(for: itemProxy, - isDM: isDM, - hasPredecessor: hasPredecessor, - roomDisplayName: displayName, - timelineItemFactory: timelineItemFactory, - activeTimeline: activeTimeline) - - return timelineItem + self.buildTimelineItem(for: itemProxy, + isDM: isDM, + hasPredecessor: hasPredecessor, + roomDisplayName: displayName, + timelineItemFactory: timelineItemFactory, + activeTimeline: activeTimeline) } if items.isEmpty { diff --git a/ElementX/Sources/Services/Timeline/TimelineItemContent/ReadReceipt.swift b/ElementX/Sources/Services/Timeline/TimelineItemContent/ReadReceipt.swift index 84dd0b5f7..935f8db18 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItemContent/ReadReceipt.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItemContent/ReadReceipt.swift @@ -14,5 +14,7 @@ struct ReadReceipt: Hashable { } extension ReadReceipt: Identifiable { - var id: String { userID } + var id: String { + userID + } } diff --git a/ElementX/Sources/Services/Timeline/TimelineItemContent/RoomTimelineItemProperties.swift b/ElementX/Sources/Services/Timeline/TimelineItemContent/RoomTimelineItemProperties.swift index 08bf3542f..d72e41c54 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItemContent/RoomTimelineItemProperties.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItemContent/RoomTimelineItemProperties.swift @@ -10,11 +10,11 @@ import Foundation /// Properties of a matrix event that are common between all timeline items. struct RoomTimelineItemProperties: Hashable { - // Information on the item this one replying to + /// Information on the item this one replying to var replyDetails: TimelineItemReplyDetails? - // Whether it's part of a thread or not + /// Whether it's part of a thread or not var isThreaded = false - // Information about the thread this message is the root of, if any + /// Information about the thread this message is the root of, if any var threadSummary: TimelineItemThreadSummary? /// Whether the item has been edited. var isEdited = false diff --git a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift index 31a051b5a..e49696708 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift @@ -624,7 +624,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol { return .init(body: messageContent.body, formattedBody: formattedBody, formattedBodyHTMLString: htmlBody) } - // This fixes the issue of the name not belonging to the first

defined paragraph + /// This fixes the issue of the name not belonging to the first

defined paragraph private func buildEmoteFormattedBodyFromHTML(html: String, name: String) -> AttributedString? { let htmlBodyPlaceholder = "{htmlBodyPlaceholder}" var finalString = AttributedString(L10n.commonEmote(name, htmlBodyPlaceholder)) diff --git a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactoryProtocol.swift b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactoryProtocol.swift index 8c5fc48e4..33309b73a 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactoryProtocol.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactoryProtocol.swift @@ -7,7 +7,6 @@ // import Foundation - import MatrixRustSDK protocol RoomTimelineItemFactoryProtocol { diff --git a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemView.swift b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemView.swift index cabc11f68..92d47a5f4 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemView.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemView.swift @@ -1,4 +1,6 @@ // +import OrderedCollections + // Copyright 2025 Element Creations Ltd. // Copyright 2022-2025 New Vector Ltd. // @@ -7,8 +9,6 @@ // import SwiftUI -import OrderedCollections - struct RoomTimelineItemView: View { @Environment(\.timelineContext) var context @ObservedObject var viewState: RoomTimelineItemViewState diff --git a/ElementX/Sources/Services/UserSession/SessionDirectories.swift b/ElementX/Sources/Services/UserSession/SessionDirectories.swift index 64ae6e8e0..12bbece08 100644 --- a/ElementX/Sources/Services/UserSession/SessionDirectories.swift +++ b/ElementX/Sources/Services/UserSession/SessionDirectories.swift @@ -12,8 +12,13 @@ struct SessionDirectories: Hashable, Codable { let dataDirectory: URL let cacheDirectory: URL - var dataPath: String { dataDirectory.path(percentEncoded: false) } - var cachePath: String { cacheDirectory.path(percentEncoded: false) } + var dataPath: String { + dataDirectory.path(percentEncoded: false) + } + + var cachePath: String { + cacheDirectory.path(percentEncoded: false) + } // MARK: Data Management diff --git a/ElementX/Sources/Services/UserSession/UserSessionStore.swift b/ElementX/Sources/Services/UserSession/UserSessionStore.swift index eed8f6097..4ecabca01 100644 --- a/ElementX/Sources/Services/UserSession/UserSessionStore.swift +++ b/ElementX/Sources/Services/UserSession/UserSessionStore.swift @@ -16,11 +16,18 @@ class UserSessionStore: UserSessionStoreProtocol { private let appHooks: AppHooks /// Whether or not there are sessions in the store. - var hasSessions: Bool { !keychainController.restorationTokens().isEmpty } + var hasSessions: Bool { + !keychainController.restorationTokens().isEmpty + } + /// All the user IDs managed by the store. - var userIDs: [String] { keychainController.restorationTokens().map(\.userID) } + var userIDs: [String] { + keychainController.restorationTokens().map(\.userID) + } - var clientSessionDelegate: ClientSessionDelegate { keychainController } + var clientSessionDelegate: ClientSessionDelegate { + keychainController + } init(keychainController: KeychainControllerProtocol, appSettings: AppSettings, diff --git a/ElementX/Sources/Services/Users/UserProfileProxy.swift b/ElementX/Sources/Services/Users/UserProfileProxy.swift index ff3263947..14c66fc67 100644 --- a/ElementX/Sources/Services/Users/UserProfileProxy.swift +++ b/ElementX/Sources/Services/Users/UserProfileProxy.swift @@ -64,5 +64,7 @@ extension SearchUsersResultsProxy { } extension UserProfileProxy: Identifiable { - var id: String { userID } + var id: String { + userID + } } diff --git a/ElementX/Sources/UITests/UITestsSignalling.swift b/ElementX/Sources/UITests/UITestsSignalling.swift index e22326d62..e3cac5c44 100644 --- a/ElementX/Sources/UITests/UITestsSignalling.swift +++ b/ElementX/Sources/UITests/UITestsSignalling.swift @@ -48,7 +48,9 @@ enum UITestsSignalError: String, LocalizedError { /// Failed to send a signal as a connection hasn't been established. case notConnected - var errorDescription: String? { "UITestsSignalError.\(rawValue)" } + var errorDescription: String? { + "UITestsSignalError.\(rawValue)" + } } enum UITestsSignalling { diff --git a/Enterprise b/Enterprise index ab6f65f11..8dc7d75b8 160000 --- a/Enterprise +++ b/Enterprise @@ -1 +1 @@ -Subproject commit ab6f65f115b5d5335390e5218942e9c1b7ddc6b7 +Subproject commit 8dc7d75b883dbd12dc0ba978c6719f4d1032534e diff --git a/IntegrationTests/Sources/Common.swift b/IntegrationTests/Sources/Common.swift index 66babbc69..625e53964 100644 --- a/IntegrationTests/Sources/Common.swift +++ b/IntegrationTests/Sources/Common.swift @@ -13,7 +13,9 @@ enum IntegrationTestsError: Error { } extension XCUIApplication { - private var doesNotExistPredicate: NSPredicate { NSPredicate(format: "exists == 0") } + private var doesNotExistPredicate: NSPredicate { + NSPredicate(format: "exists == 0") + } func login(currentTestCase: XCTestCase) throws { let getStartedButton = buttons[A11yIdentifiers.authenticationStartScreen.signIn] diff --git a/IntegrationTests/Sources/UserFlowTests.swift b/IntegrationTests/Sources/UserFlowTests.swift index 22e73b743..c440601a8 100644 --- a/IntegrationTests/Sources/UserFlowTests.swift +++ b/IntegrationTests/Sources/UserFlowTests.swift @@ -30,7 +30,7 @@ class UserFlowTests: XCTestCase { app.logout() } - // Assumes app is on the home screen + /// Assumes app is on the home screen private func checkRoomFlows() { // Wait for the room list to paginate and correctly compute the room display names otherwise the test room // won't be found diff --git a/NSE/Sources/NotificationContentBuilder.swift b/NSE/Sources/NotificationContentBuilder.swift index 4d7818fea..9e3f1de77 100644 --- a/NSE/Sources/NotificationContentBuilder.swift +++ b/NSE/Sources/NotificationContentBuilder.swift @@ -7,11 +7,10 @@ // import Foundation -import MatrixRustSDK -import UserNotifications - import Intents +import MatrixRustSDK import SwiftUI +import UserNotifications import Version struct NotificationContentBuilder { @@ -345,7 +344,7 @@ private struct NotificationIcon { } let mediaSource: MediaSourceProxy? - // Required as the key to set images for groups + /// Required as the key to set images for groups let groupInfo: GroupInfo? var shouldDisplayAsGroup: Bool { diff --git a/NSE/Sources/NotificationItemProxy/NotificationItemProxy.swift b/NSE/Sources/NotificationItemProxy/NotificationItemProxy.swift index 6d44d296d..1854221e1 100644 --- a/NSE/Sources/NotificationItemProxy/NotificationItemProxy.swift +++ b/NSE/Sources/NotificationItemProxy/NotificationItemProxy.swift @@ -98,27 +98,51 @@ struct EmptyNotificationItemProxy: NotificationItemProxyProtocol { let receiverID: String - var senderID: String { "" } + var senderID: String { + "" + } - var senderDisplayName: String? { nil } + var senderDisplayName: String? { + nil + } - var roomDisplayName: String { "" } + var roomDisplayName: String { + "" + } - var isNoisy: Bool { false } + var isNoisy: Bool { + false + } - var isRoomSpace: Bool { false } + var isRoomSpace: Bool { + false + } - var isRoomDirect: Bool { false } + var isRoomDirect: Bool { + false + } - var isRoomPrivate: Bool { false } + var isRoomPrivate: Bool { + false + } - var senderAvatarMediaSource: MediaSourceProxy? { nil } + var senderAvatarMediaSource: MediaSourceProxy? { + nil + } - var roomAvatarMediaSource: MediaSourceProxy? { nil } + var roomAvatarMediaSource: MediaSourceProxy? { + nil + } - var roomJoinedMembers: Int { 0 } + var roomJoinedMembers: Int { + 0 + } - var hasMention: Bool { false } + var hasMention: Bool { + false + } - var threadRootEventID: String? { nil } + var threadRootEventID: String? { + nil + } } diff --git a/NSE/Sources/NotificationServiceExtension.swift b/NSE/Sources/NotificationServiceExtension.swift index a8a7795e8..37f6735b2 100644 --- a/NSE/Sources/NotificationServiceExtension.swift +++ b/NSE/Sources/NotificationServiceExtension.swift @@ -40,8 +40,8 @@ class NotificationServiceExtension: UNNotificationServiceExtension { private var cancellables: Set = [] - // We can make the whole NSE a MainActor after https://github.com/swiftlang/swift-evolution/blob/main/proposals/0371-isolated-synchronous-deinit.md - // otherwise we wouldn't be able to log the tag in the deinit. + /// We can make the whole NSE a MainActor after https://github.com/swiftlang/swift-evolution/blob/main/proposals/0371-isolated-synchronous-deinit.md + /// otherwise we wouldn't be able to log the tag in the deinit. deinit { ExtensionLogger.logMemory(with: tag) MXLog.info("\(tag) deinit") diff --git a/PreviewTests/Sources/PreviewTests.swift b/PreviewTests/Sources/PreviewTests.swift index 75f9c93e6..db29609a4 100644 --- a/PreviewTests/Sources/PreviewTests.swift +++ b/PreviewTests/Sources/PreviewTests.swift @@ -7,11 +7,10 @@ // import Combine -import SwiftUI -import XCTest - @testable import ElementX @testable import SnapshotTesting +import SwiftUI +import XCTest @MainActor class PreviewTests: XCTestCase { @@ -23,8 +22,8 @@ class PreviewTests: XCTestCase { private let deviceConfig: ViewImageConfig = .iPhoneX private let simulatorDevice: String? = "iPhone14,6" // iPhone SE 3rd Generation private let requiredOSVersion = (major: 26, minor: 1) - // The key is the name we will give to the snapshot - // The value is the actual device that will be used to render the preview + /// The key is the name we will give to the snapshot + /// The value is the actual device that will be used to render the preview private let snapshotDevices: [SnapshotDevice] = [.init(name: "iPhone", device: "iPhone 17"), .init(name: "iPad", device: "iPad")] private var recordMode: SnapshotTestingConfiguration.Record = .missing @@ -142,8 +141,7 @@ class PreviewTests: XCTestCase { preferences: SnapshotPreferences) -> String? { let matchingView = isScreen ? AnyView(view) : AnyView(view .frame(width: device.size?.width) - .fixedSize(horizontal: false, vertical: true) - ) + .fixedSize(horizontal: false, vertical: true)) return withSnapshotTesting(record: recordMode) { verifySnapshot(of: matchingView, @@ -255,5 +253,7 @@ private extension Diffing where Value == UIImage { private extension UIEdgeInsets { /// A custom inset that prevents the snapshotting library from rendering the /// origin at (10000, 10000) which breaks some of our views such as MessageText. - static var one: UIEdgeInsets { UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1) } + static var one: UIEdgeInsets { + UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1) + } } diff --git a/Tools/Scripts/Templates/SimpleScreenExample/Tests/Unit/TemplateScreenViewModelTests.swift b/Tools/Scripts/Templates/SimpleScreenExample/Tests/Unit/TemplateScreenViewModelTests.swift index cdb7d3ffd..53d710629 100644 --- a/Tools/Scripts/Templates/SimpleScreenExample/Tests/Unit/TemplateScreenViewModelTests.swift +++ b/Tools/Scripts/Templates/SimpleScreenExample/Tests/Unit/TemplateScreenViewModelTests.swift @@ -5,9 +5,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class TemplateScreenViewModelTests: XCTestCase { @@ -26,7 +25,7 @@ class TemplateScreenViewModelTests: XCTestCase { XCTAssertEqual(context.viewState.counter, 0) } - func testTextField() async throws { + func testTextField() { context.composerText = "123" context.send(viewAction: .textChanged) XCTAssertEqual(context.composerText, "123") diff --git a/Tools/Sources/Commands/OutdatedPackages.swift b/Tools/Sources/Commands/OutdatedPackages.swift index c3fb4aa07..e2962aba4 100644 --- a/Tools/Sources/Commands/OutdatedPackages.swift +++ b/Tools/Sources/Commands/OutdatedPackages.swift @@ -5,7 +5,9 @@ import Foundation struct OutdatedPackages: ParsableCommand { static let configuration = CommandConfiguration(abstract: "A tool to check outdated package dependencies. Please make sure you have already run setup-project before using this tool.") - private var projectSwiftPMDirectoryURL: URL { .projectDirectory.appendingPathComponent("ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm") } + private var projectSwiftPMDirectoryURL: URL { + .projectDirectory.appendingPathComponent("ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm") + } func run() throws { try checkToolsDependencies() diff --git a/Tools/Sources/Extensions/URL.swift b/Tools/Sources/Extensions/URL.swift index f2c5bec4c..94e57b0e7 100644 --- a/Tools/Sources/Extensions/URL.swift +++ b/Tools/Sources/Extensions/URL.swift @@ -2,7 +2,15 @@ import ArgumentParser import Foundation extension URL { - static var projectDirectory: URL { URL(fileURLWithPath: FileManager.default.currentDirectoryPath) } - static var parentDirectory: URL { .projectDirectory.deletingLastPathComponent() } - static var sdkDirectory: URL { .parentDirectory.appendingPathComponent("matrix-rust-sdk") } + static var projectDirectory: URL { + URL(fileURLWithPath: FileManager.default.currentDirectoryPath) + } + + static var parentDirectory: URL { + .projectDirectory.deletingLastPathComponent() + } + + static var sdkDirectory: URL { + .parentDirectory.appendingPathComponent("matrix-rust-sdk") + } } diff --git a/UITests/Sources/AppLockSetupTests.swift b/UITests/Sources/AppLockSetupTests.swift index ce73c7c6b..88c07937f 100644 --- a/UITests/Sources/AppLockSetupTests.swift +++ b/UITests/Sources/AppLockSetupTests.swift @@ -26,7 +26,9 @@ class AppLockSetupUITests: XCTestCase { /// Not part of the flow, only to verify the stack is cleared. static let clearedStack = 99 - static var isPhone: Bool { UIDevice.current.userInterfaceIdiom == .phone } + static var isPhone: Bool { + UIDevice.current.userInterfaceIdiom == .phone + } } func testCreateFlow() async throws { diff --git a/UITests/Sources/AuthenticationFlowCoordinatorTests.swift b/UITests/Sources/AuthenticationFlowCoordinatorTests.swift index 8358d20cf..410fa54da 100644 --- a/UITests/Sources/AuthenticationFlowCoordinatorTests.swift +++ b/UITests/Sources/AuthenticationFlowCoordinatorTests.swift @@ -43,7 +43,7 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase { app.buttons[A11yIdentifiers.loginScreen.continue].tap() } - func testLoginWithIncorrectPassword() async throws { + func testLoginWithIncorrectPassword() { // Given the authentication flow. let app = Application.launch(.authenticationFlow) @@ -102,8 +102,8 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase { try await app.assertScreenshot() } - // Disabled for now as the looping isn't 100% fool-proof and we have OIDC on the integration tests - // so this mock version doesn't really add anything to the tests as a whole. + /// Disabled for now as the looping isn't 100% fool-proof and we have OIDC on the integration tests + /// so this mock version doesn't really add anything to the tests as a whole. func disabled_testSelectingOIDCServer() { // Allow this test to run for longer to help with the loop whilst waiting to resolve the // webcredentials for the Web Authentication Session (see below). diff --git a/UITests/Sources/UserSessionScreenTests.swift b/UITests/Sources/UserSessionScreenTests.swift index 2a01494ed..7ab325851 100644 --- a/UITests/Sources/UserSessionScreenTests.swift +++ b/UITests/Sources/UserSessionScreenTests.swift @@ -59,7 +59,7 @@ class UserSessionScreenTests: XCTestCase { try await app.assertScreenshot() } - func testElementCall() async throws { + func testElementCall() { let app = Application.launch(.userSessionScreen) app.buttons[A11yIdentifiers.homeScreen.roomName(firstRoomName)].tap() diff --git a/UnitTests/Sources/AVMetadataMachineReadableCodeObjectExtensionsTest.swift b/UnitTests/Sources/AVMetadataMachineReadableCodeObjectExtensionsTest.swift index 215335716..bef447007 100644 --- a/UnitTests/Sources/AVMetadataMachineReadableCodeObjectExtensionsTest.swift +++ b/UnitTests/Sources/AVMetadataMachineReadableCodeObjectExtensionsTest.swift @@ -7,9 +7,8 @@ // import AVKit -import XCTest - @testable import ElementX +import XCTest final class AVMetadataMachineReadableCodeObjectExtensionsTest: XCTestCase { func testDecodeQRCodeVersion8() { diff --git a/UnitTests/Sources/AnalyticsSettingsScreenViewModelTests.swift b/UnitTests/Sources/AnalyticsSettingsScreenViewModelTests.swift index 3f14c2cbc..61c5491f0 100644 --- a/UnitTests/Sources/AnalyticsSettingsScreenViewModelTests.swift +++ b/UnitTests/Sources/AnalyticsSettingsScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class AnalyticsSettingsScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/AnalyticsTests.swift b/UnitTests/Sources/AnalyticsTests.swift index dcbe58c56..2a0b9174a 100644 --- a/UnitTests/Sources/AnalyticsTests.swift +++ b/UnitTests/Sources/AnalyticsTests.swift @@ -210,11 +210,9 @@ class AnalyticsTests: XCTestCase { let client = PostHogAnalyticsClient(posthogFactory: MockPostHogFactory(mock: posthogMock)) try client.start(analyticsConfiguration: XCTUnwrap(appSettings.analyticsConfiguration)) - client.updateSuperProperties( - AnalyticsEvent.SuperProperties(appPlatform: .EXI, - cryptoSDK: .Rust, - cryptoSDKVersion: "000") - ) + client.updateSuperProperties(AnalyticsEvent.SuperProperties(appPlatform: .EXI, + cryptoSDK: .Rust, + cryptoSDKVersion: "000")) // When sending an event (tests run under Debug configuration so this is sent to the development instance) client.screen(AnalyticsEvent.MobileScreen(durationMs: nil, screenName: .Home)) @@ -250,11 +248,9 @@ class AnalyticsTests: XCTestCase { XCTAssertEqual(capturedEvent?.properties?["cryptoSDKVersion"] as? String, "000") // Updating should keep the previously set properties - client.updateSuperProperties( - AnalyticsEvent.SuperProperties(appPlatform: .EXI, - cryptoSDK: .Rust, - cryptoSDKVersion: "001") - ) + client.updateSuperProperties(AnalyticsEvent.SuperProperties(appPlatform: .EXI, + cryptoSDK: .Rust, + cryptoSDKVersion: "001")) client.capture(someEvent) let capturedEvent2 = posthogMock.capturePropertiesUserPropertiesReceivedArguments diff --git a/UnitTests/Sources/AppLock/AppLockScreenViewModelTests.swift b/UnitTests/Sources/AppLock/AppLockScreenViewModelTests.swift index 7b03cba7b..28c75bc97 100644 --- a/UnitTests/Sources/AppLock/AppLockScreenViewModelTests.swift +++ b/UnitTests/Sources/AppLock/AppLockScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class AppLockScreenViewModelTests: XCTestCase { @@ -17,7 +16,9 @@ class AppLockScreenViewModelTests: XCTestCase { var keychainController: KeychainControllerMock! var viewModel: AppLockScreenViewModelProtocol! - var context: AppLockScreenViewModelType.Context { viewModel.context } + var context: AppLockScreenViewModelType.Context { + viewModel.context + } override func setUp() { AppSettings.resetAllSettings() diff --git a/UnitTests/Sources/AppLock/AppLockServiceTests.swift b/UnitTests/Sources/AppLock/AppLockServiceTests.swift index 617911027..c2cd81905 100644 --- a/UnitTests/Sources/AppLock/AppLockServiceTests.swift +++ b/UnitTests/Sources/AppLock/AppLockServiceTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class AppLockServiceTests: XCTestCase { diff --git a/UnitTests/Sources/AppLock/AppLockSettingsScreenViewModelTests.swift b/UnitTests/Sources/AppLock/AppLockSettingsScreenViewModelTests.swift index 3dfc014f0..ef02fd2e4 100644 --- a/UnitTests/Sources/AppLock/AppLockSettingsScreenViewModelTests.swift +++ b/UnitTests/Sources/AppLock/AppLockSettingsScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class AppLockSetupSettingsScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/AppLock/AppLockSetupBiometricsScreenViewModelTests.swift b/UnitTests/Sources/AppLock/AppLockSetupBiometricsScreenViewModelTests.swift index 196927fac..adc125b2f 100644 --- a/UnitTests/Sources/AppLock/AppLockSetupBiometricsScreenViewModelTests.swift +++ b/UnitTests/Sources/AppLock/AppLockSetupBiometricsScreenViewModelTests.swift @@ -6,16 +6,17 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class AppLockSetupBiometricsScreenViewModelTests: XCTestCase { var appLockService: AppLockServiceMock! var viewModel: AppLockSetupBiometricsScreenViewModelProtocol! - var context: AppLockSetupBiometricsScreenViewModelType.Context { viewModel.context } + var context: AppLockSetupBiometricsScreenViewModelType.Context { + viewModel.context + } override func setUp() { AppSettings.resetAllSettings() diff --git a/UnitTests/Sources/AppLock/AppLockSetupPINScreenViewModelTests.swift b/UnitTests/Sources/AppLock/AppLockSetupPINScreenViewModelTests.swift index ce898ffeb..172318b0a 100644 --- a/UnitTests/Sources/AppLock/AppLockSetupPINScreenViewModelTests.swift +++ b/UnitTests/Sources/AppLock/AppLockSetupPINScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class AppLockSetupPINScreenViewModelTests: XCTestCase { @@ -16,7 +15,9 @@ class AppLockSetupPINScreenViewModelTests: XCTestCase { var keychainController: KeychainControllerMock! var viewModel: AppLockSetupPINScreenViewModelProtocol! - var context: AppLockSetupPINScreenViewModelType.Context { viewModel.context } + var context: AppLockSetupPINScreenViewModelType.Context { + viewModel.context + } override func setUp() { AppSettings.resetAllSettings() diff --git a/UnitTests/Sources/AppLock/AppLockTimerTests.swift b/UnitTests/Sources/AppLock/AppLockTimerTests.swift index 350db1e94..ac2eef209 100644 --- a/UnitTests/Sources/AppLock/AppLockTimerTests.swift +++ b/UnitTests/Sources/AppLock/AppLockTimerTests.swift @@ -6,19 +6,29 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest class AppLockTimerTests: XCTestCase { var timer: AppLockTimer! let now = Date.now - var gracePeriod: TimeInterval { timer.gracePeriod } - var halfGracePeriod: TimeInterval { gracePeriod / 2 } - var gracePeriodX2: TimeInterval { gracePeriod * 2 } - var gracePeriodX10: TimeInterval { gracePeriod * 10 } + var gracePeriod: TimeInterval { + timer.gracePeriod + } + + var halfGracePeriod: TimeInterval { + gracePeriod / 2 + } + + var gracePeriodX2: TimeInterval { + gracePeriod * 2 + } + + var gracePeriodX10: TimeInterval { + gracePeriod * 10 + } override func tearDown() { timer = nil diff --git a/UnitTests/Sources/AppLock/PINTextFieldTests.swift b/UnitTests/Sources/AppLock/PINTextFieldTests.swift index d1701db21..0cd55cee0 100644 --- a/UnitTests/Sources/AppLock/PINTextFieldTests.swift +++ b/UnitTests/Sources/AppLock/PINTextFieldTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest class PINTextFieldTests: XCTestCase { func testSanitize() { diff --git a/UnitTests/Sources/AppRouteURLParserTests.swift b/UnitTests/Sources/AppRouteURLParserTests.swift index fe074b092..0a07c2abf 100644 --- a/UnitTests/Sources/AppRouteURLParserTests.swift +++ b/UnitTests/Sources/AppRouteURLParserTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest class AppRouteURLParserTests: XCTestCase { var appSettings: AppSettings! diff --git a/UnitTests/Sources/ArrayTests.swift b/UnitTests/Sources/ArrayTests.swift index 1a259dad3..561a2b1b1 100644 --- a/UnitTests/Sources/ArrayTests.swift +++ b/UnitTests/Sources/ArrayTests.swift @@ -6,11 +6,9 @@ // Please see LICENSE files in the repository root for full details. // -import Foundation - -import XCTest - @testable import ElementX +import Foundation +import XCTest class ArrayTests: XCTestCase { func testGrouping() { diff --git a/UnitTests/Sources/AttributedStringBuilderTests.swift b/UnitTests/Sources/AttributedStringBuilderTests.swift index 19ba32786..2be40684f 100644 --- a/UnitTests/Sources/AttributedStringBuilderTests.swift +++ b/UnitTests/Sources/AttributedStringBuilderTests.swift @@ -770,7 +770,7 @@ class AttributedStringBuilderTests: XCTestCase { XCTAssertEqual(String(attributedString.characters), " 1. A\n • A1\n • A2\n • A3\n 2. B\n 3. C") } - // https://github.com/element-hq/element-x-ios/issues/4856 + /// https://github.com/element-hq/element-x-ios/issues/4856 func testNormalisedWhitespaces() { let html = """ Stefan pushed diff --git a/UnitTests/Sources/AudioPlayerStateTests.swift b/UnitTests/Sources/AudioPlayerStateTests.swift index f479d70ab..d56b8ecfb 100644 --- a/UnitTests/Sources/AudioPlayerStateTests.swift +++ b/UnitTests/Sources/AudioPlayerStateTests.swift @@ -46,14 +46,14 @@ class AudioPlayerStateTests: XCTestCase { } } - func testAttach() async throws { + func testAttach() { audioPlayerState.attachAudioPlayer(audioPlayerMock) XCTAssert(audioPlayerState.isAttached) XCTAssertEqual(audioPlayerState.playbackState, .loading) } - func testDetach() async throws { + func testDetach() { audioPlayerState.attachAudioPlayer(audioPlayerMock) audioPlayerState.detachAudioPlayer() @@ -103,13 +103,13 @@ class AudioPlayerStateTests: XCTestCase { XCTAssertEqual(audioPlayerState.playerButtonPlaybackState, .playing) } - func testReportError() async throws { + func testReportError() { XCTAssertEqual(audioPlayerState.playbackState, .stopped) audioPlayerState.reportError() XCTAssertEqual(audioPlayerState.playbackState, .error) } - func testUpdateProgress() async throws { + func testUpdateProgress() async { audioPlayerState.attachAudioPlayer(audioPlayerMock) // If we try to set a negative progress, the new progress must be 0.0 diff --git a/UnitTests/Sources/AudioRecorderStateTests.swift b/UnitTests/Sources/AudioRecorderStateTests.swift index a4da7ca92..d4584f69d 100644 --- a/UnitTests/Sources/AudioRecorderStateTests.swift +++ b/UnitTests/Sources/AudioRecorderStateTests.swift @@ -36,12 +36,12 @@ class AudioRecorderStateTests: XCTestCase { audioRecorderMock = buildAudioRecorderMock() } - func testAttach() async throws { + func testAttach() { audioRecorderState.attachAudioRecorder(audioRecorderMock) XCTAssertEqual(audioRecorderState.recordingState, .stopped) } - func testDetach() async throws { + func testDetach() async { audioRecorderState.attachAudioRecorder(audioRecorderMock) audioRecorderMock.isRecording = true await audioRecorderState.detachAudioRecorder() @@ -49,7 +49,7 @@ class AudioRecorderStateTests: XCTestCase { XCTAssertEqual(audioRecorderState.recordingState, .stopped) } - func testReportError() async throws { + func testReportError() { XCTAssertEqual(audioRecorderState.recordingState, .stopped) audioRecorderState.reportError() XCTAssertEqual(audioRecorderState.recordingState, .error) diff --git a/UnitTests/Sources/AuthenticationServiceTests.swift b/UnitTests/Sources/AuthenticationServiceTests.swift index 2e74138d2..ca509cf02 100644 --- a/UnitTests/Sources/AuthenticationServiceTests.swift +++ b/UnitTests/Sources/AuthenticationServiceTests.swift @@ -6,10 +6,9 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX import MatrixRustSDKMocks +import XCTest class AuthenticationServiceTests: XCTestCase { var client: ClientSDKMock! diff --git a/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift b/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift index 2bf98c38a..c65333953 100644 --- a/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift +++ b/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift @@ -6,10 +6,9 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX import MatrixRustSDKMocks +import XCTest @MainActor class AuthenticationStartScreenViewModelTests: XCTestCase { @@ -19,7 +18,9 @@ class AuthenticationStartScreenViewModelTests: XCTestCase { var authenticationService: AuthenticationServiceProtocol! var viewModel: AuthenticationStartScreenViewModel! - var context: AuthenticationStartScreenViewModel.Context { viewModel.context } + var context: AuthenticationStartScreenViewModel.Context { + viewModel.context + } override func setUp() { AppSettings.resetAllSettings() diff --git a/UnitTests/Sources/BlockedUsersScreenViewModelTests.swift b/UnitTests/Sources/BlockedUsersScreenViewModelTests.swift index ce71052d9..fca008160 100644 --- a/UnitTests/Sources/BlockedUsersScreenViewModelTests.swift +++ b/UnitTests/Sources/BlockedUsersScreenViewModelTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class BlockedUsersScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/BugReportScreenViewModelTests.swift b/UnitTests/Sources/BugReportScreenViewModelTests.swift index d86d4e0a8..82c705ffb 100644 --- a/UnitTests/Sources/BugReportScreenViewModelTests.swift +++ b/UnitTests/Sources/BugReportScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class BugReportScreenViewModelTests: XCTestCase { @@ -32,7 +31,7 @@ class BugReportScreenViewModelTests: XCTestCase { XCTAssertTrue(context.sendingLogsEnabled) } - func testClearScreenshot() async throws { + func testClearScreenshot() { let clientProxy = ClientProxyMock(.init(userID: "@mock.client.com")) let viewModel = BugReportScreenViewModel(bugReportService: BugReportServiceMock(), clientProxy: clientProxy, @@ -45,7 +44,7 @@ class BugReportScreenViewModelTests: XCTestCase { XCTAssertNil(context.viewState.screenshot) } - func testAttachScreenshot() async throws { + func testAttachScreenshot() { let clientProxy = ClientProxyMock(.init(userID: "@mock.client.com")) let viewModel = BugReportScreenViewModel(bugReportService: BugReportServiceMock(), clientProxy: clientProxy, diff --git a/UnitTests/Sources/BugReportServiceTests.swift b/UnitTests/Sources/BugReportServiceTests.swift index 59b8b23de..af6be553d 100644 --- a/UnitTests/Sources/BugReportServiceTests.swift +++ b/UnitTests/Sources/BugReportServiceTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -@testable import ElementX - import Combine +@testable import ElementX import Foundation import XCTest @@ -51,7 +50,7 @@ class BugReportServiceTests: XCTestCase { XCTAssertFalse(reportURL.isEmpty) } - func testInitialStateWithRealService() throws { + func testInitialStateWithRealService() { let urlPublisher: CurrentValueSubject = .init(.url("https://example.com/submit")) let service = BugReportService(rageshakeURLPublisher: urlPublisher.asCurrentValuePublisher(), applicationID: "mock_app_id", @@ -63,7 +62,7 @@ class BugReportServiceTests: XCTestCase { XCTAssertFalse(service.crashedLastRun) } - func testInitialStateWithRealServiceAndDisabled() throws { + func testInitialStateWithRealServiceAndDisabled() { let urlPublisher: CurrentValueSubject = .init(.disabled) let service = BugReportService(rageshakeURLPublisher: urlPublisher.asCurrentValuePublisher(), applicationID: "mock_app_id", @@ -198,7 +197,6 @@ private extension URLSession { static var mock: URLSession { let configuration = URLSessionConfiguration.default configuration.protocolClasses = [MockURLProtocol.self] + (configuration.protocolClasses ?? []) - let result = URLSession(configuration: configuration) - return result + return URLSession(configuration: configuration) } } diff --git a/UnitTests/Sources/CallScreenViewModelTests.swift b/UnitTests/Sources/CallScreenViewModelTests.swift index 1616bbc10..107b6494b 100644 --- a/UnitTests/Sources/CallScreenViewModelTests.swift +++ b/UnitTests/Sources/CallScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class CallScreenViewModelTests: XCTestCase { } diff --git a/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift b/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift index bf949cfd4..fcdb5ee2a 100644 --- a/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift +++ b/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift @@ -6,10 +6,9 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - import Combine @testable import ElementX +import XCTest @MainActor class ChatsTabFlowCoordinatorTests: XCTestCase { @@ -22,8 +21,13 @@ class ChatsTabFlowCoordinatorTests: XCTestCase { var cancellables = Set() - var detailCoordinator: CoordinatorProtocol? { splitCoordinator?.detailCoordinator } - var detailNavigationStack: NavigationStackCoordinator? { detailCoordinator as? NavigationStackCoordinator } + var detailCoordinator: CoordinatorProtocol? { + splitCoordinator?.detailCoordinator + } + + var detailNavigationStack: NavigationStackCoordinator? { + detailCoordinator as? NavigationStackCoordinator + } override func setUp() async throws { cancellables.removeAll() diff --git a/UnitTests/Sources/CompletionSuggestionServiceTests.swift b/UnitTests/Sources/CompletionSuggestionServiceTests.swift index f83b371fd..65dd10e63 100644 --- a/UnitTests/Sources/CompletionSuggestionServiceTests.swift +++ b/UnitTests/Sources/CompletionSuggestionServiceTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor final class CompletionSuggestionServiceTests: XCTestCase { diff --git a/UnitTests/Sources/ComposerToolbarViewModelTests.swift b/UnitTests/Sources/ComposerToolbarViewModelTests.swift index d81de03d3..51ffbc541 100644 --- a/UnitTests/Sources/ComposerToolbarViewModelTests.swift +++ b/UnitTests/Sources/ComposerToolbarViewModelTests.swift @@ -9,9 +9,8 @@ import Combine @testable import ElementX import MatrixRustSDK -import XCTest - import WysiwygComposer +import XCTest @MainActor class ComposerToolbarViewModelTests: XCTestCase { @@ -144,13 +143,13 @@ class ComposerToolbarViewModelTests: XCTestCase { XCTAssertEqual(wysiwygViewModel.content.html, "#room-alias:matrix.org ") } - func testAllUsersSuggestion() { + func testAllUsersSuggestion() throws { let suggestion = SuggestionItem(suggestionType: .allUsers(.room(id: "", name: nil, avatarURL: nil)), range: .init(), rawSuggestionText: "") viewModel.context.send(viewAction: .selectedSuggestion(suggestion)) var string = "@room" // swiftlint:disable:next force_unwrapping - string.unicodeScalars.append(UnicodeScalar(String.nbsp)!) + try string.unicodeScalars.append(XCTUnwrap(UnicodeScalar(String.nbsp))) XCTAssertEqual(wysiwygViewModel.content.html, string) } @@ -187,12 +186,10 @@ class ComposerToolbarViewModelTests: XCTestCase { } func testIntentionalMentions() async throws { - wysiwygViewModel.setHtmlContent( - """ -

Hello @room \ - and especially hello to Test

- """ - ) + wysiwygViewModel.setHtmlContent(""" +

Hello @room \ + and especially hello to Test

+ """) let deferred = deferFulfillment(viewModel.actions) { action in switch action { diff --git a/UnitTests/Sources/CreateRoomViewModelTests.swift b/UnitTests/Sources/CreateRoomViewModelTests.swift index 15556e3a6..349cdbc17 100644 --- a/UnitTests/Sources/CreateRoomViewModelTests.swift +++ b/UnitTests/Sources/CreateRoomViewModelTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class CreateRoomScreenViewModelTests: XCTestCase { @@ -306,7 +305,7 @@ class CreateRoomScreenViewModelTests: XCTestCase { XCTAssertEqual(clientProxy.createRoomNameTopicAccessTypeIsSpaceUserIDsAvatarURLAliasLocalPartReceivedArguments?.accessType, .spaceMembers(spaceID: space.id)) } - func testCreateRoomInAnPublicSpaceAvailableTypes() async throws { + func testCreateRoomInAnPublicSpaceAvailableTypes() { let space = SpaceServiceRoom.mock(isSpace: true, joinRule: .public) setup(spacesSelectionMode: .preSelected(space)) diff --git a/UnitTests/Sources/DateTests.swift b/UnitTests/Sources/DateTests.swift index 99eae0d88..4cf55d172 100644 --- a/UnitTests/Sources/DateTests.swift +++ b/UnitTests/Sources/DateTests.swift @@ -16,44 +16,44 @@ class DateTests: XCTestCase { let startOfToday = Calendar.current.startOfDay(for: .now) let startOfYesterday = Calendar.current.startOfDay(for: Calendar.current.date(byAdding: .day, value: -1, to: .now)!) - func testMinimalDateFormatting() { - let today = calendar.date(byAdding: DateComponents(hour: 9, minute: 30), to: startOfToday)! + func testMinimalDateFormatting() throws { + let today = try XCTUnwrap(calendar.date(byAdding: DateComponents(hour: 9, minute: 30), to: startOfToday)) XCTAssertEqual(today.formattedMinimal(), today.formatted(date: .omitted, time: .shortened)) - let yesterday = calendar.date(byAdding: .hour, value: 1, to: startOfYesterday)! + let yesterday = try XCTUnwrap(calendar.date(byAdding: .hour, value: 1, to: startOfYesterday)) XCTAssertEqual(yesterday.formattedMinimal(), yesterday.formatted(Date.RelativeFormatStyle(presentation: .named, capitalizationContext: .beginningOfSentence))) - let nearYesterday = calendar.date(byAdding: DateComponents(hour: -10), to: today)! + let nearYesterday = try XCTUnwrap(calendar.date(byAdding: DateComponents(hour: -10), to: today)) XCTAssertEqual(nearYesterday.formattedMinimal(), yesterday.formatted(Date.RelativeFormatStyle(presentation: .named, capitalizationContext: .beginningOfSentence))) - let threeDaysAgo = calendar.date(byAdding: .day, value: -3, to: startOfToday)! + let threeDaysAgo = try XCTUnwrap(calendar.date(byAdding: .day, value: -3, to: startOfToday)) XCTAssertEqual(threeDaysAgo.formattedMinimal(), threeDaysAgo.formatted(.dateTime.weekday(.wide))) - let sometimeInTheLastYear = calendar.date(byAdding: .month, value: -10, to: startOfToday)! + let sometimeInTheLastYear = try XCTUnwrap(calendar.date(byAdding: .month, value: -10, to: startOfToday)) XCTAssertEqual(sometimeInTheLastYear.formattedMinimal(), sometimeInTheLastYear.formatted(.dateTime.day().month())) - let theMillennium = calendar.date(from: DateComponents(year: 2000, month: 1, day: 1))! + let theMillennium = try XCTUnwrap(calendar.date(from: DateComponents(year: 2000, month: 1, day: 1))) XCTAssertEqual(theMillennium.formattedMinimal(), theMillennium.formatted(.dateTime.year().day().month())) } - func testDateSeparatorFormatting() { - let today = calendar.date(byAdding: DateComponents(hour: 9, minute: 30), to: startOfToday)! + func testDateSeparatorFormatting() throws { + let today = try XCTUnwrap(calendar.date(byAdding: DateComponents(hour: 9, minute: 30), to: startOfToday)) XCTAssertEqual(today.formattedDateSeparator(), "Today") - let yesterday = calendar.date(byAdding: .hour, value: 1, to: startOfYesterday)! + let yesterday = try XCTUnwrap(calendar.date(byAdding: .hour, value: 1, to: startOfYesterday)) XCTAssertEqual(yesterday.formattedDateSeparator(), "Yesterday") - let nearYesterday = calendar.date(byAdding: DateComponents(hour: -10), to: today)! + let nearYesterday = try XCTUnwrap(calendar.date(byAdding: DateComponents(hour: -10), to: today)) XCTAssertEqual(nearYesterday.formattedDateSeparator(), yesterday.formatted(Date.RelativeFormatStyle(presentation: .named, capitalizationContext: .beginningOfSentence))) - let threeDaysAgo = calendar.date(byAdding: .day, value: -3, to: startOfToday)! + let threeDaysAgo = try XCTUnwrap(calendar.date(byAdding: .day, value: -3, to: startOfToday)) XCTAssertEqual(threeDaysAgo.formattedDateSeparator(), threeDaysAgo.formatted(.dateTime.weekday(.wide))) // This test will fail during the first 6 days of the year. - let startOfTheYear = calendar.dateInterval(of: .year, for: startOfToday)!.start + let startOfTheYear = try XCTUnwrap(calendar.dateInterval(of: .year, for: startOfToday)?.start) XCTAssertEqual(startOfTheYear.formattedDateSeparator(), startOfTheYear.formatted(.dateTime.weekday(.wide).day().month(.wide))) - let theMillennium = calendar.date(from: DateComponents(year: 2000, month: 1, day: 1))! + let theMillennium = try XCTUnwrap(calendar.date(from: DateComponents(year: 2000, month: 1, day: 1))) XCTAssertEqual(theMillennium.formattedDateSeparator(), theMillennium.formatted(.dateTime.weekday(.wide).day().month(.wide).year())) } } diff --git a/UnitTests/Sources/DeactivateAccountScreenViewModelTests.swift b/UnitTests/Sources/DeactivateAccountScreenViewModelTests.swift index 00a43f6c1..c3a181b69 100644 --- a/UnitTests/Sources/DeactivateAccountScreenViewModelTests.swift +++ b/UnitTests/Sources/DeactivateAccountScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class DeactivateAccountScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/DeclineAndBlockScreenViewModelTests.swift b/UnitTests/Sources/DeclineAndBlockScreenViewModelTests.swift index 0126da994..3dcddf499 100644 --- a/UnitTests/Sources/DeclineAndBlockScreenViewModelTests.swift +++ b/UnitTests/Sources/DeclineAndBlockScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class DeclineAndBlockScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/DeveloperOptionsScreenViewModelTests.swift b/UnitTests/Sources/DeveloperOptionsScreenViewModelTests.swift index 5757e871b..4c74939f8 100644 --- a/UnitTests/Sources/DeveloperOptionsScreenViewModelTests.swift +++ b/UnitTests/Sources/DeveloperOptionsScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class DeveloperOptionsScreenViewModelTests: XCTestCase { } diff --git a/UnitTests/Sources/EditRoomAddressScreenViewModelTests.swift b/UnitTests/Sources/EditRoomAddressScreenViewModelTests.swift index 3eaaa6c31..de46e35b5 100644 --- a/UnitTests/Sources/EditRoomAddressScreenViewModelTests.swift +++ b/UnitTests/Sources/EditRoomAddressScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class EditRoomAddressScreenViewModelTests: XCTestCase { @@ -66,7 +65,7 @@ class EditRoomAddressScreenViewModelTests: XCTestCase { try await deferred.fulfill() } - func testCorrectMethodsCalledOnSaveWhenNoAliasExists() async throws { + func testCorrectMethodsCalledOnSaveWhenNoAliasExists() async { let clientProxy = ClientProxyMock(.init(userIDServerName: "matrix.org")) clientProxy.isAliasAvailableReturnValue = .success(true) let roomProxy = JoinedRoomProxyMock(.init(name: "Room Name")) @@ -98,7 +97,7 @@ class EditRoomAddressScreenViewModelTests: XCTestCase { XCTAssertFalse(roomProxy.removeRoomAliasFromRoomDirectoryCalled) } - func testCorrectMethodsCalledOnSaveWhenAliasOnSameHomeserverExists() async throws { + func testCorrectMethodsCalledOnSaveWhenAliasOnSameHomeserverExists() async { let clientProxy = ClientProxyMock(.init(userIDServerName: "matrix.org")) clientProxy.isAliasAvailableReturnValue = .success(true) let roomProxy = JoinedRoomProxyMock(.init(name: "Room Name", canonicalAlias: "#old-room-name:matrix.org")) @@ -135,7 +134,7 @@ class EditRoomAddressScreenViewModelTests: XCTestCase { await fulfillment(of: [publishingExpectation, updateAliasExpectation, removeAliasExpectation], timeout: 1.0) } - func testCorrectMethodsCalledOnSaveWhenAliasOnOtherHomeserverExists() async throws { + func testCorrectMethodsCalledOnSaveWhenAliasOnOtherHomeserverExists() async { let clientProxy = ClientProxyMock(.init(userIDServerName: "matrix.org")) clientProxy.isAliasAvailableReturnValue = .success(true) let roomProxy = JoinedRoomProxyMock(.init(name: "Room Name", canonicalAlias: "#old-room-name:element.io")) diff --git a/UnitTests/Sources/ElementCallServiceTests.swift b/UnitTests/Sources/ElementCallServiceTests.swift index 24f42e711..39e902e07 100644 --- a/UnitTests/Sources/ElementCallServiceTests.swift +++ b/UnitTests/Sources/ElementCallServiceTests.swift @@ -6,11 +6,10 @@ // import Clocks +@testable import ElementX import PushKit import XCTest -@testable import ElementX - @MainActor class ElementCallServiceTests: XCTestCase { var callProvider: CXProviderMock! @@ -74,7 +73,7 @@ class ElementCallServiceTests: XCTestCase { await fulfillment(of: [expectation2], timeout: 1) } - func testExpiredRingLifetimeIsIgnored() async { + func testExpiredRingLifetimeIsIgnored() { setupService() XCTAssertFalse(callProvider.reportNewIncomingCallWithUpdateCompletionCalled) diff --git a/UnitTests/Sources/EmojiPickerScreenViewModelTests.swift b/UnitTests/Sources/EmojiPickerScreenViewModelTests.swift index c1b0e21c0..ce53add0e 100644 --- a/UnitTests/Sources/EmojiPickerScreenViewModelTests.swift +++ b/UnitTests/Sources/EmojiPickerScreenViewModelTests.swift @@ -6,16 +6,17 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor final class EmojiPickerScreenViewModelTests: XCTestCase { var timelineProxy: TimelineProxyMock! var viewModel: EmojiPickerScreenViewModel! - var context: EmojiPickerScreenViewModel.Context { viewModel.context } + var context: EmojiPickerScreenViewModel.Context { + viewModel.context + } func testToggleReaction() async throws { setupViewModel() diff --git a/UnitTests/Sources/EmojiProviderTests.swift b/UnitTests/Sources/EmojiProviderTests.swift index 546b50bf9..08e6d4884 100644 --- a/UnitTests/Sources/EmojiProviderTests.swift +++ b/UnitTests/Sources/EmojiProviderTests.swift @@ -6,13 +6,12 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor final class EmojiProviderTests: XCTestCase { - func testWhenEmojisLoadedCategoriesAreLoadedFromLoader() async throws { + func testWhenEmojisLoadedCategoriesAreLoadedFromLoader() async { let item = EmojiItem(label: "test", unicode: "test", keywords: ["1", "2"], shortcodes: ["1", "2"]) let category = EmojiCategory(id: "test", emojis: [item]) @@ -25,7 +24,7 @@ final class EmojiProviderTests: XCTestCase { XCTAssertEqual(emojiLoaderMock.categories, categories) } - func testWhenEmojisLoadedAndSearchStringEmptyAllCategoriesReturned() async throws { + func testWhenEmojisLoadedAndSearchStringEmptyAllCategoriesReturned() async { let item = EmojiItem(label: "test", unicode: "test", keywords: ["1", "2"], shortcodes: ["1", "2"]) let category = EmojiCategory(id: "test", emojis: [item]) @@ -38,7 +37,7 @@ final class EmojiProviderTests: XCTestCase { XCTAssertEqual(emojiLoaderMock.categories, categories) } - func testWhenEmojisLoadedSecondTimeCachedValuesAreUsed() async throws { + func testWhenEmojisLoadedSecondTimeCachedValuesAreUsed() async { let item = EmojiItem(label: "test", unicode: "test", keywords: ["1", "2"], shortcodes: ["1", "2"]) let item2 = EmojiItem(label: "test2", unicode: "test2", keywords: ["3", "4"], shortcodes: ["3", "4"]) let categoriesForFirstLoad = [EmojiCategory(id: "test", @@ -58,7 +57,7 @@ final class EmojiProviderTests: XCTestCase { XCTAssertEqual(categories, categoriesForFirstLoad) } - func testWhenEmojisSearchedCorrectNumberOfCategoriesReturned() async throws { + func testWhenEmojisSearchedCorrectNumberOfCategoriesReturned() async { let searchString = "smile" var categories = [EmojiCategory]() let item0WithSearchString = EmojiItem(label: "emoji0", unicode: "\(searchString)_123", keywords: ["key1", "key1"], shortcodes: ["key1", "key1"]) diff --git a/UnitTests/Sources/ExpiringTaskRunnerTests.swift b/UnitTests/Sources/ExpiringTaskRunnerTests.swift index 2fb1bfd48..8000c2b6b 100644 --- a/UnitTests/Sources/ExpiringTaskRunnerTests.swift +++ b/UnitTests/Sources/ExpiringTaskRunnerTests.swift @@ -6,11 +6,9 @@ // Please see LICENSE files in the repository root for full details. // -import Foundation - -import XCTest - @testable import ElementX +import Foundation +import XCTest class ExpiringTaskRunnerTests: XCTestCase { enum ExpiringTaskTestError: Error { diff --git a/UnitTests/Sources/GeoURITests.swift b/UnitTests/Sources/GeoURITests.swift index 1653e7b1d..24e7b3154 100644 --- a/UnitTests/Sources/GeoURITests.swift +++ b/UnitTests/Sources/GeoURITests.swift @@ -55,7 +55,7 @@ final class GeoURITests: XCTestCase { XCTAssertEqual(uri.string, "geo:53,-8;u=35") } - func testFormattingExponentialNotation() throws { + func testFormattingExponentialNotation() { let uri = GeoURI(latitude: 1e2, longitude: -1e-2, uncertainty: 1e-4) XCTAssertEqual(uri.string, "geo:100,-0.01;u=0.0001") } diff --git a/UnitTests/Sources/GlobalSearchScreenViewModelTests.swift b/UnitTests/Sources/GlobalSearchScreenViewModelTests.swift index aa6652c13..c9871f466 100644 --- a/UnitTests/Sources/GlobalSearchScreenViewModelTests.swift +++ b/UnitTests/Sources/GlobalSearchScreenViewModelTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class GlobalSearchScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/HomeScreenRoomTests.swift b/UnitTests/Sources/HomeScreenRoomTests.swift index 651f6a8d5..80a7459b6 100644 --- a/UnitTests/Sources/HomeScreenRoomTests.swift +++ b/UnitTests/Sources/HomeScreenRoomTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class HomeScreenRoomTests: XCTestCase { diff --git a/UnitTests/Sources/HomeScreenViewModelTests.swift b/UnitTests/Sources/HomeScreenViewModelTests.swift index c598dd2e1..4e3636f0d 100644 --- a/UnitTests/Sources/HomeScreenViewModelTests.swift +++ b/UnitTests/Sources/HomeScreenViewModelTests.swift @@ -7,14 +7,15 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class HomeScreenViewModelTests: XCTestCase { var viewModel: HomeScreenViewModelProtocol! - var context: HomeScreenViewModelType.Context! { viewModel.context } + var context: HomeScreenViewModelType.Context! { + viewModel.context + } var clientProxy: ClientProxyMock! var roomSummaryProvider: RoomSummaryProviderMock! @@ -35,7 +36,7 @@ class HomeScreenViewModelTests: XCTestCase { AppSettings.resetAllSettings() } - func testSelectRoom() async throws { + func testSelectRoom() async { setupViewModel() let mockRoomID = "mock_room_id" @@ -60,7 +61,7 @@ class HomeScreenViewModelTests: XCTestCase { XCTAssertEqual(mockRoomID, selectedRoomID) } - func testTapUserAvatar() async throws { + func testTapUserAvatar() async { setupViewModel() var correctResult = false @@ -119,7 +120,7 @@ class HomeScreenViewModelTests: XCTestCase { XCTAssertNotNil(context.alertInfo) } - func testLeaveRoomSuccess() async throws { + func testLeaveRoomSuccess() async { setupViewModel() let mockRoomID = "1" @@ -147,7 +148,7 @@ class HomeScreenViewModelTests: XCTestCase { XCTAssertTrue(correctResult) } - func testShowRoomDetails() async throws { + func testShowRoomDetails() async { setupViewModel() let mockRoomID = "1" diff --git a/UnitTests/Sources/InviteUsersViewModelTests.swift b/UnitTests/Sources/InviteUsersViewModelTests.swift index 656653db5..1551fe511 100644 --- a/UnitTests/Sources/InviteUsersViewModelTests.swift +++ b/UnitTests/Sources/InviteUsersViewModelTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class InviteUsersScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/JoinRoomScreenViewModelTests.swift b/UnitTests/Sources/JoinRoomScreenViewModelTests.swift index 39de9c936..c245fdbbc 100644 --- a/UnitTests/Sources/JoinRoomScreenViewModelTests.swift +++ b/UnitTests/Sources/JoinRoomScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class JoinRoomScreenViewModelTests: XCTestCase { @@ -203,7 +202,7 @@ class JoinRoomScreenViewModelTests: XCTestCase { } extension JoinRoomScreenViewModelAction: @retroactive Equatable { - // A close enough approximation for tests. + /// A close enough approximation for tests. public static func == (lhs: JoinRoomScreenViewModelAction, rhs: JoinRoomScreenViewModelAction) -> Bool { switch (lhs, rhs) { case (.joined(.roomID(let lhsRoomID)), .joined(.roomID(let rhsRoomID))): diff --git a/UnitTests/Sources/KnockRequestsListScreenViewModelTests.swift b/UnitTests/Sources/KnockRequestsListScreenViewModelTests.swift index 480b9793d..29eaa7099 100644 --- a/UnitTests/Sources/KnockRequestsListScreenViewModelTests.swift +++ b/UnitTests/Sources/KnockRequestsListScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class KnockRequestsListScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/LegalInformationScreenViewModelTests.swift b/UnitTests/Sources/LegalInformationScreenViewModelTests.swift index 1a8aa46b0..a6cff4ebe 100644 --- a/UnitTests/Sources/LegalInformationScreenViewModelTests.swift +++ b/UnitTests/Sources/LegalInformationScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class LegalInformationScreenViewModelTests: XCTestCase { } diff --git a/UnitTests/Sources/LoggingTests.swift b/UnitTests/Sources/LoggingTests.swift index 5a95fb7a4..e7281744c 100644 --- a/UnitTests/Sources/LoggingTests.swift +++ b/UnitTests/Sources/LoggingTests.swift @@ -53,7 +53,7 @@ class LoggingTests: XCTestCase { /// This is meant to test the `Target.tests.configure(…)`, but at this stage the test is somewhat pointless /// as it is unlikely to have been called before `tearDown` has manually set the file prefix 😕. - func testTargetName() throws { + func testTargetName() { MXLog.info(UUID().uuidString) guard let logFile = Tracing.logFiles.first else { XCTFail(Constants.genericFailure) @@ -110,7 +110,7 @@ class LoggingTests: XCTestCase { XCTAssertFalse(content.contains(heroName)) } - func testTimelineContentIsRedacted() async throws { + func testTimelineContentIsRedacted() throws { try setupTest() // Given timeline items that contain text @@ -274,7 +274,7 @@ class LoggingTests: XCTestCase { XCTAssertFalse(content.contains(rustFileMessage.filename)) } - func testLogFileSorting() async throws { + func testLogFileSorting() throws { try setupTest(redirectTracingFileWriter: false) // Given a collection of log files. diff --git a/UnitTests/Sources/LoginScreenViewModelTests.swift b/UnitTests/Sources/LoginScreenViewModelTests.swift index ebb3c1f9a..22adcc817 100644 --- a/UnitTests/Sources/LoginScreenViewModelTests.swift +++ b/UnitTests/Sources/LoginScreenViewModelTests.swift @@ -6,14 +6,15 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class LoginScreenViewModelTests: XCTestCase { var viewModel: LoginScreenViewModelProtocol! - var context: LoginScreenViewModelType.Context { viewModel.context } + var context: LoginScreenViewModelType.Context { + viewModel.context + } var clientFactory: AuthenticationClientFactoryMock! var service: AuthenticationServiceProtocol! @@ -159,7 +160,7 @@ class LoginScreenViewModelTests: XCTestCase { XCTAssertEqual(context.alertInfo?.id, .elementProAlert, "An alert should be shown to the user.") } - func testLoginHint() async throws { + func testLoginHint() async { await setupViewModel(loginHint: "") XCTAssertEqual(context.username, "") diff --git a/UnitTests/Sources/ManageRoomMemberSheetViewModelTests.swift b/UnitTests/Sources/ManageRoomMemberSheetViewModelTests.swift index fd310a0af..750863753 100644 --- a/UnitTests/Sources/ManageRoomMemberSheetViewModelTests.swift +++ b/UnitTests/Sources/ManageRoomMemberSheetViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class ManageRoomMemberSheetViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/MatrixEntityRegexTests.swift b/UnitTests/Sources/MatrixEntityRegexTests.swift index 710b700a9..46ffa6ea4 100644 --- a/UnitTests/Sources/MatrixEntityRegexTests.swift +++ b/UnitTests/Sources/MatrixEntityRegexTests.swift @@ -6,11 +6,9 @@ // Please see LICENSE files in the repository root for full details. // -import Foundation - -import XCTest - @testable import ElementX +import Foundation +import XCTest class MatrixEntityRegexTests: XCTestCase { func testHomeserver() { diff --git a/UnitTests/Sources/MediaPlayerProviderTests.swift b/UnitTests/Sources/MediaPlayerProviderTests.swift index 01e12c3d9..00386c5e1 100644 --- a/UnitTests/Sources/MediaPlayerProviderTests.swift +++ b/UnitTests/Sources/MediaPlayerProviderTests.swift @@ -23,7 +23,7 @@ class MediaPlayerProviderTests: XCTestCase { mediaPlayerProvider = MediaPlayerProvider() } - func testPlayerStates() async throws { + func testPlayerStates() { let audioPlayerStateId = AudioPlayerStateIdentifier.timelineItemIdentifier(.randomEvent) // By default, there should be no player state XCTAssertNil(mediaPlayerProvider.playerState(for: audioPlayerStateId)) @@ -36,7 +36,7 @@ class MediaPlayerProviderTests: XCTestCase { XCTAssertNil(mediaPlayerProvider.playerState(for: audioPlayerStateId)) } - func testDetachAllStates() async throws { + func testDetachAllStates() { let audioPlayer = AudioPlayerMock() audioPlayer.actions = PassthroughSubject().eraseToAnyPublisher() @@ -55,7 +55,7 @@ class MediaPlayerProviderTests: XCTestCase { } } - func testDetachAllStatesWithException() async throws { + func testDetachAllStatesWithException() { let audioPlayer = AudioPlayerMock() audioPlayer.actions = PassthroughSubject().eraseToAnyPublisher() diff --git a/UnitTests/Sources/MediaProvider/MediaProviderTests.swift b/UnitTests/Sources/MediaProvider/MediaProviderTests.swift index a502e24df..950e12b9f 100644 --- a/UnitTests/Sources/MediaProvider/MediaProviderTests.swift +++ b/UnitTests/Sources/MediaProvider/MediaProviderTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -@testable import ElementX - import Combine +@testable import ElementX import Kingfisher import XCTest @@ -68,7 +67,7 @@ final class MediaProviderTests: XCTestCase { XCTAssertNil(result) } - func test_whenImageFromSourceWithSourceNil_nilReturned() throws { + func test_whenImageFromSourceWithSourceNil_nilReturned() { let image = mediaProvider.imageFromSource(nil, size: Avatars.Size.room(on: .timeline).scaledSize) XCTAssertNil(image) } diff --git a/UnitTests/Sources/MediaUploadPreviewScreenViewModelTests.swift b/UnitTests/Sources/MediaUploadPreviewScreenViewModelTests.swift index 54aed5571..3ce960551 100644 --- a/UnitTests/Sources/MediaUploadPreviewScreenViewModelTests.swift +++ b/UnitTests/Sources/MediaUploadPreviewScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class MediaUploadPreviewScreenViewModelTests: XCTestCase { @@ -17,7 +16,9 @@ class MediaUploadPreviewScreenViewModelTests: XCTestCase { var userIndicatorController: UserIndicatorControllerMock! var viewModel: MediaUploadPreviewScreenViewModel! - var context: MediaUploadPreviewScreenViewModel.Context { viewModel.context } + var context: MediaUploadPreviewScreenViewModel.Context { + viewModel.context + } enum TestError: Swift.Error { case unexpectedParameter @@ -223,10 +224,22 @@ class MediaUploadPreviewScreenViewModelTests: XCTestCase { // MARK: - Helpers - private var audioURL: URL { assertResourceURL(filename: "test_audio.mp3") } - private var fileURL: URL { assertResourceURL(filename: "test_pdf.pdf") } - private var imageURL: URL { assertResourceURL(filename: "test_animated_image.gif") } - private var videoURL: URL { assertResourceURL(filename: "landscape_test_video.mov") } + private var audioURL: URL { + assertResourceURL(filename: "test_audio.mp3") + } + + private var fileURL: URL { + assertResourceURL(filename: "test_pdf.pdf") + } + + private var imageURL: URL { + assertResourceURL(filename: "test_animated_image.gif") + } + + private var videoURL: URL { + assertResourceURL(filename: "landscape_test_video.mov") + } + private var badImageURL = URL(filePath: "/home/user/this_file_doesn't_exist.jpg") private func assertResourceURL(filename: String) -> URL { diff --git a/UnitTests/Sources/MediaUploadingPreprocessorTests.swift b/UnitTests/Sources/MediaUploadingPreprocessorTests.swift index 1cd18e7b4..caad50cb0 100644 --- a/UnitTests/Sources/MediaUploadingPreprocessorTests.swift +++ b/UnitTests/Sources/MediaUploadingPreprocessorTests.swift @@ -6,11 +6,10 @@ // Please see LICENSE files in the repository root for full details. // +@testable import ElementX import UniformTypeIdentifiers import XCTest -@testable import ElementX - final class MediaUploadingPreprocessorTests: XCTestCase { let maxUploadSize: UInt = 100 * 1024 * 1024 var appSettings: AppSettings! diff --git a/UnitTests/Sources/MessageForwardingScreenViewModelTests.swift b/UnitTests/Sources/MessageForwardingScreenViewModelTests.swift index 9959af3b9..5a01cb130 100644 --- a/UnitTests/Sources/MessageForwardingScreenViewModelTests.swift +++ b/UnitTests/Sources/MessageForwardingScreenViewModelTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class MessageForwardingScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/NavigationRootCoordinatorTests.swift b/UnitTests/Sources/NavigationRootCoordinatorTests.swift index ab83b372f..1e7c50e3f 100644 --- a/UnitTests/Sources/NavigationRootCoordinatorTests.swift +++ b/UnitTests/Sources/NavigationRootCoordinatorTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class NavigationRootCoordinatorTests: XCTestCase { diff --git a/UnitTests/Sources/NavigationSplitCoordinatorTests.swift b/UnitTests/Sources/NavigationSplitCoordinatorTests.swift index 43c15b14a..70334adf5 100644 --- a/UnitTests/Sources/NavigationSplitCoordinatorTests.swift +++ b/UnitTests/Sources/NavigationSplitCoordinatorTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class NavigationSplitCoordinatorTests: XCTestCase { diff --git a/UnitTests/Sources/NavigationStackCoordinatorTests.swift b/UnitTests/Sources/NavigationStackCoordinatorTests.swift index 194c2fba8..505df3926 100644 --- a/UnitTests/Sources/NavigationStackCoordinatorTests.swift +++ b/UnitTests/Sources/NavigationStackCoordinatorTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class NavigationStackCoordinatorTests: XCTestCase { diff --git a/UnitTests/Sources/NavigationTabCoordinatorTests.swift b/UnitTests/Sources/NavigationTabCoordinatorTests.swift index 4dc3416ca..9b947fd2a 100644 --- a/UnitTests/Sources/NavigationTabCoordinatorTests.swift +++ b/UnitTests/Sources/NavigationTabCoordinatorTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class NavigationTabCoordinatorTests: XCTestCase { diff --git a/UnitTests/Sources/NotificationContentBuilderTests.swift b/UnitTests/Sources/NotificationContentBuilderTests.swift index a8430b507..7bac15a53 100644 --- a/UnitTests/Sources/NotificationContentBuilderTests.swift +++ b/UnitTests/Sources/NotificationContentBuilderTests.swift @@ -6,11 +6,10 @@ // import Dynamic +@testable import ElementX import MatrixRustSDK import XCTest -@testable import ElementX - final class NotificationContentBuilderTests: XCTestCase { var notificationContentBuilder: NotificationContentBuilder! var mediaProvider: MediaProviderMock! diff --git a/UnitTests/Sources/NotificationManager/MockCoder.swift b/UnitTests/Sources/NotificationManager/MockCoder.swift index c6a993732..c75855be9 100644 --- a/UnitTests/Sources/NotificationManager/MockCoder.swift +++ b/UnitTests/Sources/NotificationManager/MockCoder.swift @@ -13,6 +13,11 @@ final class MockCoder: NSKeyedArchiver { finishEncoding() } - override func decodeObject(forKey _: String) -> Any { "" } - override func decodeInt64(forKey key: String) -> Int64 { 0 } + override func decodeObject(forKey _: String) -> Any { + "" + } + + override func decodeInt64(forKey key: String) -> Int64 { + 0 + } } diff --git a/UnitTests/Sources/NotificationManager/NotificationManagerTests.swift b/UnitTests/Sources/NotificationManager/NotificationManagerTests.swift index e37bdb6e0..b1021404f 100644 --- a/UnitTests/Sources/NotificationManager/NotificationManagerTests.swift +++ b/UnitTests/Sources/NotificationManager/NotificationManagerTests.swift @@ -7,11 +7,10 @@ // import Combine +@testable import ElementX import NotificationCenter import XCTest -@testable import ElementX - @MainActor final class NotificationManagerTests: XCTestCase { var notificationManager: NotificationManager! @@ -24,7 +23,9 @@ final class NotificationManagerTests: XCTestCase { private var notificationTappedDelegateCalled = false private var registerForRemoteNotificationsDelegateCalled: (() -> Void)? - private var appSettings: AppSettings { ServiceLocator.shared.settings } + private var appSettings: AppSettings { + ServiceLocator.shared.settings + } override func setUp() { AppSettings.resetAllSettings() @@ -49,12 +50,12 @@ final class NotificationManagerTests: XCTestCase { XCTAssertTrue(clientProxy.setPusherWithCalled) } - func test_whenRegisteredSuccess_completionSuccessIsCalled() async throws { + func test_whenRegisteredSuccess_completionSuccessIsCalled() async { let success = await notificationManager.register(with: Data()) XCTAssertTrue(success) } - func test_whenRegisteredAndPusherThrowsError_completionFalseIsCalled() async throws { + func test_whenRegisteredAndPusherThrowsError_completionFalseIsCalled() async { enum TestError: Error { case someError } @@ -92,13 +93,13 @@ final class NotificationManagerTests: XCTestCase { XCTAssertEqual(data.defaultPayload, try defaultPayload.toJsonString()) } - func test_whenRegisteredAndPusherTagNotSetInSettings_tagGeneratedAndSavedInSettings() async throws { + func test_whenRegisteredAndPusherTagNotSetInSettings_tagGeneratedAndSavedInSettings() async { appSettings.pusherProfileTag = nil _ = await notificationManager.register(with: Data()) XCTAssertNotNil(appSettings.pusherProfileTag) } - func test_whenRegisteredAndPusherTagIsSetInSettings_tagNotGenerated() async throws { + func test_whenRegisteredAndPusherTagIsSetInSettings_tagNotGenerated() async { appSettings.pusherProfileTag = "12345" _ = await notificationManager.register(with: Data()) XCTAssertEqual(appSettings.pusherProfileTag, "12345") @@ -111,7 +112,7 @@ final class NotificationManagerTests: XCTestCase { XCTAssertEqual(request.content.subtitle, "Subtitle") } - func test_whenStart_notificationCategoriesAreSet() throws { + func test_whenStart_notificationCategoriesAreSet() { let replyAction = UNTextInputNotificationAction(identifier: NotificationConstants.Action.inlineReply, title: L10n.actionQuickReply, options: []) @@ -132,7 +133,7 @@ final class NotificationManagerTests: XCTestCase { XCTAssertTrue(delegate.isEqual(notificationManager)) } - func test_whenStart_requestAuthorizationCalledWithCorrectParams() async throws { + func test_whenStart_requestAuthorizationCalledWithCorrectParams() async { let expectation = expectation(description: "requestAuthorization should be called") notificationCenter.requestAuthorizationOptionsClosure = { _ in expectation.fulfill() @@ -143,7 +144,7 @@ final class NotificationManagerTests: XCTestCase { XCTAssertEqual(notificationCenter.requestAuthorizationOptionsReceivedOptions, [.alert, .sound, .badge]) } - func test_whenStartAndAuthorizationGranted_delegateCalled() async throws { + func test_whenStartAndAuthorizationGranted_delegateCalled() async { authorizationStatusWasGranted = false notificationManager.delegate = self let expectation: XCTestExpectation = expectation(description: "registerForRemoteNotifications delegate function should be called") @@ -167,7 +168,7 @@ final class NotificationManagerTests: XCTestCase { XCTAssertFalse(authorizationStatusWasGranted) } - func test_whenStartAndAuthorized_registerForRemoteNotificationsCalled() async throws { + func test_whenStartAndAuthorized_registerForRemoteNotificationsCalled() async { appSettings.enableNotifications = true notificationCenter.authorizationStatusReturnValue = .authorized notificationManager.delegate = self diff --git a/UnitTests/Sources/NotificationSettingsEditScreenViewModelTests.swift b/UnitTests/Sources/NotificationSettingsEditScreenViewModelTests.swift index d7e61738b..07662bb2f 100644 --- a/UnitTests/Sources/NotificationSettingsEditScreenViewModelTests.swift +++ b/UnitTests/Sources/NotificationSettingsEditScreenViewModelTests.swift @@ -6,11 +6,10 @@ // Please see LICENSE files in the repository root for full details. // +@testable import ElementX import MatrixRustSDK import XCTest -@testable import ElementX - @MainActor class NotificationSettingsEditScreenViewModelTests: XCTestCase { private var viewModel: NotificationSettingsEditScreenViewModelProtocol! diff --git a/UnitTests/Sources/NotificationSettingsScreenViewModelTests.swift b/UnitTests/Sources/NotificationSettingsScreenViewModelTests.swift index 9ade62ebb..310c3d40d 100644 --- a/UnitTests/Sources/NotificationSettingsScreenViewModelTests.swift +++ b/UnitTests/Sources/NotificationSettingsScreenViewModelTests.swift @@ -6,11 +6,10 @@ // Please see LICENSE files in the repository root for full details. // +@testable import ElementX import MatrixRustSDK import XCTest -@testable import ElementX - @MainActor class NotificationSettingsScreenViewModelTests: XCTestCase { private var viewModel: NotificationSettingsScreenViewModelProtocol! diff --git a/UnitTests/Sources/PillContextTests.swift b/UnitTests/Sources/PillContextTests.swift index 13630270b..f9612424a 100644 --- a/UnitTests/Sources/PillContextTests.swift +++ b/UnitTests/Sources/PillContextTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class PillContextTests: XCTestCase { @@ -228,7 +227,7 @@ class PillContextTests: XCTestCase { XCTAssertEqual(context.viewState.displayText, "💬 > 1") } - func testEventOnRoomAliasMention() async throws { + func testEventOnRoomAliasMention() { let proxyMock = JoinedRoomProxyMock(.init()) let mockController = MockTimelineController() mockController.roomProxy = proxyMock @@ -254,7 +253,7 @@ class PillContextTests: XCTestCase { XCTAssertEqual(context.viewState.displayText, "💬 > #Foundation and Empire") } - func testEventOnRoomAliasMentionMissingRoom() async throws { + func testEventOnRoomAliasMentionMissingRoom() { let proxyMock = JoinedRoomProxyMock(.init()) let mockController = MockTimelineController() mockController.roomProxy = proxyMock diff --git a/UnitTests/Sources/PinnedEventsBannerStateTests.swift b/UnitTests/Sources/PinnedEventsBannerStateTests.swift index 1f13cc82b..9f931fca2 100644 --- a/UnitTests/Sources/PinnedEventsBannerStateTests.swift +++ b/UnitTests/Sources/PinnedEventsBannerStateTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest class PinnedEventsBannerStateTests: XCTestCase { func testEmpty() { diff --git a/UnitTests/Sources/PollFormScreenViewModelTests.swift b/UnitTests/Sources/PollFormScreenViewModelTests.swift index 497498730..63f27ec3c 100644 --- a/UnitTests/Sources/PollFormScreenViewModelTests.swift +++ b/UnitTests/Sources/PollFormScreenViewModelTests.swift @@ -6,16 +6,17 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class PollFormScreenViewModelTests: XCTestCase { let timelineProxy = TimelineProxyMock(.init()) var viewModel: PollFormScreenViewModelProtocol! - var context: PollFormScreenViewModelType.Context { viewModel.context } + var context: PollFormScreenViewModelType.Context { + viewModel.context + } func testNewPollInitialState() async throws { setupViewModel() diff --git a/UnitTests/Sources/QRCodeLoginScreenViewModelTests.swift b/UnitTests/Sources/QRCodeLoginScreenViewModelTests.swift index 70dff92cb..de188df50 100644 --- a/UnitTests/Sources/QRCodeLoginScreenViewModelTests.swift +++ b/UnitTests/Sources/QRCodeLoginScreenViewModelTests.swift @@ -7,10 +7,9 @@ // import Combine -import XCTest - @testable import ElementX import MatrixRustSDKMocks +import XCTest @MainActor final class QRCodeLoginScreenViewModelTests: XCTestCase { @@ -24,7 +23,9 @@ final class QRCodeLoginScreenViewModelTests: XCTestCase { private var appMediator: AppMediatorMock! private var viewModel: QRCodeLoginScreenViewModelProtocol! - private var context: QRCodeLoginScreenViewModelType.Context { viewModel.context } + private var context: QRCodeLoginScreenViewModelType.Context { + viewModel.context + } func testLoginInitialState() { setupViewModel(mode: .login) diff --git a/UnitTests/Sources/RemotePreferenceTests.swift b/UnitTests/Sources/RemotePreferenceTests.swift index 2674d8464..16d00f9b0 100644 --- a/UnitTests/Sources/RemotePreferenceTests.swift +++ b/UnitTests/Sources/RemotePreferenceTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest class RemotePreferenceTests: XCTestCase { func testOverrideAndReset() { diff --git a/UnitTests/Sources/ReportRoomScreenViewModelTests.swift b/UnitTests/Sources/ReportRoomScreenViewModelTests.swift index 633723a5f..4212bf051 100644 --- a/UnitTests/Sources/ReportRoomScreenViewModelTests.swift +++ b/UnitTests/Sources/ReportRoomScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class ReportRoomScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/ResolveVerifiedUserSendFailureScreenViewModelTests.swift b/UnitTests/Sources/ResolveVerifiedUserSendFailureScreenViewModelTests.swift index d483d3b46..2a2bd8853 100644 --- a/UnitTests/Sources/ResolveVerifiedUserSendFailureScreenViewModelTests.swift +++ b/UnitTests/Sources/ResolveVerifiedUserSendFailureScreenViewModelTests.swift @@ -6,15 +6,16 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class ResolveVerifiedUserSendFailureScreenViewModelTests: XCTestCase { let roomProxy = JoinedRoomProxyMock(.init()) var viewModel: ResolveVerifiedUserSendFailureScreenViewModel! - var context: ResolveVerifiedUserSendFailureScreenViewModel.Context { viewModel.context } + var context: ResolveVerifiedUserSendFailureScreenViewModel.Context { + viewModel.context + } func testUnsignedDevice() async throws { // Given a failure where a single user has an unverified device diff --git a/UnitTests/Sources/RestorationTokenTests.swift b/UnitTests/Sources/RestorationTokenTests.swift index 03b082fed..cd21797aa 100644 --- a/UnitTests/Sources/RestorationTokenTests.swift +++ b/UnitTests/Sources/RestorationTokenTests.swift @@ -6,10 +6,9 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX import MatrixRustSDK +import XCTest class RestorationTokenTests: XCTestCase { func testDecodeTokenWithSlidingSyncProxy() throws { diff --git a/UnitTests/Sources/RoomChangePermissionsScreenViewModelTests.swift b/UnitTests/Sources/RoomChangePermissionsScreenViewModelTests.swift index b5a9b3a4b..c40d45f6b 100644 --- a/UnitTests/Sources/RoomChangePermissionsScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomChangePermissionsScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class RoomChangePermissionsScreenViewModelTests: XCTestCase { @@ -92,7 +91,7 @@ class RoomChangePermissionsScreenViewModelTests: XCTestCase { "Only the avatar setting should be applied. No other settings were changed so they should be nil to remain left alone.") } - func testSaveNoChanges() async throws { + func testSaveNoChanges() { setUp(isSpace: false) // Given a screen with no changes. XCTAssertFalse(context.viewState.hasChanges) @@ -104,7 +103,7 @@ class RoomChangePermissionsScreenViewModelTests: XCTestCase { XCTAssertFalse(roomProxy.applyPowerLevelChangesCalled) } - func testDefaultStateRoom() async throws { + func testDefaultStateRoom() { setUp(isSpace: false) XCTAssertNotNil(context.settings[.roomDetails]) XCTAssertNotNil(context.settings[.memberModeration]) @@ -112,7 +111,7 @@ class RoomChangePermissionsScreenViewModelTests: XCTestCase { XCTAssertNil(context.settings[.manageSpace]) } - func testDefaultStateSpace() async throws { + func testDefaultStateSpace() { setUp(isSpace: true) XCTAssertNotNil(context.settings[.roomDetails]) XCTAssertNotNil(context.settings[.memberModeration]) diff --git a/UnitTests/Sources/RoomChangeRolesScreenViewModelTests.swift b/UnitTests/Sources/RoomChangeRolesScreenViewModelTests.swift index 7e4d5a4d1..3de3f9e5d 100644 --- a/UnitTests/Sources/RoomChangeRolesScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomChangeRolesScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class RoomChangeRolesScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift b/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift index bed52fa8f..138a6ed27 100644 --- a/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift @@ -6,11 +6,10 @@ // Please see LICENSE files in the repository root for full details. // +@testable import ElementX import MatrixRustSDK import XCTest -@testable import ElementX - @MainActor class RoomDetailsEditScreenViewModelTests: XCTestCase { var viewModel: RoomDetailsEditScreenViewModel! @@ -134,7 +133,7 @@ class RoomDetailsEditScreenViewModelTests: XCTestCase { try await deferred.fulfill() } - func testErrorShownOnFailedFetchOfMedia() async throws { + func testErrorShownOnFailedFetchOfMedia() async { setupViewModel(roomProxyConfiguration: .init(name: "Some room", members: [.mockMeAdmin])) viewModel.didSelectMediaUrl(url: .picturesDirectory) try? await Task.sleep(for: .milliseconds(100)) diff --git a/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift b/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift index d704727f9..790cdfccb 100644 --- a/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift @@ -8,18 +8,20 @@ import AsyncAlgorithms import Combine +@testable import ElementX import MatrixRustSDK import SwiftUI import XCTest -@testable import ElementX - @MainActor class RoomDetailsScreenViewModelTests: XCTestCase { var viewModel: RoomDetailsScreenViewModel! var roomProxyMock: JoinedRoomProxyMock! var notificationSettingsProxyMock: NotificationSettingsProxyMock! - var context: RoomDetailsScreenViewModelType.Context { viewModel.context } + var context: RoomDetailsScreenViewModelType.Context { + viewModel.context + } + var cancellables = Set() override func setUp() { @@ -75,7 +77,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { XCTAssertEqual(context.viewState.bindings.leaveRoomAlertItem?.subtitle, L10n.leaveRoomAlertPrivateSubtitle) } - func testLeaveRoomTappedWithLessThanTwoMembers() async { + func testLeaveRoomTappedWithLessThanTwoMembers() { let mockedMembers: [RoomMemberProxyMock] = [.mockAlice] roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, diff --git a/UnitTests/Sources/RoomDirectorySearchScreenScreenViewModelTests.swift b/UnitTests/Sources/RoomDirectorySearchScreenScreenViewModelTests.swift index 371128ae5..c9783c6fd 100644 --- a/UnitTests/Sources/RoomDirectorySearchScreenScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomDirectorySearchScreenScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class RoomDirectorySearchScreenScreenViewModelTests: XCTestCase { } diff --git a/UnitTests/Sources/RoomFlowCoordinatorTests.swift b/UnitTests/Sources/RoomFlowCoordinatorTests.swift index a6ee20cb3..341dcf991 100644 --- a/UnitTests/Sources/RoomFlowCoordinatorTests.swift +++ b/UnitTests/Sources/RoomFlowCoordinatorTests.swift @@ -6,11 +6,10 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - import Combine @testable import ElementX import MatrixRustSDKMocks +import XCTest @MainActor class RoomFlowCoordinatorTests: XCTestCase { diff --git a/UnitTests/Sources/RoomListFiltersStateTests.swift b/UnitTests/Sources/RoomListFiltersStateTests.swift index 3eaa58362..bea823626 100644 --- a/UnitTests/Sources/RoomListFiltersStateTests.swift +++ b/UnitTests/Sources/RoomListFiltersStateTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest final class RoomListFiltersStateTests: XCTestCase { var appSettings: AppSettings! @@ -108,7 +107,7 @@ final class RoomListFiltersStateTests: XCTestCase { // MARK: Low Priority feature flag - // Don't forget to add .lowPriority into the mix above when enabling the feature. + /// Don't forget to add .lowPriority into the mix above when enabling the feature. func testWithLowPriorityFeature() { enableLowPriorityFeature() XCTAssertFalse(state.isFiltering) diff --git a/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift b/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift index 33e74e985..b473aeaa8 100644 --- a/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift +++ b/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift @@ -6,16 +6,17 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class RoomMemberDetailsViewModelTests: XCTestCase { var viewModel: RoomMemberDetailsScreenViewModelProtocol! var roomProxyMock: JoinedRoomProxyMock! var roomMemberProxyMock: RoomMemberProxyMock! - var context: RoomMemberDetailsScreenViewModelType.Context { viewModel.context } + var context: RoomMemberDetailsScreenViewModelType.Context { + viewModel.context + } override func setUp() async throws { roomProxyMock = JoinedRoomProxyMock(.init(name: "")) diff --git a/UnitTests/Sources/RoomMembersFlowCoordinatorTests.swift b/UnitTests/Sources/RoomMembersFlowCoordinatorTests.swift index 0888e50c9..2899a40d3 100644 --- a/UnitTests/Sources/RoomMembersFlowCoordinatorTests.swift +++ b/UnitTests/Sources/RoomMembersFlowCoordinatorTests.swift @@ -5,10 +5,9 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - import Combine @testable import ElementX +import XCTest @MainActor class RoomMembersFlowCoordinatorTests: XCTestCase { diff --git a/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift b/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift index 103667eed..ff7b22909 100644 --- a/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class RoomMembersListScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/RoomNotificationSettingsScreenViewModelTests.swift b/UnitTests/Sources/RoomNotificationSettingsScreenViewModelTests.swift index a866a4a50..799944b5d 100644 --- a/UnitTests/Sources/RoomNotificationSettingsScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomNotificationSettingsScreenViewModelTests.swift @@ -7,11 +7,10 @@ // import Combine +@testable import ElementX import MatrixRustSDK import XCTest -@testable import ElementX - @MainActor class RoomNotificationSettingsScreenViewModelTests: XCTestCase { var roomProxyMock: JoinedRoomProxyMock! diff --git a/UnitTests/Sources/RoomPermissionsTests.swift b/UnitTests/Sources/RoomPermissionsTests.swift index b33816f09..b08f694ce 100644 --- a/UnitTests/Sources/RoomPermissionsTests.swift +++ b/UnitTests/Sources/RoomPermissionsTests.swift @@ -6,11 +6,10 @@ // Please see LICENSE files in the repository root for full details. // +@testable import ElementX import MatrixRustSDK import XCTest -@testable import ElementX - class RoomPermissionsTests: XCTestCase { func testFromRust() { // Given a set of power level changes with various values. diff --git a/UnitTests/Sources/RoomPollsHistoryScreenViewModelTests.swift b/UnitTests/Sources/RoomPollsHistoryScreenViewModelTests.swift index 3f253c7e1..703d3c339 100644 --- a/UnitTests/Sources/RoomPollsHistoryScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomPollsHistoryScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class RoomPollsHistoryScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/RoomRolesAndPermissionsScreenViewModelTests.swift b/UnitTests/Sources/RoomRolesAndPermissionsScreenViewModelTests.swift index 1b5c34bfc..ede24920b 100644 --- a/UnitTests/Sources/RoomRolesAndPermissionsScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomRolesAndPermissionsScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class RoomRolesAndPermissionsScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/RoomScreenViewModelTests.swift b/UnitTests/Sources/RoomScreenViewModelTests.swift index b798b4041..b79bc6993 100644 --- a/UnitTests/Sources/RoomScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomScreenViewModelTests.swift @@ -6,11 +6,10 @@ // Please see LICENSE files in the repository root for full details. // +import Combine @testable import ElementX import MatrixRustSDK import MatrixRustSDKMocks - -import Combine import XCTest @MainActor diff --git a/UnitTests/Sources/RoomSummaryProviderTests.swift b/UnitTests/Sources/RoomSummaryProviderTests.swift index b5258a384..261f739f7 100644 --- a/UnitTests/Sources/RoomSummaryProviderTests.swift +++ b/UnitTests/Sources/RoomSummaryProviderTests.swift @@ -6,12 +6,11 @@ // Please see LICENSE files in the repository root for full details. // +@testable import ElementX import MatrixRustSDK import MatrixRustSDKMocks import XCTest -@testable import ElementX - final class RoomSummaryProviderTests: XCTestCase { var appSettings: AppSettings! var roomList: RoomListSDKMock! diff --git a/UnitTests/Sources/RoomSummaryTests.swift b/UnitTests/Sources/RoomSummaryTests.swift index 3740d69f8..1cd47cc2b 100644 --- a/UnitTests/Sources/RoomSummaryTests.swift +++ b/UnitTests/Sources/RoomSummaryTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest class RoomSummaryTests: XCTestCase { // swiftlint:disable:next large_tuple diff --git a/UnitTests/Sources/RoomTests.swift b/UnitTests/Sources/RoomTests.swift index fabb80a65..748c3923e 100644 --- a/UnitTests/Sources/RoomTests.swift +++ b/UnitTests/Sources/RoomTests.swift @@ -6,14 +6,13 @@ // Please see LICENSE files in the repository root for full details. // +@testable import ElementX import MatrixRustSDK import MatrixRustSDKMocks import XCTest -@testable import ElementX - class RoomTests: XCTestCase { - func testCallIntent() async throws { + func testCallIntent() async { let room = RoomSDKMock() room.hasActiveRoomCallReturnValue = false room.isDirectReturnValue = false diff --git a/UnitTests/Sources/SecureBackupKeyBackupScreenViewModelTests.swift b/UnitTests/Sources/SecureBackupKeyBackupScreenViewModelTests.swift index 3eedd1f1c..6f5149fe7 100644 --- a/UnitTests/Sources/SecureBackupKeyBackupScreenViewModelTests.swift +++ b/UnitTests/Sources/SecureBackupKeyBackupScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class SecureBackupKeyBackupScreenViewModelTests: XCTestCase { } diff --git a/UnitTests/Sources/SecureBackupLogoutConfirmationScreenViewModelTests.swift b/UnitTests/Sources/SecureBackupLogoutConfirmationScreenViewModelTests.swift index 4fc10ccec..0ed688621 100644 --- a/UnitTests/Sources/SecureBackupLogoutConfirmationScreenViewModelTests.swift +++ b/UnitTests/Sources/SecureBackupLogoutConfirmationScreenViewModelTests.swift @@ -7,14 +7,15 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class SecureBackupLogoutConfirmationScreenViewModelTests: XCTestCase { var viewModel: SecureBackupLogoutConfirmationScreenViewModel! - var context: SecureBackupLogoutConfirmationScreenViewModel.Context { viewModel.context } + var context: SecureBackupLogoutConfirmationScreenViewModel.Context { + viewModel.context + } var secureBackupController: SecureBackupControllerMock! var reachabilitySubject: CurrentValueSubject! diff --git a/UnitTests/Sources/SecureBackupRecoveryKeyScreenViewModelTests.swift b/UnitTests/Sources/SecureBackupRecoveryKeyScreenViewModelTests.swift index 2c488119a..b591112b5 100644 --- a/UnitTests/Sources/SecureBackupRecoveryKeyScreenViewModelTests.swift +++ b/UnitTests/Sources/SecureBackupRecoveryKeyScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class SecureBackupRecoveryKeyScreenViewModelTests: XCTestCase { } diff --git a/UnitTests/Sources/SecureBackupScreenViewModelTests.swift b/UnitTests/Sources/SecureBackupScreenViewModelTests.swift index c952dd6f0..ed193088c 100644 --- a/UnitTests/Sources/SecureBackupScreenViewModelTests.swift +++ b/UnitTests/Sources/SecureBackupScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class SecureBackupScreenViewModelTests: XCTestCase { } diff --git a/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift b/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift index 3771617bb..c2d482bb5 100644 --- a/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift +++ b/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift @@ -7,11 +7,10 @@ // import Combine +@testable import ElementX import MatrixRustSDK import XCTest -@testable import ElementX - @MainActor class SecurityAndPrivacyScreenViewModelTests: XCTestCase { var viewModel: SecurityAndPrivacyScreenViewModelProtocol! diff --git a/UnitTests/Sources/ServerConfigurationScreenViewStateTests.swift b/UnitTests/Sources/ServerConfigurationScreenViewStateTests.swift index 2f8e857d4..4c1b39975 100644 --- a/UnitTests/Sources/ServerConfigurationScreenViewStateTests.swift +++ b/UnitTests/Sources/ServerConfigurationScreenViewStateTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class ServerConfirmationScreenViewStateTests: XCTestCase { diff --git a/UnitTests/Sources/ServerConfirmationScreenViewModelTests.swift b/UnitTests/Sources/ServerConfirmationScreenViewModelTests.swift index bfe9e4183..ab826652d 100644 --- a/UnitTests/Sources/ServerConfirmationScreenViewModelTests.swift +++ b/UnitTests/Sources/ServerConfirmationScreenViewModelTests.swift @@ -6,11 +6,10 @@ // Please see LICENSE files in the repository root for full details. // +@testable import ElementX import MatrixRustSDKMocks import XCTest -@testable import ElementX - @MainActor class ServerConfirmationScreenViewModelTests: XCTestCase { var clientFactory: AuthenticationClientFactoryMock! @@ -19,7 +18,9 @@ class ServerConfirmationScreenViewModelTests: XCTestCase { var appSettings: AppSettings! var viewModel: ServerConfirmationScreenViewModel! - var context: ServerConfirmationScreenViewModel.Context { viewModel.context } + var context: ServerConfirmationScreenViewModel.Context { + viewModel.context + } override func setUp() { AppSettings.resetAllSettings() diff --git a/UnitTests/Sources/ServerSelectionScreenViewModelTests.swift b/UnitTests/Sources/ServerSelectionScreenViewModelTests.swift index bb16d9b5a..63838ad16 100644 --- a/UnitTests/Sources/ServerSelectionScreenViewModelTests.swift +++ b/UnitTests/Sources/ServerSelectionScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class ServerSelectionScreenViewModelTests: XCTestCase { @@ -16,7 +15,9 @@ class ServerSelectionScreenViewModelTests: XCTestCase { var service: AuthenticationServiceProtocol! var viewModel: ServerSelectionScreenViewModelProtocol! - var context: ServerSelectionScreenViewModelType.Context { viewModel.context } + var context: ServerSelectionScreenViewModelType.Context { + viewModel.context + } func testSelectForLogin() async throws { // Given a view model for login. diff --git a/UnitTests/Sources/SessionDirectoriesTests.swift b/UnitTests/Sources/SessionDirectoriesTests.swift index c153cba8e..9da89d9aa 100644 --- a/UnitTests/Sources/SessionDirectoriesTests.swift +++ b/UnitTests/Sources/SessionDirectoriesTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest class SessionDirectoriesTests: XCTestCase { let fileManager = FileManager.default @@ -93,9 +92,17 @@ class SessionDirectoriesTests: XCTestCase { } private extension SessionDirectories { - var mockStateStorePath: String { dataDirectory.appending(component: "matrix-sdk-state.sqlite3").path(percentEncoded: false) } - var mockCryptoStorePath: String { dataDirectory.appending(component: "matrix-sdk-crypto.sqlite3").path(percentEncoded: false) } - var mockEventCachePath: String { cacheDirectory.appending(component: "matrix-sdk-event-cache.sqlite3").path(percentEncoded: false) } + var mockStateStorePath: String { + dataDirectory.appending(component: "matrix-sdk-state.sqlite3").path(percentEncoded: false) + } + + var mockCryptoStorePath: String { + dataDirectory.appending(component: "matrix-sdk-crypto.sqlite3").path(percentEncoded: false) + } + + var mockEventCachePath: String { + cacheDirectory.appending(component: "matrix-sdk-event-cache.sqlite3").path(percentEncoded: false) + } func generateMockData() { generateMockDatabase(atPath: mockStateStorePath) diff --git a/UnitTests/Sources/SessionVerificationStateMachineTests.swift b/UnitTests/Sources/SessionVerificationStateMachineTests.swift index 37e755e34..db84188d3 100644 --- a/UnitTests/Sources/SessionVerificationStateMachineTests.swift +++ b/UnitTests/Sources/SessionVerificationStateMachineTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class SessionVerificationStateMachineTests: XCTestCase { diff --git a/UnitTests/Sources/SessionVerificationViewModelTests.swift b/UnitTests/Sources/SessionVerificationViewModelTests.swift index 56f8f6bbc..9141baf4d 100644 --- a/UnitTests/Sources/SessionVerificationViewModelTests.swift +++ b/UnitTests/Sources/SessionVerificationViewModelTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class SessionVerificationViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/SettingsScreenViewModelTests.swift b/UnitTests/Sources/SettingsScreenViewModelTests.swift index 83acbc556..f9a2672da 100644 --- a/UnitTests/Sources/SettingsScreenViewModelTests.swift +++ b/UnitTests/Sources/SettingsScreenViewModelTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class SettingsScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/SoftLogoutScreenViewModelTests.swift b/UnitTests/Sources/SoftLogoutScreenViewModelTests.swift index 62ea26ad7..f9fa512b3 100644 --- a/UnitTests/Sources/SoftLogoutScreenViewModelTests.swift +++ b/UnitTests/Sources/SoftLogoutScreenViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class SoftLogoutScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/SpaceAddRoomsScreenViewModelTests.swift b/UnitTests/Sources/SpaceAddRoomsScreenViewModelTests.swift index 4af093b77..2aa2afe6a 100644 --- a/UnitTests/Sources/SpaceAddRoomsScreenViewModelTests.swift +++ b/UnitTests/Sources/SpaceAddRoomsScreenViewModelTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class SpaceAddRoomsScreenViewModelTests: XCTestCase { @@ -17,7 +16,9 @@ class SpaceAddRoomsScreenViewModelTests: XCTestCase { var spaceServiceProxy: SpaceServiceProxyMock! var viewModel: SpaceAddRoomsScreenViewModelProtocol! - var context: SpaceAddRoomsScreenViewModelType.Context { viewModel.context } + var context: SpaceAddRoomsScreenViewModelType.Context { + viewModel.context + } func testAddingChildRoom() async throws { setupViewModel() diff --git a/UnitTests/Sources/SpaceListScreenViewModelTests.swift b/UnitTests/Sources/SpaceListScreenViewModelTests.swift index 4e0da50df..e0733fc7e 100644 --- a/UnitTests/Sources/SpaceListScreenViewModelTests.swift +++ b/UnitTests/Sources/SpaceListScreenViewModelTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class SpacesScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/SpaceScreenViewModelTests.swift b/UnitTests/Sources/SpaceScreenViewModelTests.swift index 0fcac777b..d4d915d88 100644 --- a/UnitTests/Sources/SpaceScreenViewModelTests.swift +++ b/UnitTests/Sources/SpaceScreenViewModelTests.swift @@ -7,11 +7,10 @@ // import Combine -import XCTest - @testable import ElementX import MatrixRustSDK import MatrixRustSDKMocks +import XCTest @MainActor class SpaceScreenViewModelTests: XCTestCase { @@ -178,7 +177,7 @@ class SpaceScreenViewModelTests: XCTestCase { try await deferredState.fulfill() } - func testManageRoomsWithoutRemoving() async throws { + func testManageRoomsWithoutRemoving() throws { setupViewModel(initialSpaceRooms: mockSpaceRooms) XCTAssertEqual(context.viewState.editMode, .inactive) XCTAssertTrue(context.viewState.editModeSelectedIDs.isEmpty) diff --git a/UnitTests/Sources/StartChatViewModelTests.swift b/UnitTests/Sources/StartChatViewModelTests.swift index bbe6cb7f8..1bafa453f 100644 --- a/UnitTests/Sources/StartChatViewModelTests.swift +++ b/UnitTests/Sources/StartChatViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class StartChatScreenViewModelTests: XCTestCase { @@ -32,7 +31,7 @@ class StartChatScreenViewModelTests: XCTestCase { appSettings: ServiceLocator.shared.settings) } - func testQueryShowingNoResults() async throws { + func testQueryShowingNoResults() async { await search(query: "A") XCTAssertEqual(context.viewState.usersSection.type, .suggestions) diff --git a/UnitTests/Sources/StaticLocationScreenViewModelTests.swift b/UnitTests/Sources/StaticLocationScreenViewModelTests.swift index 0efa34dd2..e69733392 100644 --- a/UnitTests/Sources/StaticLocationScreenViewModelTests.swift +++ b/UnitTests/Sources/StaticLocationScreenViewModelTests.swift @@ -7,16 +7,17 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class StaticLocationScreenViewModelTests: XCTestCase { let timelineProxy = TimelineProxyMock(.init()) var viewModel: StaticLocationScreenViewModelProtocol! - var context: StaticLocationScreenViewModel.Context { viewModel.context } + var context: StaticLocationScreenViewModel.Context { + viewModel.context + } private var cancellables = Set() @@ -31,7 +32,7 @@ class StaticLocationScreenViewModelTests: XCTestCase { self.viewModel = viewModel } - func testUserDidPan() async throws { + func testUserDidPan() { XCTAssertTrue(context.viewState.isSharingUserLocation) XCTAssertEqual(context.showsUserLocationMode, .showAndFollow) context.send(viewAction: .userDidPan) @@ -39,7 +40,7 @@ class StaticLocationScreenViewModelTests: XCTestCase { XCTAssertEqual(context.showsUserLocationMode, .show) } - func testCenterOnUser() async throws { + func testCenterOnUser() { XCTAssertTrue(context.viewState.isSharingUserLocation) context.showsUserLocationMode = .show XCTAssertFalse(context.viewState.isSharingUserLocation) @@ -48,14 +49,14 @@ class StaticLocationScreenViewModelTests: XCTestCase { XCTAssertEqual(context.showsUserLocationMode, .showAndFollow) } - func testCenterOnUserWithoutAuth() async throws { + func testCenterOnUserWithoutAuth() { context.showsUserLocationMode = .hide context.isLocationAuthorized = nil context.send(viewAction: .centerToUser) XCTAssertEqual(context.showsUserLocationMode, .showAndFollow) } - func testCenterOnUserWithDeniedAuth() async throws { + func testCenterOnUserWithDeniedAuth() { context.isLocationAuthorized = false context.showsUserLocationMode = .hide context.send(viewAction: .centerToUser) @@ -63,7 +64,7 @@ class StaticLocationScreenViewModelTests: XCTestCase { XCTAssertNotNil(context.alertInfo) } - func testErrorMapping() async throws { + func testErrorMapping() { let mapError = AlertInfo(locationSharingViewError: .mapError(.failedLoadingMap)) XCTAssertEqual(mapError.message, L10n.errorFailedLoadingMap(InfoPlistReader.main.bundleDisplayName)) let locationError = AlertInfo(locationSharingViewError: .mapError(.failedLocatingUser)) diff --git a/UnitTests/Sources/StringTests.swift b/UnitTests/Sources/StringTests.swift index eb4cb5a89..15a96825a 100644 --- a/UnitTests/Sources/StringTests.swift +++ b/UnitTests/Sources/StringTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest class StringTests: XCTestCase { func testEmptyIsAscii() { diff --git a/UnitTests/Sources/TimelineItemFactoryTests.swift b/UnitTests/Sources/TimelineItemFactoryTests.swift index df4738635..fe9a0cf7d 100644 --- a/UnitTests/Sources/TimelineItemFactoryTests.swift +++ b/UnitTests/Sources/TimelineItemFactoryTests.swift @@ -8,12 +8,11 @@ @testable import ElementX import MatrixRustSDK - import XCTest @MainActor class TimelineItemFactoryTests: XCTestCase { - func testCallInvite() async { + func testCallInvite() { let ownUserID = "@alice:matrix.org" let senderUserID = "@bob:matrix.org" diff --git a/UnitTests/Sources/TimelineMediaPreviewViewModelTests.swift b/UnitTests/Sources/TimelineMediaPreviewViewModelTests.swift index 984e78d41..5c81c4da0 100644 --- a/UnitTests/Sources/TimelineMediaPreviewViewModelTests.swift +++ b/UnitTests/Sources/TimelineMediaPreviewViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -@testable import ElementX - import Combine +@testable import ElementX import MatrixRustSDK import QuickLook import SwiftUI @@ -17,7 +16,10 @@ import XCTest @MainActor class TimelineMediaPreviewViewModelTests: XCTestCase { var viewModel: TimelineMediaPreviewViewModel! - var context: TimelineMediaPreviewViewModel.Context { viewModel.context } + var context: TimelineMediaPreviewViewModel.Context { + viewModel.context + } + var mediaProvider: MediaProviderMock! var photoLibraryManager: PhotoLibraryManagerMock! var timelineController: MockTimelineController! diff --git a/UnitTests/Sources/TimelineViewModelTests.swift b/UnitTests/Sources/TimelineViewModelTests.swift index 0a6eb703a..bbadcc2ae 100644 --- a/UnitTests/Sources/TimelineViewModelTests.swift +++ b/UnitTests/Sources/TimelineViewModelTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -@testable import ElementX - import Combine +@testable import ElementX import MatrixRustSDK import XCTest @@ -230,7 +229,7 @@ class TimelineViewModelTests: XCTestCase { XCTAssertNil(viewModel.context.viewState.timelineState.focussedEvent) } - func testInitialFocusViewState() async throws { + func testInitialFocusViewState() { let timelineController = MockTimelineController() let viewModel = makeViewModel(focussedEventID: "t10", timelineController: timelineController) @@ -248,7 +247,7 @@ class TimelineViewModelTests: XCTestCase { let (viewModel, _, timelineProxy, _) = readReceiptsConfiguration(with: items) // When sending a read receipt for the last item. - viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(items.last!.id)) + try viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(XCTUnwrap(items.last?.id))) try await Task.sleep(for: .milliseconds(100)) // Then the receipt should be sent. @@ -266,7 +265,7 @@ class TimelineViewModelTests: XCTestCase { let (viewModel, _, timelineProxy, _) = readReceiptsConfiguration(with: items) // When sending a read receipt for the last item. - viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(items.last!.id)) + try viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(XCTUnwrap(items.last?.id))) try await Task.sleep(for: .milliseconds(100)) // Then nothing should be sent. @@ -281,7 +280,7 @@ class TimelineViewModelTests: XCTestCase { let (viewModel, _, _, _) = readReceiptsConfiguration(with: items) // When sending a read receipt for the last item. - viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(items.last!.id)) + try viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(XCTUnwrap(items.last?.id))) try await Task.sleep(for: .milliseconds(100)) } diff --git a/UnitTests/Sources/URLComponentsTests.swift b/UnitTests/Sources/URLComponentsTests.swift index 929d93f91..e21df5099 100644 --- a/UnitTests/Sources/URLComponentsTests.swift +++ b/UnitTests/Sources/URLComponentsTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest class URLComponentsTests: XCTestCase { func testAddFragmentQueryItems() { diff --git a/UnitTests/Sources/URLTests.swift b/UnitTests/Sources/URLTests.swift index e175f88b7..c11790003 100644 --- a/UnitTests/Sources/URLTests.swift +++ b/UnitTests/Sources/URLTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest class URLTests: XCTestCase { func testURLDirectoryName() { diff --git a/UnitTests/Sources/UserAgentBuilderTests.swift b/UnitTests/Sources/UserAgentBuilderTests.swift index e23c5e3c5..30f8d7029 100644 --- a/UnitTests/Sources/UserAgentBuilderTests.swift +++ b/UnitTests/Sources/UserAgentBuilderTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest class UserAgentBuilderTests: XCTestCase { func testIsNotNil() { diff --git a/UnitTests/Sources/UserDetailsEditScreenViewModelTests.swift b/UnitTests/Sources/UserDetailsEditScreenViewModelTests.swift index 32994b0eb..73a8914d9 100644 --- a/UnitTests/Sources/UserDetailsEditScreenViewModelTests.swift +++ b/UnitTests/Sources/UserDetailsEditScreenViewModelTests.swift @@ -7,9 +7,8 @@ // import Combine -import XCTest - @testable import ElementX +import XCTest @MainActor class UserDetailsEditScreenViewModelTests: XCTestCase { diff --git a/UnitTests/Sources/UserDiscoveryService/UserDiscoveryServiceTest.swift b/UnitTests/Sources/UserDiscoveryService/UserDiscoveryServiceTest.swift index 198d32bae..6911cd103 100644 --- a/UnitTests/Sources/UserDiscoveryService/UserDiscoveryServiceTest.swift +++ b/UnitTests/Sources/UserDiscoveryService/UserDiscoveryServiceTest.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class UserDiscoveryServiceTest: XCTestCase { @@ -20,14 +19,14 @@ class UserDiscoveryServiceTest: XCTestCase { service = UserDiscoveryService(clientProxy: clientProxy) } - func testQueryShowingResults() async throws { + func testQueryShowingResults() async { clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: [UserProfileProxy.mockAlice], limited: true)) let results = await (try? search(query: "AAA").get()) ?? [] assertSearchResults(results, toBe: 1) } - func testOwnerIsFiltered() async throws { + func testOwnerIsFiltered() async { clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: [UserProfileProxy(userID: "@foo:matrix.org")], limited: true)) let results = await (try? search(query: "AAA").get()) ?? [] diff --git a/UnitTests/Sources/UserIndicatorControllerTests.swift b/UnitTests/Sources/UserIndicatorControllerTests.swift index 054e2ab34..18dc7cf6f 100644 --- a/UnitTests/Sources/UserIndicatorControllerTests.swift +++ b/UnitTests/Sources/UserIndicatorControllerTests.swift @@ -6,11 +6,9 @@ // Please see LICENSE files in the repository root for full details. // -import Foundation - -import XCTest - @testable import ElementX +import Foundation +import XCTest @MainActor class UserIndicatorControllerTests: XCTestCase { diff --git a/UnitTests/Sources/UserPreferenceTests.swift b/UnitTests/Sources/UserPreferenceTests.swift index 60c928115..9da110f5a 100644 --- a/UnitTests/Sources/UserPreferenceTests.swift +++ b/UnitTests/Sources/UserPreferenceTests.swift @@ -16,7 +16,7 @@ final class UserPreferenceTests: XCTestCase { UserDefaults.testDefaults.removePersistentDomain(forName: .userDefaultsSuiteName) } - func testStorePlistValue() throws { + func testStorePlistValue() { let setPreference = { let value = TestPreferences() value.plist = "Hello" @@ -31,7 +31,7 @@ final class UserPreferenceTests: XCTestCase { XCTAssertNil(UserDefaults.testDefaults.data(forKey: .key2), "Hello") } - func testStoreCodableValue() throws { + func testStoreCodableValue() { let storedType = CodableTestType(a: "some", b: [1, 2, 3]) let setPreference = { @@ -47,7 +47,7 @@ final class UserPreferenceTests: XCTestCase { XCTAssertNotNil(UserDefaults.testDefaults.data(forKey: .key3)) } - func testStorePlistValueOnVolatileStorage() throws { + func testStorePlistValueOnVolatileStorage() { let setPreference = { let value = TestPreferences() value.volatileVar = "Hello" @@ -60,7 +60,7 @@ final class UserPreferenceTests: XCTestCase { XCTAssertNil(value.volatileVar) } - func testStoreCodableValueOnVolatileStorage() throws { + func testStoreCodableValueOnVolatileStorage() { let storedType = CodableTestType(a: "some", b: [1, 2, 3]) let setPreference = { @@ -76,7 +76,7 @@ final class UserPreferenceTests: XCTestCase { XCTAssertNil(UserDefaults.testDefaults.data(forKey: .key4)) } - func testStorePlistArray() throws { + func testStorePlistArray() { let setPreference = { let value = TestPreferences() value.plistArray = [1, 2, 3] @@ -91,7 +91,7 @@ final class UserPreferenceTests: XCTestCase { XCTAssertNil(UserDefaults.testDefaults.data(forKey: .key5), "Hello") } - func testAssignNilToPlistType() throws { + func testAssignNilToPlistType() { let setPreference = { let value = TestPreferences() value.plist = "Hello" @@ -106,7 +106,7 @@ final class UserPreferenceTests: XCTestCase { XCTAssertNil(UserDefaults.testDefaults.string(forKey: .key2)) } - func testAssignNilToCodableType() throws { + func testAssignNilToCodableType() { let storedType = CodableTestType(a: "some", b: [1, 2, 3]) let setPreference = { diff --git a/UnitTests/Sources/UserProfileScreenViewModelTests.swift b/UnitTests/Sources/UserProfileScreenViewModelTests.swift index 772fb3027..0db8154a1 100644 --- a/UnitTests/Sources/UserProfileScreenViewModelTests.swift +++ b/UnitTests/Sources/UserProfileScreenViewModelTests.swift @@ -6,14 +6,15 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - @testable import ElementX +import XCTest @MainActor class UserProfileScreenViewModelTests: XCTestCase { var viewModel: UserProfileScreenViewModel! - var context: UserProfileScreenViewModelType.Context { viewModel.context } + var context: UserProfileScreenViewModelType.Context { + viewModel.context + } func testInitialState() async throws { let profile = UserProfileProxy(userID: "@alice:matrix.org", displayName: "Alice", avatarURL: .mockMXCAvatar) diff --git a/UnitTests/Sources/UserSessionFlowCoordinatorTests.swift b/UnitTests/Sources/UserSessionFlowCoordinatorTests.swift index b6732598e..188603685 100644 --- a/UnitTests/Sources/UserSessionFlowCoordinatorTests.swift +++ b/UnitTests/Sources/UserSessionFlowCoordinatorTests.swift @@ -6,10 +6,9 @@ // Please see LICENSE files in the repository root for full details. // -import XCTest - import Combine @testable import ElementX +import XCTest @MainActor class UserSessionFlowCoordinatorTests: XCTestCase { @@ -22,10 +21,21 @@ class UserSessionFlowCoordinatorTests: XCTestCase { let homeserverReachabilitySubject: CurrentValueSubject = .init(.reachable) var cancellables = Set() - var tabCoordinator: NavigationTabCoordinator? { rootCoordinator?.rootCoordinator as? NavigationTabCoordinator } - var chatsSplitCoordinator: NavigationSplitCoordinator? { tabCoordinator?.tabCoordinators.first as? NavigationSplitCoordinator } - var detailCoordinator: CoordinatorProtocol? { chatsSplitCoordinator?.detailCoordinator } - var detailNavigationStack: NavigationStackCoordinator? { detailCoordinator as? NavigationStackCoordinator } + var tabCoordinator: NavigationTabCoordinator? { + rootCoordinator?.rootCoordinator as? NavigationTabCoordinator + } + + var chatsSplitCoordinator: NavigationSplitCoordinator? { + tabCoordinator?.tabCoordinators.first as? NavigationSplitCoordinator + } + + var detailCoordinator: CoordinatorProtocol? { + chatsSplitCoordinator?.detailCoordinator + } + + var detailNavigationStack: NavigationStackCoordinator? { + detailCoordinator as? NavigationStackCoordinator + } override func setUp() async throws { cancellables.removeAll() @@ -66,7 +76,7 @@ class UserSessionFlowCoordinatorTests: XCTestCase { // MARK: Navigation - func testInitialState() async throws { + func testInitialState() { XCTAssertNotNil(chatsSplitCoordinator) XCTAssertNil(detailCoordinator) } diff --git a/UnitTests/Sources/VoiceMessageCacheTests.swift b/UnitTests/Sources/VoiceMessageCacheTests.swift index 6599d9784..aa86ca95f 100644 --- a/UnitTests/Sources/VoiceMessageCacheTests.swift +++ b/UnitTests/Sources/VoiceMessageCacheTests.swift @@ -40,7 +40,7 @@ class VoiceMessageCacheTests: XCTestCase { try fileManager.removeItem(at: testTemporaryDirectory) } - func testFileURL() async throws { + func testFileURL() throws { // If the file is not already in the cache, no URL is expected XCTAssertNil(voiceMessageCache.fileURL(for: mediaSource)) @@ -54,7 +54,7 @@ class VoiceMessageCacheTests: XCTestCase { XCTAssertEqual(cachedURL, voiceMessageCache.fileURL(for: mediaSource)) } - func testCacheInvalidFileExtension() async throws { + func testCacheInvalidFileExtension() throws { // An error should be raised if the file extension is not "m4a" let mpegFileURL = try createTemporaryFile(named: testFilename, withExtension: "mpg") guard case .failure(let error) = voiceMessageCache.cache(mediaSource: mediaSource, using: mpegFileURL, move: true) else { @@ -65,7 +65,7 @@ class VoiceMessageCacheTests: XCTestCase { XCTAssertEqual(error, .invalidFileExtension) } - func testCacheCopy() async throws { + func testCacheCopy() throws { let fileURL = try createTemporaryFile(named: testFilename, withExtension: mpeg4aacFileExtension) guard case .success(let cacheURL) = voiceMessageCache.cache(mediaSource: mediaSource, using: fileURL, move: false) else { XCTFail("A success is expected") @@ -78,7 +78,7 @@ class VoiceMessageCacheTests: XCTestCase { XCTAssertTrue(fileManager.fileExists(atPath: cacheURL.path())) } - func testCacheMove() async throws { + func testCacheMove() throws { let fileURL = try createTemporaryFile(named: testFilename, withExtension: mpeg4aacFileExtension) guard case .success(let cacheURL) = voiceMessageCache.cache(mediaSource: mediaSource, using: fileURL, move: true) else { XCTFail("A success is expected") diff --git a/UnitTests/Sources/VoiceMessageRecorderTests.swift b/UnitTests/Sources/VoiceMessageRecorderTests.swift index d6e653a11..2daa26c8f 100644 --- a/UnitTests/Sources/VoiceMessageRecorderTests.swift +++ b/UnitTests/Sources/VoiceMessageRecorderTests.swift @@ -70,28 +70,28 @@ class VoiceMessageRecorderTests: XCTestCase { try await deferred.fulfill() } - func testRecordingURL() async throws { + func testRecordingURL() { audioRecorder.audioFileURL = recordingURL XCTAssertEqual(voiceMessageRecorder.recordingURL, recordingURL) } - func testRecordingDuration() async throws { + func testRecordingDuration() { audioRecorder.currentTime = 10.3 XCTAssertEqual(voiceMessageRecorder.recordingDuration, 10.3) } - func testStartRecording() async throws { + func testStartRecording() async { _ = await voiceMessageRecorder.startRecording() XCTAssert(audioRecorder.recordAudioFileURLCalled) } - func testStopRecording() async throws { + func testStopRecording() async { _ = await voiceMessageRecorder.stopRecording() // Internal audio recorder must have been stopped XCTAssert(audioRecorder.stopRecordingCalled) } - func testCancelRecording() async throws { + func testCancelRecording() async { await voiceMessageRecorder.cancelRecording() // Internal audio recorder must have been stopped XCTAssert(audioRecorder.stopRecordingCalled) @@ -99,13 +99,13 @@ class VoiceMessageRecorderTests: XCTestCase { XCTAssert(audioRecorder.deleteRecordingCalled) } - func testDeleteRecording() async throws { + func testDeleteRecording() async { await voiceMessageRecorder.deleteRecording() // The recording audio file must have been deleted XCTAssert(audioRecorder.deleteRecordingCalled) } - func testStartPlaybackNoPreview() async throws { + func testStartPlaybackNoPreview() async { guard case .failure(.previewNotAvailable) = await voiceMessageRecorder.startPlayback() else { XCTFail("An error is expected") return @@ -172,7 +172,7 @@ class VoiceMessageRecorderTests: XCTestCase { XCTAssertEqual(audioPlayer.seekToReceivedProgress, 0.4) } - func testBuildRecordedWaveform() async throws { + func testBuildRecordedWaveform() async { // If there is no recording file, an error is expected audioRecorder.audioFileURL = nil guard case .failure(.missingRecordingFile) = await voiceMessageRecorder.buildRecordingWaveform() else { @@ -192,7 +192,7 @@ class VoiceMessageRecorderTests: XCTestCase { XCTAssert(!data.isEmpty) } - func testSendVoiceMessage_NoRecordingFile() async throws { + func testSendVoiceMessage_NoRecordingFile() async { let timelineController = MockTimelineController() // If there is no recording file, an error is expected @@ -204,7 +204,7 @@ class VoiceMessageRecorderTests: XCTestCase { } } - func testSendVoiceMessage_ConversionError() async throws { + func testSendVoiceMessage_ConversionError() async { audioRecorder.audioFileURL = recordingURL // If the converter returns an error audioConverter.convertToOpusOggSourceURLDestinationURLThrowableError = AudioConverterError.conversionFailed(nil) @@ -217,7 +217,7 @@ class VoiceMessageRecorderTests: XCTestCase { } } - func testSendVoiceMessage_InvalidFile() async throws { + func testSendVoiceMessage_InvalidFile() async { guard let audioFileURL = Bundle(for: Self.self).url(forResource: "test_voice_message", withExtension: "m4a") else { XCTFail("Test audio file is missing") return @@ -237,7 +237,7 @@ class VoiceMessageRecorderTests: XCTestCase { } } - func testSendVoiceMessage_WaveformAnlyseFailed() async throws { + func testSendVoiceMessage_WaveformAnlyseFailed() async { guard let imageFileURL = Bundle(for: Self.self).url(forResource: "test_image", withExtension: "png") else { XCTFail("Test audio file is missing") return @@ -258,7 +258,7 @@ class VoiceMessageRecorderTests: XCTestCase { } } - func testSendVoiceMessage_SendError() async throws { + func testSendVoiceMessage_SendError() async { guard let audioFileURL = Bundle(for: Self.self).url(forResource: "test_voice_message", withExtension: "m4a") else { XCTFail("Test audio file is missing") return @@ -281,7 +281,7 @@ class VoiceMessageRecorderTests: XCTestCase { } } - func testSendVoiceMessage() async throws { + func testSendVoiceMessage() async { guard let imageFileURL = Bundle(for: Self.self).url(forResource: "test_voice_message", withExtension: "m4a") else { XCTFail("Test audio file is missing") return diff --git a/compound-ios/Inspector/Sources/CompoundInspectorApp.swift b/compound-ios/Inspector/Sources/CompoundInspectorApp.swift index ba83f49ff..081f3d231 100644 --- a/compound-ios/Inspector/Sources/CompoundInspectorApp.swift +++ b/compound-ios/Inspector/Sources/CompoundInspectorApp.swift @@ -15,8 +15,13 @@ struct CompoundInspectorApp: App { @State private var colorScheme: ColorScheme = .light @State private var dynamicTypeSize: DynamicTypeSize = .large - private var isDark: Bool { colorScheme == .dark } - private var preferredColorScheme: ColorScheme? { ProcessInfo.processInfo.isMacCatalystApp ? colorScheme : nil } + private var isDark: Bool { + colorScheme == .dark + } + + private var preferredColorScheme: ColorScheme? { + ProcessInfo.processInfo.isMacCatalystApp ? colorScheme : nil + } var body: some Scene { WindowGroup { diff --git a/compound-ios/Sources/Compound/Buttons/SendButton.swift b/compound-ios/Sources/Compound/Buttons/SendButton.swift index d4703f516..32235da86 100644 --- a/compound-ios/Sources/Compound/Buttons/SendButton.swift +++ b/compound-ios/Sources/Compound/Buttons/SendButton.swift @@ -20,7 +20,9 @@ public struct SendButton: View { return colorScheme == .light ? .compound.iconOnSolidPrimary : .compound.iconPrimary } - private var gradient: Gradient { isEnabled ? .compound.action : .init(colors: [.clear]) } + private var gradient: Gradient { + isEnabled ? .compound.action : .init(colors: [.clear]) + } /// Creates a send button that performs the provided action. public init(action: @escaping () -> Void) { diff --git a/compound-ios/Sources/Compound/Colors/CompoundColors.swift b/compound-ios/Sources/Compound/Colors/CompoundColors.swift index d2fcc4183..f82d3a8db 100644 --- a/compound-ios/Sources/Compound/Colors/CompoundColors.swift +++ b/compound-ios/Sources/Compound/Colors/CompoundColors.swift @@ -16,7 +16,9 @@ public extension Color { public extension ShapeStyle where Self == Color { /// The colours used by Element as defined in Compound Design Tokens. - static var compound: CompoundColors { Self.compound } + static var compound: CompoundColors { + Self.compound + } } /// The colours used by Element as defined in Compound Design Tokens. @@ -100,7 +102,9 @@ public class CompoundColors { private extension UITraitCollection { /// Whether or not the trait collection contains a `userInterfaceStyle` of `.light`. - var isLight: Bool { userInterfaceStyle == .light } + var isLight: Bool { + userInterfaceStyle == .light + } } public struct DecorativeColor: Equatable { diff --git a/compound-ios/Sources/Compound/Colors/CompoundGradients.swift b/compound-ios/Sources/Compound/Colors/CompoundGradients.swift index 6a4da9e44..a58534020 100644 --- a/compound-ios/Sources/Compound/Colors/CompoundGradients.swift +++ b/compound-ios/Sources/Compound/Colors/CompoundGradients.swift @@ -17,22 +17,30 @@ public extension Gradient { /// The gradients used by Element as defined in Compound Design Tokens. /// This struct only contains the gradients assembled from the individual colour stops. public struct CompoundGradients { - // We need to use computed properties here so that the gradients include the - // latest token overrides that have been applied since the struct was created. - public var action: Gradient { .init(colors: [.compound.gradientActionStop1, - .compound.gradientActionStop2, - .compound.gradientActionStop3, - .compound.gradientActionStop4]) } - public var subtle: Gradient { .init(colors: [.compound.gradientSubtleStop1, - .compound.gradientSubtleStop2, - .compound.gradientSubtleStop3, - .compound.gradientSubtleStop4, - .compound.gradientSubtleStop5, - .compound.gradientSubtleStop6]) } - public var info: Gradient { .init(colors: [.compound.gradientInfoStop1, - .compound.gradientInfoStop2, - .compound.gradientInfoStop3, - .compound.gradientInfoStop4, - .compound.gradientInfoStop5, - .compound.gradientInfoStop6]) } + /// We need to use computed properties here so that the gradients include the + /// latest token overrides that have been applied since the struct was created. + public var action: Gradient { + .init(colors: [.compound.gradientActionStop1, + .compound.gradientActionStop2, + .compound.gradientActionStop3, + .compound.gradientActionStop4]) + } + + public var subtle: Gradient { + .init(colors: [.compound.gradientSubtleStop1, + .compound.gradientSubtleStop2, + .compound.gradientSubtleStop3, + .compound.gradientSubtleStop4, + .compound.gradientSubtleStop5, + .compound.gradientSubtleStop6]) + } + + public var info: Gradient { + .init(colors: [.compound.gradientInfoStop1, + .compound.gradientInfoStop2, + .compound.gradientInfoStop3, + .compound.gradientInfoStop4, + .compound.gradientInfoStop5, + .compound.gradientInfoStop6]) + } } diff --git a/compound-ios/Sources/Compound/Colors/CompoundUIColors.swift b/compound-ios/Sources/Compound/Colors/CompoundUIColors.swift index 5d293f0b0..c23fea3af 100644 --- a/compound-ios/Sources/Compound/Colors/CompoundUIColors.swift +++ b/compound-ios/Sources/Compound/Colors/CompoundUIColors.swift @@ -53,5 +53,7 @@ public class CompoundUIColors { private extension UITraitCollection { /// Whether or not the trait collection contains a `userInterfaceStyle` of `.light`. - var isLight: Bool { userInterfaceStyle == .light } + var isLight: Bool { + userInterfaceStyle == .light + } } diff --git a/compound-ios/Sources/Compound/List/ListInlinePicker.swift b/compound-ios/Sources/Compound/List/ListInlinePicker.swift index bddb5b763..67c0fe2c0 100644 --- a/compound-ios/Sources/Compound/List/ListInlinePicker.swift +++ b/compound-ios/Sources/Compound/List/ListInlinePicker.swift @@ -33,7 +33,9 @@ struct ListInlinePicker: View { // MARK: - Previews struct ListInlinePicker_Previews: PreviewProvider, TestablePreview { - static var previews: some View { Preview() } + static var previews: some View { + Preview() + } struct Preview: View { @State var selection = "Item 1" diff --git a/compound-ios/Sources/Compound/List/ListRow.swift b/compound-ios/Sources/Compound/List/ListRow.swift index 12e75eff2..f30c51c0b 100644 --- a/compound-ios/Sources/Compound/List/ListRow.swift +++ b/compound-ios/Sources/Compound/List/ListRow.swift @@ -154,7 +154,7 @@ public struct ListRow, details: ListRowDetails? = nil, @@ -173,7 +173,7 @@ public extension ListRow where CustomContent == EmptyView { } } -// Normal row without a details icon. +/// Normal row without a details icon. public extension ListRow where DetailsIcon == EmptyView, CustomContent == EmptyView { init(label: ListRowLabel, details: ListRowDetails? = nil, @@ -192,7 +192,7 @@ public extension ListRow where DetailsIcon == EmptyView, CustomContent == EmptyV } } -// Custom row without a label or details label. +/// Custom row without a label or details label. public extension ListRow where Icon == EmptyView, DetailsIcon == EmptyView { init(kind: Kind) { label = ListRowLabel() @@ -449,7 +449,7 @@ public struct ListRow_Previews: PreviewProvider, TestablePreview { } } - @ViewBuilder static var othersSection: some View { + static var othersSection: some View { Section { ListRow(kind: .custom { Text("This is a custom row") diff --git a/compound-ios/Sources/Compound/List/ListRowAccessory.swift b/compound-ios/Sources/Compound/List/ListRowAccessory.swift index 38179a159..53dc2cc97 100644 --- a/compound-ios/Sources/Compound/List/ListRowAccessory.swift +++ b/compound-ios/Sources/Compound/List/ListRowAccessory.swift @@ -52,7 +52,10 @@ public struct ListRowAccessory: View { let kind: Kind /// Negative padding added to prevent the accessory interfering with the row's padding. - private var verticalPaddingFix: CGFloat { -4 } + private var verticalPaddingFix: CGFloat { + -4 + } + /// Absolute bodge until we have the circle icon in Compound. @ScaledMetric private var circleOverlayInsets = 5 diff --git a/compound-ios/Sources/Compound/List/ListRowLabel.swift b/compound-ios/Sources/Compound/List/ListRowLabel.swift index cd331ebe8..fb84df4a5 100644 --- a/compound-ios/Sources/Compound/List/ListRowLabel.swift +++ b/compound-ios/Sources/Compound/List/ListRowLabel.swift @@ -79,7 +79,9 @@ public struct ListRowLabel: View { return role == .destructive ? .compound.textCriticalPrimary : .compound.textPrimary } - var titleLineLimit: Int? { layout == .avatar ? 1 : lineLimit } + var titleLineLimit: Int? { + layout == .avatar ? 1 : lineLimit + } var statusColor: Color { isEnabled ? .compound.textSecondary : .compound.textDisabled diff --git a/compound-ios/Sources/Compound/List/ListRowTrailingSection.swift b/compound-ios/Sources/Compound/List/ListRowTrailingSection.swift index 0440cd008..fe4f1e5f0 100644 --- a/compound-ios/Sources/Compound/List/ListRowTrailingSection.swift +++ b/compound-ios/Sources/Compound/List/ListRowTrailingSection.swift @@ -38,7 +38,9 @@ public struct ListRowTrailingSection: View { private var accessory: ListRowAccessory? @ScaledMetric private var iconSize = 24 - private var hideAccessory: Bool { isWaiting && accessory?.kind == .unselected } + private var hideAccessory: Bool { + isWaiting && accessory?.kind == .unselected + } init(_ details: ListRowDetails?, accessory: ListRowAccessory? = nil) { title = details?.title diff --git a/compound-ios/Sources/Compound/Text Field Styles/SearchFieldStyle.swift b/compound-ios/Sources/Compound/Text Field Styles/SearchFieldStyle.swift index 7983fda21..b60b3e9d7 100644 --- a/compound-ios/Sources/Compound/Text Field Styles/SearchFieldStyle.swift +++ b/compound-ios/Sources/Compound/Text Field Styles/SearchFieldStyle.swift @@ -12,7 +12,6 @@ public extension View { /// Styles a search bar text field using the Compound design tokens. /// This modifier is to be used in combination with `.searchable`. @MainActor - @ViewBuilder func compoundSearchField() -> some View { introspect(.navigationStack, on: .supportedVersions, scope: .ancestor) { navigationController in // Uses the navigation stack as .searchField is unreliable when pushing the second search bar, during the create rooms flow. diff --git a/compound-ios/Tests/CompoundTests/AvatarColorsTests.swift b/compound-ios/Tests/CompoundTests/AvatarColorsTests.swift index aca77d558..1b8c1c2ea 100644 --- a/compound-ios/Tests/CompoundTests/AvatarColorsTests.swift +++ b/compound-ios/Tests/CompoundTests/AvatarColorsTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import Foundation - @testable import Compound +import Foundation import SwiftUI import XCTest @@ -17,7 +16,7 @@ final class DecorativeColorsTests: XCTestCase { let input: String private let webOutput: Int - // remember that web starts the index from 1 while we start from 0 + /// remember that web starts the index from 1 while we start from 0 var output: Int { webOutput - 1 } diff --git a/compound-ios/Tests/CompoundTests/FontSizeTests.swift b/compound-ios/Tests/CompoundTests/FontSizeTests.swift index 6e93ccd32..4bd8dd15a 100644 --- a/compound-ios/Tests/CompoundTests/FontSizeTests.swift +++ b/compound-ios/Tests/CompoundTests/FontSizeTests.swift @@ -12,7 +12,7 @@ import XCTest final class FontSizeTests: XCTestCase { /// Test all system text styles to assert mapping between `Font` and `UIFont`. - func testTextStyle() throws { + func testTextStyle() { let caption2FontSize = FontSize.reflecting(.caption2) XCTAssertEqual(caption2FontSize?.value, 11) XCTAssertEqual(caption2FontSize?.style, .caption2) diff --git a/compound-ios/Tests/CompoundTests/OverrideColorTests.swift b/compound-ios/Tests/CompoundTests/OverrideColorTests.swift index 52b41c031..3d489a50e 100644 --- a/compound-ios/Tests/CompoundTests/OverrideColorTests.swift +++ b/compound-ios/Tests/CompoundTests/OverrideColorTests.swift @@ -6,9 +6,8 @@ // Please see LICENSE files in the repository root for full details. // -import Foundation - @testable import Compound +import Foundation import XCTest @MainActor diff --git a/compound-ios/Tests/CompoundTests/PreviewTests.swift b/compound-ios/Tests/CompoundTests/PreviewTests.swift index 621cd15e2..b896daa6f 100644 --- a/compound-ios/Tests/CompoundTests/PreviewTests.swift +++ b/compound-ios/Tests/CompoundTests/PreviewTests.swift @@ -7,11 +7,10 @@ // import Combine -import SwiftUI -import XCTest - @testable import Compound @testable import SnapshotTesting +import SwiftUI +import XCTest @MainActor class PreviewTests: XCTestCase { @@ -23,8 +22,8 @@ class PreviewTests: XCTestCase { private let deviceConfig: ViewImageConfig = .iPhoneX private let simulatorDevice: String? = "iPhone14,6" // iPhone SE 3rd Generation private let requiredOSVersion = (major: 26, minor: 1) - // The key is the name we will give to the snapshot - // The value is the actual device that will be used to render the preview + /// The key is the name we will give to the snapshot + /// The value is the actual device that will be used to render the preview private let snapshotDevices: [SnapshotDevice] = [.init(name: "iPhone", device: "iPhone 17"), .init(name: "iPad", device: "iPad")] private var recordMode: SnapshotTestingConfiguration.Record = .missing @@ -130,8 +129,7 @@ class PreviewTests: XCTestCase { preferences: SnapshotPreferences) -> String? { let matchingView = isScreen ? AnyView(view) : AnyView(view .frame(width: device.size?.width) - .fixedSize(horizontal: false, vertical: true) - ) + .fixedSize(horizontal: false, vertical: true)) return withSnapshotTesting(record: recordMode) { verifySnapshot(of: matchingView, @@ -243,5 +241,7 @@ private extension Diffing where Value == UIImage { private extension UIEdgeInsets { /// A custom inset that prevents the snapshotting library from rendering the /// origin at (10000, 10000) which breaks some of our views such as MessageText. - static var one: UIEdgeInsets { UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1) } + static var one: UIEdgeInsets { + UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1) + } }