-
Notifications
You must be signed in to change notification settings - Fork 118
[Local Catalog] POS Settings: add local catalog sync settings UI #16125
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
a399e1f
a98a079
d7f6691
13a5b4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,192 @@ | ||||||||||||||
import SwiftUI | ||||||||||||||
|
||||||||||||||
struct POSSettingsLocalCatalogDetailView: View { | ||||||||||||||
// TODO: WOOMOB-1335 - implement full sync cellular data setting functionality | ||||||||||||||
@State private var allowFullSyncOnCellular: Bool = true | ||||||||||||||
|
||||||||||||||
private var backgroundColor: Color { | ||||||||||||||
Color.posOnSecondaryContainer | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
var body: some View { | ||||||||||||||
NavigationStack { | ||||||||||||||
VStack(spacing: POSSpacing.none) { | ||||||||||||||
POSPageHeaderView(title: Localization.localCatalogTitle) | ||||||||||||||
.foregroundColor(.posSurface) | ||||||||||||||
.accessibilityAddTraits(.isHeader) | ||||||||||||||
|
||||||||||||||
ScrollView { | ||||||||||||||
VStack(spacing: POSSpacing.medium) { | ||||||||||||||
catalogStatusView | ||||||||||||||
managingDataUsageView | ||||||||||||||
manualCatalogUpdateView | ||||||||||||||
Comment on lines
+20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
They're not full views anyway, but even if they were, the word "view" seems unnecessary here |
||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
.background(backgroundColor) | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
private extension POSSettingsLocalCatalogDetailView { | ||||||||||||||
@ViewBuilder | ||||||||||||||
var catalogStatusView: some View { | ||||||||||||||
VStack(spacing: POSSpacing.none) { | ||||||||||||||
sectionHeaderView(title: Localization.catalogStatus) | ||||||||||||||
|
||||||||||||||
VStack(spacing: POSSpacing.medium) { | ||||||||||||||
// TODO: WOOMOB-1100 - replace with catalog data | ||||||||||||||
fieldRowView(label: Localization.catalogSize, value: "1,250 products, 3,420 variations (1.8 GB)") | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1.8GB scared me for a moment. Might be best to either make a note in this view that this is fake data, or use something clearly impossible (500TB or something)... |
||||||||||||||
fieldRowView(label: Localization.lastIncrementalUpdate, value: "5 minutes ago") | ||||||||||||||
fieldRowView(label: Localization.lastFullSync, value: "Today at 2:34 PM") | ||||||||||||||
} | ||||||||||||||
.padding(.bottom, POSPadding.medium) | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
@ViewBuilder | ||||||||||||||
var managingDataUsageView: some View { | ||||||||||||||
VStack(spacing: POSSpacing.none) { | ||||||||||||||
sectionHeaderView(title: Localization.managingDataUsage) | ||||||||||||||
|
||||||||||||||
VStack(spacing: POSSpacing.medium) { | ||||||||||||||
toggleRowView(label: Localization.allowFullSyncOnCellular, isOn: $allowFullSyncOnCellular) | ||||||||||||||
} | ||||||||||||||
.padding(.bottom, POSPadding.medium) | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
@ViewBuilder | ||||||||||||||
var manualCatalogUpdateView: some View { | ||||||||||||||
VStack(spacing: POSSpacing.none) { | ||||||||||||||
sectionHeaderView(title: Localization.manualCatalogUpdate) | ||||||||||||||
|
||||||||||||||
VStack(spacing: POSSpacing.medium) { | ||||||||||||||
Text(Localization.manualUpdateInfo) | ||||||||||||||
.font(.posCaptionRegular) | ||||||||||||||
.foregroundStyle(.secondary) | ||||||||||||||
.frame(maxWidth: .infinity, alignment: .leading) | ||||||||||||||
|
||||||||||||||
Button(action: { | ||||||||||||||
// Handle refresh catalog action | ||||||||||||||
}) { | ||||||||||||||
Text(Localization.refreshCatalog) | ||||||||||||||
} | ||||||||||||||
.buttonStyle(POSFilledButtonStyle(size: .normal)) | ||||||||||||||
} | ||||||||||||||
.padding(.horizontal, POSPadding.medium) | ||||||||||||||
.padding(.bottom, POSPadding.medium) | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
@ViewBuilder | ||||||||||||||
func sectionHeaderView(title: String) -> some View { | ||||||||||||||
ZStack { | ||||||||||||||
backgroundColor | ||||||||||||||
Text(title) | ||||||||||||||
.font(.posBodyLargeBold) | ||||||||||||||
.foregroundColor(.posOnSurface) | ||||||||||||||
.frame(maxWidth: .infinity, alignment: .leading) | ||||||||||||||
.padding(.horizontal, POSPadding.medium) | ||||||||||||||
.padding(.vertical, POSPadding.small) | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
@ViewBuilder | ||||||||||||||
func fieldRowView(label: String, value: String) -> some View { | ||||||||||||||
VStack(alignment: .leading, spacing: POSPadding.small) { | ||||||||||||||
Text(label) | ||||||||||||||
.font(.posBodyMediumRegular()) | ||||||||||||||
Text(value) | ||||||||||||||
.font(.posBodyMediumRegular()) | ||||||||||||||
.foregroundStyle(.secondary) | ||||||||||||||
} | ||||||||||||||
.frame(maxWidth: .infinity, alignment: .leading) | ||||||||||||||
.padding(.horizontal, POSPadding.medium) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
@ViewBuilder | ||||||||||||||
func toggleRowView(label: String, isOn: Binding<Bool>) -> some View { | ||||||||||||||
HStack { | ||||||||||||||
Text(label) | ||||||||||||||
.font(.posBodyMediumRegular()) | ||||||||||||||
Spacer() | ||||||||||||||
Toggle("", isOn: isOn) | ||||||||||||||
.toggleStyle(SwitchToggleStyle()) | ||||||||||||||
} | ||||||||||||||
.frame(maxWidth: .infinity, alignment: .leading) | ||||||||||||||
.padding(.horizontal, POSPadding.medium) | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
private extension POSSettingsLocalCatalogDetailView { | ||||||||||||||
enum Localization { | ||||||||||||||
static let localCatalogTitle = NSLocalizedString( | ||||||||||||||
"posSettingsLocalCatalogDetailView.title", | ||||||||||||||
value: "Catalog Settings", | ||||||||||||||
comment: "Navigation title for the local catalog details in POS settings." | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
static let catalogStatus = NSLocalizedString( | ||||||||||||||
"posSettingsLocalCatalogDetailView.catalogStatus", | ||||||||||||||
value: "Catalog Status", | ||||||||||||||
comment: "Section title for catalog status in Point of Sale settings." | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
static let managingDataUsage = NSLocalizedString( | ||||||||||||||
"posSettingsLocalCatalogDetailView.managingDataUsage", | ||||||||||||||
value: "Managing data usage", | ||||||||||||||
comment: "Section title for managing data usage in Point of Sale settings." | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
static let lastIncrementalUpdate = NSLocalizedString( | ||||||||||||||
"posSettingsLocalCatalogDetailView.lastIncrementalUpdate", | ||||||||||||||
value: "Last incremental update", | ||||||||||||||
comment: "Label for last incremental update field in Point of Sale settings." | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
static let lastFullSync = NSLocalizedString( | ||||||||||||||
"posSettingsLocalCatalogDetailView.lastFullSync", | ||||||||||||||
value: "Last full sync", | ||||||||||||||
comment: "Label for last full sync field in Point of Sale settings." | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
static let catalogSize = NSLocalizedString( | ||||||||||||||
"posSettingsLocalCatalogDetailView.catalogSize", | ||||||||||||||
value: "Catalog size", | ||||||||||||||
comment: "Label for catalog size field in Point of Sale settings." | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
static let allowFullSyncOnCellular = NSLocalizedString( | ||||||||||||||
"posSettingsLocalCatalogDetailView.allowFullSyncOnCellular", | ||||||||||||||
value: "Allow full sync on cellular data", | ||||||||||||||
comment: "Label for allow full sync on cellular data toggle in Point of Sale settings." | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
static let manualCatalogUpdate = NSLocalizedString( | ||||||||||||||
"posSettingsLocalCatalogDetailView.manualCatalogUpdate", | ||||||||||||||
value: "Manual Catalog Update", | ||||||||||||||
comment: "Section title for manual catalog update in Point of Sale settings." | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
static let manualUpdateInfo = NSLocalizedString( | ||||||||||||||
"posSettingsLocalCatalogDetailView.manualUpdateInfo", | ||||||||||||||
value: "Use this refresh only when something seems off - POS keeps data current automatically.", | ||||||||||||||
comment: "Info text explaining when to use manual catalog update." | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
static let refreshCatalog = NSLocalizedString( | ||||||||||||||
"posSettingsLocalCatalogDetailView.refreshCatalog", | ||||||||||||||
value: "Refresh catalog", | ||||||||||||||
comment: "Button text for refreshing the catalog manually." | ||||||||||||||
) | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
#if DEBUG | ||||||||||||||
#Preview { | ||||||||||||||
POSSettingsLocalCatalogDetailView() | ||||||||||||||
} | ||||||||||||||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,17 @@ extension PointOfSaleSettingsView { | |
} | ||
) | ||
|
||
// TODO: WOOMOB-1287 - integrate with local catalog feature eligibility | ||
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleLocalCatalogi1) { | ||
PointOfSaleSettingsCard( | ||
item: .localCatalog, | ||
isSelected: selection == .localCatalog, | ||
onTap: { | ||
selection = .localCatalog | ||
} | ||
) | ||
} | ||
|
||
Spacer() | ||
|
||
PointOfSaleSettingsCard( | ||
|
@@ -76,6 +87,8 @@ extension PointOfSaleSettingsView { | |
PointOfSaleSettingsStoreDetailView(viewModel: settingsController.storeViewModel) | ||
case .hardware: | ||
PointOfSaleSettingsHardwareDetailView(settingsController: settingsController) | ||
case .localCatalog: | ||
POSSettingsLocalCatalogDetailView() | ||
case .help: | ||
PointOfSaleSettingsHelpDetailView() | ||
default: | ||
|
@@ -141,6 +154,7 @@ extension PointOfSaleSettingsView { | |
enum SidebarNavigation: String, CaseIterable, Identifiable { | ||
case store | ||
case hardware | ||
case localCatalog | ||
case help | ||
|
||
var id: Self { self } | ||
|
@@ -149,6 +163,7 @@ extension PointOfSaleSettingsView { | |
switch self { | ||
case .store: return Localization.sidebarNavigationStoreTitle | ||
case .hardware: return Localization.sidebarNavigationHardwareTitle | ||
case .localCatalog: return Localization.sidebarNavigationLocalCatalogTitle | ||
case .help: return Localization.sidebarNavigationHelpTitle | ||
} | ||
} | ||
|
@@ -157,6 +172,7 @@ extension PointOfSaleSettingsView { | |
switch self { | ||
case .store: return Localization.sidebarNavigationStoreSubtitle | ||
case .hardware: return Localization.sidebarNavigationHardwareSubtitle | ||
case .localCatalog: return Localization.sidebarNavigationLocalCatalogSubtitle | ||
case .help: return Localization.sidebarNavigationHelpSubtitle | ||
} | ||
} | ||
|
@@ -165,6 +181,7 @@ extension PointOfSaleSettingsView { | |
switch self { | ||
case .store: return "bag" | ||
case .hardware: return "wrench.and.screwdriver" | ||
case .localCatalog: return "internaldrive" | ||
case .help: return "questionmark.circle" | ||
} | ||
} | ||
|
@@ -207,6 +224,18 @@ extension PointOfSaleSettingsView { | |
comment: "Description of the settings to be found within the Hardware section." | ||
) | ||
|
||
static let sidebarNavigationLocalCatalogTitle = NSLocalizedString( | ||
"pointOfSaleSettingsView.sidebarNavigationLocalCatalogTitle", | ||
value: "Local catalog", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps just |
||
comment: "Title of the Local catalog section within Point of Sale settings." | ||
) | ||
|
||
static let sidebarNavigationLocalCatalogSubtitle = NSLocalizedString( | ||
"pointOfSaleSettingsView.sidebarNavigationLocalCatalogSubtitle", | ||
value: "Manage catalog settings", | ||
comment: "Description of the settings to be found within the Local catalog section." | ||
) | ||
|
||
static let sidebarNavigationHelpSubtitle = NSLocalizedString( | ||
"pointOfSaleSettingsView.sidebarNavigationHelpSubtitle", | ||
value: "Get help and support", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this can't change, maybe it's better to make it a constant?