diff --git a/Modules/Sources/Localizations/Localizations.swift b/Modules/Sources/Localizations/Localizations.swift index 545d5f4..b4fca38 100644 --- a/Modules/Sources/Localizations/Localizations.swift +++ b/Modules/Sources/Localizations/Localizations.swift @@ -33,34 +33,34 @@ import NLocalizationManager import LocalizationManager #endif public final class Localizations: LocalizableModel { - public var printerOutput = PrinterOutput() - public var deliveryType = DeliveryType() - public var searchOrders = SearchOrders() + public var orderDetailNewOrderSection = OrderDetailNewOrderSection() public var units = Units() - public var orderStatus = OrderStatus() - public var settings = Settings() public var defaultSection = DefaultSection() - public var orderDetailNewOrderSection = OrderDetailNewOrderSection() - public var error = Error() + public var deliveryType = DeliveryType() public var login = Login() + public var orderStatus = OrderStatus() + public var error = Error() public var orderDetails = OrderDetails() + public var printerOutput = PrinterOutput() public var printer = Printer() + public var searchOrders = SearchOrders() public var dashboard = Dashboard() + public var settings = Settings() enum CodingKeys: String, CodingKey { - case printerOutput - case deliveryType - case searchOrders + case orderDetailNewOrderSection case units - case orderStatus - case settings case defaultSection = "default" - case orderDetailNewOrderSection - case error + case deliveryType case login + case orderStatus + case error case orderDetails + case printerOutput case printer + case searchOrders case dashboard + case settings } public override init() { super.init() } @@ -68,59 +68,61 @@ public final class Localizations: LocalizableModel { public required init(from decoder: Decoder) throws { super.init() let container = try decoder.container(keyedBy: CodingKeys.self) - printerOutput = try container.decodeIfPresent(PrinterOutput.self, forKey: .printerOutput) ?? printerOutput - deliveryType = try container.decodeIfPresent(DeliveryType.self, forKey: .deliveryType) ?? deliveryType - searchOrders = try container.decodeIfPresent(SearchOrders.self, forKey: .searchOrders) ?? searchOrders + orderDetailNewOrderSection = try container.decodeIfPresent(OrderDetailNewOrderSection.self, forKey: .orderDetailNewOrderSection) ?? orderDetailNewOrderSection units = try container.decodeIfPresent(Units.self, forKey: .units) ?? units - orderStatus = try container.decodeIfPresent(OrderStatus.self, forKey: .orderStatus) ?? orderStatus - settings = try container.decodeIfPresent(Settings.self, forKey: .settings) ?? settings defaultSection = try container.decodeIfPresent(DefaultSection.self, forKey: .defaultSection) ?? defaultSection - orderDetailNewOrderSection = try container.decodeIfPresent(OrderDetailNewOrderSection.self, forKey: .orderDetailNewOrderSection) ?? orderDetailNewOrderSection - error = try container.decodeIfPresent(Error.self, forKey: .error) ?? error + deliveryType = try container.decodeIfPresent(DeliveryType.self, forKey: .deliveryType) ?? deliveryType login = try container.decodeIfPresent(Login.self, forKey: .login) ?? login + orderStatus = try container.decodeIfPresent(OrderStatus.self, forKey: .orderStatus) ?? orderStatus + error = try container.decodeIfPresent(Error.self, forKey: .error) ?? error orderDetails = try container.decodeIfPresent(OrderDetails.self, forKey: .orderDetails) ?? orderDetails + printerOutput = try container.decodeIfPresent(PrinterOutput.self, forKey: .printerOutput) ?? printerOutput printer = try container.decodeIfPresent(Printer.self, forKey: .printer) ?? printer + searchOrders = try container.decodeIfPresent(SearchOrders.self, forKey: .searchOrders) ?? searchOrders dashboard = try container.decodeIfPresent(Dashboard.self, forKey: .dashboard) ?? dashboard + settings = try container.decodeIfPresent(Settings.self, forKey: .settings) ?? settings } public override subscript(key: String) -> LocalizableSection? { switch key { - case CodingKeys.printerOutput.stringValue: return printerOutput - case CodingKeys.deliveryType.stringValue: return deliveryType - case CodingKeys.searchOrders.stringValue: return searchOrders + case CodingKeys.orderDetailNewOrderSection.stringValue: return orderDetailNewOrderSection case CodingKeys.units.stringValue: return units - case CodingKeys.orderStatus.stringValue: return orderStatus - case CodingKeys.settings.stringValue: return settings case CodingKeys.defaultSection.stringValue: return defaultSection - case CodingKeys.orderDetailNewOrderSection.stringValue: return orderDetailNewOrderSection - case CodingKeys.error.stringValue: return error + case CodingKeys.deliveryType.stringValue: return deliveryType case CodingKeys.login.stringValue: return login + case CodingKeys.orderStatus.stringValue: return orderStatus + case CodingKeys.error.stringValue: return error case CodingKeys.orderDetails.stringValue: return orderDetails + case CodingKeys.printerOutput.stringValue: return printerOutput case CodingKeys.printer.stringValue: return printer + case CodingKeys.searchOrders.stringValue: return searchOrders case CodingKeys.dashboard.stringValue: return dashboard + case CodingKeys.settings.stringValue: return settings default: return nil } } - public final class PrinterOutput: LocalizableSection { - public var noteHeader = "" - public var orderNumber = "" - public var warmHeader = "" - public var includeCutlery = "" - public var errorNoDeviceFound = "" - public var otherHeader = "" - public var errorDeviceConnectionFailed = "" - public var coldHeader = "" + public final class OrderDetailNewOrderSection: LocalizableSection { + public var deliveryTimeHeader = "" + public var subheader = "" + public var pickedUpInStoreAt = "" + public var phoneNumberHeader = "" + public var pickupTimeHeader = "" + public var rejectButton = "" + public var customerNameHeader = "" + public var acceptButton = "" + public var header = "" enum CodingKeys: String, CodingKey { - case noteHeader - case orderNumber - case warmHeader - case includeCutlery - case errorNoDeviceFound - case otherHeader - case errorDeviceConnectionFailed - case coldHeader + case deliveryTimeHeader + case subheader + case pickedUpInStoreAt + case phoneNumberHeader + case pickupTimeHeader + case rejectButton + case customerNameHeader + case acceptButton + case header } public override init() { super.init() } @@ -128,38 +130,56 @@ public final class Localizations: LocalizableModel { public required init(from decoder: Decoder) throws { super.init() let container = try decoder.container(keyedBy: CodingKeys.self) - noteHeader = try container.decodeIfPresent(String.self, forKey: .noteHeader) ?? "__noteHeader" - orderNumber = try container.decodeIfPresent(String.self, forKey: .orderNumber) ?? "__orderNumber" - warmHeader = try container.decodeIfPresent(String.self, forKey: .warmHeader) ?? "__warmHeader" - includeCutlery = try container.decodeIfPresent(String.self, forKey: .includeCutlery) ?? "__includeCutlery" - errorNoDeviceFound = try container.decodeIfPresent(String.self, forKey: .errorNoDeviceFound) ?? "__errorNoDeviceFound" - otherHeader = try container.decodeIfPresent(String.self, forKey: .otherHeader) ?? "__otherHeader" - errorDeviceConnectionFailed = try container.decodeIfPresent(String.self, forKey: .errorDeviceConnectionFailed) ?? "__errorDeviceConnectionFailed" - coldHeader = try container.decodeIfPresent(String.self, forKey: .coldHeader) ?? "__coldHeader" + deliveryTimeHeader = try container.decodeIfPresent(String.self, forKey: .deliveryTimeHeader) ?? "__deliveryTimeHeader" + subheader = try container.decodeIfPresent(String.self, forKey: .subheader) ?? "__subheader" + pickedUpInStoreAt = try container.decodeIfPresent(String.self, forKey: .pickedUpInStoreAt) ?? "__pickedUpInStoreAt" + phoneNumberHeader = try container.decodeIfPresent(String.self, forKey: .phoneNumberHeader) ?? "__phoneNumberHeader" + pickupTimeHeader = try container.decodeIfPresent(String.self, forKey: .pickupTimeHeader) ?? "__pickupTimeHeader" + rejectButton = try container.decodeIfPresent(String.self, forKey: .rejectButton) ?? "__rejectButton" + customerNameHeader = try container.decodeIfPresent(String.self, forKey: .customerNameHeader) ?? "__customerNameHeader" + acceptButton = try container.decodeIfPresent(String.self, forKey: .acceptButton) ?? "__acceptButton" + header = try container.decodeIfPresent(String.self, forKey: .header) ?? "__header" } public override subscript(key: String) -> String? { switch key { - case CodingKeys.noteHeader.stringValue: return noteHeader - case CodingKeys.orderNumber.stringValue: return orderNumber - case CodingKeys.warmHeader.stringValue: return warmHeader - case CodingKeys.includeCutlery.stringValue: return includeCutlery - case CodingKeys.errorNoDeviceFound.stringValue: return errorNoDeviceFound - case CodingKeys.otherHeader.stringValue: return otherHeader - case CodingKeys.errorDeviceConnectionFailed.stringValue: return errorDeviceConnectionFailed - case CodingKeys.coldHeader.stringValue: return coldHeader + case CodingKeys.deliveryTimeHeader.stringValue: return deliveryTimeHeader + case CodingKeys.subheader.stringValue: return subheader + case CodingKeys.pickedUpInStoreAt.stringValue: return pickedUpInStoreAt + case CodingKeys.phoneNumberHeader.stringValue: return phoneNumberHeader + case CodingKeys.pickupTimeHeader.stringValue: return pickupTimeHeader + case CodingKeys.rejectButton.stringValue: return rejectButton + case CodingKeys.customerNameHeader.stringValue: return customerNameHeader + case CodingKeys.acceptButton.stringValue: return acceptButton + case CodingKeys.header.stringValue: return header default: return nil } } } - public final class DeliveryType: LocalizableSection { - public var collect = "" - public var delivery = "" + public final class Units: LocalizableSection { + public var ltr = "" + public var kgm = "" + public var clt = "" + public var d70 = "" + public var cmt = "" + public var e14 = "" + public var h87 = "" + public var dlt = "" + public var grm = "" + public var mlt = "" enum CodingKeys: String, CodingKey { - case collect - case delivery + case ltr + case kgm + case clt + case d70 + case cmt + case e14 + case h87 + case dlt + case grm + case mlt } public override init() { super.init() } @@ -167,48 +187,64 @@ public final class Localizations: LocalizableModel { public required init(from decoder: Decoder) throws { super.init() let container = try decoder.container(keyedBy: CodingKeys.self) - collect = try container.decodeIfPresent(String.self, forKey: .collect) ?? "__collect" - delivery = try container.decodeIfPresent(String.self, forKey: .delivery) ?? "__delivery" + ltr = try container.decodeIfPresent(String.self, forKey: .ltr) ?? "__ltr" + kgm = try container.decodeIfPresent(String.self, forKey: .kgm) ?? "__kgm" + clt = try container.decodeIfPresent(String.self, forKey: .clt) ?? "__clt" + d70 = try container.decodeIfPresent(String.self, forKey: .d70) ?? "__d70" + cmt = try container.decodeIfPresent(String.self, forKey: .cmt) ?? "__cmt" + e14 = try container.decodeIfPresent(String.self, forKey: .e14) ?? "__e14" + h87 = try container.decodeIfPresent(String.self, forKey: .h87) ?? "__h87" + dlt = try container.decodeIfPresent(String.self, forKey: .dlt) ?? "__dlt" + grm = try container.decodeIfPresent(String.self, forKey: .grm) ?? "__grm" + mlt = try container.decodeIfPresent(String.self, forKey: .mlt) ?? "__mlt" } public override subscript(key: String) -> String? { switch key { - case CodingKeys.collect.stringValue: return collect - case CodingKeys.delivery.stringValue: return delivery + case CodingKeys.ltr.stringValue: return ltr + case CodingKeys.kgm.stringValue: return kgm + case CodingKeys.clt.stringValue: return clt + case CodingKeys.d70.stringValue: return d70 + case CodingKeys.cmt.stringValue: return cmt + case CodingKeys.e14.stringValue: return e14 + case CodingKeys.h87.stringValue: return h87 + case CodingKeys.dlt.stringValue: return dlt + case CodingKeys.grm.stringValue: return grm + case CodingKeys.mlt.stringValue: return mlt default: return nil } } } - public final class SearchOrders: LocalizableSection { - public var statusCompleted = "" - public var orderStatusHeader = "" - public var statusShipped = "" - public var searchfieldPlaceholder = "" - public var statusAccepted = "" - public var statusRejected = "" - public var statusReady = "" - public var emptyMessage = "" - public var orderDateHeader = "" - public var title = "" - public var customerNameHeader = "" - public var orderNumberHeader = "" - public var statusNew = "" + public final class DefaultSection: LocalizableSection { + public var retry = "" + public var no = "" + public var skip = "" + public var cancel = "" + public var settings = "" + public var previous = "" + public var yes = "" + public var edit = "" + public var back = "" + public var next = "" + public var later = "" + public var save = "" + public var ok = "" enum CodingKeys: String, CodingKey { - case statusCompleted - case orderStatusHeader - case statusShipped - case searchfieldPlaceholder - case statusAccepted - case statusRejected - case statusReady - case emptyMessage - case orderDateHeader - case title - case customerNameHeader - case orderNumberHeader - case statusNew + case retry + case no + case skip + case cancel + case settings + case previous + case yes + case edit + case back + case next + case later + case save + case ok } public override init() { super.init() } @@ -216,64 +252,48 @@ public final class Localizations: LocalizableModel { public required init(from decoder: Decoder) throws { super.init() let container = try decoder.container(keyedBy: CodingKeys.self) - statusCompleted = try container.decodeIfPresent(String.self, forKey: .statusCompleted) ?? "__statusCompleted" - orderStatusHeader = try container.decodeIfPresent(String.self, forKey: .orderStatusHeader) ?? "__orderStatusHeader" - statusShipped = try container.decodeIfPresent(String.self, forKey: .statusShipped) ?? "__statusShipped" - searchfieldPlaceholder = try container.decodeIfPresent(String.self, forKey: .searchfieldPlaceholder) ?? "__searchfieldPlaceholder" - statusAccepted = try container.decodeIfPresent(String.self, forKey: .statusAccepted) ?? "__statusAccepted" - statusRejected = try container.decodeIfPresent(String.self, forKey: .statusRejected) ?? "__statusRejected" - statusReady = try container.decodeIfPresent(String.self, forKey: .statusReady) ?? "__statusReady" - emptyMessage = try container.decodeIfPresent(String.self, forKey: .emptyMessage) ?? "__emptyMessage" - orderDateHeader = try container.decodeIfPresent(String.self, forKey: .orderDateHeader) ?? "__orderDateHeader" - title = try container.decodeIfPresent(String.self, forKey: .title) ?? "__title" - customerNameHeader = try container.decodeIfPresent(String.self, forKey: .customerNameHeader) ?? "__customerNameHeader" - orderNumberHeader = try container.decodeIfPresent(String.self, forKey: .orderNumberHeader) ?? "__orderNumberHeader" - statusNew = try container.decodeIfPresent(String.self, forKey: .statusNew) ?? "__statusNew" + retry = try container.decodeIfPresent(String.self, forKey: .retry) ?? "__retry" + no = try container.decodeIfPresent(String.self, forKey: .no) ?? "__no" + skip = try container.decodeIfPresent(String.self, forKey: .skip) ?? "__skip" + cancel = try container.decodeIfPresent(String.self, forKey: .cancel) ?? "__cancel" + settings = try container.decodeIfPresent(String.self, forKey: .settings) ?? "__settings" + previous = try container.decodeIfPresent(String.self, forKey: .previous) ?? "__previous" + yes = try container.decodeIfPresent(String.self, forKey: .yes) ?? "__yes" + edit = try container.decodeIfPresent(String.self, forKey: .edit) ?? "__edit" + back = try container.decodeIfPresent(String.self, forKey: .back) ?? "__back" + next = try container.decodeIfPresent(String.self, forKey: .next) ?? "__next" + later = try container.decodeIfPresent(String.self, forKey: .later) ?? "__later" + save = try container.decodeIfPresent(String.self, forKey: .save) ?? "__save" + ok = try container.decodeIfPresent(String.self, forKey: .ok) ?? "__ok" } public override subscript(key: String) -> String? { switch key { - case CodingKeys.statusCompleted.stringValue: return statusCompleted - case CodingKeys.orderStatusHeader.stringValue: return orderStatusHeader - case CodingKeys.statusShipped.stringValue: return statusShipped - case CodingKeys.searchfieldPlaceholder.stringValue: return searchfieldPlaceholder - case CodingKeys.statusAccepted.stringValue: return statusAccepted - case CodingKeys.statusRejected.stringValue: return statusRejected - case CodingKeys.statusReady.stringValue: return statusReady - case CodingKeys.emptyMessage.stringValue: return emptyMessage - case CodingKeys.orderDateHeader.stringValue: return orderDateHeader - case CodingKeys.title.stringValue: return title - case CodingKeys.customerNameHeader.stringValue: return customerNameHeader - case CodingKeys.orderNumberHeader.stringValue: return orderNumberHeader - case CodingKeys.statusNew.stringValue: return statusNew + case CodingKeys.retry.stringValue: return retry + case CodingKeys.no.stringValue: return no + case CodingKeys.skip.stringValue: return skip + case CodingKeys.cancel.stringValue: return cancel + case CodingKeys.settings.stringValue: return settings + case CodingKeys.previous.stringValue: return previous + case CodingKeys.yes.stringValue: return yes + case CodingKeys.edit.stringValue: return edit + case CodingKeys.back.stringValue: return back + case CodingKeys.next.stringValue: return next + case CodingKeys.later.stringValue: return later + case CodingKeys.save.stringValue: return save + case CodingKeys.ok.stringValue: return ok default: return nil } } } - public final class Units: LocalizableSection { - public var dlt = "" - public var grm = "" - public var clt = "" - public var kgm = "" - public var mlt = "" - public var cmt = "" - public var d70 = "" - public var ltr = "" - public var h87 = "" - public var e14 = "" + public final class DeliveryType: LocalizableSection { + public var collect = "" + public var delivery = "" enum CodingKeys: String, CodingKey { - case dlt - case grm - case clt - case kgm - case mlt - case cmt - case d70 - case ltr - case h87 - case e14 + case collect + case delivery } public override init() { super.init() } @@ -281,40 +301,42 @@ public final class Localizations: LocalizableModel { public required init(from decoder: Decoder) throws { super.init() let container = try decoder.container(keyedBy: CodingKeys.self) - dlt = try container.decodeIfPresent(String.self, forKey: .dlt) ?? "__dlt" - grm = try container.decodeIfPresent(String.self, forKey: .grm) ?? "__grm" - clt = try container.decodeIfPresent(String.self, forKey: .clt) ?? "__clt" - kgm = try container.decodeIfPresent(String.self, forKey: .kgm) ?? "__kgm" - mlt = try container.decodeIfPresent(String.self, forKey: .mlt) ?? "__mlt" - cmt = try container.decodeIfPresent(String.self, forKey: .cmt) ?? "__cmt" - d70 = try container.decodeIfPresent(String.self, forKey: .d70) ?? "__d70" - ltr = try container.decodeIfPresent(String.self, forKey: .ltr) ?? "__ltr" - h87 = try container.decodeIfPresent(String.self, forKey: .h87) ?? "__h87" - e14 = try container.decodeIfPresent(String.self, forKey: .e14) ?? "__e14" + collect = try container.decodeIfPresent(String.self, forKey: .collect) ?? "__collect" + delivery = try container.decodeIfPresent(String.self, forKey: .delivery) ?? "__delivery" } public override subscript(key: String) -> String? { switch key { - case CodingKeys.dlt.stringValue: return dlt - case CodingKeys.grm.stringValue: return grm - case CodingKeys.clt.stringValue: return clt - case CodingKeys.kgm.stringValue: return kgm - case CodingKeys.mlt.stringValue: return mlt - case CodingKeys.cmt.stringValue: return cmt - case CodingKeys.d70.stringValue: return d70 - case CodingKeys.ltr.stringValue: return ltr - case CodingKeys.h87.stringValue: return h87 - case CodingKeys.e14.stringValue: return e14 + case CodingKeys.collect.stringValue: return collect + case CodingKeys.delivery.stringValue: return delivery default: return nil } } } - public final class OrderStatus: LocalizableSection { - public var accepted = "" + public final class Login: LocalizableSection { + public var emailHeader = "" + public var passwordPlaceholder = "" + public var title = "" + public var emailPlaceholder = "" + public var errorInvalidCredentials = "" + public var appName = "" + public var resetPasswordMessage = "" + public var passwordHeader = "" + public var loginButton = "" + public var appVersionPrefix = "" enum CodingKeys: String, CodingKey { - case accepted + case emailHeader + case passwordPlaceholder + case title + case emailPlaceholder + case errorInvalidCredentials + case appName + case resetPasswordMessage + case passwordHeader + case loginButton + case appVersionPrefix } public override init() { super.init() } @@ -322,42 +344,40 @@ public final class Localizations: LocalizableModel { public required init(from decoder: Decoder) throws { super.init() let container = try decoder.container(keyedBy: CodingKeys.self) - accepted = try container.decodeIfPresent(String.self, forKey: .accepted) ?? "__accepted" + emailHeader = try container.decodeIfPresent(String.self, forKey: .emailHeader) ?? "__emailHeader" + passwordPlaceholder = try container.decodeIfPresent(String.self, forKey: .passwordPlaceholder) ?? "__passwordPlaceholder" + title = try container.decodeIfPresent(String.self, forKey: .title) ?? "__title" + emailPlaceholder = try container.decodeIfPresent(String.self, forKey: .emailPlaceholder) ?? "__emailPlaceholder" + errorInvalidCredentials = try container.decodeIfPresent(String.self, forKey: .errorInvalidCredentials) ?? "__errorInvalidCredentials" + appName = try container.decodeIfPresent(String.self, forKey: .appName) ?? "__appName" + resetPasswordMessage = try container.decodeIfPresent(String.self, forKey: .resetPasswordMessage) ?? "__resetPasswordMessage" + passwordHeader = try container.decodeIfPresent(String.self, forKey: .passwordHeader) ?? "__passwordHeader" + loginButton = try container.decodeIfPresent(String.self, forKey: .loginButton) ?? "__loginButton" + appVersionPrefix = try container.decodeIfPresent(String.self, forKey: .appVersionPrefix) ?? "__appVersionPrefix" } public override subscript(key: String) -> String? { switch key { - case CodingKeys.accepted.stringValue: return accepted + case CodingKeys.emailHeader.stringValue: return emailHeader + case CodingKeys.passwordPlaceholder.stringValue: return passwordPlaceholder + case CodingKeys.title.stringValue: return title + case CodingKeys.emailPlaceholder.stringValue: return emailPlaceholder + case CodingKeys.errorInvalidCredentials.stringValue: return errorInvalidCredentials + case CodingKeys.appName.stringValue: return appName + case CodingKeys.resetPasswordMessage.stringValue: return resetPasswordMessage + case CodingKeys.passwordHeader.stringValue: return passwordHeader + case CodingKeys.loginButton.stringValue: return loginButton + case CodingKeys.appVersionPrefix.stringValue: return appVersionPrefix default: return nil } } } - public final class Settings: LocalizableSection { - public var logOutAlertCancel = "" - public var printerHeader = "" - public var logOutAlertMessage = "" - public var usernameHeader = "" - public var logoutAlertTitle = "" - public var appVersionHeader = "" - public var closeButton = "" - public var logOutButton = "" - public var logOutAlertConfirm = "" - public var title = "" - public var selectPrinterButton = "" + public final class OrderStatus: LocalizableSection { + public var accepted = "" enum CodingKeys: String, CodingKey { - case logOutAlertCancel - case printerHeader - case logOutAlertMessage - case usernameHeader - case logoutAlertTitle - case appVersionHeader - case closeButton - case logOutButton - case logOutAlertConfirm - case title - case selectPrinterButton + case accepted } public override init() { super.init() } @@ -365,66 +385,30 @@ public final class Localizations: LocalizableModel { public required init(from decoder: Decoder) throws { super.init() let container = try decoder.container(keyedBy: CodingKeys.self) - logOutAlertCancel = try container.decodeIfPresent(String.self, forKey: .logOutAlertCancel) ?? "__logOutAlertCancel" - printerHeader = try container.decodeIfPresent(String.self, forKey: .printerHeader) ?? "__printerHeader" - logOutAlertMessage = try container.decodeIfPresent(String.self, forKey: .logOutAlertMessage) ?? "__logOutAlertMessage" - usernameHeader = try container.decodeIfPresent(String.self, forKey: .usernameHeader) ?? "__usernameHeader" - logoutAlertTitle = try container.decodeIfPresent(String.self, forKey: .logoutAlertTitle) ?? "__logoutAlertTitle" - appVersionHeader = try container.decodeIfPresent(String.self, forKey: .appVersionHeader) ?? "__appVersionHeader" - closeButton = try container.decodeIfPresent(String.self, forKey: .closeButton) ?? "__closeButton" - logOutButton = try container.decodeIfPresent(String.self, forKey: .logOutButton) ?? "__logOutButton" - logOutAlertConfirm = try container.decodeIfPresent(String.self, forKey: .logOutAlertConfirm) ?? "__logOutAlertConfirm" - title = try container.decodeIfPresent(String.self, forKey: .title) ?? "__title" - selectPrinterButton = try container.decodeIfPresent(String.self, forKey: .selectPrinterButton) ?? "__selectPrinterButton" + accepted = try container.decodeIfPresent(String.self, forKey: .accepted) ?? "__accepted" } public override subscript(key: String) -> String? { switch key { - case CodingKeys.logOutAlertCancel.stringValue: return logOutAlertCancel - case CodingKeys.printerHeader.stringValue: return printerHeader - case CodingKeys.logOutAlertMessage.stringValue: return logOutAlertMessage - case CodingKeys.usernameHeader.stringValue: return usernameHeader - case CodingKeys.logoutAlertTitle.stringValue: return logoutAlertTitle - case CodingKeys.appVersionHeader.stringValue: return appVersionHeader - case CodingKeys.closeButton.stringValue: return closeButton - case CodingKeys.logOutButton.stringValue: return logOutButton - case CodingKeys.logOutAlertConfirm.stringValue: return logOutAlertConfirm - case CodingKeys.title.stringValue: return title - case CodingKeys.selectPrinterButton.stringValue: return selectPrinterButton + case CodingKeys.accepted.stringValue: return accepted default: return nil } } } - public final class DefaultSection: LocalizableSection { - public var save = "" - public var skip = "" - public var later = "" - public var yes = "" - public var next = "" - public var no = "" - public var retry = "" - public var ok = "" - public var previous = "" - public var edit = "" - public var cancel = "" - public var back = "" - public var settings = "" + public final class Error: LocalizableSection { + public var serverError = "" + public var connectionError = "" + public var unknownError = "" + public var authenticationError = "" + public var errorTitle = "" enum CodingKeys: String, CodingKey { - case save - case skip - case later - case yes - case next - case no - case retry - case ok - case previous - case edit - case cancel - case back - case settings + case serverError + case connectionError + case unknownError + case authenticationError + case errorTitle } public override init() { super.init() } @@ -432,267 +416,98 @@ public final class Localizations: LocalizableModel { public required init(from decoder: Decoder) throws { super.init() let container = try decoder.container(keyedBy: CodingKeys.self) - save = try container.decodeIfPresent(String.self, forKey: .save) ?? "__save" - skip = try container.decodeIfPresent(String.self, forKey: .skip) ?? "__skip" - later = try container.decodeIfPresent(String.self, forKey: .later) ?? "__later" - yes = try container.decodeIfPresent(String.self, forKey: .yes) ?? "__yes" - next = try container.decodeIfPresent(String.self, forKey: .next) ?? "__next" - no = try container.decodeIfPresent(String.self, forKey: .no) ?? "__no" - retry = try container.decodeIfPresent(String.self, forKey: .retry) ?? "__retry" - ok = try container.decodeIfPresent(String.self, forKey: .ok) ?? "__ok" - previous = try container.decodeIfPresent(String.self, forKey: .previous) ?? "__previous" - edit = try container.decodeIfPresent(String.self, forKey: .edit) ?? "__edit" - cancel = try container.decodeIfPresent(String.self, forKey: .cancel) ?? "__cancel" - back = try container.decodeIfPresent(String.self, forKey: .back) ?? "__back" - settings = try container.decodeIfPresent(String.self, forKey: .settings) ?? "__settings" + serverError = try container.decodeIfPresent(String.self, forKey: .serverError) ?? "__serverError" + connectionError = try container.decodeIfPresent(String.self, forKey: .connectionError) ?? "__connectionError" + unknownError = try container.decodeIfPresent(String.self, forKey: .unknownError) ?? "__unknownError" + authenticationError = try container.decodeIfPresent(String.self, forKey: .authenticationError) ?? "__authenticationError" + errorTitle = try container.decodeIfPresent(String.self, forKey: .errorTitle) ?? "__errorTitle" } public override subscript(key: String) -> String? { switch key { - case CodingKeys.save.stringValue: return save - case CodingKeys.skip.stringValue: return skip - case CodingKeys.later.stringValue: return later - case CodingKeys.yes.stringValue: return yes - case CodingKeys.next.stringValue: return next - case CodingKeys.no.stringValue: return no - case CodingKeys.retry.stringValue: return retry - case CodingKeys.ok.stringValue: return ok - case CodingKeys.previous.stringValue: return previous - case CodingKeys.edit.stringValue: return edit - case CodingKeys.cancel.stringValue: return cancel - case CodingKeys.back.stringValue: return back - case CodingKeys.settings.stringValue: return settings + case CodingKeys.serverError.stringValue: return serverError + case CodingKeys.connectionError.stringValue: return connectionError + case CodingKeys.unknownError.stringValue: return unknownError + case CodingKeys.authenticationError.stringValue: return authenticationError + case CodingKeys.errorTitle.stringValue: return errorTitle default: return nil } } } - public final class OrderDetailNewOrderSection: LocalizableSection { - public var header = "" + public final class OrderDetails: LocalizableSection { + public var sectionSubheaderColdProducts = "" public var pickupTimeHeader = "" - public var deliveryTimeHeader = "" - public var phoneNumberHeader = "" - public var acceptButton = "" - public var pickedUpInStoreAt = "" + public var pickedUpButton = "" + public var sectionHeaderCustomerInfo = "" public var rejectButton = "" - public var customerNameHeader = "" - public var subheader = "" - - enum CodingKeys: String, CodingKey { - case header - case pickupTimeHeader - case deliveryTimeHeader - case phoneNumberHeader - case acceptButton - case pickedUpInStoreAt - case rejectButton - case customerNameHeader - case subheader - } - - public override init() { super.init() } - - public required init(from decoder: Decoder) throws { - super.init() - let container = try decoder.container(keyedBy: CodingKeys.self) - header = try container.decodeIfPresent(String.self, forKey: .header) ?? "__header" - pickupTimeHeader = try container.decodeIfPresent(String.self, forKey: .pickupTimeHeader) ?? "__pickupTimeHeader" - deliveryTimeHeader = try container.decodeIfPresent(String.self, forKey: .deliveryTimeHeader) ?? "__deliveryTimeHeader" - phoneNumberHeader = try container.decodeIfPresent(String.self, forKey: .phoneNumberHeader) ?? "__phoneNumberHeader" - acceptButton = try container.decodeIfPresent(String.self, forKey: .acceptButton) ?? "__acceptButton" - pickedUpInStoreAt = try container.decodeIfPresent(String.self, forKey: .pickedUpInStoreAt) ?? "__pickedUpInStoreAt" - rejectButton = try container.decodeIfPresent(String.self, forKey: .rejectButton) ?? "__rejectButton" - customerNameHeader = try container.decodeIfPresent(String.self, forKey: .customerNameHeader) ?? "__customerNameHeader" - subheader = try container.decodeIfPresent(String.self, forKey: .subheader) ?? "__subheader" - } - - public override subscript(key: String) -> String? { - switch key { - case CodingKeys.header.stringValue: return header - case CodingKeys.pickupTimeHeader.stringValue: return pickupTimeHeader - case CodingKeys.deliveryTimeHeader.stringValue: return deliveryTimeHeader - case CodingKeys.phoneNumberHeader.stringValue: return phoneNumberHeader - case CodingKeys.acceptButton.stringValue: return acceptButton - case CodingKeys.pickedUpInStoreAt.stringValue: return pickedUpInStoreAt - case CodingKeys.rejectButton.stringValue: return rejectButton - case CodingKeys.customerNameHeader.stringValue: return customerNameHeader - case CodingKeys.subheader.stringValue: return subheader - default: return nil - } - } - } - - public final class Error: LocalizableSection { - public var errorTitle = "" - public var authenticationError = "" - public var serverError = "" - public var unknownError = "" - public var connectionError = "" - - enum CodingKeys: String, CodingKey { - case errorTitle - case authenticationError - case serverError - case unknownError - case connectionError - } - - public override init() { super.init() } - - public required init(from decoder: Decoder) throws { - super.init() - let container = try decoder.container(keyedBy: CodingKeys.self) - errorTitle = try container.decodeIfPresent(String.self, forKey: .errorTitle) ?? "__errorTitle" - authenticationError = try container.decodeIfPresent(String.self, forKey: .authenticationError) ?? "__authenticationError" - serverError = try container.decodeIfPresent(String.self, forKey: .serverError) ?? "__serverError" - unknownError = try container.decodeIfPresent(String.self, forKey: .unknownError) ?? "__unknownError" - connectionError = try container.decodeIfPresent(String.self, forKey: .connectionError) ?? "__connectionError" - } - - public override subscript(key: String) -> String? { - switch key { - case CodingKeys.errorTitle.stringValue: return errorTitle - case CodingKeys.authenticationError.stringValue: return authenticationError - case CodingKeys.serverError.stringValue: return serverError - case CodingKeys.unknownError.stringValue: return unknownError - case CodingKeys.connectionError.stringValue: return connectionError - default: return nil - } - } - } - - public final class Login: LocalizableSection { - public var appName = "" - public var emailPlaceholder = "" - public var passwordHeader = "" - public var appVersionPrefix = "" - public var errorInvalidCredentials = "" - public var title = "" - public var loginButton = "" - public var resetPasswordMessage = "" - public var passwordPlaceholder = "" - public var emailHeader = "" - - enum CodingKeys: String, CodingKey { - case appName - case emailPlaceholder - case passwordHeader - case appVersionPrefix - case errorInvalidCredentials - case title - case loginButton - case resetPasswordMessage - case passwordPlaceholder - case emailHeader - } - - public override init() { super.init() } - - public required init(from decoder: Decoder) throws { - super.init() - let container = try decoder.container(keyedBy: CodingKeys.self) - appName = try container.decodeIfPresent(String.self, forKey: .appName) ?? "__appName" - emailPlaceholder = try container.decodeIfPresent(String.self, forKey: .emailPlaceholder) ?? "__emailPlaceholder" - passwordHeader = try container.decodeIfPresent(String.self, forKey: .passwordHeader) ?? "__passwordHeader" - appVersionPrefix = try container.decodeIfPresent(String.self, forKey: .appVersionPrefix) ?? "__appVersionPrefix" - errorInvalidCredentials = try container.decodeIfPresent(String.self, forKey: .errorInvalidCredentials) ?? "__errorInvalidCredentials" - title = try container.decodeIfPresent(String.self, forKey: .title) ?? "__title" - loginButton = try container.decodeIfPresent(String.self, forKey: .loginButton) ?? "__loginButton" - resetPasswordMessage = try container.decodeIfPresent(String.self, forKey: .resetPasswordMessage) ?? "__resetPasswordMessage" - passwordPlaceholder = try container.decodeIfPresent(String.self, forKey: .passwordPlaceholder) ?? "__passwordPlaceholder" - emailHeader = try container.decodeIfPresent(String.self, forKey: .emailHeader) ?? "__emailHeader" - } - - public override subscript(key: String) -> String? { - switch key { - case CodingKeys.appName.stringValue: return appName - case CodingKeys.emailPlaceholder.stringValue: return emailPlaceholder - case CodingKeys.passwordHeader.stringValue: return passwordHeader - case CodingKeys.appVersionPrefix.stringValue: return appVersionPrefix - case CodingKeys.errorInvalidCredentials.stringValue: return errorInvalidCredentials - case CodingKeys.title.stringValue: return title - case CodingKeys.loginButton.stringValue: return loginButton - case CodingKeys.resetPasswordMessage.stringValue: return resetPasswordMessage - case CodingKeys.passwordPlaceholder.stringValue: return passwordPlaceholder - case CodingKeys.emailHeader.stringValue: return emailHeader - default: return nil - } - } - } - - public final class OrderDetails: LocalizableSection { - public var printButton = "" + public var aPiece = "" + public var sectionHeaderOtherProducts = "" + public var infoEmail = "" + public var includeCutlery = "" + public var customerNoteHeader = "" public var outForDeliveryButton = "" - public var errorCouldNotFetchProducts = "" - public var rejectButton = "" public var rejectOrderAlertMessage = "" - public var includeCutlery = "" - public var rejectOrderAlertTitle = "" - public var infoTakeoutPhone = "" - public var infoMobilePhone = "" - public var pickupTimeHeader = "" - public var infoCustomerName = "" public var infoTakeOutShopID = "" - public var completedBanner = "" - public var customerNoteHeader = "" - public var sectionHeaderColdProducts = "" - public var sectionHeaderOrderStatus = "" - public var sectionSubheaderColdProducts = "" + public var infoCustomerName = "" + public var rejectOrderAlertTitle = "" public var infoAddress = "" - public var infoDeliveryTime = "" - public var aPiece = "" + public var infoTakeoutPhone = "" public var rejectOrderAlertCancel = "" - public var pickedUpButton = "" - public var infoEmail = "" - public var readyButton = "" + public var rejectOrderAlertConfirm = "" + public var completedBanner = "" public var today = "" + public var underPreparationButton = "" public var deliveryTypeHeader = "" - public var sectionHeaderTakeout = "" - public var infoPaymentType = "" - public var rejectOrderAlertConfirm = "" + public var printButton = "" public var errorStatusUpdateFailed = "" - public var sectionHeaderOtherProducts = "" - public var infoOrderTime = "" - public var underPreparationButton = "" - public var sectionHeaderCustomerInfo = "" + public var infoDeliveryTime = "" + public var infoPaymentType = "" public var sectionHeaderWarmProducts = "" + public var sectionHeaderColdProducts = "" + public var sectionHeaderOrderStatus = "" + public var sectionHeaderTakeout = "" + public var infoMobilePhone = "" + public var readyButton = "" + public var infoOrderTime = "" + public var errorCouldNotFetchProducts = "" enum CodingKeys: String, CodingKey { - case printButton - case outForDeliveryButton - case errorCouldNotFetchProducts + case sectionSubheaderColdProducts + case pickupTimeHeader + case pickedUpButton + case sectionHeaderCustomerInfo case rejectButton - case rejectOrderAlertMessage + case aPiece + case sectionHeaderOtherProducts + case infoEmail case includeCutlery - case rejectOrderAlertTitle - case infoTakeoutPhone - case infoMobilePhone - case pickupTimeHeader - case infoCustomerName - case infoTakeOutShopID - case completedBanner case customerNoteHeader - case sectionHeaderColdProducts - case sectionHeaderOrderStatus - case sectionSubheaderColdProducts + case outForDeliveryButton + case rejectOrderAlertMessage + case infoTakeOutShopID + case infoCustomerName + case rejectOrderAlertTitle case infoAddress - case infoDeliveryTime - case aPiece + case infoTakeoutPhone case rejectOrderAlertCancel - case pickedUpButton - case infoEmail - case readyButton + case rejectOrderAlertConfirm + case completedBanner case today + case underPreparationButton case deliveryTypeHeader - case sectionHeaderTakeout - case infoPaymentType - case rejectOrderAlertConfirm + case printButton case errorStatusUpdateFailed - case sectionHeaderOtherProducts - case infoOrderTime - case underPreparationButton - case sectionHeaderCustomerInfo + case infoDeliveryTime + case infoPaymentType case sectionHeaderWarmProducts + case sectionHeaderColdProducts + case sectionHeaderOrderStatus + case sectionHeaderTakeout + case infoMobilePhone + case readyButton + case infoOrderTime + case errorCouldNotFetchProducts } public override init() { super.init() } @@ -700,104 +515,155 @@ public final class Localizations: LocalizableModel { public required init(from decoder: Decoder) throws { super.init() let container = try decoder.container(keyedBy: CodingKeys.self) - printButton = try container.decodeIfPresent(String.self, forKey: .printButton) ?? "__printButton" - outForDeliveryButton = try container.decodeIfPresent(String.self, forKey: .outForDeliveryButton) ?? "__outForDeliveryButton" - errorCouldNotFetchProducts = try container.decodeIfPresent(String.self, forKey: .errorCouldNotFetchProducts) ?? "__errorCouldNotFetchProducts" + sectionSubheaderColdProducts = try container.decodeIfPresent(String.self, forKey: .sectionSubheaderColdProducts) ?? "__sectionSubheaderColdProducts" + pickupTimeHeader = try container.decodeIfPresent(String.self, forKey: .pickupTimeHeader) ?? "__pickupTimeHeader" + pickedUpButton = try container.decodeIfPresent(String.self, forKey: .pickedUpButton) ?? "__pickedUpButton" + sectionHeaderCustomerInfo = try container.decodeIfPresent(String.self, forKey: .sectionHeaderCustomerInfo) ?? "__sectionHeaderCustomerInfo" rejectButton = try container.decodeIfPresent(String.self, forKey: .rejectButton) ?? "__rejectButton" - rejectOrderAlertMessage = try container.decodeIfPresent(String.self, forKey: .rejectOrderAlertMessage) ?? "__rejectOrderAlertMessage" + aPiece = try container.decodeIfPresent(String.self, forKey: .aPiece) ?? "__aPiece" + sectionHeaderOtherProducts = try container.decodeIfPresent(String.self, forKey: .sectionHeaderOtherProducts) ?? "__sectionHeaderOtherProducts" + infoEmail = try container.decodeIfPresent(String.self, forKey: .infoEmail) ?? "__infoEmail" includeCutlery = try container.decodeIfPresent(String.self, forKey: .includeCutlery) ?? "__includeCutlery" - rejectOrderAlertTitle = try container.decodeIfPresent(String.self, forKey: .rejectOrderAlertTitle) ?? "__rejectOrderAlertTitle" - infoTakeoutPhone = try container.decodeIfPresent(String.self, forKey: .infoTakeoutPhone) ?? "__infoTakeoutPhone" - infoMobilePhone = try container.decodeIfPresent(String.self, forKey: .infoMobilePhone) ?? "__infoMobilePhone" - pickupTimeHeader = try container.decodeIfPresent(String.self, forKey: .pickupTimeHeader) ?? "__pickupTimeHeader" - infoCustomerName = try container.decodeIfPresent(String.self, forKey: .infoCustomerName) ?? "__infoCustomerName" - infoTakeOutShopID = try container.decodeIfPresent(String.self, forKey: .infoTakeOutShopID) ?? "__infoTakeOutShopID" - completedBanner = try container.decodeIfPresent(String.self, forKey: .completedBanner) ?? "__completedBanner" customerNoteHeader = try container.decodeIfPresent(String.self, forKey: .customerNoteHeader) ?? "__customerNoteHeader" - sectionHeaderColdProducts = try container.decodeIfPresent(String.self, forKey: .sectionHeaderColdProducts) ?? "__sectionHeaderColdProducts" - sectionHeaderOrderStatus = try container.decodeIfPresent(String.self, forKey: .sectionHeaderOrderStatus) ?? "__sectionHeaderOrderStatus" - sectionSubheaderColdProducts = try container.decodeIfPresent(String.self, forKey: .sectionSubheaderColdProducts) ?? "__sectionSubheaderColdProducts" + outForDeliveryButton = try container.decodeIfPresent(String.self, forKey: .outForDeliveryButton) ?? "__outForDeliveryButton" + rejectOrderAlertMessage = try container.decodeIfPresent(String.self, forKey: .rejectOrderAlertMessage) ?? "__rejectOrderAlertMessage" + infoTakeOutShopID = try container.decodeIfPresent(String.self, forKey: .infoTakeOutShopID) ?? "__infoTakeOutShopID" + infoCustomerName = try container.decodeIfPresent(String.self, forKey: .infoCustomerName) ?? "__infoCustomerName" + rejectOrderAlertTitle = try container.decodeIfPresent(String.self, forKey: .rejectOrderAlertTitle) ?? "__rejectOrderAlertTitle" infoAddress = try container.decodeIfPresent(String.self, forKey: .infoAddress) ?? "__infoAddress" - infoDeliveryTime = try container.decodeIfPresent(String.self, forKey: .infoDeliveryTime) ?? "__infoDeliveryTime" - aPiece = try container.decodeIfPresent(String.self, forKey: .aPiece) ?? "__aPiece" + infoTakeoutPhone = try container.decodeIfPresent(String.self, forKey: .infoTakeoutPhone) ?? "__infoTakeoutPhone" rejectOrderAlertCancel = try container.decodeIfPresent(String.self, forKey: .rejectOrderAlertCancel) ?? "__rejectOrderAlertCancel" - pickedUpButton = try container.decodeIfPresent(String.self, forKey: .pickedUpButton) ?? "__pickedUpButton" - infoEmail = try container.decodeIfPresent(String.self, forKey: .infoEmail) ?? "__infoEmail" - readyButton = try container.decodeIfPresent(String.self, forKey: .readyButton) ?? "__readyButton" + rejectOrderAlertConfirm = try container.decodeIfPresent(String.self, forKey: .rejectOrderAlertConfirm) ?? "__rejectOrderAlertConfirm" + completedBanner = try container.decodeIfPresent(String.self, forKey: .completedBanner) ?? "__completedBanner" today = try container.decodeIfPresent(String.self, forKey: .today) ?? "__today" + underPreparationButton = try container.decodeIfPresent(String.self, forKey: .underPreparationButton) ?? "__underPreparationButton" deliveryTypeHeader = try container.decodeIfPresent(String.self, forKey: .deliveryTypeHeader) ?? "__deliveryTypeHeader" - sectionHeaderTakeout = try container.decodeIfPresent(String.self, forKey: .sectionHeaderTakeout) ?? "__sectionHeaderTakeout" - infoPaymentType = try container.decodeIfPresent(String.self, forKey: .infoPaymentType) ?? "__infoPaymentType" - rejectOrderAlertConfirm = try container.decodeIfPresent(String.self, forKey: .rejectOrderAlertConfirm) ?? "__rejectOrderAlertConfirm" + printButton = try container.decodeIfPresent(String.self, forKey: .printButton) ?? "__printButton" errorStatusUpdateFailed = try container.decodeIfPresent(String.self, forKey: .errorStatusUpdateFailed) ?? "__errorStatusUpdateFailed" - sectionHeaderOtherProducts = try container.decodeIfPresent(String.self, forKey: .sectionHeaderOtherProducts) ?? "__sectionHeaderOtherProducts" - infoOrderTime = try container.decodeIfPresent(String.self, forKey: .infoOrderTime) ?? "__infoOrderTime" - underPreparationButton = try container.decodeIfPresent(String.self, forKey: .underPreparationButton) ?? "__underPreparationButton" - sectionHeaderCustomerInfo = try container.decodeIfPresent(String.self, forKey: .sectionHeaderCustomerInfo) ?? "__sectionHeaderCustomerInfo" + infoDeliveryTime = try container.decodeIfPresent(String.self, forKey: .infoDeliveryTime) ?? "__infoDeliveryTime" + infoPaymentType = try container.decodeIfPresent(String.self, forKey: .infoPaymentType) ?? "__infoPaymentType" sectionHeaderWarmProducts = try container.decodeIfPresent(String.self, forKey: .sectionHeaderWarmProducts) ?? "__sectionHeaderWarmProducts" + sectionHeaderColdProducts = try container.decodeIfPresent(String.self, forKey: .sectionHeaderColdProducts) ?? "__sectionHeaderColdProducts" + sectionHeaderOrderStatus = try container.decodeIfPresent(String.self, forKey: .sectionHeaderOrderStatus) ?? "__sectionHeaderOrderStatus" + sectionHeaderTakeout = try container.decodeIfPresent(String.self, forKey: .sectionHeaderTakeout) ?? "__sectionHeaderTakeout" + infoMobilePhone = try container.decodeIfPresent(String.self, forKey: .infoMobilePhone) ?? "__infoMobilePhone" + readyButton = try container.decodeIfPresent(String.self, forKey: .readyButton) ?? "__readyButton" + infoOrderTime = try container.decodeIfPresent(String.self, forKey: .infoOrderTime) ?? "__infoOrderTime" + errorCouldNotFetchProducts = try container.decodeIfPresent(String.self, forKey: .errorCouldNotFetchProducts) ?? "__errorCouldNotFetchProducts" } public override subscript(key: String) -> String? { switch key { - case CodingKeys.printButton.stringValue: return printButton - case CodingKeys.outForDeliveryButton.stringValue: return outForDeliveryButton - case CodingKeys.errorCouldNotFetchProducts.stringValue: return errorCouldNotFetchProducts + case CodingKeys.sectionSubheaderColdProducts.stringValue: return sectionSubheaderColdProducts + case CodingKeys.pickupTimeHeader.stringValue: return pickupTimeHeader + case CodingKeys.pickedUpButton.stringValue: return pickedUpButton + case CodingKeys.sectionHeaderCustomerInfo.stringValue: return sectionHeaderCustomerInfo case CodingKeys.rejectButton.stringValue: return rejectButton - case CodingKeys.rejectOrderAlertMessage.stringValue: return rejectOrderAlertMessage + case CodingKeys.aPiece.stringValue: return aPiece + case CodingKeys.sectionHeaderOtherProducts.stringValue: return sectionHeaderOtherProducts + case CodingKeys.infoEmail.stringValue: return infoEmail case CodingKeys.includeCutlery.stringValue: return includeCutlery - case CodingKeys.rejectOrderAlertTitle.stringValue: return rejectOrderAlertTitle - case CodingKeys.infoTakeoutPhone.stringValue: return infoTakeoutPhone - case CodingKeys.infoMobilePhone.stringValue: return infoMobilePhone - case CodingKeys.pickupTimeHeader.stringValue: return pickupTimeHeader - case CodingKeys.infoCustomerName.stringValue: return infoCustomerName - case CodingKeys.infoTakeOutShopID.stringValue: return infoTakeOutShopID - case CodingKeys.completedBanner.stringValue: return completedBanner case CodingKeys.customerNoteHeader.stringValue: return customerNoteHeader - case CodingKeys.sectionHeaderColdProducts.stringValue: return sectionHeaderColdProducts - case CodingKeys.sectionHeaderOrderStatus.stringValue: return sectionHeaderOrderStatus - case CodingKeys.sectionSubheaderColdProducts.stringValue: return sectionSubheaderColdProducts + case CodingKeys.outForDeliveryButton.stringValue: return outForDeliveryButton + case CodingKeys.rejectOrderAlertMessage.stringValue: return rejectOrderAlertMessage + case CodingKeys.infoTakeOutShopID.stringValue: return infoTakeOutShopID + case CodingKeys.infoCustomerName.stringValue: return infoCustomerName + case CodingKeys.rejectOrderAlertTitle.stringValue: return rejectOrderAlertTitle case CodingKeys.infoAddress.stringValue: return infoAddress - case CodingKeys.infoDeliveryTime.stringValue: return infoDeliveryTime - case CodingKeys.aPiece.stringValue: return aPiece + case CodingKeys.infoTakeoutPhone.stringValue: return infoTakeoutPhone case CodingKeys.rejectOrderAlertCancel.stringValue: return rejectOrderAlertCancel - case CodingKeys.pickedUpButton.stringValue: return pickedUpButton - case CodingKeys.infoEmail.stringValue: return infoEmail - case CodingKeys.readyButton.stringValue: return readyButton + case CodingKeys.rejectOrderAlertConfirm.stringValue: return rejectOrderAlertConfirm + case CodingKeys.completedBanner.stringValue: return completedBanner case CodingKeys.today.stringValue: return today + case CodingKeys.underPreparationButton.stringValue: return underPreparationButton case CodingKeys.deliveryTypeHeader.stringValue: return deliveryTypeHeader - case CodingKeys.sectionHeaderTakeout.stringValue: return sectionHeaderTakeout - case CodingKeys.infoPaymentType.stringValue: return infoPaymentType - case CodingKeys.rejectOrderAlertConfirm.stringValue: return rejectOrderAlertConfirm + case CodingKeys.printButton.stringValue: return printButton case CodingKeys.errorStatusUpdateFailed.stringValue: return errorStatusUpdateFailed - case CodingKeys.sectionHeaderOtherProducts.stringValue: return sectionHeaderOtherProducts - case CodingKeys.infoOrderTime.stringValue: return infoOrderTime - case CodingKeys.underPreparationButton.stringValue: return underPreparationButton - case CodingKeys.sectionHeaderCustomerInfo.stringValue: return sectionHeaderCustomerInfo + case CodingKeys.infoDeliveryTime.stringValue: return infoDeliveryTime + case CodingKeys.infoPaymentType.stringValue: return infoPaymentType case CodingKeys.sectionHeaderWarmProducts.stringValue: return sectionHeaderWarmProducts + case CodingKeys.sectionHeaderColdProducts.stringValue: return sectionHeaderColdProducts + case CodingKeys.sectionHeaderOrderStatus.stringValue: return sectionHeaderOrderStatus + case CodingKeys.sectionHeaderTakeout.stringValue: return sectionHeaderTakeout + case CodingKeys.infoMobilePhone.stringValue: return infoMobilePhone + case CodingKeys.readyButton.stringValue: return readyButton + case CodingKeys.infoOrderTime.stringValue: return infoOrderTime + case CodingKeys.errorCouldNotFetchProducts.stringValue: return errorCouldNotFetchProducts + default: return nil + } + } + } + + public final class PrinterOutput: LocalizableSection { + public var otherHeader = "" + public var errorNoDeviceFound = "" + public var noteHeader = "" + public var coldHeader = "" + public var errorDeviceConnectionFailed = "" + public var warmHeader = "" + public var orderNumber = "" + public var includeCutlery = "" + + enum CodingKeys: String, CodingKey { + case otherHeader + case errorNoDeviceFound + case noteHeader + case coldHeader + case errorDeviceConnectionFailed + case warmHeader + case orderNumber + case includeCutlery + } + + public override init() { super.init() } + + public required init(from decoder: Decoder) throws { + super.init() + let container = try decoder.container(keyedBy: CodingKeys.self) + otherHeader = try container.decodeIfPresent(String.self, forKey: .otherHeader) ?? "__otherHeader" + errorNoDeviceFound = try container.decodeIfPresent(String.self, forKey: .errorNoDeviceFound) ?? "__errorNoDeviceFound" + noteHeader = try container.decodeIfPresent(String.self, forKey: .noteHeader) ?? "__noteHeader" + coldHeader = try container.decodeIfPresent(String.self, forKey: .coldHeader) ?? "__coldHeader" + errorDeviceConnectionFailed = try container.decodeIfPresent(String.self, forKey: .errorDeviceConnectionFailed) ?? "__errorDeviceConnectionFailed" + warmHeader = try container.decodeIfPresent(String.self, forKey: .warmHeader) ?? "__warmHeader" + orderNumber = try container.decodeIfPresent(String.self, forKey: .orderNumber) ?? "__orderNumber" + includeCutlery = try container.decodeIfPresent(String.self, forKey: .includeCutlery) ?? "__includeCutlery" + } + + public override subscript(key: String) -> String? { + switch key { + case CodingKeys.otherHeader.stringValue: return otherHeader + case CodingKeys.errorNoDeviceFound.stringValue: return errorNoDeviceFound + case CodingKeys.noteHeader.stringValue: return noteHeader + case CodingKeys.coldHeader.stringValue: return coldHeader + case CodingKeys.errorDeviceConnectionFailed.stringValue: return errorDeviceConnectionFailed + case CodingKeys.warmHeader.stringValue: return warmHeader + case CodingKeys.orderNumber.stringValue: return orderNumber + case CodingKeys.includeCutlery.stringValue: return includeCutlery default: return nil } } } public final class Printer: LocalizableSection { + public var sectionHeaderActivePrinter = "" public var errorSomethingHappened = "" - public var sectionHeaderNewPrinters = "" + public var title = "" + public var deleteButton = "" public var bluetoothHintFooter = "" public var connectedSuccessMessage = "" - public var sectionHeaderActivePrinter = "" - public var deleteButton = "" + public var sectionHeaderNewPrinters = "" public var connectButton = "" - public var title = "" enum CodingKeys: String, CodingKey { + case sectionHeaderActivePrinter case errorSomethingHappened - case sectionHeaderNewPrinters + case title + case deleteButton case bluetoothHintFooter case connectedSuccessMessage - case sectionHeaderActivePrinter - case deleteButton + case sectionHeaderNewPrinters case connectButton - case title } public override init() { super.init() } @@ -805,66 +671,137 @@ public final class Localizations: LocalizableModel { public required init(from decoder: Decoder) throws { super.init() let container = try decoder.container(keyedBy: CodingKeys.self) + sectionHeaderActivePrinter = try container.decodeIfPresent(String.self, forKey: .sectionHeaderActivePrinter) ?? "__sectionHeaderActivePrinter" errorSomethingHappened = try container.decodeIfPresent(String.self, forKey: .errorSomethingHappened) ?? "__errorSomethingHappened" - sectionHeaderNewPrinters = try container.decodeIfPresent(String.self, forKey: .sectionHeaderNewPrinters) ?? "__sectionHeaderNewPrinters" + title = try container.decodeIfPresent(String.self, forKey: .title) ?? "__title" + deleteButton = try container.decodeIfPresent(String.self, forKey: .deleteButton) ?? "__deleteButton" bluetoothHintFooter = try container.decodeIfPresent(String.self, forKey: .bluetoothHintFooter) ?? "__bluetoothHintFooter" connectedSuccessMessage = try container.decodeIfPresent(String.self, forKey: .connectedSuccessMessage) ?? "__connectedSuccessMessage" - sectionHeaderActivePrinter = try container.decodeIfPresent(String.self, forKey: .sectionHeaderActivePrinter) ?? "__sectionHeaderActivePrinter" - deleteButton = try container.decodeIfPresent(String.self, forKey: .deleteButton) ?? "__deleteButton" + sectionHeaderNewPrinters = try container.decodeIfPresent(String.self, forKey: .sectionHeaderNewPrinters) ?? "__sectionHeaderNewPrinters" connectButton = try container.decodeIfPresent(String.self, forKey: .connectButton) ?? "__connectButton" - title = try container.decodeIfPresent(String.self, forKey: .title) ?? "__title" } public override subscript(key: String) -> String? { switch key { + case CodingKeys.sectionHeaderActivePrinter.stringValue: return sectionHeaderActivePrinter case CodingKeys.errorSomethingHappened.stringValue: return errorSomethingHappened - case CodingKeys.sectionHeaderNewPrinters.stringValue: return sectionHeaderNewPrinters + case CodingKeys.title.stringValue: return title + case CodingKeys.deleteButton.stringValue: return deleteButton case CodingKeys.bluetoothHintFooter.stringValue: return bluetoothHintFooter case CodingKeys.connectedSuccessMessage.stringValue: return connectedSuccessMessage - case CodingKeys.sectionHeaderActivePrinter.stringValue: return sectionHeaderActivePrinter - case CodingKeys.deleteButton.stringValue: return deleteButton + case CodingKeys.sectionHeaderNewPrinters.stringValue: return sectionHeaderNewPrinters case CodingKeys.connectButton.stringValue: return connectButton + default: return nil + } + } + } + + public final class SearchOrders: LocalizableSection { + public var orderNumberHeader = "" + public var statusRejected = "" + public var statusNew = "" + public var title = "" + public var statusShipped = "" + public var customerNameHeader = "" + public var statusCompleted = "" + public var statusReady = "" + public var orderDateHeader = "" + public var statusAccepted = "" + public var emptyMessage = "" + public var searchfieldPlaceholder = "" + public var orderStatusHeader = "" + + enum CodingKeys: String, CodingKey { + case orderNumberHeader + case statusRejected + case statusNew + case title + case statusShipped + case customerNameHeader + case statusCompleted + case statusReady + case orderDateHeader + case statusAccepted + case emptyMessage + case searchfieldPlaceholder + case orderStatusHeader + } + + public override init() { super.init() } + + public required init(from decoder: Decoder) throws { + super.init() + let container = try decoder.container(keyedBy: CodingKeys.self) + orderNumberHeader = try container.decodeIfPresent(String.self, forKey: .orderNumberHeader) ?? "__orderNumberHeader" + statusRejected = try container.decodeIfPresent(String.self, forKey: .statusRejected) ?? "__statusRejected" + statusNew = try container.decodeIfPresent(String.self, forKey: .statusNew) ?? "__statusNew" + title = try container.decodeIfPresent(String.self, forKey: .title) ?? "__title" + statusShipped = try container.decodeIfPresent(String.self, forKey: .statusShipped) ?? "__statusShipped" + customerNameHeader = try container.decodeIfPresent(String.self, forKey: .customerNameHeader) ?? "__customerNameHeader" + statusCompleted = try container.decodeIfPresent(String.self, forKey: .statusCompleted) ?? "__statusCompleted" + statusReady = try container.decodeIfPresent(String.self, forKey: .statusReady) ?? "__statusReady" + orderDateHeader = try container.decodeIfPresent(String.self, forKey: .orderDateHeader) ?? "__orderDateHeader" + statusAccepted = try container.decodeIfPresent(String.self, forKey: .statusAccepted) ?? "__statusAccepted" + emptyMessage = try container.decodeIfPresent(String.self, forKey: .emptyMessage) ?? "__emptyMessage" + searchfieldPlaceholder = try container.decodeIfPresent(String.self, forKey: .searchfieldPlaceholder) ?? "__searchfieldPlaceholder" + orderStatusHeader = try container.decodeIfPresent(String.self, forKey: .orderStatusHeader) ?? "__orderStatusHeader" + } + + public override subscript(key: String) -> String? { + switch key { + case CodingKeys.orderNumberHeader.stringValue: return orderNumberHeader + case CodingKeys.statusRejected.stringValue: return statusRejected + case CodingKeys.statusNew.stringValue: return statusNew case CodingKeys.title.stringValue: return title + case CodingKeys.statusShipped.stringValue: return statusShipped + case CodingKeys.customerNameHeader.stringValue: return customerNameHeader + case CodingKeys.statusCompleted.stringValue: return statusCompleted + case CodingKeys.statusReady.stringValue: return statusReady + case CodingKeys.orderDateHeader.stringValue: return orderDateHeader + case CodingKeys.statusAccepted.stringValue: return statusAccepted + case CodingKeys.emptyMessage.stringValue: return emptyMessage + case CodingKeys.searchfieldPlaceholder.stringValue: return searchfieldPlaceholder + case CodingKeys.orderStatusHeader.stringValue: return orderStatusHeader default: return nil } } } public final class Dashboard: LocalizableSection { + public var columnOutForDeliveryEmpty = "" public var columnReadyEmpty = "" + public var sectionToday = "" public var allOrdersButton = "" + public var itemsSingular = "" + public var sectionTomorrow = "" + public var sectionLater = "" public var itemsPlural = "" - public var columnOutForDelivery = "" + public var columnAccepted = "" public var columnIncomingEmpty = "" + public var columnIncoming = "" + public var columnOutForDelivery = "" public var columnReady = "" public var columnDoneTodayEmpty = "" - public var columnAcceptedEmpty = "" - public var columnAccepted = "" - public var columnOutForDeliveryEmpty = "" - public var sectionTomorrow = "" - public var sectionLater = "" - public var itemsSingular = "" public var columnDoneToday = "" - public var sectionToday = "" - public var columnIncoming = "" + public var columnAcceptedEmpty = "" enum CodingKeys: String, CodingKey { + case columnOutForDeliveryEmpty case columnReadyEmpty + case sectionToday case allOrdersButton + case itemsSingular + case sectionTomorrow + case sectionLater case itemsPlural - case columnOutForDelivery + case columnAccepted case columnIncomingEmpty + case columnIncoming + case columnOutForDelivery case columnReady case columnDoneTodayEmpty - case columnAcceptedEmpty - case columnAccepted - case columnOutForDeliveryEmpty - case sectionTomorrow - case sectionLater - case itemsSingular case columnDoneToday - case sectionToday - case columnIncoming + case columnAcceptedEmpty } public override init() { super.init() } @@ -872,42 +809,105 @@ public final class Localizations: LocalizableModel { public required init(from decoder: Decoder) throws { super.init() let container = try decoder.container(keyedBy: CodingKeys.self) + columnOutForDeliveryEmpty = try container.decodeIfPresent(String.self, forKey: .columnOutForDeliveryEmpty) ?? "__columnOutForDeliveryEmpty" columnReadyEmpty = try container.decodeIfPresent(String.self, forKey: .columnReadyEmpty) ?? "__columnReadyEmpty" + sectionToday = try container.decodeIfPresent(String.self, forKey: .sectionToday) ?? "__sectionToday" allOrdersButton = try container.decodeIfPresent(String.self, forKey: .allOrdersButton) ?? "__allOrdersButton" + itemsSingular = try container.decodeIfPresent(String.self, forKey: .itemsSingular) ?? "__itemsSingular" + sectionTomorrow = try container.decodeIfPresent(String.self, forKey: .sectionTomorrow) ?? "__sectionTomorrow" + sectionLater = try container.decodeIfPresent(String.self, forKey: .sectionLater) ?? "__sectionLater" itemsPlural = try container.decodeIfPresent(String.self, forKey: .itemsPlural) ?? "__itemsPlural" - columnOutForDelivery = try container.decodeIfPresent(String.self, forKey: .columnOutForDelivery) ?? "__columnOutForDelivery" + columnAccepted = try container.decodeIfPresent(String.self, forKey: .columnAccepted) ?? "__columnAccepted" columnIncomingEmpty = try container.decodeIfPresent(String.self, forKey: .columnIncomingEmpty) ?? "__columnIncomingEmpty" + columnIncoming = try container.decodeIfPresent(String.self, forKey: .columnIncoming) ?? "__columnIncoming" + columnOutForDelivery = try container.decodeIfPresent(String.self, forKey: .columnOutForDelivery) ?? "__columnOutForDelivery" columnReady = try container.decodeIfPresent(String.self, forKey: .columnReady) ?? "__columnReady" columnDoneTodayEmpty = try container.decodeIfPresent(String.self, forKey: .columnDoneTodayEmpty) ?? "__columnDoneTodayEmpty" - columnAcceptedEmpty = try container.decodeIfPresent(String.self, forKey: .columnAcceptedEmpty) ?? "__columnAcceptedEmpty" - columnAccepted = try container.decodeIfPresent(String.self, forKey: .columnAccepted) ?? "__columnAccepted" - columnOutForDeliveryEmpty = try container.decodeIfPresent(String.self, forKey: .columnOutForDeliveryEmpty) ?? "__columnOutForDeliveryEmpty" - sectionTomorrow = try container.decodeIfPresent(String.self, forKey: .sectionTomorrow) ?? "__sectionTomorrow" - sectionLater = try container.decodeIfPresent(String.self, forKey: .sectionLater) ?? "__sectionLater" - itemsSingular = try container.decodeIfPresent(String.self, forKey: .itemsSingular) ?? "__itemsSingular" columnDoneToday = try container.decodeIfPresent(String.self, forKey: .columnDoneToday) ?? "__columnDoneToday" - sectionToday = try container.decodeIfPresent(String.self, forKey: .sectionToday) ?? "__sectionToday" - columnIncoming = try container.decodeIfPresent(String.self, forKey: .columnIncoming) ?? "__columnIncoming" + columnAcceptedEmpty = try container.decodeIfPresent(String.self, forKey: .columnAcceptedEmpty) ?? "__columnAcceptedEmpty" } public override subscript(key: String) -> String? { switch key { + case CodingKeys.columnOutForDeliveryEmpty.stringValue: return columnOutForDeliveryEmpty case CodingKeys.columnReadyEmpty.stringValue: return columnReadyEmpty + case CodingKeys.sectionToday.stringValue: return sectionToday case CodingKeys.allOrdersButton.stringValue: return allOrdersButton + case CodingKeys.itemsSingular.stringValue: return itemsSingular + case CodingKeys.sectionTomorrow.stringValue: return sectionTomorrow + case CodingKeys.sectionLater.stringValue: return sectionLater case CodingKeys.itemsPlural.stringValue: return itemsPlural - case CodingKeys.columnOutForDelivery.stringValue: return columnOutForDelivery + case CodingKeys.columnAccepted.stringValue: return columnAccepted case CodingKeys.columnIncomingEmpty.stringValue: return columnIncomingEmpty + case CodingKeys.columnIncoming.stringValue: return columnIncoming + case CodingKeys.columnOutForDelivery.stringValue: return columnOutForDelivery case CodingKeys.columnReady.stringValue: return columnReady case CodingKeys.columnDoneTodayEmpty.stringValue: return columnDoneTodayEmpty - case CodingKeys.columnAcceptedEmpty.stringValue: return columnAcceptedEmpty - case CodingKeys.columnAccepted.stringValue: return columnAccepted - case CodingKeys.columnOutForDeliveryEmpty.stringValue: return columnOutForDeliveryEmpty - case CodingKeys.sectionTomorrow.stringValue: return sectionTomorrow - case CodingKeys.sectionLater.stringValue: return sectionLater - case CodingKeys.itemsSingular.stringValue: return itemsSingular case CodingKeys.columnDoneToday.stringValue: return columnDoneToday - case CodingKeys.sectionToday.stringValue: return sectionToday - case CodingKeys.columnIncoming.stringValue: return columnIncoming + case CodingKeys.columnAcceptedEmpty.stringValue: return columnAcceptedEmpty + default: return nil + } + } + } + + public final class Settings: LocalizableSection { + public var logOutButton = "" + public var printerHeader = "" + public var appVersionHeader = "" + public var selectPrinterButton = "" + public var logOutAlertMessage = "" + public var title = "" + public var logOutAlertCancel = "" + public var usernameHeader = "" + public var closeButton = "" + public var logoutAlertTitle = "" + public var logOutAlertConfirm = "" + + enum CodingKeys: String, CodingKey { + case logOutButton + case printerHeader + case appVersionHeader + case selectPrinterButton + case logOutAlertMessage + case title + case logOutAlertCancel + case usernameHeader + case closeButton + case logoutAlertTitle + case logOutAlertConfirm + } + + public override init() { super.init() } + + public required init(from decoder: Decoder) throws { + super.init() + let container = try decoder.container(keyedBy: CodingKeys.self) + logOutButton = try container.decodeIfPresent(String.self, forKey: .logOutButton) ?? "__logOutButton" + printerHeader = try container.decodeIfPresent(String.self, forKey: .printerHeader) ?? "__printerHeader" + appVersionHeader = try container.decodeIfPresent(String.self, forKey: .appVersionHeader) ?? "__appVersionHeader" + selectPrinterButton = try container.decodeIfPresent(String.self, forKey: .selectPrinterButton) ?? "__selectPrinterButton" + logOutAlertMessage = try container.decodeIfPresent(String.self, forKey: .logOutAlertMessage) ?? "__logOutAlertMessage" + title = try container.decodeIfPresent(String.self, forKey: .title) ?? "__title" + logOutAlertCancel = try container.decodeIfPresent(String.self, forKey: .logOutAlertCancel) ?? "__logOutAlertCancel" + usernameHeader = try container.decodeIfPresent(String.self, forKey: .usernameHeader) ?? "__usernameHeader" + closeButton = try container.decodeIfPresent(String.self, forKey: .closeButton) ?? "__closeButton" + logoutAlertTitle = try container.decodeIfPresent(String.self, forKey: .logoutAlertTitle) ?? "__logoutAlertTitle" + logOutAlertConfirm = try container.decodeIfPresent(String.self, forKey: .logOutAlertConfirm) ?? "__logOutAlertConfirm" + } + + public override subscript(key: String) -> String? { + switch key { + case CodingKeys.logOutButton.stringValue: return logOutButton + case CodingKeys.printerHeader.stringValue: return printerHeader + case CodingKeys.appVersionHeader.stringValue: return appVersionHeader + case CodingKeys.selectPrinterButton.stringValue: return selectPrinterButton + case CodingKeys.logOutAlertMessage.stringValue: return logOutAlertMessage + case CodingKeys.title.stringValue: return title + case CodingKeys.logOutAlertCancel.stringValue: return logOutAlertCancel + case CodingKeys.usernameHeader.stringValue: return usernameHeader + case CodingKeys.closeButton.stringValue: return closeButton + case CodingKeys.logoutAlertTitle.stringValue: return logoutAlertTitle + case CodingKeys.logOutAlertConfirm.stringValue: return logOutAlertConfirm default: return nil } } diff --git a/Modules/Sources/NetworkClient/Client.swift b/Modules/Sources/NetworkClient/Client.swift index 5377931..de59c3a 100644 --- a/Modules/Sources/NetworkClient/Client.swift +++ b/Modules/Sources/NetworkClient/Client.swift @@ -5,7 +5,6 @@ // Created by Jakob Mygind on 04/01/2022. // -import Combine import Foundation import Network import XCTestDynamicOverlay @@ -17,7 +16,7 @@ public struct NetworkClient { public let status: NWPath.Status } - public var pathUpdatePublisher: AnyPublisher + public var pathUpdateStream: () -> AsyncStream } extension NetworkClient.NetworkPath { @@ -26,53 +25,60 @@ extension NetworkClient.NetworkPath { } } +#if DEBUG extension NetworkClient { - public static let failing = Self.init(pathUpdatePublisher: .failing()) + public static var failing: Self { + return .init(pathUpdateStream: { + XCTFail("\(Self.self).pathUpdateStream method not implemented.") + fatalError("\(Self.self).pathUpdateStream method not implemented.") + }) + } + public static let noop = Self.init( - pathUpdatePublisher: Empty(completeImmediately: false).eraseToAnyPublisher()) + pathUpdateStream: { .init(unfolding: { .none }) } + ) public static let happy = Self.init( - pathUpdatePublisher: .init(value: .init(status: .satisfied))) + pathUpdateStream: { + .init { continuation in + continuation.yield(.init(status: .satisfied)) + continuation.finish() + } + } + ) public static let unhappy = Self.init( - pathUpdatePublisher: .init(value: .init(status: .unsatisfied))) - - public static var flakey: Self { + pathUpdateStream: { + .init { continuation in + continuation.yield(.init(status: .unsatisfied)) + continuation.finish() + } + } + ) + private static var timer: Timer! + + public static func flakey( + firstStatus: NWPath.Status = .unsatisfied, + timeInterval: TimeInterval = 3 + ) -> Self { Self( - pathUpdatePublisher: Timer.publish( - every: 3, tolerance: nil, on: .main, in: .default, options: nil - ) - .autoconnect() - .scan( - NWPath.Status.satisfied, - { status, _ in - status == .satisfied ? .unsatisfied : .satisfied + pathUpdateStream: { + AsyncStream { continuation in + var currentStatus = firstStatus + continuation.yield(.init(status: firstStatus)) + timer = Timer( + timeInterval: timeInterval, + repeats: true + ) { _ in + currentStatus = currentStatus == .satisfied ? .unsatisfied : .satisfied + continuation.yield(.init(status: currentStatus)) + } + continuation.onTermination = { _ in + timer.invalidate() + } + RunLoop.main.add(timer, forMode: .default) } - ) - .map(NetworkClient.NetworkPath.init(status:)) - .eraseToAnyPublisher() + } ) } } - -extension AnyPublisher { - fileprivate static func failing(_ message: String = "") -> Self { - .fireAndForget { - XCTFail("\(message.isEmpty ? "" : "\(message) - ")A failing effect ran.") - } - } - - fileprivate init(value: Output) { - self = Just(value).setFailureType(to: Failure.self).eraseToAnyPublisher() - } - - fileprivate init(_ error: Failure) { - self = Fail(error: error).eraseToAnyPublisher() - } - - fileprivate static func fireAndForget(_ work: @escaping () -> Void) -> Self { - Deferred { () -> Empty in - work() - return Empty(completeImmediately: true) - }.eraseToAnyPublisher() - } -} +#endif diff --git a/Modules/Sources/NetworkClient/Live.swift b/Modules/Sources/NetworkClient/Live.swift index 9f03710..61c8669 100644 --- a/Modules/Sources/NetworkClient/Live.swift +++ b/Modules/Sources/NetworkClient/Live.swift @@ -12,19 +12,20 @@ import Network extension NetworkClient { public static func live(queue: DispatchQueue) -> Self { - let subject = PassthroughSubject() let monitor = NWPathMonitor() - monitor.pathUpdateHandler = subject.send(_:) return Self.init( - pathUpdatePublisher: - subject - .handleEvents( - receiveSubscription: { _ in monitor.start(queue: queue) }, - receiveCancel: monitor.cancel - ) - .map(NetworkClient.NetworkPath.init(rawValue:)) - .eraseToAnyPublisher() + pathUpdateStream: { + AsyncStream { continuation in + monitor.start(queue: queue) + monitor.pathUpdateHandler = { path in + continuation.yield(.init(rawValue: path)) + } + continuation.onTermination = { _ in + monitor.cancel() + } + } + } ) } }