Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♿️ - Settings #546

Merged
merged 23 commits into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3768fbe
Accessibility - Settings - Dismiss button (#532)
dusi Dec 20, 2018
9217fd3
Accessibility - Settings - Rows (#534)
dusi Dec 21, 2018
d3a8246
Add accessibility hint in case email is unverified (#535)
dusi Jan 3, 2019
e232781
Accessibility - Settings - Change email - Current email (#537)
dusi Jan 4, 2019
e3b2ce7
♿️ - Settings - Message Banner (#539)
dusi Jan 8, 2019
a82ddec
Expose delete my kickstarter account button instead of the label (#549)
dusi Jan 9, 2019
b6836d9
♿️- Settings - Notifications - Heading (#550)
cdolm92 Jan 9, 2019
89dc48d
♿️- Settings - Change email / Change password input fields (#545)
cdolm92 Jan 16, 2019
35c3ac2
♿️ - Settings - Switch Toggle Rows (#544)
dusi Jan 17, 2019
02d5ff3
♿️ - Settings - Notifications - Daily Digest picker bug (#547)
cdolm92 Jan 17, 2019
ac4d24e
♿️ - Settings > Notifications - Manage project notifications + Email …
dusi Jan 18, 2019
9649519
Merge branch 'master' into a11y-settings
dusi Jan 31, 2019
93d80ca
Infer UIView.AnimationOptions type
dusi Jan 31, 2019
5be8d8f
Combine conditions
dusi Jan 31, 2019
d9728de
Use more functional return
justinswart Jan 31, 2019
b8133be
Merge branch 'a11y-settings' of https://github.com/kickstarter/ios-os…
dusi Jan 31, 2019
853567a
Fix Github's messed up suggestion
dusi Jan 31, 2019
e303019
Update accessibility label to better match with localized server errors
dusi Jan 31, 2019
9d3e92d
Add localized string
dusi Feb 4, 2019
59542ff
Use localized string
dusi Feb 4, 2019
1ceb7c3
Align filter
dusi Feb 6, 2019
8b8f21b
Remove unused call to setNeedsLayout
dusi Feb 6, 2019
c10d5ae
Merge branch 'master' into a11y-settings
dusi Feb 6, 2019
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
27 changes: 18 additions & 9 deletions Kickstarter-iOS/DataSources/SettingsPrivacyDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,40 @@ internal enum Section: Int {
case deleteAccount
}

public struct SettingsPrivacyCellValue {
public struct SettingsPrivacyStaticCellValue {
let cellType: SettingsStaticCellType
let user: User
}

public struct SettingsPrivacySwitchCellValue {
let cellType: SettingsSwitchCellType
let user: User
}

internal final class SettingsPrivacyDataSource: ValueCellDataSource {
internal func load(user: User) {
self.set(values: [user],
let followingCellValue = SettingsPrivacyStaticCellValue(cellType: .following, user: user)

self.set(values: [followingCellValue],
cellClass: SettingsFollowCell.self,
inSection: Section.following.rawValue)

self.set(values: [Strings.When_following_is_on_you_can_follow_the_acticity_of_others()],
self.set(values: [followingCellValue.cellType.description],
cellClass: SettingsPrivacyStaticCell.self,
inSection: Section.followingFooter.rawValue)

self.set(values: [user],
let recommendationsCellValue = SettingsPrivacyStaticCellValue(cellType: .recommendations, user: user)

self.set(values: [recommendationsCellValue],
cellClass: SettingsPrivacyRecommendationCell.self,
inSection: Section.recommendations.rawValue)

self.set(values: [Strings.We_use_your_activity_internally_to_make_recommendations_for_you()],
self.set(values: [recommendationsCellValue.cellType.description],
cellClass: SettingsPrivacyStaticCell.self,
inSection: Section.recommendationsFooter.rawValue)

if !user.isCreator {
let cellValue = SettingsPrivacyCellValue(user: user, cellType: .privacy)
let cellValue = SettingsPrivacySwitchCellValue(cellType: .privacy, user: user)

self.set(values: [cellValue],
cellClass: SettingsPrivacySwitchCell.self,
Expand All @@ -54,17 +63,17 @@ internal final class SettingsPrivacyDataSource: ValueCellDataSource {

internal override func configureCell(tableCell cell: UITableViewCell, withValue value: Any) {
switch (cell, value) {
case let (cell as SettingsFollowCell, value as User):
case let (cell as SettingsFollowCell, value as SettingsPrivacyStaticCellValue):
cell.configureWith(value: value)
case let (cell as SettingsPrivacyRecommendationCell, value as User):
case let (cell as SettingsPrivacyRecommendationCell, value as SettingsPrivacyStaticCellValue):
cell.configureWith(value: value)
case let (cell as SettingsPrivacyRequestDataCell, value as User):
cell.configureWith(value: value)
case let (cell as SettingsPrivacyDeleteAccountCell, value as User):
cell.configureWith(value: value)
case let (cell as SettingsPrivacyStaticCell, value as String):
cell.configureWith(value: value)
case let (cell as SettingsPrivacySwitchCell, value as SettingsPrivacyCellValue):
case let (cell as SettingsPrivacySwitchCell, value as SettingsPrivacySwitchCellValue):
cell.configureWith(value: value)
default:
fatalError("Unrecognized combo (\(cell), \(value)).")
Expand Down
3 changes: 2 additions & 1 deletion Kickstarter-iOS/Locales/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
"Manage_your_pledge_below" = "Manage your pledge below";
"Manage_your_reward" = "Manage your reward";
"Message_backer" = "Message backer";
"Message_banner.accessibility.Double_tap_to_dismiss" = "Double tap to dismiss.";
"Message_creator" = "Message creator";
"Message_user_name" = "Message %{user_name}…";
"Messages" = "Messages";
Expand Down Expand Up @@ -1449,4 +1450,4 @@
"updates_count_updates.zero" = "%{updates_count} updates";
"via_custom" = "via custom";
"via_external" = "via external";
"via_kickstarter" = "via Kickstarter";
"via_kickstarter" = "via Kickstarter";
3 changes: 2 additions & 1 deletion Kickstarter-iOS/Locales/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
"Manage_your_pledge_below" = "Folgenden Beitrag verwalten";
"Manage_your_reward" = "Belohnung verwalten";
"Message_backer" = "Nachricht an Unterstützer senden";
"Message_banner.accessibility.Double_tap_to_dismiss" = "Double tap to dismiss.";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently this string is not localized, but based on the conversation we had with @peat it should not delay merging stuff to master/:shipit:

"Message_creator" = "Nachricht an Projektgründer senden";
"Message_user_name" = "Nachricht senden an %{user_name}…";
"Messages" = "Nachrichten";
Expand Down Expand Up @@ -1449,4 +1450,4 @@
"updates_count_updates.zero" = "%{updates_count} Updates";
"via_custom" = "Benutzerdefiniert";
"via_external" = "Extern";
"via_kickstarter" = "über Kickstarter";
"via_kickstarter" = "über Kickstarter";
3 changes: 2 additions & 1 deletion Kickstarter-iOS/Locales/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
"Manage_your_pledge_below" = "Administra tu contribución:";
"Manage_your_reward" = "Administra tu recompensa";
"Message_backer" = "Enviar mensaje a patrocinador";
"Message_banner.accessibility.Double_tap_to_dismiss" = "Double tap to dismiss.";
"Message_creator" = "Enviar mensaje al creador";
"Message_user_name" = "Mensaje a %{user_name}…";
"Messages" = "Mensajes";
Expand Down Expand Up @@ -1449,4 +1450,4 @@
"updates_count_updates.zero" = "%{updates_count} actualizaciones";
"via_custom" = "a través de personalizados";
"via_external" = "a través de externos";
"via_kickstarter" = "a través de Kickstarter";
"via_kickstarter" = "a través de Kickstarter";
3 changes: 2 additions & 1 deletion Kickstarter-iOS/Locales/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
"Manage_your_pledge_below" = "Gérer mon engagement";
"Manage_your_reward" = "Gérer votre récompense";
"Message_backer" = "Envoyer un message au contributeur";
"Message_banner.accessibility.Double_tap_to_dismiss" = "Double tap to dismiss.";
"Message_creator" = "Envoyer un message au créateur";
"Message_user_name" = "Envoyer un message à %{user_name}";
"Messages" = "Messages";
Expand Down Expand Up @@ -1449,4 +1450,4 @@
"updates_count_updates.zero" = "%{updates_count} actus";
"via_custom" = "sites référents personnalisés";
"via_external" = "sites référents externes";
"via_kickstarter" = "Kickstarter";
"via_kickstarter" = "Kickstarter";
3 changes: 2 additions & 1 deletion Kickstarter-iOS/Locales/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
"Manage_your_pledge_below" = "以下のプレッジを変更";
"Manage_your_reward" = "リワードの管理";
"Message_backer" = "バッカーにメッセージする";
"Message_banner.accessibility.Double_tap_to_dismiss" = "Double tap to dismiss.";
"Message_creator" = "クリエーターにメッセージする";
"Message_user_name" = "%{user_name} にメッセージ";
"Messages" = "メッセージ";
Expand Down Expand Up @@ -1449,4 +1450,4 @@
"updates_count_updates.zero" = "%{updates_count} 件のアップデート";
"via_custom" = "リファラー経由";
"via_external" = "外部を経由";
"via_kickstarter" = "kickstarterを経由";
"via_kickstarter" = "kickstarterを経由";
6 changes: 4 additions & 2 deletions Kickstarter-iOS/Views/Cells/FindFriendsCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ final class FindFriendsCell: UITableViewCell, ValueCell, NibLoading {
private let viewModel: FindFriendsCellViewModelType = FindFriendsCellViewModel()

func configureWith(value: SettingsCellValue) {
let user = value.user
self.viewModel.inputs.configure(with: user)
_ = self
|> \.accessibilityTraits .~ value.cellType.accessibilityTraits

self.viewModel.inputs.configure(with: value.user)
}

override func bindViewModel() {
Expand Down
12 changes: 6 additions & 6 deletions Kickstarter-iOS/Views/Cells/ProjectNotificationCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ internal final class ProjectNotificationCell: UITableViewCell, ValueCell {
@IBOutlet fileprivate weak var notificationSwitch: UISwitch!
@IBOutlet fileprivate weak var separatorView: UIView!

internal override func awakeFromNib() {
internal override func awakeFromNib() {
super.awakeFromNib()

self.notificationSwitch.addTarget(
self,
action: #selector(notificationTapped),
for: UIControl.Event.valueChanged
)
_ = self
|> \.accessibilityElements .~ [self.notificationSwitch]

self.notificationSwitch.addTarget(self, action: #selector(notificationTapped), for: .valueChanged)
}

internal override func bindStyles() {
Expand All @@ -46,6 +45,7 @@ internal final class ProjectNotificationCell: UITableViewCell, ValueCell {
super.bindViewModel()

self.nameLabel.rac.text = self.viewModel.outputs.name
self.notificationSwitch.rac.accessibilityLabel = self.viewModel.outputs.name
self.notificationSwitch.rac.on = self.viewModel.outputs.notificationOn

self.viewModel.outputs.notifyDelegateOfSaveError
Expand Down
12 changes: 11 additions & 1 deletion Kickstarter-iOS/Views/Cells/SettingsAccountWarningCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ final class SettingsAccountWarningCell: UITableViewCell, ValueCell, NibLoading {
@IBOutlet fileprivate weak var warningIconImage: UIImageView!

func configureWith(value shouldHideAlertIcon: Bool) {
_ = self
|> \.accessibilityTraits .~ .button

_ = self.warningIconImage
|> \.isHidden .~ shouldHideAlertIcon
|> \.isHidden .~ shouldHideAlertIcon

if !shouldHideAlertIcon {
_ = self
|> \.accessibilityHint %~ { _ in
Strings.Email_unverified()
}
}
}

override func bindStyles() {
Expand Down
21 changes: 19 additions & 2 deletions Kickstarter-iOS/Views/Cells/SettingsFollowCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,21 @@ internal final class SettingsFollowCell: UITableViewCell, ValueCell {
@IBOutlet fileprivate weak var followingSwitch: UISwitch!
@IBOutlet fileprivate var separatorView: [UIView]!

internal func configureWith(value user: User) {
self.viewModel.inputs.configureWith(user: user)
override func awakeFromNib() {
super.awakeFromNib()

_ = self
|> \.accessibilityElements .~ [self.followingSwitch]

_ = self.followingSwitch
|> \.accessibilityLabel %~ { _ in Strings.Following() }
}

internal func configureWith(value: SettingsPrivacyStaticCellValue) {
self.viewModel.inputs.configureWith(user: value.user)

_ = self.followingSwitch
|> \.accessibilityHint .~ value.cellType.description
}

internal override func bindStyles() {
Expand Down Expand Up @@ -63,6 +76,10 @@ internal final class SettingsFollowCell: UITableViewCell, ValueCell {
self.followingSwitch.rac.on = self.viewModel.outputs.followingPrivacyOn
}

func toggleOn(animated: Bool = true) {
self.followingSwitch.setOn(true, animated: animated)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is true hard-coded here 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. So this method could be more generic (i.e. toggle(on: Bool, animated: Bool)) but since we only ever need to toggle back ON we have used more specific function named toggleOn which implies that we're switching the toggle ON...hence setOn(true, ...)

}

@IBAction func followingPrivacySwitchTapped(_ followingPrivacySwitch: UISwitch) {
self.viewModel.inputs.followTapped(on: followingPrivacySwitch.isOn)
}
Expand Down
17 changes: 13 additions & 4 deletions Kickstarter-iOS/Views/Cells/SettingsNewslettersCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,28 @@ internal final class SettingsNewslettersCell: UITableViewCell, ValueCell {

public weak var delegate: SettingsNewslettersCellDelegate?

func configureWith(value: (newsletter: Newsletter, user: User)) {
override func awakeFromNib() {
super.awakeFromNib()

_ = self
|> \.accessibilityElements .~ [self.newslettersSwitch]
}

func configureWith(value: (newsletter: Newsletter, user: User)) {
self.viewModel.inputs.configureWith(value: value)

_ = self.newslettersSwitch
|> \.accessibilityLabel .~ value.newsletter.displayableName
|> \.accessibilityHint .~ value.newsletter.displayableDescription

_ = self.newslettersLabel
|> UILabel.lens.text %~ { _ in value.newsletter.displayableName }
|> \.text .~ value.newsletter.displayableName

_ = self.newslettersDescriptionLabel
|> UILabel.lens.text %~ { _ in value.newsletter.displayableDescription }
|> \.text .~ value.newsletter.displayableDescription
}

override func bindStyles() {

_ = self.separatorViews
||> separatorStyle

Expand Down
21 changes: 17 additions & 4 deletions Kickstarter-iOS/Views/Cells/SettingsNewslettersTopCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ final internal class SettingsNewslettersTopCell: UITableViewCell, ValueCell {

public weak var delegate: SettingsNewslettersTopCellDelegate?

override func awakeFromNib() {
super.awakeFromNib()

_ = self
|> \.accessibilityElements .~ [self.newsletterSwitch]

_ = self.descriptionLabel
|> \.text %~ { _ in Strings.Stay_up_to_date_newsletter() }

_ = self.newsletterSwitch
|> \.accessibilityLabel %~ { _ in Strings.profile_settings_newsletter_subscribe_all() }
|> \.accessibilityHint %~ { _ in Strings.Stay_up_to_date_newsletter() }

_ = self.titleLabel
|> \.text %~ { _ in Strings.profile_settings_newsletter_subscribe_all() }
}

func configureWith(value: User) {
self.viewModel.inputs.configureWith(value: value)
}
Expand All @@ -29,9 +46,6 @@ final internal class SettingsNewslettersTopCell: UITableViewCell, ValueCell {

_ = self.descriptionLabel
|> settingsDescriptionLabelStyle
|> UILabel.lens.text %~ { _ in
Strings.Stay_up_to_date_newsletter()
}

_ = self.newsletterSwitch
|> settingsSwitchStyle
Expand All @@ -41,7 +55,6 @@ final internal class SettingsNewslettersTopCell: UITableViewCell, ValueCell {

_ = self.titleLabel
|> settingsTitleLabelStyle
|> UILabel.lens.text %~ { _ in Strings.profile_settings_newsletter_subscribe_all() }
}

override func bindViewModel() {
Expand Down
5 changes: 3 additions & 2 deletions Kickstarter-iOS/Views/Cells/SettingsNotificationCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ final class SettingsNotificationCell: UITableViewCell, NibLoading, ValueCell {

viewModel.inputs.configure(with: cellValue)

_ = self
|> \.accessibilityTraits .~ cellValue.cellType.accessibilityTraits

_ = titleLabel
|> UILabel.lens.text .~ cellValue.cellType.title

Expand Down Expand Up @@ -95,8 +98,6 @@ final class SettingsNotificationCell: UITableViewCell, NibLoading, ValueCell {
self.projectCountLabel.rac.text = viewModel.outputs.projectCountText
self.pushNotificationsButton.rac.selected = viewModel.outputs.pushNotificationsEnabled
self.pushNotificationsButton.rac.hidden = viewModel.outputs.pushNotificationButtonIsHidden
self.projectCountLabel.rac.accessibilityHint = viewModel.outputs
.manageProjectNotificationsButtonAccessibilityHint

viewModel.outputs.enableButtonAnimation
.observeForUI()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ final class SettingsNotificationPickerCell: UITableViewCell, NibLoading, ValueCe
func configureWith(value: SettingsNotificationCellValue) {
self.viewModel.inputs.configure(with: value)

_ = self
|> \.accessibilityTraits .~ value.cellType.accessibilityTraits

_ = titleLabel
|> UILabel.lens.text .~ value.cellType.title
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ internal final class SettingsPrivacyDeleteAccountCell: UITableViewCell, ValueCel
internal override func awakeFromNib() {
super.awakeFromNib()

_ = self
|> \.accessibilityElements .~ [self.deleteAccountButton]

_ = self.deleteAccountButton
|> \.accessibilityLabel %~ { _ in Strings.Delete_my_Kickstarter_Account() }

self.deleteAccountButton.addTarget(self, action: #selector(deleteAccountTapped), for: .touchUpInside)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,21 @@ internal final class SettingsPrivacyRecommendationCell: UITableViewCell, ValueCe
@IBOutlet fileprivate weak var recommendationsSwitch: UISwitch!
@IBOutlet fileprivate var separatorView: [UIView]!

internal func configureWith(value user: User) {
self.viewModel.inputs.configureWith(user: user)
override func awakeFromNib() {
super.awakeFromNib()

_ = self
|> \.accessibilityElements .~ [self.recommendationsSwitch]

_ = self.recommendationsSwitch
|> \.accessibilityLabel %~ { _ in Strings.Recommendations() }
}

internal func configureWith(value: SettingsPrivacyStaticCellValue) {
self.viewModel.inputs.configureWith(user: value.user)

_ = self.recommendationsSwitch
|> \.accessibilityHint .~ value.cellType.description
}

internal override func bindStyles() {
Expand Down
7 changes: 7 additions & 0 deletions Kickstarter-iOS/Views/Cells/SettingsPrivacyStaticCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import UIKit
internal final class SettingsPrivacyStaticCell: UITableViewCell, ValueCell {
@IBOutlet fileprivate weak var privacyInfoLabel: UILabel!

override func awakeFromNib() {
super.awakeFromNib()

_ = self
|> \.accessibilityElementsHidden .~ true
}

func configureWith(value: String) {
_ = self.privacyInfoLabel
|> UILabel.lens.text %~ { _ in value }
Expand Down
Loading