Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,12 @@ private extension String {

#if DEBUG
#Preview {
if #available(iOS 17.0, *) {
PointOfSaleOrderSyncCouponsErrorMessageView(message: "An error happened!") {}
.environment(POSPreviewHelpers.makePreviewAggregateModel())
}
PointOfSaleOrderSyncCouponsErrorMessageView(message: "An error happened!") {}
.environment(POSPreviewHelpers.makePreviewAggregateModel())
}

#Preview {
if #available(iOS 17.0, *) {
PointOfSaleOrderSyncCouponsErrorMessageView(message: "Lo sentimos, este cupón no se puede aplicar a los productos seleccionados.") {}
.environment(POSPreviewHelpers.makePreviewAggregateModel())
}
PointOfSaleOrderSyncCouponsErrorMessageView(message: "Lo sentimos, este cupón no se puede aplicar a los productos seleccionados.") {}
.environment(POSPreviewHelpers.makePreviewAggregateModel())
}
#endif
50 changes: 20 additions & 30 deletions WooCommerce/Classes/POS/TabBar/POSIneligibleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,48 +209,38 @@ private extension POSIneligibleReason {
#if DEBUG

#Preview("Unsupported currency") {
if #available(iOS 17.0, *) {
POSIneligibleView(
reason: .unsupportedCurrency(countryCode: .US, supportedCurrencies: [.USD]),
onRefresh: {}
)
}
POSIneligibleView(
reason: .unsupportedCurrency(countryCode: .US, supportedCurrencies: [.USD]),
onRefresh: {}
)
}

#Preview("WooCommerce plugin not found") {
if #available(iOS 17.0, *) {
POSIneligibleView(
reason: .wooCommercePluginNotFound,
onRefresh: {}
)
}
POSIneligibleView(
reason: .wooCommercePluginNotFound,
onRefresh: {}
)
}

#Preview("Feature switch disabled") {
if #available(iOS 17.0, *) {
POSIneligibleView(
reason: .featureSwitchDisabled,
onRefresh: {}
)
}
POSIneligibleView(
reason: .featureSwitchDisabled,
onRefresh: {}
)
}

#Preview("Site settings unavailable") {
if #available(iOS 17.0, *) {
POSIneligibleView(
reason: .siteSettingsNotAvailable,
onRefresh: {}
)
}
POSIneligibleView(
reason: .siteSettingsNotAvailable,
onRefresh: {}
)
}

#Preview("Unsupported WooCommerce version") {
if #available(iOS 17.0, *) {
POSIneligibleView(
reason: .unsupportedWooCommerceVersion(minimumVersion: "9.6.0"),
onRefresh: {}
)
}
POSIneligibleView(
reason: .unsupportedWooCommerceVersion(minimumVersion: "9.6.0"),
onRefresh: {}
)
}

