mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Run SwiftFormat.
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ final class AdvancedSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
clientProxy: parameters.clientProxy,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(AdvancedSettingsScreen(context: viewModel.context))
|
||||
}
|
||||
|
||||
+2
-2
@@ -38,11 +38,11 @@ struct AdvancedSettingsScreenViewState: BindableState {
|
||||
@dynamicMemberLookup
|
||||
struct AdvancedSettingsScreenViewStateBindings {
|
||||
private let advancedSettings: AdvancedSettingsProtocol
|
||||
|
||||
|
||||
init(advancedSettings: AdvancedSettingsProtocol) {
|
||||
self.advancedSettings = advancedSettings
|
||||
}
|
||||
|
||||
|
||||
subscript<Setting>(dynamicMember keyPath: ReferenceWritableKeyPath<AdvancedSettingsProtocol, Setting>) -> Setting {
|
||||
get { advancedSettings[keyPath: keyPath] }
|
||||
set { advancedSettings[keyPath: keyPath] = newValue }
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ final class DeactivateAccountScreenCoordinator: CoordinatorProtocol {
|
||||
private let viewModel: DeactivateAccountScreenViewModelProtocol
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
|
||||
private let actionsSubject: PassthroughSubject<DeactivateAccountScreenCoordinatorAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<DeactivateAccountScreenCoordinatorAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
@@ -48,7 +48,7 @@ final class DeactivateAccountScreenCoordinator: CoordinatorProtocol {
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(DeactivateAccountScreen(context: viewModel.context))
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ class DeactivateAccountScreenViewModel: DeactivateAccountScreenViewModelType, De
|
||||
var actionsPublisher: AnyPublisher<DeactivateAccountScreenViewModelAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
|
||||
init(clientProxy: ClientProxyProtocol, userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.clientProxy = clientProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
@@ -49,7 +49,7 @@ class DeactivateAccountScreenViewModel: DeactivateAccountScreenViewModelType, De
|
||||
},
|
||||
secondaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil))
|
||||
}
|
||||
|
||||
|
||||
func deactivateAccount() async {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: deactivatingIndicatorID,
|
||||
type: .modal(progress: .indeterminate, interactiveDismissDisabled: true, allowsInteraction: false),
|
||||
|
||||
+4
-4
@@ -35,11 +35,11 @@ struct DeveloperOptionsScreenViewState: BindableState {
|
||||
@dynamicMemberLookup
|
||||
struct DeveloperOptionsScreenViewStateBindings {
|
||||
private let developerOptions: DeveloperOptionsProtocol
|
||||
|
||||
|
||||
init(developerOptions: DeveloperOptionsProtocol) {
|
||||
self.developerOptions = developerOptions
|
||||
}
|
||||
|
||||
|
||||
subscript<Setting>(dynamicMember keyPath: ReferenceWritableKeyPath<DeveloperOptionsProtocol, Setting>) -> Setting {
|
||||
get { developerOptions[keyPath: keyPath] }
|
||||
set { developerOptions[keyPath: keyPath] = newValue }
|
||||
@@ -68,11 +68,11 @@ protocol DeveloperOptionsProtocol: AnyObject {
|
||||
var knockingEnabled: Bool { get set }
|
||||
|
||||
var linkPreviewsEnabled: Bool { get set }
|
||||
|
||||
|
||||
var jumpToReadMarkerEnabled: Bool { get set }
|
||||
|
||||
var linkNewDeviceEnabled: Bool { get set }
|
||||
|
||||
|
||||
var roomThreadListEnabled: Bool { get set }
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
||||
if let logsSize = try? FileManager.default.sizeForDirectory(at: .appGroupLogsDirectory) {
|
||||
components.append(.init(name: "Log Files", size: formatter.format(Int64(logsSize))))
|
||||
}
|
||||
|
||||
|
||||
state.storeSizes = components
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -87,12 +87,12 @@ struct DeveloperOptionsScreen: View {
|
||||
Text("Can leak the device IP address when loading link metadata.")
|
||||
.foregroundStyle(.compound.textCriticalPrimary)
|
||||
}
|
||||
|
||||
|
||||
Toggle(isOn: $context.jumpToReadMarkerEnabled) {
|
||||
Text("Jump to unread")
|
||||
Text("Adds a button to jump to the read marker, plus a presence dot on the scroll-to-bottom button when new messages arrive while scrolled away.")
|
||||
}
|
||||
|
||||
|
||||
Toggle(isOn: $context.knockingEnabled) {
|
||||
Text("Knocking")
|
||||
Text("Ask to join rooms")
|
||||
@@ -109,7 +109,7 @@ struct DeveloperOptionsScreen: View {
|
||||
} footer: {
|
||||
Text("This setting controls how end-to-end encryption (E2EE) keys are exchanged. Enabling it will prevent the inclusion of devices that have not been explicitly verified by their owners.")
|
||||
}
|
||||
|
||||
|
||||
Section("Element Call remote URL override") {
|
||||
TextField("Leave empty to use EC locally", text: $elementCallURLOverrideString)
|
||||
.autocorrectionDisabled(true)
|
||||
@@ -182,7 +182,7 @@ struct DeveloperOptionsScreen: View {
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar { toolbar }
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var effectsView: some View {
|
||||
if showConfetti {
|
||||
@@ -192,7 +192,7 @@ struct DeveloperOptionsScreen: View {
|
||||
.task { await removeConfettiAfterDelay() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func removeConfettiAfterDelay() async {
|
||||
try? await Task.sleep(for: .seconds(4))
|
||||
showConfetti = false
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ final class NotificationSettingsEditScreenCoordinator: CoordinatorProtocol {
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(NotificationSettingsEditScreen(context: viewModel.context))
|
||||
}
|
||||
@@ -48,7 +48,7 @@ final class NotificationSettingsEditScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
private func presentRoomNotificationSettings(roomID: String) async {
|
||||
guard case let .joined(roomProxy) = await parameters.userSession.clientProxy.roomForIdentifier(roomID) else { return }
|
||||
|
||||
|
||||
let roomNotificationSettingsParameters = RoomNotificationSettingsScreenCoordinatorParameters(navigationStackCoordinator: parameters.navigationStackCoordinator,
|
||||
notificationSettingsProxy: parameters.userSession.clientProxy.notificationSettings,
|
||||
roomProxy: roomProxy,
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ struct NotificationSettingsEditScreenViewState: BindableState {
|
||||
var pendingMode: NotificationSettingsEditScreenDefaultMode?
|
||||
var roomsWithUserDefinedMode: [NotificationSettingsEditScreenRoom] = []
|
||||
var canPushEncryptedEvents = false
|
||||
|
||||
|
||||
func isSelected(mode: NotificationSettingsEditScreenDefaultMode) -> Bool {
|
||||
pendingMode == nil && defaultMode == mode
|
||||
}
|
||||
@@ -101,7 +101,7 @@ struct NotificationSettingsEditScreenRoom: Identifiable, Equatable {
|
||||
let roomId: String?
|
||||
|
||||
var name = ""
|
||||
|
||||
|
||||
var avatar: RoomAvatar
|
||||
|
||||
var notificationMode: RoomNotificationModeProxy?
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ struct NotificationSettingsEditScreen: View {
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
||||
private var notificationModeSection: some View {
|
||||
Section {
|
||||
ForEach(context.viewState.availableDefaultModes, id: \.self) { mode in
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ struct NotificationSettingsEditScreenRoomCell: View {
|
||||
struct NotificationSettingsEditScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
let summaryProvider = RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))
|
||||
|
||||
|
||||
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
|
||||
notificationSettingsProxy.getRoomsWithUserDefinedRulesReturnValue = []
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ final class NotificationSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
init(parameters: NotificationSettingsScreenCoordinatorParameters) {
|
||||
self.parameters = parameters
|
||||
|
||||
|
||||
viewModel = NotificationSettingsScreenViewModel(appSettings: parameters.appSettings,
|
||||
userNotificationCenter: parameters.userNotificationCenter,
|
||||
notificationToneManager: NotificationToneManager(appSettings: parameters.appSettings),
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ struct NotificationSettingsScreenViewState: BindableState {
|
||||
var showSystemNotificationsAlert: Bool {
|
||||
bindings.enableNotifications && isUserPermissionGranted == false
|
||||
}
|
||||
|
||||
|
||||
var settings: NotificationSettingsScreenSettings?
|
||||
var applyingChange = false
|
||||
var selectedAlertTone: NotificationTone
|
||||
|
||||
+15
-15
@@ -21,11 +21,11 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
@CancellableTask private var fetchSettingsTask: Task<Void, Error>?
|
||||
private let notificationTonePreviewer: AudioPlayerProtocol
|
||||
private let notificationToneManager: NotificationToneManagerProtocol
|
||||
|
||||
|
||||
var actions: AnyPublisher<NotificationSettingsScreenViewModelAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
|
||||
init(appSettings: AppSettings,
|
||||
userNotificationCenter: UserNotificationCenterProtocol,
|
||||
notificationToneManager: NotificationToneManagerProtocol,
|
||||
@@ -44,7 +44,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
isModallyPresented: isModallyPresented,
|
||||
selectedAlertTone: appSettings.selectedNotificationTone ?? NotificationToneManager.defaultElementXMessageTone,
|
||||
availableCustomTones: notificationToneManager.customTones()))
|
||||
|
||||
|
||||
// Listen for changes to AppSettings.
|
||||
appSettings.$enableNotifications
|
||||
.weakAssign(to: \.state.bindings.enableNotifications, on: self)
|
||||
@@ -75,7 +75,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
func fetchInitialContent() {
|
||||
fetchSettings()
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
override func process(viewAction: NotificationSettingsScreenViewAction) {
|
||||
@@ -117,11 +117,11 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
||||
func readSystemAuthorizationStatus() async {
|
||||
state.isUserPermissionGranted = await userNotificationCenter.authorizationStatus() == .authorized
|
||||
}
|
||||
|
||||
|
||||
func toggleNotifications() {
|
||||
appSettings.enableNotifications.toggle()
|
||||
}
|
||||
@@ -161,11 +161,11 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
// Group chats
|
||||
var groupChatsMode = await notificationSettingsProxy.getDefaultRoomNotificationMode(isEncrypted: false, isOneToOne: false)
|
||||
let encryptedGroupChatsMode = await notificationSettingsProxy.getDefaultRoomNotificationMode(isEncrypted: true, isOneToOne: false)
|
||||
|
||||
|
||||
// Direct chats
|
||||
var directChatsMode = await notificationSettingsProxy.getDefaultRoomNotificationMode(isEncrypted: false, isOneToOne: true)
|
||||
let encryptedDirectChatsMode = await notificationSettingsProxy.getDefaultRoomNotificationMode(isEncrypted: true, isOneToOne: true)
|
||||
|
||||
|
||||
// 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`)
|
||||
if groupChatsMode != encryptedGroupChatsMode {
|
||||
@@ -183,16 +183,16 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
let roomMentionsEnabled = try? await notificationSettingsProxy.isRoomMentionEnabled()
|
||||
let callEnabled = try? await notificationSettingsProxy.isCallEnabled()
|
||||
let invitationsEnabled = try? await notificationSettingsProxy.isInviteForMeEnabled()
|
||||
|
||||
|
||||
guard !Task.isCancelled else { return }
|
||||
|
||||
|
||||
let notificationSettings = NotificationSettingsScreenSettings(groupChatsMode: groupChatsMode,
|
||||
directChatsMode: directChatsMode,
|
||||
roomMentionsEnabled: roomMentionsEnabled,
|
||||
callsEnabled: callEnabled,
|
||||
invitationsEnabled: invitationsEnabled,
|
||||
inconsistentSettings: inconsistentSettings)
|
||||
|
||||
|
||||
state.settings = notificationSettings
|
||||
state.bindings.roomMentionsEnabled = notificationSettings.roomMentionsEnabled ?? false
|
||||
state.bindings.callsEnabled = notificationSettings.callsEnabled ?? false
|
||||
@@ -234,7 +234,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
}
|
||||
state.applyingChange = false
|
||||
}
|
||||
|
||||
|
||||
func enableCalls(_ enable: Bool) async {
|
||||
guard let notificationSettings = state.settings else { return }
|
||||
do {
|
||||
@@ -260,7 +260,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
}
|
||||
state.applyingChange = false
|
||||
}
|
||||
|
||||
|
||||
/// Imports the audio file at the given sandboxed URL into the tone library, refreshing the available custom tones on success.
|
||||
private func addCustomAlertTone(from urlResult: Result<URL, Error>) async {
|
||||
do {
|
||||
@@ -290,13 +290,13 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
MXLog.error("Error setting selected alert tone to designated location in filesystem: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Deletes the given tones from the library. If the active tone is deleted, the selection resets to the default.
|
||||
private func deleteAlertTones(_ tones: [NotificationTone]) {
|
||||
for tone in tones {
|
||||
do {
|
||||
try notificationToneManager.deleteCustomTone(tone)
|
||||
|
||||
|
||||
if tone == state.selectedAlertTone {
|
||||
appSettings.selectedNotificationTone = nil
|
||||
}
|
||||
|
||||
+13
-13
@@ -38,7 +38,7 @@ struct NotificationSettingsScreen: View {
|
||||
if context.viewState.settings?.invitationsEnabled != nil {
|
||||
additionalSettingsSection
|
||||
}
|
||||
|
||||
|
||||
soundSelectionSection
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ struct NotificationSettingsScreen: View {
|
||||
.compoundListSectionHeader()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var mentionsSection: some View {
|
||||
Section {
|
||||
ListRow(label: .plain(title: L10n.screenNotificationSettingsRoomMentionLabel),
|
||||
@@ -171,7 +171,7 @@ struct NotificationSettingsScreen: View {
|
||||
.compoundListSectionHeader()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var soundSelectionSection: some View {
|
||||
Section {
|
||||
@@ -185,12 +185,12 @@ struct NotificationSettingsScreen: View {
|
||||
Text(L10n.screenNotificationSettingsSoundSectionTitle)
|
||||
.compoundListSectionHeader()
|
||||
}
|
||||
|
||||
|
||||
Section(isExpanded: $context.shouldShowAlertSounds) {
|
||||
presetSoundSelectionSection
|
||||
} header: { }
|
||||
}
|
||||
|
||||
|
||||
private var presetSoundSelectionSection: some View {
|
||||
ForEach(NotificationToneManager.allDefaultAlerts, id: \.filename) { alertTone in
|
||||
ListRow(label: .plain(title: alertTone.label),
|
||||
@@ -199,7 +199,7 @@ struct NotificationSettingsScreen: View {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var customSoundSelectionSection: some View {
|
||||
ForEach(context.viewState.availableCustomTones, id: \.filename) { alertTone in
|
||||
@@ -212,10 +212,10 @@ struct NotificationSettingsScreen: View {
|
||||
let tones = indices.map {
|
||||
context.viewState.availableCustomTones[$0]
|
||||
}
|
||||
|
||||
|
||||
context.send(viewAction: .deleteCustomAlertTones(tones))
|
||||
}
|
||||
|
||||
|
||||
ListRow(label: .plain(title: L10n.screenNotificationSettingsSoundCustomSoundButtonTitle),
|
||||
kind: .button {
|
||||
context.shouldShowCustomAlertTonePicker = true
|
||||
@@ -231,7 +231,7 @@ struct NotificationSettingsScreen: View {
|
||||
context.send(viewAction: .addedCustomAlertTone($0))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var configurationMismatchSection: some View {
|
||||
Section {
|
||||
ListRow(kind: .custom {
|
||||
@@ -278,9 +278,9 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
}
|
||||
notificationSettingsProxy.isRoomMentionEnabledReturnValue = true
|
||||
notificationSettingsProxy.isCallEnabledReturnValue = false
|
||||
|
||||
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "John Doe"))))
|
||||
|
||||
|
||||
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
|
||||
userNotificationCenter: notificationCenter,
|
||||
notificationToneManager: NotificationToneManagerMock(.init()),
|
||||
@@ -310,7 +310,7 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
notificationSettingsProxy.isCallEnabledReturnValue = false
|
||||
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "John Doe"))))
|
||||
|
||||
|
||||
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
|
||||
userNotificationCenter: notificationCenter,
|
||||
notificationToneManager: NotificationToneManagerMock(.init()),
|
||||
@@ -320,7 +320,7 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
viewModel.fetchInitialContent()
|
||||
return viewModel
|
||||
}()
|
||||
|
||||
|
||||
static var previews: some View {
|
||||
NotificationSettingsScreen(context: viewModel.context)
|
||||
.snapshotPreferences(expect: viewModel.context.observe(\.viewState.settings).map { $0 != nil })
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ struct UserDetailsEditScreenViewState: BindableState {
|
||||
var nameDidChange: Bool {
|
||||
bindings.name != currentDisplayName
|
||||
}
|
||||
|
||||
|
||||
var avatarDidChange: Bool {
|
||||
localMedia != nil || selectedAvatarURL != currentAvatarURL
|
||||
}
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ import SwiftUI
|
||||
struct UserDetailsEditScreen: View {
|
||||
@Bindable var context: UserDetailsEditScreenViewModel.Context
|
||||
@FocusState private var focus: Bool
|
||||
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
Section {
|
||||
@@ -55,7 +55,7 @@ struct UserDetailsEditScreen: View {
|
||||
.disabled(!context.viewState.canSave)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var avatar: some View {
|
||||
Button {
|
||||
context.send(viewAction: .presentMediaSource)
|
||||
@@ -76,7 +76,7 @@ struct UserDetailsEditScreen: View {
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.listRowBackground(Color.clear)
|
||||
}
|
||||
|
||||
|
||||
private var nameSection: some View {
|
||||
Section {
|
||||
ListRow(label: .plain(title: L10n.screenEditProfileDisplayNamePlaceholder),
|
||||
|
||||
Reference in New Issue
Block a user