Skip to content

Commit 1c0d0ec

Browse files
committed
Merge branch 'trunk' into add-load-stats-test
2 parents 27a1d7c + ed99c88 commit 1c0d0ec

File tree

42 files changed

+1549
-205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1549
-205
lines changed

Networking/Networking/Extensions/DateFormatter+Woo.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,31 +107,31 @@ public extension DateFormatter {
107107
/// Date formatter used for creating the properly-formatted date range info. Typically
108108
/// used when setting the end date on `AnalyticsHubTimeRangeGenerator`.
109109
///
110-
public static let analyticsHubDayMonthYearFormatter: DateFormatter = {
110+
public static func createAnalyticsHubDayMonthYearFormatter(timezone: TimeZone) -> DateFormatter {
111111
let formatter = DateFormatter()
112-
formatter.locale = Locale(identifier: "en_US_POSIX")
112+
formatter.timeZone = timezone
113113
formatter.dateFormat = "MMM d, yyyy"
114114
return formatter
115-
}()
115+
}
116116

117117
/// Date formatter used for creating the properly-formatted date range info. Typically
118118
/// used when setting the end date of a same-month range on `AnalyticsHubTimeRangeGenerator`.
119119
///
120-
public static let analyticsHubDayYearFormatter: DateFormatter = {
120+
public static func createAnalyticsHubDayYearFormatter(timezone: TimeZone) -> DateFormatter {
121121
let formatter = DateFormatter()
122-
formatter.locale = Locale(identifier: "en_US_POSIX")
122+
formatter.timeZone = timezone
123123
formatter.dateFormat = "d, yyyy"
124124
return formatter
125-
}()
125+
}
126126

127127
/// Date formatter used for creating the properly-formatted date range info. Typically
128128
/// used when setting the start date on `AnalyticsHubTimeRangeGenerator`.
129129
///
130-
public static let analyticsHubDayMonthFormatter: DateFormatter = {
130+
public static func createAnalyticsHubDayMonthFormatter(timezone: TimeZone) -> DateFormatter {
131131
let formatter = DateFormatter()
132-
formatter.locale = Locale(identifier: "en_US_POSIX")
132+
formatter.timeZone = timezone
133133
formatter.dateFormat = "MMM d"
134134
return formatter
135-
}()
135+
}
136136
}
137137
}

WooCommerce/Classes/Extensions/UIImage+Woo.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,18 @@ extension UIImage {
498498
return UIImage(named: "card-reader-scanning")!
499499
}
500500

