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
@@ -0,0 +1,81 @@
import UIKit

/// Modal presented when a firmware update is being installed
///
final class CardPresentModalBuiltInConfigurationProgress: CardPresentPaymentsModalViewModel, CardPresentModalProgressDisplaying {
/// Called when cancel button is tapped
private let cancelAction: (() -> Void)?

let textMode: PaymentsModalTextMode = .fullInfo
let actionsMode: PaymentsModalActionsMode

var topSubtitle: String? = nil

var progress: Float

let primaryButtonTitle: String? = nil

let secondaryButtonTitle: String? = Localization.cancel

let auxiliaryButtonTitle: String? = nil

var titleComplete: String

var titleInProgress: String

var messageComplete: String?

var messageInProgress: String?

var accessibilityLabel: String? {
Localization.title
}

init(progress: Float, cancel: (() -> Void)?) {
self.progress = progress
self.cancelAction = cancel

titleComplete = Localization.titleComplete
titleInProgress = Localization.title
messageComplete = Localization.messageComplete
messageInProgress = Localization.message
actionsMode = cancel != nil ? .secondaryOnlyAction : .none
}

func didTapPrimaryButton(in viewController: UIViewController?) {}

func didTapSecondaryButton(in viewController: UIViewController?) {
cancelAction?()
}

func didTapAuxiliaryButton(in viewController: UIViewController?) {}
}

