Skip to content

Commit

Permalink
Using UIImageView instead of BPKIconView for airline logo (#1628)
Browse files Browse the repository at this point in the history
* Using UIImageView instead of BPKIconView for airline logo

* Updated with PR comments

* Fixed snapshot colours

* Used correct color value

* Updated snapshot after color change
  • Loading branch information
JLau-Sky committed Apr 6, 2023
1 parent f16af78 commit 7f0410f
Show file tree
Hide file tree
Showing 21 changed files with 21 additions and 16 deletions.
17 changes: 11 additions & 6 deletions Backpack/FlightLeg/Classes/BPKFlightLeg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import Foundation
import UIKit

public final class BPKFlightLeg: UIView {
private let airlineLogoSize = 24.0

private let departureArrivalTime: String
private let nextDayArrival: String?
private let flightDescription: NSAttributedString
Expand All @@ -28,7 +30,7 @@ public final class BPKFlightLeg: UIView {
private let duration: String
private let operatedBy: String?
private let warning: String?
private let carrierLogo: BPKIconName
private let carrierLogo: UIImage?

private let departureArrivalTimeLabel: BPKLabel = {
let departureArrtvalTimeLabel = BPKLabel()
Expand Down Expand Up @@ -73,8 +75,8 @@ public final class BPKFlightLeg: UIView {
warningLabel.lineBreakMode = .byWordWrapping
return warningLabel
}()
private let carrierLogoIcon: BPKLargeIconView = {
let carrierLogoIcon = BPKLargeIconView()
private let carrierLogoIcon: UIImageView = {
let carrierLogoIcon = UIImageView()
carrierLogoIcon.tintColor = BPKColor.textOnLightColor
return carrierLogoIcon
}()
Expand All @@ -97,7 +99,7 @@ public final class BPKFlightLeg: UIView {
duration: String,
operatedBy: String?,
warning: String?,
carrierLogo: BPKIconName
carrierLogo: UIImage?
) {
self.departureArrivalTime = departureArrivalTime
self.nextDayArrival = nextDayArrival
Expand Down Expand Up @@ -146,15 +148,18 @@ public final class BPKFlightLeg: UIView {
let verticalStackView = UIView()
verticalStackView.translatesAutoresizingMaskIntoConstraints = false

carrierLogoIcon.iconName = carrierLogo
carrierLogoIcon.image = carrierLogo
leadingStackView.addArrangedSubview(carrierLogoIcon)
verticalStackView.addSubview(leadingStackView)

NSLayoutConstraint.activate([
leadingStackView.topAnchor.constraint(equalTo: verticalStackView.topAnchor, constant: BPKSpacingSm),
leadingStackView.bottomAnchor.constraint(equalTo: verticalStackView.bottomAnchor),
leadingStackView.leadingAnchor.constraint(equalTo: verticalStackView.leadingAnchor),
leadingStackView.trailingAnchor.constraint(equalTo: verticalStackView.trailingAnchor)
leadingStackView.trailingAnchor.constraint(equalTo: verticalStackView.trailingAnchor),

carrierLogoIcon.widthAnchor.constraint(equalToConstant: airlineLogoSize),
carrierLogoIcon.heightAnchor.constraint(equalToConstant: airlineLogoSize)
])
return verticalStackView
}
Expand Down
10 changes: 5 additions & 5 deletions Backpack/Tests/SnapshotTests/BPKFlightLegSnapshotTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class BPKFlightLegSnapshotTest: XCTestCase {
duration: String = "7h 55m",
operatedBy: String? = nil,
warning: String? = nil,
carrierLogo: BPKIconName = .airline
carrierLogo: UIImage? = BPKIcon.makeLargeIcon(name: .airline, color: BPKColor.textOnLightColor)
) -> UIView {
let parentView = UIView(frame: .zero)
parentView.backgroundColor = BPKColor.surfaceDefaultColor
Expand Down Expand Up @@ -106,7 +106,7 @@ final class BPKFlightLegSnapshotTest: XCTestCase {
highlightStopsInfo: true,
operatedBy: "Operated by WestJet",
warning: "Change airports in London",
carrierLogo: .airline
carrierLogo: BPKIcon.makeLargeIcon(name: .airline, color: BPKColor.textOnLightColor)
)
assertSnapshot(flightLegStackView)
}
Expand All @@ -121,7 +121,7 @@ final class BPKFlightLegSnapshotTest: XCTestCase {
duration: "7h 55m",
operatedBy: "Operated by WestJet",
warning: "Change airports in London",
carrierLogo: .airlineMultiple
carrierLogo: BPKIcon.makeLargeIcon(name: .airlineMultiple, color: BPKColor.textOnLightColor)
)
assertSnapshot(flightLegStackView)
}
Expand All @@ -137,7 +137,7 @@ final class BPKFlightLegSnapshotTest: XCTestCase {
operatedBy: "Operated by WestJet Operated by WestJet Operated" +
"by WestJet Operated by WestJet Operated by WestJet",
warning: "Change airports in London",
carrierLogo: .airlineMultiple
carrierLogo: BPKIcon.makeLargeIcon(name: .airlineMultiple, color: BPKColor.textOnLightColor)
)
assertSnapshot(flightLegStackView)
}
Expand All @@ -152,7 +152,7 @@ final class BPKFlightLegSnapshotTest: XCTestCase {
duration: "نس 10د",
operatedBy: "Operated by WestJet",
warning: "Change airports in London",
carrierLogo: .airlineMultiple
carrierLogo: BPKIcon.makeLargeIcon(name: .airlineMultiple, color: BPKColor.textOnLightColor)
)
assertSnapshot(flightLegStackView)
}
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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class BPKFlightLegViewController: UIViewController {
duration: String,
operatedBy: String? = nil,
warning: String? = nil,
carrierLogo: BPKIconName
carrierLogo: UIImage? = nil
) -> BPKFlightLeg {

return BPKFlightLeg(
Expand All @@ -103,7 +103,7 @@ class BPKFlightLegViewController: UIViewController {
flightDescription: defaultDescription,
stopsInfo: "Direct",
duration: "7h 55m",
carrierLogo: .airline
carrierLogo: BPKIcon.makeLargeIcon(name: .airline, color: BPKColor.textOnLightColor)
)
}

Expand All @@ -117,7 +117,7 @@ class BPKFlightLegViewController: UIViewController {
duration: "7h 55m",
operatedBy: "Operated by WestJet",
warning: "Change airports in London",
carrierLogo: .airlineMultiple
carrierLogo: BPKIcon.makeLargeIcon(name: .airlineMultiple, color: BPKColor.textOnLightColor)
)
}

Expand All @@ -132,7 +132,7 @@ class BPKFlightLegViewController: UIViewController {
operatedBy: "Operated by WestJet Operated by WestJet Operated" +
"by WestJet Operated by WestJet Operated by WestJet",
warning: "Change airports in London",
carrierLogo: .airlineMultiple
carrierLogo: BPKIcon.makeLargeIcon(name: .airlineMultiple, color: BPKColor.textOnLightColor)
)
}

Expand All @@ -146,7 +146,7 @@ class BPKFlightLegViewController: UIViewController {
duration: "7h 55m",
operatedBy: "Operated by WestJet",
warning: "Change airports in London",
carrierLogo: .airlineMultiple
carrierLogo: BPKIcon.makeLargeIcon(name: .airlineMultiple, color: BPKColor.textOnLightColor)
)
}

Expand Down

0 comments on commit 7f0410f

Please sign in to comment.