501+
static var tempBuiltInReaderCheck: UIImage {
502+
return UIImage(named: "temp-woo-tap-on-mobile-check")!
503+
}
504+
505+
static var tempBuiltInReaderPrepare: UIImage {
506+
return UIImage(named: "temp-woo-tap-on-mobile-prepare")!
507+
}
508+
509+
static var tempBuiltInReaderPayment: UIImage {
510+
return UIImage(named: "temp-woo-tap-on-mobile")!
511+
}
512+
501513
/// Found Card Reader
502514
///
503515
static var cardReaderFound: UIImage {
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import UIKit
2+
3+
/// Modal presented when a firmware update is being installed
4+
///
5+
final class CardPresentModalBuiltInConfigurationProgress: CardPresentPaymentsModalViewModel, CardPresentModalProgressDisplaying {
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 topSubtitle: String? = nil
13+
14+
var progress: Float
15+
16+
let primaryButtonTitle: String? = nil
17+
18+
let secondaryButtonTitle: String? = Localization.cancel
19+
20+
let auxiliaryButtonTitle: String? = nil
21+
22+
var titleComplete: String
23+
24+
var titleInProgress: String
25+
26+
var messageComplete: String?
27+
28+
var messageInProgress: String?
29+
30+
var accessibilityLabel: String? {
31+
Localization.title
32+
}
33+
34+
init(progress: Float, cancel: (() -> Void)?) {
35+
self.progress = progress
36+
self.cancelAction = cancel
37+
38+
titleComplete = Localization.titleComplete
39+
titleInProgress = Localization.title
40+
messageComplete = Localization.messageComplete
41+
messageInProgress = Localization.message
42+
actionsMode = cancel != nil ? .secondaryOnlyAction : .none
43+
}
44+
45+
func didTapPrimaryButton(in viewController: UIViewController?) {}
46+
47+
func didTapSecondaryButton(in viewController: UIViewController?) {
48+
cancelAction?()
49+
}
50+
51+
func didTapAuxiliaryButton(in viewController: UIViewController?) {}
52+
}
53+
54+
private extension CardPresentModalBuiltInConfigurationProgress {
55+
enum Localization {
56+
static let title = NSLocalizedString(
57+
"Configuring iPhone",
58+
comment: "Dialog title that displays when iPhone configuration is being updated for use as a card reader"
59+
)
60+
61+
static let titleComplete = NSLocalizedString(
62+
"Configuration updated",
63+
comment: "Dialog title that displays when a configuration update just finished installing"
64+
)
65+
66+
static let message = NSLocalizedString(
67+
"Your iPhone needs to be configured to collect payments.",
68+
comment: "Label that displays when a configuration update is happening"
69+
)
70+
71+
static let messageComplete = NSLocalizedString(
72+
"Your phone will be ready to collect payments in a moment...",
73+
comment: "Dialog message that displays when a configuration update just finished installing"
74+
)
75+
76+
static let cancel = NSLocalizedString(
77+
"Cancel",
78+
comment: "Label for a cancel button"
79+
)
80+
}
81+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import UIKit
2+
3+
/// Modal presented when we are connecting to a reader
4+
///
5+
final class CardPresentModalBuiltInConnectingToReader: CardPresentPaymentsModalViewModel {
6+
let textMode: PaymentsModalTextMode = .reducedBottomInfo
7+
let actionsMode: PaymentsModalActionsMode = .none
8+
9+
let topTitle: String = Localization.title
10+
11+
var topSubtitle: String?
12+
13+
let image: UIImage = .tempBuiltInReaderCheck
14+
15+
let primaryButtonTitle: String? = nil
16+
17+
let secondaryButtonTitle: String? = nil
18+
19+
let auxiliaryButtonTitle: String? = nil
20+
21+
let bottomTitle: String? = Localization.instruction
22+
23+
var bottomSubtitle: String?
24+
25+
var accessibilityLabel: String? {
26+
return topTitle + Localization.instruction
27+
}
28+
29+
init() {}
30+
31+
func didTapPrimaryButton(in viewController: UIViewController?) {}
32+
33+
func didTapSecondaryButton(in viewController: UIViewController?) {}
34+
35+
func didTapAuxiliaryButton(in viewController: UIViewController?) {}
36+
}
37+
38+
private extension CardPresentModalBuiltInConnectingToReader {
39+
enum Localization {
40+
static let title = NSLocalizedString(
41+
"Preparing iPhone card reader...",
42+
comment: "Title label for modal dialog that appears when connecting to a built in card reader"
43+
)
44+
45+
static let instruction = NSLocalizedString(
46+
"The first time you connect, you may be prompted to accept Apple's Terms of Service.",
47+
comment: "Label within the modal dialog that appears when connecting to a built in card reader"
48+
)
49+
}
50+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import UIKit
2+
3+
/// Modal presented when we are scanning for a reader to connect to
4+
///
5+
final class CardPresentModalBuiltInReaderCheckingDeviceSupport: CardPresentPaymentsModalViewModel {
6+
/// Called when cancel button is tapped
7+
private let cancelAction: () -> Void
8+
9+
let textMode: PaymentsModalTextMode = .reducedBottomInfo
10+
let actionsMode: PaymentsModalActionsMode = .secondaryActionAndAuxiliaryButton
11+
12+
let topTitle: String = Localization.title
13+
14+
var topSubtitle: String?
15+
16+
let image: UIImage = .tempBuiltInReaderPrepare
17+
18+
let primaryButtonTitle: String? = nil
19+
20+
let secondaryButtonTitle: String? = Localization.cancel
21+
22+
let auxiliaryButtonTitle: String? = nil
23+
24+
let auxiliaryButtonimage: UIImage? = .infoOutlineImage
25+
26+
var auxiliaryAttributedButtonTitle: NSAttributedString? {
27+
let result = NSMutableAttributedString(
28+
string: .localizedStringWithFormat(
29+
Localization.learnMoreText,
30+
Localization.learnMoreLink
31+
),
32+
attributes: [.foregroundColor: UIColor.text]
33+
)
34+
result.replaceFirstOccurrence(
35+
of: Localization.learnMoreLink,
36+
with: NSAttributedString(
37+
string: Localization.learnMoreLink,
38+
attributes: [
39+
.foregroundColor: UIColor.accent,
40+
.underlineStyle: NSUnderlineStyle.single.rawValue
41+
]
42+
))
43+
result.addAttribute(.font, value: UIFont.footnote, range: NSRange(location: 0, length: result.length))
44+
return result
45+
}
46+
47+
let bottomTitle: String? = Localization.instruction
48+
49+
var bottomSubtitle: String?
50+
51+
var accessibilityLabel: String? {
52+
guard let bottomTitle = bottomTitle else {
53+
return topTitle
54+
}
55+
return topTitle + bottomTitle
56+
}
57+
58+
init(cancel: @escaping () -> Void) {
59+
self.cancelAction = cancel
60+
}
61+
62+
func didTapPrimaryButton(in viewController: UIViewController?) {}
63+
64+
func didTapSecondaryButton(in viewController: UIViewController?) {
65+
cancelAction()
66+
}
67+
68+
func didTapAuxiliaryButton(in viewController: UIViewController?) {
69+
ServiceLocator.analytics.track(.cardPresentOnboardingLearnMoreTapped)
70+
guard let viewController = viewController else {
71+
return
72+
}
73+
WebviewHelper.launch(Constants.learnMoreURL.asURL(), with: viewController)
74+
}
75+
}
76+
77+
private extension CardPresentModalBuiltInReaderCheckingDeviceSupport {
78+
enum Constants {
79+
static let learnMoreURL = WooConstants.URLs.inPersonPaymentsLearnMoreWCPay
80+
}
81+
82+
enum Localization {
83+
static let title = NSLocalizedString(
84+
"cardPresent.builtIn.modalCheckingDeviceSupport.title",
85+
value: "Checking device",
86+
comment: "Title label for modal dialog that appears when searching for a card reader"
87+
)
88+
89+
static let instruction = NSLocalizedString(
90+
"cardPresent.builtIn.modalCheckingDeviceSupport.instruction",
91+
value: "Please wait while we check that your device is ready for Tap to Pay on iPhone.",
92+
comment: "Label within the modal dialog that appears when checking the built in card reader"
93+
)
94+
95+
static let cancel = NSLocalizedString(
96+
"cardPresent.builtIn.modalCheckingDeviceSupport.cancelButton",
97+
value: "Cancel",
98+
comment: "Label for a cancel button"
99+
)
100+
101+
static let learnMoreLink = NSLocalizedString(
102+
"cardPresent.builtIn.modalCheckingDeviceSupport.learnMore.link",
103+
value: "Learn more",
104+
comment: """
105+
A label prompting users to learn more about In-Person Payments.
106+
This is the link to the website, and forms part of a longer sentence which it should be considered a part of.
107+
"""
108+
)
109+
110+
static let learnMoreText = NSLocalizedString(
111+
"cardPresent.builtIn.modalCheckingDeviceSupport.learnMore.text",
112+
value: "%1$@ about In‑Person Payments",
113+
comment: """
114+
A label prompting users to learn more about In-Person Payments.
115+
The hyphen in "In‑Person" is a non-breaking hyphen (U+2011).
116+
If your translation of that term also happens to contains a hyphen, please be sure to use the non-breaking hyphen character for it.
117+
%1$@ is a placeholder that always replaced with \"Learn more\" string,
118+
which should be translated separately and considered part of this sentence.
119+
"""
120+
)
121+
}
122+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import UIKit
2+
3+
protocol CardPresentModalProgressDisplaying: CardPresentPaymentsModalViewModel {
4+
var progress: Float { get }
5+
var isComplete: Bool { get }
6+
var titleComplete: String { get }
7+
var titleInProgress: String { get }
8+
var messageComplete: String? { get }
9+
var messageInProgress: String? { get }
10+
}
11+
12+
extension CardPresentModalProgressDisplaying {
13+
var image: UIImage {
14+
.softwareUpdateProgress(progress: CGFloat(progress))
15+
}
16+
17+
var isComplete: Bool {
18+
progress == 1
19+
}
20+
21+
var topTitle: String {
22+
isComplete ? titleComplete : titleInProgress
23+
}
24+
25+
var bottomTitle: String? {
26+
String(format: CardPresentModalProgressDisplayingLocalization.percentComplete, 100 * progress)
27+
}
28+
29+
var bottomSubtitle: String? {
30+
isComplete ? messageComplete : messageInProgress
31+
}
32+
}
33+
34+
fileprivate enum CardPresentModalProgressDisplayingLocalization {
35+
static let percentComplete = NSLocalizedString(
36+
"%.0f%% complete",
37+
comment: "Label that describes the completed progress of an update being installed (e.g. 15% complete). Keep the %.0f%% exactly as is"
38+
)
39+
}

0 commit comments

Comments
 (0)