Skip to content

Commit

Permalink
BPKRating right-to-left fix (#1639)
Browse files Browse the repository at this point in the history
* SONIC-1385: update uikit BPKRating to show 10/4.5 in right to left

* SONIC-1385: update swift ui BPKRating to show 10/4.5 in right to left
  • Loading branch information
dennis-li-skyscanner committed Apr 13, 2023
1 parent 8e6e776 commit 66ea754
Show file tree
Hide file tree
Showing 21 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Backpack-Common/BPKCommonRatingScale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public enum BPKCommonRatingScale {
}

public func displayedScale() -> String {
return String(format: "/%.0f", range.upperBound)
return String(format: "%.0f", range.upperBound)
}
}
5 changes: 5 additions & 0 deletions Backpack-SwiftUI/Rating/Classes/BPKRating.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public struct BPKRating<Content: View>: View {
style: size.fontStyle.ratingValueLabelFontStyle
).layoutPriority(4)
if showScale {
BPKText(
"/",
style: size.fontStyle.ratingScaleLabelFontStyle
).foregroundColor(.textSecondaryColor)
.layoutPriority(3)
BPKText(
ratingScale.displayedScale(),
style: size.fontStyle.ratingScaleLabelFontStyle
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions Backpack/Rating/Classes/BPKRating.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ public class BPKRating: UIView {
return label
}()

private let ratingScaleSlashLabel: BPKLabel = {
let label = BPKLabel(fontStyle: .textCaption)
label.textColor = BPKColor.textSecondaryColor
label.text = "/"
return label
}()

private let titleLabel: BPKLabel = {
let label = BPKLabel(fontStyle: .textLabel1)
label.textColor = BPKColor.textPrimaryColor
Expand Down Expand Up @@ -168,6 +175,7 @@ public class BPKRating: UIView {
].forEach(horizontalStackView.addArrangedSubview(_:))
[
ratingValueLabel,
ratingScaleSlashLabel,
ratingScaleLabel
].forEach(ratingValueAndScaleStackView.addArrangedSubview(_:))

Expand Down Expand Up @@ -196,6 +204,7 @@ public class BPKRating: UIView {

private func updateLookAndFeel() {
ratingScaleLabel.isHidden = !showScale
ratingScaleSlashLabel.isHidden = !showScale
if showScale {
ratingScaleLabel.text = ratingScale.displayedScale()
}
Expand All @@ -211,6 +220,7 @@ public class BPKRating: UIView {
switch size {
case .default:
ratingValueLabel.fontStyle = .textLabel1
ratingScaleSlashLabel.fontStyle = .textCaption
ratingScaleLabel.fontStyle = .textCaption
titleLabel.fontStyle = .textLabel1
subtitleLabel.fontStyle = .textCaption
Expand All @@ -220,6 +230,7 @@ public class BPKRating: UIView {
titleSubtitleStackView.alignment = .lastBaseline
case .large:
ratingValueLabel.fontStyle = .textHero5
ratingScaleSlashLabel.fontStyle = .textBodyDefault
ratingScaleLabel.fontStyle = .textBodyDefault
titleLabel.fontStyle = .textHeading5
subtitleLabel.fontStyle = .textBodyDefault
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 66ea754

Please sign in to comment.