private extension CardPresentModalBuiltInConfigurationProgress {
enum Localization {
static let title = NSLocalizedString(
"Configuring iPhone",
comment: "Dialog title that displays when iPhone configuration is being updated for use as a card reader"
)

static let titleComplete = NSLocalizedString(
"Configuration updated",
comment: "Dialog title that displays when a configuration update just finished installing"
)

static let message = NSLocalizedString(
"Your iPhone needs to be configured to collect payments.",
comment: "Label that displays when a configuration update is happening"
)

static let messageComplete = NSLocalizedString(
"Your phone will be ready to collect payments in a moment...",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous message uses iPhone and this one says phone. While its not wrong, we might want to be consistent there.

comment: "Dialog message that displays when a configuration update just finished installing"
)

static let cancel = NSLocalizedString(
"Cancel",
comment: "Label for a cancel button"
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import UIKit

protocol CardPresentModalProgressDisplaying: CardPresentPaymentsModalViewModel {
var progress: Float { get }
var isComplete: Bool { get }
var titleComplete: String { get }
var titleInProgress: String { get }
var messageComplete: String? { get }
var messageInProgress: String? { get }
}

extension CardPresentModalProgressDisplaying {
var image: UIImage {
.softwareUpdateProgress(progress: CGFloat(progress))
}

var isComplete: Bool {
progress == 1
}

var topTitle: String {
isComplete ? titleComplete : titleInProgress
}

var bottomTitle: String? {
String(format: CardPresentModalProgressDisplayingLocalization.percentComplete, 100 * progress)
}

var bottomSubtitle: String? {
isComplete ? messageComplete : messageInProgress
}
}

fileprivate enum CardPresentModalProgressDisplayingLocalization {
static let percentComplete = NSLocalizedString(
"%.0f%% complete",
comment: "Label that describes the completed progress of an update being installed (e.g. 15% complete). Keep the %.0f%% exactly as is"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,45 @@ import UIKit

/// Modal presented when a firmware update is being installed
///
final class CardPresentModalUpdateProgress: CardPresentPaymentsModalViewModel {
final class CardPresentModalUpdateProgress: CardPresentPaymentsModalViewModel, CardPresentModalProgressDisplaying {
/// Called when cancel button is tapped
private let cancelAction: (() -> Void)?

let textMode: PaymentsModalTextMode = .fullInfo
let actionsMode: PaymentsModalActionsMode

var topTitle: String

var topSubtitle: String? = nil

let image: UIImage
var progress: Float

let primaryButtonTitle: String? = nil

let secondaryButtonTitle: String? = Localization.cancel

let auxiliaryButtonTitle: String? = nil

let bottomTitle: String?
var titleComplete: String

var titleInProgress: String

var bottomSubtitle: String? = nil
var messageComplete: String?

var messageInProgress: String?

var accessibilityLabel: String? {
Localization.title
}

init(requiredUpdate: Bool, progress: Float, cancel: (() -> Void)?) {
self.progress = progress
self.cancelAction = cancel
actionsMode = cancel != nil ? .secondaryOnlyAction : .none
titleComplete = Localization.titleComplete
titleInProgress = Localization.title

let isComplete = progress == 1
topTitle = isComplete ? Localization.titleComplete : Localization.title
image = .softwareUpdateProgress(progress: CGFloat(progress))
bottomTitle = String(format: Localization.percentComplete, 100 * progress)
if !isComplete {
bottomSubtitle = requiredUpdate ? Localization.messageRequired : Localization.messageOptional
messageInProgress = requiredUpdate ? Localization.messageRequired : Localization.messageOptional
}
actionsMode = cancel != nil ? .secondaryOnlyAction : .none
}

func didTapPrimaryButton(in viewController: UIViewController?) {}
Expand All @@ -63,12 +64,6 @@ private extension CardPresentModalUpdateProgress {
comment: "Dialog title that displays when a software update just finished installing"
)


static let percentComplete = NSLocalizedString(
"%.0f%% complete",
comment: "Label that describes the completed progress of a software update being installed (e.g. 15% complete). Keep the %.0f%% exactly as is"
)

static let messageRequired = NSLocalizedString(
"Your card reader software needs to be updated to collect payments. Cancelling will block your reader connection.",
comment: "Label that displays when a mandatory software update is happening"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ struct BuiltInReaderConnectionAlertsProvider: CardReaderConnectionAlertsProvidin
return CardPresentModalUpdateFailedNonRetryable(close: close)
}
}
func updateProgress(requiredUpdate: Bool, progress: Float,

func updateProgress(requiredUpdate: Bool,
progress: Float,
cancel: (() -> Void)?) -> CardPresentPaymentsModalViewModel {
CardPresentModalUpdateProgress(requiredUpdate: requiredUpdate, progress: progress, cancel: cancel)
CardPresentModalBuiltInConfigurationProgress(progress: progress, cancel: cancel)
}
}
8 changes: 8 additions & 0 deletions WooCommerce/WooCommerce.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@
03E471C4293A1F8D001A58AD /* BuiltInReaderConnectionAlertsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E471C3293A1F8D001A58AD /* BuiltInReaderConnectionAlertsProvider.swift */; };
03E471C6293A2E95001A58AD /* CardPresentModalBuiltInReaderCheckingDeviceSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E471C5293A2E95001A58AD /* CardPresentModalBuiltInReaderCheckingDeviceSupport.swift */; };
03E471C8293A3076001A58AD /* CardPresentModalBuiltInConnectingToReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E471C7293A3075001A58AD /* CardPresentModalBuiltInConnectingToReader.swift */; };
03E471CA293E0A30001A58AD /* CardPresentModalBuiltInConfigurationProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E471C9293E0A2F001A58AD /* CardPresentModalBuiltInConfigurationProgress.swift */; };
03E471CC293E0FB8001A58AD /* CardPresentModalProgressDisplaying.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E471CB293E0FB8001A58AD /* CardPresentModalProgressDisplaying.swift */; };
03EF24FA28BF5D21006A033E /* InPersonPaymentsCashOnDeliveryToggleRowViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EF24F928BF5D21006A033E /* InPersonPaymentsCashOnDeliveryToggleRowViewModel.swift */; };
03EF24FC28BF996F006A033E /* InPersonPaymentsCashOnDeliveryPaymentGatewayHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EF24FB28BF996F006A033E /* InPersonPaymentsCashOnDeliveryPaymentGatewayHelpers.swift */; };
03EF24FE28C0B356006A033E /* CardPresentPaymentsPlugin+CashOnDelivery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EF24FD28C0B356006A033E /* CardPresentPaymentsPlugin+CashOnDelivery.swift */; };
Expand Down Expand Up @@ -2511,6 +2513,8 @@
03E471C3293A1F8D001A58AD /* BuiltInReaderConnectionAlertsProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuiltInReaderConnectionAlertsProvider.swift; sourceTree = "<group>"; };
03E471C5293A2E95001A58AD /* CardPresentModalBuiltInReaderCheckingDeviceSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardPresentModalBuiltInReaderCheckingDeviceSupport.swift; sourceTree = "<group>"; };
03E471C7293A3075001A58AD /* CardPresentModalBuiltInConnectingToReader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardPresentModalBuiltInConnectingToReader.swift; sourceTree = "<group>"; };
03E471C9293E0A2F001A58AD /* CardPresentModalBuiltInConfigurationProgress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardPresentModalBuiltInConfigurationProgress.swift; sourceTree = "<group>"; };
03E471CB293E0FB8001A58AD /* CardPresentModalProgressDisplaying.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardPresentModalProgressDisplaying.swift; sourceTree = "<group>"; };
03EF24F928BF5D21006A033E /* InPersonPaymentsCashOnDeliveryToggleRowViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InPersonPaymentsCashOnDeliveryToggleRowViewModel.swift; sourceTree = "<group>"; };
03EF24FB28BF996F006A033E /* InPersonPaymentsCashOnDeliveryPaymentGatewayHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InPersonPaymentsCashOnDeliveryPaymentGatewayHelpers.swift; sourceTree = "<group>"; };
03EF24FD28C0B356006A033E /* CardPresentPaymentsPlugin+CashOnDelivery.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CardPresentPaymentsPlugin+CashOnDelivery.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -8555,6 +8559,8 @@
children = (
D8815AE626383FD600EDAD62 /* CardPresentPaymentsModalViewModel.swift */,
03E471C5293A2E95001A58AD /* CardPresentModalBuiltInReaderCheckingDeviceSupport.swift */,
03E471C9293E0A2F001A58AD /* CardPresentModalBuiltInConfigurationProgress.swift */,
03E471CB293E0FB8001A58AD /* CardPresentModalProgressDisplaying.swift */,
03E471C7293A3075001A58AD /* CardPresentModalBuiltInConnectingToReader.swift */,
311237ED2714DA240033C44E /* CardPresentModalDisplayMessage.swift */,
D8815B0026385E3F00EDAD62 /* CardPresentModalTapCard.swift */,
Expand Down Expand Up @@ -9992,6 +9998,7 @@
E138D4FC269EEAFE006EA5C6 /* InPersonPaymentsViewModel.swift in Sources */,
039D948F276113490044EF38 /* UIView+SuperviewConstraints.swift in Sources */,
D8736B5322EF4F5900A14A29 /* NotificationsBadgeController.swift in Sources */,
03E471CC293E0FB8001A58AD /* CardPresentModalProgressDisplaying.swift in Sources */,
B541B220218A007C008FE7C1 /* NSMutableParagraphStyle+Helpers.swift in Sources */,
45AE582C230D9D35001901E3 /* OrderNoteHeaderTableViewCell.swift in Sources */,
6832C7CA26DA5C4500BA4088 /* LabeledTextViewTableViewCell.swift in Sources */,
Expand All @@ -10012,6 +10019,7 @@
E1325EFB28FD544E00EC9B2A /* InAppPurchasesDebugView.swift in Sources */,
74460D4022289B7600D7316A /* Coordinator.swift in Sources */,
B57C743D20F5493300EEFC87 /* AccountHeaderView.swift in Sources */,
03E471CA293E0A30001A58AD /* CardPresentModalBuiltInConfigurationProgress.swift in Sources */,
31AD0B1126E9575F000B6391 /* CardPresentModalConnectingFailed.swift in Sources */,
576EA39425264C9B00AFC0B3 /* RefundConfirmationViewModel.swift in Sources */,
DEC51B00276AEE91009F3DF4 /* SystemStatusReportViewModel.swift in Sources */,
Expand Down