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

πŸ‘©β€πŸ”¬ [Investment Day] Add Smart Invert Support #645

Merged
merged 4 commits into from
Apr 9, 2019
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
5 changes: 5 additions & 0 deletions Kickstarter-iOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ internal final class AppDelegate: UIResponder, UIApplicationDelegate {
UIView.doBadSwizzleStuff()
UIViewController.doBadSwizzleStuff()

if #available(iOS 11, *) {
// swiftlint:disable:next line_length
UIImageView.appearance(whenContainedInInstancesOf: [UITabBar.self]).accessibilityIgnoresInvertColors = true
}

AppEnvironment.replaceCurrentEnvironment(
AppEnvironment.fromStorage(
ubiquitousStore: NSUbiquitousKeyValueStore.default,
Expand Down
6 changes: 6 additions & 0 deletions Kickstarter-iOS/Views/Cells/ActivityFriendBackingCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ internal final class ActivityFriendBackingCell: UITableViewCell, ValueCell {
_ = self.containerView
|> UIView.lens.layoutMargins .~ .init(all: Styles.grid(2))

_ = self.friendImageView
|> ignoresInvertColorsImageViewStyle

_ = self.fundingProgressContainerView
|> UIView.lens.backgroundColor .~ .ksr_navy_400

Expand All @@ -83,6 +86,9 @@ internal final class ActivityFriendBackingCell: UITableViewCell, ValueCell {
|> UILabel.lens.font .~ .ksr_title1(size: 18)
|> UILabel.lens.textColor .~ .ksr_soft_black

_ = self.projectImageView
|> ignoresInvertColorsImageViewStyle

_ = self.projectTextContainerView
|> UIView.lens.alpha .~ 0.96
|> UIView.lens.layoutMargins .~ .init(topBottom: Styles.gridHalf(5),
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ActivityFriendFollowCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ internal final class ActivityFriendFollowCell: UITableViewCell, ValueCell {
_ = self.containerView
|> UIView.lens.layoutMargins .~ .init(topBottom: Styles.grid(3), leftRight: Styles.grid(2))

_ = self.friendImageView
|> ignoresInvertColorsImageViewStyle

_ = self.friendLabel
|> UILabel.lens.textColor .~ .ksr_soft_black

Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ActivityProjectStatusCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ internal final class ActivityProjectStatusCell: UITableViewCell, ValueCell {
|> UILabel.lens.font .~ .ksr_title1(size: 18)
|> UILabel.lens.textColor .~ .ksr_soft_black

_ = self.projectImageView
|> ignoresInvertColorsImageViewStyle

_ = self.textBackgroundView
|> UIView.lens.alpha .~ 0.96
|> UIView.lens.layoutMargins .~ .init(all: Styles.grid(2))
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ActivitySampleBackingCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ internal final class ActivitySampleBackingCell: UITableViewCell, ValueCell {
_ = self.backerImageAndInfoStackView
|> UIStackView.lens.spacing .~ Styles.grid(2)

_ = self.backerImageView
|> ignoresInvertColorsImageViewStyle

_ = self.backingTitleLabel
|> activitySampleBackingTitleLabelStyle

Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ActivitySampleFollowCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ internal final class ActivitySampleFollowCell: UITableViewCell, ValueCell {
_ = self.friendImageAndFollowStackView
|> UIStackView.lens.spacing .~ Styles.grid(2)

_ = self.friendImageView
|> ignoresInvertColorsImageViewStyle

_ = self.seeAllActivityButton
|> activitySampleSeeAllActivityButtonStyle
}
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ActivitySampleProjectCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ internal final class ActivitySampleProjectCell: UITableViewCell, ValueCell {
_ = self.projectSubtitleAndTitleStackView
|> UIStackView.lens.spacing .~ Styles.gridHalf(1)

_ = self.projectImageView
|> ignoresInvertColorsImageViewStyle

_ = self.projectSubtitleLabel
|> activitySampleProjectSubtitleLabelStyle

Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ActivitySurveyResponseCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ internal final class ActivitySurveyResponseCell: UITableViewCell, ValueCell {
_ = self.containerView
|> UIView.lens.layoutMargins .~ .init(all: Styles.grid(2))

_ = self.creatorImageView
|> ignoresInvertColorsImageViewStyle

_ = self.creatorNameLabel
|> UILabel.lens.font .~ .ksr_headline(size: 13)
|> UILabel.lens.textColor .~ .ksr_soft_black
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ActivityUpdateCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ internal final class ActivityUpdateCell: UITableViewCell, ValueCell {
|> UILabel.lens.font .~ .ksr_subhead()
|> UILabel.lens.textColor .~ .ksr_text_dark_grey_400

_ = self.projectImageView
|> ignoresInvertColorsImageViewStyle

_ = self.projectNameLabel
|> UILabel.lens.font .~ .ksr_headline(size: 14)
|> UILabel.lens.textColor .~ .ksr_text_navy_600
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ internal final class BackerDashboardEmptyStateCell: UITableViewCell, ValueCell {
|> UILabel.lens.font .~ UIFont.ksr_headline(size: 21.0)

_ = self.iconImageView
|> UIImageView.lens.tintColor .~ .ksr_soft_black
|> UIImageView.lens.tintColor .~ .ksr_soft_black
}
}
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/BackerDashboardProjectCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ internal final class BackerDashboardProjectCell: UITableViewCell, ValueCell {
|> UIView.lens.backgroundColor .~ .ksr_soft_black
|> UIView.lens.alpha .~ 0.15

_ = self.projectImageView
|> ignoresInvertColorsImageViewStyle

_ = self.savedIconImageView
|> UIImageView.lens.tintColor .~ .init(white: 1.0, alpha: 0.99)
}
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/CommentCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ internal final class CommentCell: UITableViewCell, ValueCell {
|> UITableViewCell.lens.contentView.layoutMargins .~
.init(topBottom: Styles.grid(3), leftRight: Styles.grid(2))

_ = self.avatarImageView
|> ignoresInvertColorsImageViewStyle

_ = self.bodyTextView
|> UITextView.lens.isScrollEnabled .~ false
|> UITextView.lens.textContainerInset .~ UIEdgeInsets.zero
Expand Down
6 changes: 6 additions & 0 deletions Kickstarter-iOS/Views/Cells/DiscoveryPostcardCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ internal final class DiscoveryPostcardCell: UITableViewCell, ValueCell {
_ = self.metadataBackgroundView
|> cardStyle()

_ = self.projectImageView
|> ignoresInvertColorsImageViewStyle

_ = self.projectInfoStackView
|> UIStackView.lens.spacing .~ Styles.grid(4)

Expand Down Expand Up @@ -197,6 +200,9 @@ internal final class DiscoveryPostcardCell: UITableViewCell, ValueCell {
_ = self.socialAvatarImageView
|> UIImageView.lens.layer.shouldRasterize .~ true

_ = self.socialAvatarImageView
|> ignoresInvertColorsImageViewStyle

_ = self.socialLabel
|> UILabel.lens.numberOfLines .~ 2
|> UILabel.lens.textColor .~ .ksr_text_navy_600
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/FindFriendsFriendFollowCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ internal final class FindFriendsFriendFollowCell: UITableViewCell, ValueCell {
override func bindStyles() {
super.bindStyles()

_ = self.avatarImageView
|> ignoresInvertColorsImageViewStyle

_ = self.friendNameLabel
|> UILabel.lens.textColor .~ .ksr_soft_black
|> UILabel.lens.font .~ UIFont.ksr_headline(size: 14.0)
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/MessageCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ internal final class MessageCell: UITableViewCell, ValueCell {
: .init(topBottom: Styles.grid(3), leftRight: Styles.grid(2))
}

_ = self.avatarImageView
|> ignoresInvertColorsImageViewStyle

_ = self.bodyTextView
|> UITextView.lens.textColor .~ .ksr_dark_grey_500
|> UITextView.lens.font .~ UIFont.ksr_subhead(size: 14.0)
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/MessageThreadCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ internal final class MessageThreadCell: UITableViewCell, ValueCell {
: .init(topBottom: Styles.grid(3), leftRight: Styles.grid(2))
}

_ = self.avatarImageView
|> ignoresInvertColorsImageViewStyle

_ = self.bodyLabel
|> UILabel.lens.textColor .~ .ksr_dark_grey_500
|> UILabel.lens.font .~ UIFont.ksr_subhead(size: 14.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ internal final class MostPopularSearchProjectCell: UITableViewCell, ValueCell {
_ = self.percentFundedLabel
|> UILabel.lens.font .~ .ksr_headline(size: 14)

_ = self.projectImageView
|> ignoresInvertColorsImageViewStyle

_ = self.projectInfoStackView
|> UIStackView.lens.spacing .~ Styles.grid(2)

Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ProjectActivityBackingCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ internal final class ProjectActivityBackingCell: UITableViewCell, ValueCell {
}
|> UITableViewCell.lens.accessibilityHint %~ { _ in Strings.Opens_pledge_info() }

_ = self.backerImageView
|> ignoresInvertColorsImageViewStyle

_ = self.backingButton
|> projectActivityFooterButton
|> UIButton.lens.title(for: .normal) %~ { _ in Strings.dashboard_activity_pledge_info() }
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ProjectActivityCommentCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ internal final class ProjectActivityCommentCell: UITableViewCell, ValueCell {
}
|> UITableViewCell.lens.accessibilityHint %~ { _ in Strings.Opens_comments() }

_ = self.authorImageView
|> ignoresInvertColorsImageViewStyle

_ = self.backingButton
|> projectActivityFooterButton
|> UIButton.lens.title(for: .normal) %~ { _ in Strings.dashboard_activity_pledge_info() }
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ProjectBannerCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ internal final class ProjectBannerCell: UITableViewCell, ValueCell {
}

internal override func bindStyles() {
_ = self.projectImageView
|> ignoresInvertColorsImageViewStyle

_ = self.projectNameLabel
|> UILabel.lens.textColor .~ .white
|> UILabel.lens.font .~ .ksr_title1(size: 16)
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ProjectPamphletMainCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ internal final class ProjectPamphletMainCell: UITableViewCell, ValueCell {
|> UILabel.lens.font .~ UIFont.ksr_caption2().italicized
|> UILabel.lens.numberOfLines .~ 2

_ = self.creatorImageView
|> ignoresInvertColorsImageViewStyle

_ = self.creatorButton
|> UIButton.lens.accessibilityHint %~ { _ in Strings.Opens_creator_profile() }

Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Cells/ProjectPamphletMinimalCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ internal final class ProjectPamphletMinimalCell: UITableViewCell, ValueCell {
|> UIImageView.lens.contentMode .~ .scaleAspectFit
|> UIImageView.lens.backgroundColor .~ .ksr_soft_black

_ = self.projectImageView
|> ignoresInvertColorsImageViewStyle

_ = self.projectNameLabel
|> UILabel.lens.font %~~ { _, label in
label.traitCollection.isRegularRegular
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ internal final class BackerDashboardViewController: UIViewController {

_ = self |> baseControllerStyle()

_ = self.avatarImageView
|> ignoresInvertColorsImageViewStyle

_ = self.navigationItem
|> UINavigationItem.lens.title %~ { _ in Strings.tabbar_profile() }

Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Controllers/BackingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ internal final class BackingViewController: UIViewController {
|> baseControllerStyle()
|> UIViewController.lens.title %~ { _ in Strings.project_view_button() }

_ = self.backerAvatarImageView
|> ignoresInvertColorsImageViewStyle

_ = self.contentView
|> UIView.lens.layoutMargins .~ UIEdgeInsets(top: Styles.grid(5), left: Styles.grid(2),
bottom: Styles.grid(4), right: Styles.grid(2))
Expand Down
3 changes: 3 additions & 0 deletions Kickstarter-iOS/Views/Controllers/VideoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public final class VideoViewController: UIViewController {
_ = self.projectImageView
|> UIImageView.lens.accessibilityElementsHidden .~ true

_ = self.projectImageView
|> ignoresInvertColorsImageViewStyle

_ = self.videoOverlayView
|> UIView.lens.backgroundColor .~ .black
}
Expand Down
9 changes: 9 additions & 0 deletions Library/Styles/BaseStyles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum Styles {
}

public typealias ButtonStyle = (UIButton) -> UIButton
public typealias ImageViewStyle = (UIImageView) -> UIImageView
public typealias LabelStyle = (UILabel) -> UILabel
public typealias StackViewStyle = (UIStackView) -> UIStackView
public typealias TableViewStyle = (UITableView) -> UITableView
Expand Down Expand Up @@ -135,6 +136,14 @@ public let formFieldStyle: TextFieldStyle = { (textField: UITextField) in
|> \.tintColor .~ UIColor.ksr_green_700
}

public let ignoresInvertColorsImageViewStyle: ImageViewStyle = { (imageView: UIImageView) in
if #available(iOS 11, *) {
return imageView
|> \.accessibilityIgnoresInvertColors .~ true
}
return imageView
}

public let separatorStyle: ViewStyle = { (view: UIView) in
view
|> \.backgroundColor .~ UIColor.ksr_grey_400
Expand Down