#endif
3 changes: 1 addition & 2 deletions WooCommerce/Classes/POS/TabBar/POSTabCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ private extension POSTabCoordinator {
let orderService = POSOrderService(siteID: siteID,
credentials: credentials,
selectedSite: defaultSitePublisher,
appPasswordSupportState: isAppPasswordSupported),
#available(iOS 17.0, *) {
appPasswordSupportState: isAppPasswordSupported) {
let posView = PointOfSaleEntryPointView(
siteID: siteID,
itemFetchStrategyFactory: posItemFetchStrategyFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class OrderPaymentDetailsViewModel {
}

var subtotalValue: String {
return order.subtotalValue(currencyFormatter: currencyFormatter) ?? String()
return order.subtotalValue(currencyFormatter: currencyFormatter)
}

var shouldHideSubtotal: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ struct InPersonPaymentsMenu: View {
viewModel.purchaseCardReaderTapped()
} label: {
PaymentsRow(image: Image(uiImage: .shoppingCartIcon),
title: Localization.purchaseCardReader,
isActive: $viewModel.presentPurchaseCardReader) {
AuthenticatedWebView(isPresented: .constant(true),
viewModel: viewModel.purchaseCardReaderWebViewModel)
}
title: Localization.purchaseCardReader)
}
.buttonStyle(.scrollViewRow)
.navigationDestination(isPresented: $viewModel.presentPurchaseCardReader) {
AuthenticatedWebView(isPresented: .constant(true),
viewModel: viewModel.purchaseCardReaderWebViewModel)
}

Button {
viewModel.manageCardReadersTapped()
Expand Down Expand Up @@ -118,12 +118,12 @@ struct InPersonPaymentsMenu: View {
viewModel.cardReaderManualsTapped()
} label: {
PaymentsRow(image: Image(uiImage: .cardReaderManualIcon),
title: Localization.cardReaderManuals,
isActive: $viewModel.presentCardReaderManuals) {
CardReaderManualsView()
}
title: Localization.cardReaderManuals)
}
.buttonStyle(.scrollViewRow)
.navigationDestination(isPresented: $viewModel.presentCardReaderManuals) {
CardReaderManualsView()
}
.accessibilityIdentifier(AccessibilityIdentifiers.cardReaderManualRow)
} header: {
Text(Localization.cardReaderSectionTitle.uppercased())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
import SwiftUI

struct PaymentsRow<Destination>: View where Destination: View {
struct PaymentsRow: View {
private let image: Image
private let title: String
private let subtitle: String?
private let shouldBadgeImage: Bool
private var isActive: Binding<Bool>?
@ViewBuilder private let destination: (() -> Destination)?

init(image: Image,
title: String,
subtitle: String? = nil,
shouldBadgeImage: Bool = false,
isActive: Binding<Bool>,
@ViewBuilder destination: @escaping () -> Destination) {
shouldBadgeImage: Bool = false) {
self.image = image
self.title = title
self.subtitle = subtitle
self.shouldBadgeImage = shouldBadgeImage
self.destination = destination
self.isActive = isActive
}

var body: some View {
Expand Down Expand Up @@ -49,36 +43,6 @@ struct PaymentsRow<Destination>: View where Destination: View {
Spacer()
}
.contentShape(Rectangle())

navigationLink
}

@ViewBuilder
private var navigationLink: some View {
if let isActive,
let destination {
NavigationLink(isActive: isActive) {
destination()
} label: {
EmptyView()
}
} else {
EmptyView()
}
}
}

extension PaymentsRow where Destination == Never {
init(image: Image,
title: String,
subtitle: String? = nil,
shouldBadgeImage: Bool = false) {
self.image = image
self.title = title
self.subtitle = subtitle
self.shouldBadgeImage = shouldBadgeImage
self.destination = nil
self.isActive = nil
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,5 @@ private extension AddressMapPickerView {
}

#Preview {
if #available(iOS 17, *) {
AddressMapPickerView(fields: .constant(.init()), countryByCode: { _ in nil })
} else {
EmptyView()
}
AddressMapPickerView(fields: .constant(.init()), countryByCode: { _ in nil })
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ struct SingleAddressForm: View {
}
}
.sheet(isPresented: $showMapPicker) {
if #available(iOS 17, *) {
AddressMapPickerView(fields: $fields, countryByCode: countryByCode)
}
AddressMapPickerView(fields: $fields, countryByCode: countryByCode)
}
}

Expand Down Expand Up @@ -324,7 +322,7 @@ struct SingleAddressForm: View {
.padding(.horizontal, insets: safeAreaInsets)
.accessibility(addTraits: .isHeader)
VStack(spacing: 0) {
if #available(iOS 17, *), ServiceLocator.featureFlagService.isFeatureFlagEnabled(.orderAddressMapSearch) {
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.orderAddressMapSearch) {
Button(action: {
showMapPicker = true
ServiceLocator.analytics.track(.orderDetailEditAddressMapPickerTapped,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,9 @@ private extension BadgeView {
func backgroundView() -> some View {
switch backgroundShape {
case .circle:
if #available(iOS 17, *) {
Circle()
.fill(customizations.backgroundColor)
.stroke(Color.white, lineWidth: Layout.borderLineWidth)
} else {
ZStack {
Circle()
.fill(customizations.backgroundColor)
Circle()
.stroke(Color.white, lineWidth: Layout.borderLineWidth)
}
}
Circle()
.fill(customizations.backgroundColor)
.stroke(Color.white, lineWidth: Layout.borderLineWidth)
case .roundedRectangle(let cornerRadius):
RoundedRectangle(cornerRadius: cornerRadius)
.stroke(.white, lineWidth: Layout.borderLineWidth)
Expand Down
Loading