Created
May 31, 2022 09:47
-
-
Save koke/f0d992ec62d0095bda322c15ab90f2df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Storage | |
enum BetaFeature { | |
case viewAddOns | |
case productSKUScanner | |
case couponManagement | |
} | |
extension BetaFeature { | |
var title: String { | |
switch self { | |
case .viewAddOns: | |
return NSLocalizedString( | |
"View Add-Ons", | |
comment: "Cell title on the beta features screen to enable the order add-ons feature") | |
case .productSKUScanner: | |
return NSLocalizedString( | |
"Product SKU Scanner", | |
comment: "Cell title on beta features screen to enable product SKU input scanner in inventory settings.") | |
case .couponManagement: | |
return NSLocalizedString( | |
"Coupon Management", | |
comment: "Cell title on beta features screen to enable coupon management") | |
} | |
} | |
var description: String { | |
switch self { | |
case .viewAddOns: | |
return NSLocalizedString( | |
"Test out viewing Order Add-Ons as we get ready to launch", | |
comment: "Cell description on the beta features screen to enable the order add-ons feature") | |
case .productSKUScanner: | |
return NSLocalizedString( | |
"Test out scanning a barcode for a product SKU in the product inventory settings", | |
comment: "Cell description on beta features screen to enable product SKU input scanner in inventory settings.") | |
case .couponManagement: | |
return NSLocalizedString( | |
"Test out managing coupons as we get ready to launch", | |
comment: "Cell description on beta features screen to enable coupon management") | |
} | |
} | |
var settingsKey: KeyPath<GeneralAppSettings, Bool> { | |
switch self { | |
case .viewAddOns: | |
return \.isViewAddOnsSwitchEnabled | |
case .productSKUScanner: | |
return \.isProductSKUInputScannerSwitchEnabled | |
case .couponManagement: | |
return \.isCouponManagementSwitchEnabled | |
} | |
} | |
} | |
extension BetaFeature { | |
var isEnabled: Bool { | |
// TODO: actually load settings from storage | |
let settings = GeneralAppSettings(installationDate: nil, feedbacks: [:], isViewAddOnsSwitchEnabled: true, isProductSKUInputScannerSwitchEnabled: true, isCouponManagementSwitchEnabled: true, knownCardReaders: []) | |
return settings[keyPath: settingsKey] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment