Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import UIKit

final class TranslationLanguageCell: UICollectionViewListCell, ThemeApplicable {
private var details: PreferredLanguageDetails?

func configure(with details: PreferredLanguageDetails, theme: Theme) {
self.details = details
var content = defaultContentConfiguration()
content.text = details.mainText
content.secondaryText = details.subtitleText
contentConfiguration = content
accessories = []
accessibilityLabel = details.mainText
applyTheme(theme: theme)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,7 @@ final class TranslationPickerSettingsViewController: UIViewController,
)
}

let languageReg = UICollectionView.CellRegistration<
TranslationLanguageCell, TranslationSettingsItem
> { [weak self] cell, _, item in
guard let self, case let .language(details) = item else { return }
cell.configure(with: details, theme: themeManager.getCurrentTheme(for: windowUUID))
if details.isDeviceLanguage {
cell.accessories = [.reorder(displayed: .whenEditing)]
} else {
cell.accessories = [
.delete(displayed: .whenEditing, actionHandler: { [weak self] in
guard let self else { return }
store.dispatch(TranslationSettingsViewAction(
languageCode: details.code,
windowUUID: windowUUID,
actionType: TranslationSettingsViewActionType.removeLanguage
))
}),
.reorder(displayed: .whenEditing)
]
}
}
let languageReg = makeLanguageCellRegistration()

let addLanguageReg = UICollectionView.CellRegistration<
TranslationAddLanguageCell, TranslationSettingsItem
Expand Down Expand Up @@ -279,6 +259,39 @@ final class TranslationPickerSettingsViewController: UIViewController,
return dataSource
}

private func makeLanguageCellRegistration(
) -> UICollectionView.CellRegistration<TranslationLanguageCell, TranslationSettingsItem> {
UICollectionView.CellRegistration { [weak self] cell, _, item in
guard let self, case let .language(details) = item else { return }
cell.configure(with: details, theme: themeManager.getCurrentTheme(for: windowUUID))
if details.isDeviceLanguage {
cell.accessories = [.reorder(displayed: .whenEditing)]
} else {
let deleteActionHandler = { [weak self] in
guard let self else { return }
store.dispatch(TranslationSettingsViewAction(
languageCode: details.code,
windowUUID: windowUUID,
actionType: TranslationSettingsViewActionType.removeLanguage
))
}
cell.accessories = [
.delete(displayed: .whenEditing, actionHandler: deleteActionHandler),
.reorder(displayed: .whenEditing)
]
cell.accessibilityCustomActions = [
UIAccessibilityCustomAction(
name: .Settings.Translation.PreferredLanguages.RemoveLanguageA11yAction,
actionHandler: { _ in
deleteActionHandler()
return true
}
)
]
}
}
}

// MARK: - Toggle actions

@objc private func didToggleTranslations(_ sender: UISwitch) {
Expand Down
6 changes: 6 additions & 0 deletions firefox-ios/Shared/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3388,6 +3388,12 @@ extension String {
value: "Add Language…",
comment: "Row label in the preferred languages list that opens the language picker to add a new preferred language for translation."
)
public static let RemoveLanguageA11yAction = MZLocalizedString(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this being a new string the feature shouldn't be made available to the end user until v151. Can you can confirm that this is behind a feature flag and no experiment will be running for this until v151?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct. The feature flag is .translationLanguagePicker.

key: "Settings.Translation.PreferredLanguages.RemoveLanguageA11yAction.v151",
tableName: "Settings",
value: "Delete",
comment: "VoiceOver custom action label on a preferred language row in the Translation settings screen, used to remove that language from the list."
)
}

public struct AutoTranslate {
Expand Down
Loading