Skip to content
14 changes: 14 additions & 0 deletions WireUI/Sources/WireLocators/Locators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public enum Locators {
// We are keeping the current title+field identifiers for now to avoid
// changing existing references across the app.
case accountHeader = "Account"
case pictureCell
case colorCell
case conversationBackgroundSwitch = "ConversationBackgroundSwitch"
case nameField = "NameField"
case nameFieldDisabled = "NameFieldDisabled"
case usernameField = "UsernameField"
Expand All @@ -136,6 +139,13 @@ public enum Locators {

}

public enum ThemeSettingsPage: AutoPrefixedEnum {

case lightOption
case darkOption
case systemOption
}

public enum ActiveConversationPage: String {

case videoCallBarButton
Expand All @@ -147,6 +157,7 @@ public enum Locators {
case sharedDriveButton
case ephemeralTimeSelectionButton
case message
case linkPreviewCell = "LinkPreviewCell"
case imageCell
case videoCell
case videoPlayButton
Expand Down Expand Up @@ -180,6 +191,7 @@ public enum Locators {
case showOtherRowButton
case pingButton
case guestsArePresent = "Guests are present"
case conversationBackground
case openOngoingCallButton

}
Expand Down Expand Up @@ -317,6 +329,8 @@ public enum Locators {

public enum OptionsOnSettingsPage: String {

case theme = "Theme"
case themeCell
case lockWithPasscode = "Lock With Passcode"
case createLinkPreviews = "Create Link Previews"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ class UserImageView: AvatarImageView, UserObserving {
let updateBlock = {
self.avatar = avatar
self.container.backgroundColor = self.containerBackgroundColor(for: user)
self.accessibilityValue = switch avatar {
case .image:
"image"
case .text:
"initials"
}
}

if animated, !ProcessInfo.processInfo.isRunningTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import WireCommonComponents
import WireDataModel
import WireDesign
import WireFoundation
import WireLocators
import WireLogging
import WireMainNavigationUI
import WireMessagingDomain
Expand Down Expand Up @@ -252,6 +253,7 @@ final class ConversationContentViewController: UIViewController {
tableView.delaysContentTouches = false
tableView.keyboardDismissMode = AutomationHelper.sharedHelper
.disableInteractiveKeyboardDismissal ? .none : .interactive
tableView.accessibilityIdentifier = Locators.ActiveConversationPage.conversationBackground.rawValue

setupMentionsResultsView()

Expand Down Expand Up @@ -296,9 +298,11 @@ final class ConversationContentViewController: UIViewController {
}
guard let color, userDefaults.bool(forKey: .conversationBackground) else {
set(color: SemanticColors.View.backgroundConversationView)
tableView.accessibilityValue = "default"
return
}
set(color: color.accentColor.conversationBackgroundColor)
tableView.accessibilityValue = color.accentColor.name
}

@objc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ final class ProfileHeaderViewController: UIViewController {
imageView.showsInitialsOnly = options.contains(.showInitialsOnly)
imageView.userSession = userSession
imageView.user = user
updateProfilePictureAccessibilityValue()

if !ProcessInfo.processInfo.isRunningTests, let session = userSession as? ZMUserSession {
userObserver = UserChangeInfo.add(observer: self, for: user, in: session)
Expand Down Expand Up @@ -521,6 +522,9 @@ extension ProfileHeaderViewController: UserObserving {
userStatus.isProteusVerified = changeInfo.user.isVerified
updateE2EICertifiedStatus()
}
if changeInfo.imageMediumDataChanged || changeInfo.imageSmallProfileDataChanged {
updateProfilePictureAccessibilityValue()
}
}
}

Expand Down Expand Up @@ -549,3 +553,13 @@ extension ProfileHeaderViewController {
}

}

private extension ProfileHeaderViewController {

func updateProfilePictureAccessibilityValue() {
let hasProfileImage = !imageView.showsInitialsOnly &&
(user.previewImageData != nil || user.completeImageData != nil)
imageView.accessibilityValue = hasProfileImage ? "image" : "initials"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ class SettingsAppearanceCellDescriptor: SettingsGroupCellDescriptorType, Setting

init(
text: String,
identifier: String? = .none,
previewGenerator: PreviewGeneratorType? = .none,
presentationStyle: PresentationStyle,
presentationAction: @escaping (_ sender: UIView) -> UIViewController?,
settingsCoordinator: AnySettingsCoordinator
) {
self.text = text
self.identifier = identifier
self.previewGenerator = previewGenerator
self.presentationStyle = presentationStyle
self.presentationAction = presentationAction
Expand All @@ -63,6 +65,7 @@ class SettingsAppearanceCellDescriptor: SettingsGroupCellDescriptorType, Setting
func featureCell(_ cell: SettingsCellType) {
if let tableCell = cell as? SettingsAppearanceCell {
tableCell.configure(with: .appearance(title: text))
tableCell.accessibilityIdentifier = identifier

if let previewGenerator {
tableCell.type = previewGenerator(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func == (left: SettingsCellDescriptorType, right: SettingsCellDescriptorType) ->
}

typealias PreviewGeneratorType = (SettingsCellDescriptorType) -> SettingsCellPreview
typealias AccessibilityValueGeneratorType = (SettingsCellDescriptorType) -> String?

protocol SettingsGroupCellDescriptorType: SettingsCellDescriptorType {
var viewController: UIViewController? { get set }
Expand Down Expand Up @@ -191,6 +192,7 @@ final class SettingsGroupCellDescriptor: SettingsInternalGroupCellDescriptorType
let icon: StyleKitIcon?

let previewGenerator: PreviewGeneratorType?
let accessibilityValueGenerator: AccessibilityValueGeneratorType?

weak var group: (any SettingsGroupCellDescriptorType)?

Expand All @@ -210,6 +212,7 @@ final class SettingsGroupCellDescriptor: SettingsInternalGroupCellDescriptorType
style: InternalScreenStyle = .grouped,
identifier: String? = .none,
previewGenerator: PreviewGeneratorType? = .none,
accessibilityValueGenerator: AccessibilityValueGeneratorType? = .none,
icon: StyleKitIcon? = nil,
accessibilityBackButtonText: String,
settingsTopLevelMenuItem: SettingsTopLevelMenuItem?,
Expand All @@ -221,6 +224,7 @@ final class SettingsGroupCellDescriptor: SettingsInternalGroupCellDescriptorType
self.style = style
self.identifier = identifier
self.previewGenerator = previewGenerator
self.accessibilityValueGenerator = accessibilityValueGenerator
self.icon = icon
self.accessibilityBackButtonText = accessibilityBackButtonText
self.settingsTopLevelMenuItem = settingsTopLevelMenuItem
Expand All @@ -237,7 +241,8 @@ final class SettingsGroupCellDescriptor: SettingsInternalGroupCellDescriptorType
cell.icon = icon
if let cell = cell as? SettingsTableCell {
cell.showDisclosureIndicatorAccessoryView()
cell.accessibilityIdentifier = settingsTopLevelMenuItem?.accessibilityID
cell.accessibilityIdentifier = settingsTopLevelMenuItem?.accessibilityID ?? identifier
cell.accessibilityValue = accessibilityValueGenerator?(self)
cell.accessibilityTraits = .button
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import WireDataModel
import WireDesign
import WireDomain
import WireFoundation
import WireLocators
import WireLogging
import WireNetwork
import WireSettingsUI
Expand Down Expand Up @@ -325,6 +326,7 @@ extension SettingsCellDescriptorFactory {
}
return SettingsAppearanceCellDescriptor(
text: L10n.Localizable.Self.Settings.AccountPictureGroup.picture.capitalized,
identifier: Locators.AccountSettingsPage.pictureCell.rawValue,
previewGenerator: previewGenerator,
presentationStyle: .alert,
presentationAction: presentationAction,
Expand All @@ -335,6 +337,7 @@ extension SettingsCellDescriptorFactory {
private func colorElement() -> any SettingsCellDescriptorType {
SettingsAppearanceCellDescriptor(
text: L10n.Localizable.Self.Settings.AccountPictureGroup.color.capitalized,
identifier: Locators.AccountSettingsPage.colorCell.rawValue,
previewGenerator: colorElementPreviewGenerator,
presentationStyle: .navigation,
presentationAction: colorElementPresentationAction,
Expand All @@ -348,7 +351,7 @@ extension SettingsCellDescriptorFactory {
settingsProperty:
settingsPropertyFactory.property(.conversationBackground),
inverse: false,
identifier: "ConversationBackgroundSwitch"
identifier: Locators.AccountSettingsPage.conversationBackgroundSwitch.rawValue
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import LocalAuthentication
import UIKit
import WireCommonComponents
import WireLocators
import WireSettingsUI
import WireSyncEngine

Expand Down Expand Up @@ -263,12 +264,31 @@ extension SettingsCellDescriptorFactory {
settingsCoordinator: AnySettingsCoordinator,
userSession: UserSession
) -> SettingsCellDescriptorType {
let accessibilityValue: AccessibilityValueGeneratorType = { _ in
let value = property.value().value() as? Int
let option = value.flatMap { SettingsColorScheme(rawValue: $0) } ?? .defaultPreference
#if DEBUG
return "\(option.keyValueString)|\(ColorScheme.default.variant.keyValueString)"
#else
return option.displayString
#endif
}
let cells = SettingsColorScheme.allCases.map { option -> SettingsPropertySelectValueCellDescriptor in
let identifier = switch option {
case .light:
Locators.ThemeSettingsPage.lightOption.rawValue
case .dark:
Locators.ThemeSettingsPage.darkOption.rawValue
case .system:
Locators.ThemeSettingsPage.systemOption.rawValue
}

return SettingsPropertySelectValueCellDescriptor(
settingsProperty: property,
value: SettingsPropertyValue(option.rawValue),
title: option.displayString
title: option.displayString,
identifier: identifier,
accessibilityValueGenerator: accessibilityValue
)
}

Expand All @@ -282,8 +302,9 @@ extension SettingsCellDescriptorFactory {
return SettingsGroupCellDescriptor(
items: [section],
title: property.propertyName.settingsPropertyLabelText,
identifier: nil,
identifier: Locators.OptionsOnSettingsPage.themeCell.rawValue,
previewGenerator: preview,
accessibilityValueGenerator: accessibilityValue,
accessibilityBackButtonText: L10n.Accessibility.OptionsSettings.BackButton.description,
settingsTopLevelMenuItem: nil,
settingsCoordinator: settingsCoordinator,
Expand Down Expand Up @@ -400,3 +421,16 @@ extension SettingsCellDescriptorFactory {
!SecurityFlags.forceEncryptionAtRest.isEnabled && settingsPropertyFactory.isAppLockAvailable
}
}

#if DEBUG
private extension ColorSchemeVariant {
var keyValueString: String {
switch self {
case .dark:
"dark"
case .light:
"light"
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class SettingsPropertySelectValueCellDescriptor: SettingsPropertyCellDescr
let value: SettingsPropertyValue
let title: String
let identifier: String?
let accessibilityValueGenerator: AccessibilityValueGeneratorType?

typealias SelectActionType = (SettingsPropertySelectValueCellDescriptor) -> Void
let selectAction: SelectActionType?
Expand All @@ -39,19 +40,25 @@ final class SettingsPropertySelectValueCellDescriptor: SettingsPropertyCellDescr
value: SettingsPropertyValue,
title: String,
identifier: String? = .none,
accessibilityValueGenerator: AccessibilityValueGeneratorType? = .none,
selectAction: SelectActionType? = .none,
backgroundColor: UIColor? = .none
) {
self.settingsProperty = settingsProperty
self.value = value
self.title = title
self.identifier = identifier
self.accessibilityValueGenerator = accessibilityValueGenerator
self.selectAction = selectAction
self.backgroundColor = backgroundColor
}

func featureCell(_ cell: SettingsCellType) {
cell.titleText = title
if let valueCell = cell as? SettingsTableCell {
valueCell.accessibilityIdentifier = identifier
valueCell.accessibilityValue = accessibilityValueGenerator?(self)
}
if let valueCell = cell as? SettingsValueCell {
valueCell.accessoryType = settingsProperty.value() == value ? .checkmark : .none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,21 @@ final class SettingsAppearanceCell: SettingsTableCell, CellConfigurationConfigur
iconImageView.image = image
iconImageView.backgroundColor = UIColor.clear
subtitleLabel.text = nil
accessibilityValue = "image"
titleLabelToIconInset.isActive = true
accessibilityTraits = [.button]
case let .color(color):
iconImageView.backgroundColor = color
iconImageView.image = .none
subtitleLabel.text = AccentColor.current.name
accessibilityValue = AccentColor.current.name
titleLabelToIconInset.isActive = true
accessibilityTraits = [.button]
default:
subtitleLabel.text = nil
iconImageView.backgroundColor = UIColor.clear
iconImageView.image = .none
accessibilityValue = nil
titleLabelToIconInset.isActive = false
accessibilityTraits = []
}
Expand Down
Loading
Loading