diff --git a/Modules/Sources/Experiments/DefaultFeatureFlagService.swift b/Modules/Sources/Experiments/DefaultFeatureFlagService.swift index ec3b2566eba..ee2e132a234 100644 --- a/Modules/Sources/Experiments/DefaultFeatureFlagService.swift +++ b/Modules/Sources/Experiments/DefaultFeatureFlagService.swift @@ -96,7 +96,7 @@ public struct DefaultFeatureFlagService: FeatureFlagService { case .pointOfSaleAsATabi2: return buildConfig == .localDeveloper || buildConfig == .alpha case .pointOfSaleOrdersi1: - return false + return buildConfig == .localDeveloper || buildConfig == .alpha default: return true } diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Order Summary Section/SummaryTableViewCell.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Order Summary Section/SummaryTableViewCell.swift index d9a3dff568a..2abeee9b88c 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Order Summary Section/SummaryTableViewCell.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Order Summary Section/SummaryTableViewCell.swift @@ -2,59 +2,6 @@ import UIKit import Yosemite import Gridicons -/// The ViewModel for `SummaryTableViewCell`. -/// -/// TODO This and that cell class should be renamed to be less ambiguous. -/// -struct SummaryTableViewCellViewModel { - fileprivate struct OrderStatusPresentation { - let style: OrderStatusEnum - let title: String - } - - private let billingAddress: Address? - private let dateCreated: Date - - fileprivate let presentation: OrderStatusPresentation - - private let calendar: Calendar - - init(order: Order, - status: OrderStatus?, - calendar: Calendar = .current) { - - billingAddress = order.billingAddress - dateCreated = order.dateCreated - - presentation = OrderStatusPresentation( - style: status?.status ?? order.status, - title: status?.name ?? order.status.rawValue - ) - - self.calendar = calendar - } - - /// The full name from the billing address - /// - var billedPersonName: String { - if let fullName = billingAddress?.fullName, fullName.isNotEmpty { - return fullName - } else { - return Localization.guestName - } - } - - /// The date, time, and the order number concatenated together. Example, “Jan 22, 2018, 11:23 AM”. - /// - var subtitle: String { - let formatter = DateFormatter.dateAndTimeFormatter - formatter.timeZone = .siteTimezone - return formatter.string(from: dateCreated) - } -} - -// MARK: - SummaryTableViewCell -// final class SummaryTableViewCell: UITableViewCell { /// Label: Title @@ -65,6 +12,10 @@ final class SummaryTableViewCell: UITableViewCell { /// @IBOutlet private weak var subtitleLabel: UILabel! + /// Shows the sales channel if appropiate, at the moment only Point of Sale + /// + @IBOutlet private weak var salesChannelLabel: UILabel! + /// Label: Payment Status /// @IBOutlet private weak var paymentStatusLabel: PaddedLabel! @@ -80,7 +31,8 @@ final class SummaryTableViewCell: UITableViewCell { func configure(_ viewModel: SummaryTableViewCellViewModel) { titleLabel.text = viewModel.billedPersonName subtitleLabel.text = viewModel.subtitle - + salesChannelLabel.text = viewModel.formattedSalesChannel + salesChannelLabel.isHidden = (salesChannelLabel.text == nil) display(presentation: viewModel.presentation) } @@ -91,8 +43,6 @@ final class SummaryTableViewCell: UITableViewCell { paymentStatusLabel.text = presentation.title } - // MARK: - Overridden Methods - override func awakeFromNib() { super.awakeFromNib() @@ -124,9 +74,6 @@ final class SummaryTableViewCell: UITableViewCell { } } - -// MARK: - Private -// private extension SummaryTableViewCell { /// Preserves the current Payment BG Color @@ -154,6 +101,14 @@ private extension SummaryTableViewCell { subtitleLabel.accessibilityIdentifier = "summary-table-view-cell-created-label" paymentStatusLabel.applyPaddedLabelDefaultStyles() paymentStatusLabel.accessibilityIdentifier = "summary-table-view-cell-payment-status-label" + + if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleOrdersi1) { + salesChannelLabel.isHidden = false + salesChannelLabel.applyFootnoteStyle() + salesChannelLabel.accessibilityIdentifier = "summary-table-view-cell-sales-channel-label" + } else { + salesChannelLabel.isHidden = true + } } func configureIcon() { @@ -169,9 +124,6 @@ private extension SummaryTableViewCell { } } - -// MARK: - VoiceOver -/// private extension SummaryTableViewCell { func configureIconForVoiceOver() { updateStatusButton.accessibilityLabel = NSLocalizedString("Update Order Status", @@ -181,12 +133,3 @@ private extension SummaryTableViewCell { comment: "Accessibility hint for the button to update the order status") } } - -// MARK: - Localization - -private extension SummaryTableViewCellViewModel { - enum Localization { - static let guestName: String = NSLocalizedString("Guest", - comment: "In Order Details, the name of the billed person when there are no name and last name.") - } -} diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Order Summary Section/SummaryTableViewCell.xib b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Order Summary Section/SummaryTableViewCell.xib index 7610963a622..50793f0a33e 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Order Summary Section/SummaryTableViewCell.xib +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Order Summary Section/SummaryTableViewCell.xib @@ -1,9 +1,9 @@ - + - + @@ -17,26 +17,37 @@ - + + + + + + +