Skip to content

[Woo POS][Historical Orders] Feature flag and entry point #16022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions Modules/Sources/Experiments/DefaultFeatureFlagService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
return true
case .productImageOptimizedHandling:
return true
case .pointOfSaleBarcodeScanningi1:
return true
case .showPointOfSaleBarcodeSimulator:
// Enables a simulated barcode scanner in dev builds for testing. Do not ship this one!
return false
case .pointOfSaleAsATabi1:
return true
case .pointOfSaleAsATabi2:
Expand All @@ -101,12 +96,12 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
return true
case .pointOfSaleOrdersi2:
return true
case .pointOfSaleBarcodeScanningi2:
return true
case .pointOfSaleSettingsi1:
return false
case .orderAddressMapSearch:
return true
case .pointOfSaleHistoricalOrdersi1:
return buildConfig == .localDeveloper || buildConfig == .alpha
default:
return true
}
Expand Down
16 changes: 4 additions & 12 deletions Modules/Sources/Experiments/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,6 @@ public enum FeatureFlag: Int {
///
case pointOfSaleReceipts

/// Enables barcode scanning with an external scanner in POS
///
case pointOfSaleBarcodeScanningi1

/// Enables a simulated barcode scanner for testing in POS. Do not ship this one!
///
case showPointOfSaleBarcodeSimulator

/// Enables displaying POS as a tab in the tab bar with the same eligibility as the previous entry point
///
case pointOfSaleAsATabi1
Expand All @@ -207,15 +199,15 @@ public enum FeatureFlag: Int {
///
case pointOfSaleOrdersi2

/// Enables the Point of Sale Barcode Scanner set up flows, as part of i2
///
case pointOfSaleBarcodeScanningi2

/// Enables the entry point for Point of Sale Settings
///
case pointOfSaleSettingsi1

/// Enables the CTA to search for an address in the map in order details > shipping address.
///
case orderAddressMapSearch

/// Enables the entry point for Point of Sale Orders
///
case pointOfSaleHistoricalOrdersi1
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ struct BarcodeScanningModifier: ViewModifier {
/// Callback that is triggered when a barcode is successfully scanned
let onScan: (Result<String, HIDBarcodeParserError>) -> Void

private var isBarcodeScani1FeatureEnabled: Bool {
ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleBarcodeScanningi1)
}

func body(content: Content) -> some View {
ZStack {
content

if enabled && isBarcodeScani1FeatureEnabled {
if enabled {
BarcodeScannerContainer(onScan: onScan)
}
}
Expand Down
42 changes: 0 additions & 42 deletions WooCommerce/Classes/POS/Presentation/ItemListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ struct ItemListView: View {
@State private var searchTask: Task<Void, Never>?
@State private var didFinishSearch = true

private var isBarcodeScani1FeatureEnabled: Bool {
ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleBarcodeScanningi1)
}

private var isBarcodeScanSimulatorEnabled: Bool {
ServiceLocator.featureFlagService.isFeatureFlagEnabled(.showPointOfSaleBarcodeSimulator)
}

private var isAddingCouponAllowed: Bool {
guard case .coupons = selectedItemListType else { return false }
let itemListState = itemListState(selectedItemListType)
Expand All @@ -71,9 +63,6 @@ struct ItemListView: View {

@State private var showCouponCreationModal: Bool = false

@State private var barcodeScanSimulatorIsPresented: Bool = false
@State private var barcodeScanSimulatorText: String = ""

var body: some View {
if #available(iOS 18.0, *) {
NavigationStack {
Expand Down Expand Up @@ -244,9 +233,6 @@ private extension ItemListView {
} else {
createCouponButton

simulatedScanButton
.renderedIf(isBarcodeScanSimulatorEnabled && isBarcodeScani1FeatureEnabled)

POSPageHeaderActionButton(systemName: "magnifyingglass") {
analyticsTracker.trackSearchTapped(itemListType: selectedItemListType)
setSearch(true)
Expand All @@ -256,9 +242,6 @@ private extension ItemListView {

}
})

barcodeScanSimulator
.renderedIf(barcodeScanSimulatorIsPresented)
}
.animation(.easeInOut(duration: Constants.animationDuration), value: isSearching)
.animation(.easeInOut(duration: Constants.animationDuration), value: isAddingCouponAllowed)
Expand Down Expand Up @@ -307,31 +290,6 @@ private extension ItemListView {
.transition(.opacity.combined(with: .scale))
}

@ViewBuilder
private var simulatedScanButton: some View {
POSPageHeaderActionButton(systemName: "barcode") {
barcodeScanSimulatorIsPresented.toggle()
}
.transition(.opacity.combined(with: .scale))
}

@ViewBuilder
private var barcodeScanSimulator: some View {
HStack {
TextField(text: $barcodeScanSimulatorText) {
Text("Barcode value")
}

Button {
posModel.barcodeScanned(.success(barcodeScanSimulatorText))
} label: {
Text("Scan!")
}
.buttonStyle(POSFilledButtonStyle(size: .extraSmall))
}
.padding([.bottom, .horizontal], 16)
}

@ViewBuilder
var emptyView: some View {
switch selectedItemListType {
Expand Down
53 changes: 27 additions & 26 deletions WooCommerce/Classes/POS/Presentation/POSFloatingControlView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,15 @@ struct POSFloatingControlView: View {
title: { Text(Localization.productRestrictionsInfo) },
icon: { Image(systemName: "magnifyingglass") })
}
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleBarcodeScanningi1) {
Button {
showBarcodeScanningModal = true
ServiceLocator.analytics.track(.pointOfSaleBarcodeScanningMenuItemTapped)
} label: {
Label(
title: {
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleBarcodeScanningi2) {
Text(Localization.barcodeScanningSetup)
} else {
Text(Localization.barcodeScanning)
}
},
icon: { Image(systemName: "barcode.viewfinder") })
}
Button {
showBarcodeScanningModal = true
ServiceLocator.analytics.track(.pointOfSaleBarcodeScanningMenuItemTapped)
} label: {
Label(
title: {
Text(Localization.barcodeScanningSetup)
},
icon: { Image(systemName: "barcode.viewfinder") })
}
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleSettingsi1) {
Button {
Expand All @@ -86,6 +80,17 @@ struct POSFloatingControlView: View {
)
}
}

if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleHistoricalOrdersi1) {
Button {
// TODO: WOOMOB-1133
} label: {
Label(
title: { Text(Localization.orders) },
icon: { Image(systemName: "text.document") }
)
}
}
} label: {
VStack {
Spacer()
Expand All @@ -112,11 +117,7 @@ struct POSFloatingControlView: View {
SimpleProductsOnlyInformation(isPresented: $showProductRestrictionsModal)
}
.posModal(isPresented: $showBarcodeScanningModal) {
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleBarcodeScanningi2) {
PointOfSaleBarcodeScannerSetup(isPresented: $showBarcodeScanningModal)
} else {
PointOfSaleBarcodeScannerInformationModal(isPresented: $showBarcodeScanningModal)
}
PointOfSaleBarcodeScannerSetup(isPresented: $showBarcodeScanningModal)
}
.frame(height: Constants.size)
.background(Color.clear)
Expand Down Expand Up @@ -161,6 +162,12 @@ private extension POSFloatingControlView {
}

enum Localization {
static let orders = NSLocalizedString(
"pointOfSale.floatingButtons.orders.button.title",
value: "Orders",
comment: "The title of the menu button to access Point of Sale historical orders, shown in a fullscreen view."
)

static let exitPointOfSale = NSLocalizedString(
"pointOfSale.floatingButtons.exit.button.title",
value: "Exit POS",
Expand All @@ -187,12 +194,6 @@ private extension POSFloatingControlView {
"We only show simple and variable products in POS, this shows a modal to help explain that limitation."
)

static let barcodeScanning = NSLocalizedString(
"pointOfSale.floatingButtons.barcodeScanning.button.title",
value: "Barcode scanning",
comment: "The title of the menu button to view barcode scanner documentation, shown in a popover menu."
)

static let barcodeScanningSetup = NSLocalizedString(
"pointOfSale.floatingButtons.barcodeScanningSetup.button.title",
value: "Initial barcode scanner setup",
Expand Down
Loading