Skip to content

Commit b7a4f85

Browse files
committed
8082 Show specific configuration progress alerts
The iPhone’s built in card reader may need to be configured before it can be used. In this case, Stripe will call our LocalMobileConnectionDelegate with progress of the configuration, in the same way as it does for bluetooth reader software updates. This commit duplicates and updates the bluetooth reader software update alert for use with configuration updates.
1 parent 3332b19 commit b7a4f85

File tree

3 files changed

+92
-2
lines changed

3 files changed

+92
-2
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import UIKit
2+
3+
/// Modal presented when a firmware update is being installed
4+
///
5+
final class CardPresentModalBuiltInConfigurationProgress: CardPresentPaymentsModalViewModel {
6+
/// Called when cancel button is tapped
7+
private let cancelAction: (() -> Void)?
8+
9+
let textMode: PaymentsModalTextMode = .fullInfo
10+
let actionsMode: PaymentsModalActionsMode
11+
12+
var topTitle: String
13+
14+
var topSubtitle: String? = nil
15+
16+
let image: UIImage
17+
18+
let primaryButtonTitle: String? = nil
19+
20+
let secondaryButtonTitle: String? = Localization.cancel
21+
22+
let auxiliaryButtonTitle: String? = nil
23+
24+
let bottomTitle: String?
25+
26+
var bottomSubtitle: String? = nil
27+
28+
var accessibilityLabel: String? {
29+
Localization.title
30+
}
31+
32+
init(progress: Float, cancel: (() -> Void)?) {
33+
self.cancelAction = cancel
34+
35+
let isComplete = progress == 1
36+
topTitle = isComplete ? Localization.titleComplete : Localization.title
37+
image = .softwareUpdateProgress(progress: CGFloat(progress))
38+
bottomTitle = String(format: Localization.percentComplete, 100 * progress)
39+
bottomSubtitle = isComplete ? Localization.messageComplete : Localization.message
40+
actionsMode = cancel != nil ? .secondaryOnlyAction : .none
41+
}
42+
43+
func didTapPrimaryButton(in viewController: UIViewController?) {}
44+
45+
func didTapSecondaryButton(in viewController: UIViewController?) {
46+
cancelAction?()
47+
}
48+
49+
func didTapAuxiliaryButton(in viewController: UIViewController?) {}
50+
}
51+
52+
private extension CardPresentModalBuiltInConfigurationProgress {
53+
enum Localization {
54+
static let title = NSLocalizedString(
55+
"Configuring iPhone",
56+
comment: "Dialog title that displays when iPhone configuration is being updated for use as a card reader"
57+
)
58+
59+
static let titleComplete = NSLocalizedString(
60+
"Configuration updated",
61+
comment: "Dialog title that displays when a configuration update just finished installing"
62+
)
63+
64+
static let percentComplete = NSLocalizedString(
65+
"%.0f%% complete",
66+
comment: "Label that describes the completed progress of a software update being installed (e.g. 15% complete). Keep the %.0f%% exactly as is"
67+
)
68+
69+
static let message = NSLocalizedString(
70+
"Your iPhone needs to be configured to collect payments.",
71+
comment: "Label that displays when a configuration update is happening"
72+
)
73+
74+
static let messageComplete = NSLocalizedString(
75+
"Your phone will be ready to collect payments in a moment...",
76+
comment: "Dialog message that displays when a configuration update just finished installing"
77+
)
78+
79+
static let cancel = NSLocalizedString(
80+
"Cancel",
81+
comment: "Label for a cancel button"
82+
)
83+
}
84+
}

WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/BuiltInReaderConnectionAlertsProvider.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ struct BuiltInReaderConnectionAlertsProvider: CardReaderConnectionAlertsProvidin
3939
return CardPresentModalUpdateFailedNonRetryable(close: close)
4040
}
4141
}
42-
func updateProgress(requiredUpdate: Bool, progress: Float,
42+
43+
func updateProgress(requiredUpdate: Bool,
44+
progress: Float,
4345
cancel: (() -> Void)?) -> CardPresentPaymentsModalViewModel {
44-
CardPresentModalUpdateProgress(requiredUpdate: requiredUpdate, progress: progress, cancel: cancel)
46+
CardPresentModalBuiltInConfigurationProgress(progress: progress, cancel: cancel)
4547
}
4648
}

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@
500500
03E471C4293A1F8D001A58AD /* BuiltInReaderConnectionAlertsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E471C3293A1F8D001A58AD /* BuiltInReaderConnectionAlertsProvider.swift */; };
501501
03E471C6293A2E95001A58AD /* CardPresentModalBuiltInReaderCheckingDeviceSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E471C5293A2E95001A58AD /* CardPresentModalBuiltInReaderCheckingDeviceSupport.swift */; };
502502
03E471C8293A3076001A58AD /* CardPresentModalBuiltInConnectingToReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E471C7293A3075001A58AD /* CardPresentModalBuiltInConnectingToReader.swift */; };
503+
03E471CA293E0A30001A58AD /* CardPresentModalBuiltInConfigurationProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E471C9293E0A2F001A58AD /* CardPresentModalBuiltInConfigurationProgress.swift */; };
503504
03EF24FA28BF5D21006A033E /* InPersonPaymentsCashOnDeliveryToggleRowViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EF24F928BF5D21006A033E /* InPersonPaymentsCashOnDeliveryToggleRowViewModel.swift */; };
504505
03EF24FC28BF996F006A033E /* InPersonPaymentsCashOnDeliveryPaymentGatewayHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EF24FB28BF996F006A033E /* InPersonPaymentsCashOnDeliveryPaymentGatewayHelpers.swift */; };
505506
03EF24FE28C0B356006A033E /* CardPresentPaymentsPlugin+CashOnDelivery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EF24FD28C0B356006A033E /* CardPresentPaymentsPlugin+CashOnDelivery.swift */; };
@@ -2511,6 +2512,7 @@
25112512
03E471C3293A1F8D001A58AD /* BuiltInReaderConnectionAlertsProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuiltInReaderConnectionAlertsProvider.swift; sourceTree = "<group>"; };
25122513
03E471C5293A2E95001A58AD /* CardPresentModalBuiltInReaderCheckingDeviceSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardPresentModalBuiltInReaderCheckingDeviceSupport.swift; sourceTree = "<group>"; };
25132514
03E471C7293A3075001A58AD /* CardPresentModalBuiltInConnectingToReader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardPresentModalBuiltInConnectingToReader.swift; sourceTree = "<group>"; };
2515+
03E471C9293E0A2F001A58AD /* CardPresentModalBuiltInConfigurationProgress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardPresentModalBuiltInConfigurationProgress.swift; sourceTree = "<group>"; };
25142516
03EF24F928BF5D21006A033E /* InPersonPaymentsCashOnDeliveryToggleRowViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InPersonPaymentsCashOnDeliveryToggleRowViewModel.swift; sourceTree = "<group>"; };
25152517
03EF24FB28BF996F006A033E /* InPersonPaymentsCashOnDeliveryPaymentGatewayHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InPersonPaymentsCashOnDeliveryPaymentGatewayHelpers.swift; sourceTree = "<group>"; };
25162518
03EF24FD28C0B356006A033E /* CardPresentPaymentsPlugin+CashOnDelivery.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CardPresentPaymentsPlugin+CashOnDelivery.swift"; sourceTree = "<group>"; };
@@ -8555,6 +8557,7 @@
85558557
children = (
85568558
D8815AE626383FD600EDAD62 /* CardPresentPaymentsModalViewModel.swift */,
85578559
03E471C5293A2E95001A58AD /* CardPresentModalBuiltInReaderCheckingDeviceSupport.swift */,
8560+
03E471C9293E0A2F001A58AD /* CardPresentModalBuiltInConfigurationProgress.swift */,
85588561
03E471C7293A3075001A58AD /* CardPresentModalBuiltInConnectingToReader.swift */,
85598562
311237ED2714DA240033C44E /* CardPresentModalDisplayMessage.swift */,
85608563
D8815B0026385E3F00EDAD62 /* CardPresentModalTapCard.swift */,
@@ -10012,6 +10015,7 @@
1001210015
E1325EFB28FD544E00EC9B2A /* InAppPurchasesDebugView.swift in Sources */,
1001310016
74460D4022289B7600D7316A /* Coordinator.swift in Sources */,
1001410017
B57C743D20F5493300EEFC87 /* AccountHeaderView.swift in Sources */,
10018+
03E471CA293E0A30001A58AD /* CardPresentModalBuiltInConfigurationProgress.swift in Sources */,
1001510019
31AD0B1126E9575F000B6391 /* CardPresentModalConnectingFailed.swift in Sources */,
1001610020
576EA39425264C9B00AFC0B3 /* RefundConfirmationViewModel.swift in Sources */,
1001710021
DEC51B00276AEE91009F3DF4 /* SystemStatusReportViewModel.swift in Sources */,

0 commit comments

Comments
 (0)