diff --git a/Sources/TripKit/core/Loc+TripKit.swift b/Sources/TripKit/core/Loc+TripKit.swift index 9845f6f96..592ad3b80 100644 --- a/Sources/TripKit/core/Loc+TripKit.swift +++ b/Sources/TripKit/core/Loc+TripKit.swift @@ -101,6 +101,14 @@ extension Loc { // MARK: - Permission manager + public static var AuthorizationNeeded: String { + NSLocalizedString("Authorisation needed", tableName: "Shared", bundle: .tripKit, comment: "Authorisation needed title") + } + + public static var AuthorizationNeededDescription: String { + NSLocalizedString("Access to this feature has been restricted for your device. Please check the Settings app > General > Restrictions or ask your device provider.", tableName: "Shared", bundle: .tripKit, comment: "Authorization restricted alert message") + } + public static var ContactsAuthorizationAlertText: String { return NSLocalizedString("You previously denied this app access to your contacts. Please go to the Settings app > Privacy > Contacts and authorise this app to use this feature.", tableName: "Shared", bundle: .tripKit, comment: "Contacts authorisation needed text") } diff --git a/Sources/TripKit/managers/TKPermissionManager+AuthorizationAlert.swift b/Sources/TripKit/managers/TKPermissionManager+AuthorizationAlert.swift index 12933004c..000984728 100644 --- a/Sources/TripKit/managers/TKPermissionManager+AuthorizationAlert.swift +++ b/Sources/TripKit/managers/TKPermissionManager+AuthorizationAlert.swift @@ -48,13 +48,13 @@ extension TKPermissionManager { case .denied: message = authorizationAlertText case .restricted: - message = NSLocalizedString("Access to this feature has been restricted for your device. Please check the Settings app > General > Restrictions or ask your device provider.", tableName: "Shared", bundle: .tripKit, comment: "Authorization restricted alert message") + message = Loc.AuthorizationNeededDescription case .notDetermined, .authorized: return } - let alert = UIAlertController(title: NSLocalizedString("Authorisation needed", tableName: "Shared", bundle: .tripKit, comment: "Authorisation needed title"), message: message, preferredStyle: .alert) + let alert = UIAlertController(title: Loc.AuthorizationNeeded, message: message, preferredStyle: .alert) if let handler = openSettingsHandler { alert.addAction(.init(title: Loc.Cancel, style: .cancel)) diff --git a/Sources/TripKit/model/TKBookingTypes.swift b/Sources/TripKit/model/TKBookingTypes.swift index 122050c33..9e373680d 100644 --- a/Sources/TripKit/model/TKBookingTypes.swift +++ b/Sources/TripKit/model/TKBookingTypes.swift @@ -186,6 +186,7 @@ public enum TKBooking { case multipleSelections = "MULTIPLE_CHOICE" case requestReturnTrip = "RETURN_TRIP" case number = "NUMBER" + case terms = "TERMS" } public enum ReturnTripDateValue: Hashable { @@ -200,6 +201,7 @@ public enum TKBooking { case longText(String) case returnTripDate(ReturnTripDateValue) case number(Int, min: Int?, max: Int?) + case terms(URL, accepted: Bool) } public let required: Bool @@ -215,6 +217,7 @@ public enum TKBooking { case .multipleSelections: return .multipleSelections case .returnTripDate: return .requestReturnTrip case .number: return .number + case .terms: return .terms } } @@ -226,6 +229,7 @@ public enum TKBooking { case title case value case values + case urlValue case minValue case maxValue } @@ -253,10 +257,18 @@ public enum TKBooking { let specifiedReturnDate = try container.decode(String.self, forKey: .value) value = Self.convertStringReturnDateToInputValue(specifiedReturnDate) case .number: + // SIC. `value` is always a string! let rawValue = try container.decode(String.self, forKey: .value) + let number = Int(rawValue) ?? 0 let minValue = try container.decodeIfPresent(Int.self, forKey: .minValue) let maxValue = try container.decodeIfPresent(Int.self, forKey: .maxValue) - value = .number(Int(rawValue) ?? 0, min: minValue, max: maxValue) + value = .number(number, min: minValue, max: maxValue) + case .terms: + // SIC. `value` is always a string! + let rawValue = try container.decode(String.self, forKey: .value) + let accepted = rawValue == "true" + let url = try container.decode(URL.self, forKey: .urlValue) + value = .terms(url, accepted: accepted) } } @@ -278,10 +290,13 @@ public enum TKBooking { try container.encode(optionIds, forKey: .values) case .returnTripDate(let returnDate): try container.encode(returnDate.toString(), forKey: .value) - case .number(let number, let min, let max): + case let .number(number, min, max): try container.encode(String(number), forKey: .value) try container.encode(min, forKey: .minValue) try container.encode(max, forKey: .maxValue) + case let .terms(url, accepted): + try container.encode(accepted, forKey: .value) + try container.encode(url, forKey: .urlValue) } } } diff --git a/Sources/TripKitUI/cards/TKUITripModeByModeCard+Configuration.swift b/Sources/TripKitUI/cards/TKUITripModeByModeCard+Configuration.swift index 421856fc8..27934a563 100644 --- a/Sources/TripKitUI/cards/TKUITripModeByModeCard+Configuration.swift +++ b/Sources/TripKitUI/cards/TKUITripModeByModeCard+Configuration.swift @@ -41,14 +41,15 @@ public protocol TKUITripModeByModePageBuilder { } // MARK: - Default MxM page builder - open class TKUIDefaultPageBuilder: TKUITripModeByModePageBuilder { public init() {} /// The default page builder does nothing during clean up + @MainActor open func cleanUp(existingCards: [TGCard]) {} + @MainActor open func cards(for segment: TKSegment, mapManager: TKUITripMapManager) -> [(TGCard, TKUISegmentMode)] { if segment.order != .regular { return [] diff --git a/Sources/TripKitUI/views/TKUIAutocompletionResultCell.swift b/Sources/TripKitUI/views/TKUIAutocompletionResultCell.swift index 70d1c6f02..b7fbfd5da 100644 --- a/Sources/TripKitUI/views/TKUIAutocompletionResultCell.swift +++ b/Sources/TripKitUI/views/TKUIAutocompletionResultCell.swift @@ -35,7 +35,7 @@ extension UILabel { return } - var attributed = NSMutableAttributedString(string: text, attributes: [ + let attributed = NSMutableAttributedString(string: text, attributes: [ .foregroundColor: textColor, .font: TKStyleManager.customFont(forTextStyle: .body), ])