Skip to content

Commit

Permalink
updated preview tests and the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Velin92 committed Dec 13, 2024
1 parent d8ae11b commit 709e9a8
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 28 deletions.
40 changes: 40 additions & 0 deletions ElementX.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ struct RoomDetailsScreenViewState: BindableState {
knockingEnabled && dmRecipient == nil && isKnockableRoom && (canInviteUsers || canKickUsers || canBanUsers)
}

var canSeeSecurityAndPrivacy: Bool {
knockingEnabled && dmRecipient == nil && canEditRolesOrPermissions
}

var mediaBrowserEnabled = false

var canEdit: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ struct RoomDetailsScreen: View {
.onChange(of: context.isFavourite) { _, newValue in
context.send(viewAction: .toggleFavourite(isFavourite: newValue))
}

if context.viewState.canSeeSecurityAndPrivacy {
ListRow(label: .default(title: L10n.screenRoomDetailsSecurityAndPrivacyTitle,
icon: \.lock),
kind: .navigationLink {
context.send(viewAction: .processTapSecurityAndPrivacy)
})
}
}
}

Expand All @@ -225,13 +233,6 @@ struct RoomDetailsScreen: View {
kind: .navigationLink {
context.send(viewAction: .processTapRolesAndPermissions)
})
if context.viewState.knockingEnabled {
ListRow(label: .default(title: L10n.screenRoomDetailsSecurityAndPrivacyTitle,
icon: \.lock),
kind: .navigationLink {
context.send(viewAction: .processTapSecurityAndPrivacy)
})
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType,
case .save:
actionsSubject.send(.done)
case .tryUpdatingEncryption(let updatedValue):
// Once the room is encrypted it can never be turned off
guard !roomProxy.isEncrypted else {
return
}
if updatedValue {
state.bindings.alertInfo = .init(id: .enableEncryption,
title: L10n.screenSecurityAndPrivacyEnableEncryptionAlertTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct SecurityAndPrivacyScreen: View {
Section {
ListRow(label: .plain(title: L10n.screenSecurityAndPrivacyEncryptionToggleTitle),
kind: .toggle(encryptionBinding))
// We don't allow editing the encryption state if the current setting on the server is `enabled`
.disabled(context.viewState.currentSettings.isEncryptionEnabled)
} header: {
Text(L10n.screenSecurityAndPrivacyEncryptionSectionTitle)
.compoundListSectionHeader()
Expand All @@ -73,8 +75,10 @@ struct SecurityAndPrivacyScreen: View {

// MARK: - Previews

struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
// TODO: Add back TestablePreview, this is WIP so running preview tests for it is not necessary
struct SecurityAndPrivacyScreen_Previews: PreviewProvider {
static let inviteOnlyViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(joinRule: .invite)))

static var previews: some View {
NavigationStack {
SecurityAndPrivacyScreen(context: inviteOnlyViewModel.context)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 709e9a8

Please sign in to comment.