Flight leg

This component is for details of a flight journey from an origin to final destination.

Backpack/Flight Leg

Cocoapods class reference view on Github

Default

Day Night

Usage

The BPKFlightLeg component contains nine properties, from which five are mandatory.


                                                
                                                  departureArrivalTime: String,
                                                  nextDayArrival: String?,
                                                  flightDescription: NSAttributedString,
                                                  stopsInfo: String,
                                                  highlightStopsInfo: Bool,
                                                  duration: String,
                                                  operatedBy: String?,
                                                  warning: String?,
                                                  carrierLogo: BPKIconName
  • departureArrivalTime, nextDayArrival, stopsInfo, duration, operatedBy, warning expect Strings;
  • flightDescription expects an attributed string;
  • highlightStopsInfo expects a boolean;
  • carrierLogo expects a BPKIconName.

If a flight has more than one leg (i.e. 1 or more stops), then highlightStopsInfo must be included and be set to true.

BPKFlightLeg Example


                                                
                                                import Backpack
                                                
                                                private let defaultDescription: NSAttributedString = {
                                                    return NSAttributedString(string: "EDI-LHR, British Airways", attributes: BPKFlightLeg.descriptionDefaultAttributes())
                                                }()  
                                                private let highlightedDescription: NSAttributedString = {
                                                    let flightDescriptionString = NSMutableAttributedString(
                                                        string: "LHR-SYD, Emirates", attributes: BPKFlightLeg.descriptionDefaultAttributes())
                                                    let range = (flightDescriptionString.string as NSString).range(of: "SYD")
                                                    flightDescriptionString.addAttributes(BPKFlightLeg.airportHighlightAttributes(), range: range)
                                                
                                                    return flightDescriptionString
                                                }()
                                                
                                                let flightLegComponent = BPKFlightLeg(
                                                    departureArrivalTime: "17:25 - 19:00",
                                                    flightDescription: defaultDescription,
                                                    stopsInfo: "Direct",
                                                    duration: "1h 35m",
                                                    carrierLogo: .airline
                                                )
                                                
                                                let completeFlightLegWithAllPossibleArguments = BPKFlightLeg(
                                                    departureArrivalTime: "22:10 - 08:45",
                                                    nextDayArrival: "+2",
                                                    flightDescription: highlightedDescription,
                                                    stopsInfo: "1 Stop",
                                                    highlightStopsInfo: true,
                                                    duration: "25h 35m",
                                                    operatedBy: "Operated by Emirates",
                                                    warning: "Change airports in Dubai",
                                                    carrierLogo: .airline
                                                )