Skip to content

Commit 28e94a1

Browse files
committed
Merge branch 'develop' into issue/4778-edit-address-form-viewmodel
2 parents 0e3f8d7 + e603e38 commit 28e94a1

File tree

69 files changed

+4305
-646
lines changed

Some content is hidden

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

69 files changed

+4305
-646
lines changed

Hardware/Hardware/CardReader/CardReaderServiceError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ updating the application or using a different reader
306306
return NSLocalizedString("The card reader session has expired - please disconnect and reconnect the card reader and then try again",
307307
comment: "Error message when the card reader session has timed out.")
308308
case .internalServiceError:
309-
return NSLocalizedString("The system experienced an unexpected internal error - please try again",
309+
return NSLocalizedString("Sorry, this payment couldn’t be processed",
310310
comment: "Error message when the card reader service experiences an unexpected internal service error.")
311311
}
312312
}

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ target 'WooCommerce' do
3333
#
3434

3535
#pod 'Automattic-Tracks-iOS', :git => 'https://github.com/Automattic/Automattic-Tracks-iOS.git', :branch => 'add/build-configuration'
36-
pod 'Automattic-Tracks-iOS', '~> 0.9.0'
36+
pod 'Automattic-Tracks-iOS', '~> 0.9.1'
3737

3838
pod 'Gridicons', '~> 1.0'
3939

Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PODS:
66
- AppAuth/ExternalUserAgent (= 1.4.0)
77
- AppAuth/Core (1.4.0)
88
- AppAuth/ExternalUserAgent (1.4.0)
9-
- Automattic-Tracks-iOS (0.9.0):
9+
- Automattic-Tracks-iOS (0.9.1):
1010
- CocoaLumberjack (~> 3)
1111
- Reachability (~> 3)
1212
- Sentry (~> 6)
@@ -92,7 +92,7 @@ PODS:
9292

9393
DEPENDENCIES:
9494
- Alamofire (~> 4.8)
95-
- Automattic-Tracks-iOS (~> 0.9.0)
95+
- Automattic-Tracks-iOS (~> 0.9.1)
9696
- Charts (~> 3.6.0)
9797
- CocoaLumberjack (~> 3.5)
9898
- CocoaLumberjack/Swift (~> 3.5)
@@ -159,7 +159,7 @@ SPEC CHECKSUMS:
159159
1PasswordExtension: f97cc80ae58053c331b2b6dc8843ba7103b33794
160160
Alamofire: 3ec537f71edc9804815215393ae2b1a8ea33a844
161161
AppAuth: 31bcec809a638d7bd2f86ea8a52bd45f6e81e7c7
162-
Automattic-Tracks-iOS: f6ece12d2e630b55b701bac8bcf4301fcce9a327
162+
Automattic-Tracks-iOS: f5a6188ad8d00680748111466beabb0aea11f856
163163
Charts: b1e3a1f5a1c9ba5394438ca3b91bd8c9076310af
164164
CocoaLumberjack: 2f44e60eb91c176d471fdba43b9e3eae6a721947
165165
FormatterKit: 184db51bf120b633693a73624a4cede89ec51a41
@@ -197,6 +197,6 @@ SPEC CHECKSUMS:
197197
ZendeskSupportProvidersSDK: 2bdf8544f7cd0fd4c002546f5704b813845beb2a
198198
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
199199

200-
PODFILE CHECKSUM: 3a44929fd11c151f108c11f263d90b2586b35f49
200+
PODFILE CHECKSUM: c652601d27c6c6bbc31005c1204964ca8471f2d4
201201

202202
COCOAPODS: 1.10.2

Scripts/build-phases/generate-credentials.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ else
6262
##
6363
mkdir -p ${DERIVED_PATH}
6464

65+
if which rbenv; then
66+
# Fix an issue where, depending on the shell you are using on your machine and your rbenv setup,
67+
# running `ruby` in a bash script from Xcode script build phase might not use the right ruby
68+
# (and thus not find the appropriate gems installed by bundle & Gemfile.lock and crash).
69+
# So if rbenv is installed, make sure the shims for `ruby` are too in the context of this bash script,
70+
# so that it uses the right ruby version defined in `.ruby-version` instead of risking to use the system one.
71+
eval "$(rbenv init -)"
72+
rbenv rehash
73+
fi
74+
6575
## Generate ApiCredentials.swift
6676
##
6777
echo ">> Generating Credentials ${CREDS_OUTPUT_PATH}"

WooCommerce/Classes/ViewModels/CardPresentPayments/CardPresentModalError.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import UIKit
33
/// Modal presented on error
44
final class CardPresentModalError: CardPresentPaymentsModalViewModel {
55

6-
/// Amount charged
7-
private let amount: String
8-
96
/// The error returned by the stack
107
private let error: Error
118

@@ -17,9 +14,7 @@ final class CardPresentModalError: CardPresentPaymentsModalViewModel {
1714

1815
let topTitle: String = Localization.paymentFailed
1916

20-
var topSubtitle: String? {
21-
amount
22-
}
17+
var topSubtitle: String? = nil
2318

2419
let image: UIImage = .paymentErrorImage
2520

@@ -35,8 +30,7 @@ final class CardPresentModalError: CardPresentPaymentsModalViewModel {
3530

3631
let bottomSubtitle: String? = nil
3732

38-
init(amount: String, error: Error, primaryAction: @escaping () -> Void) {
39-
self.amount = amount
33+
init(error: Error, primaryAction: @escaping () -> Void) {
4034
self.error = error
4135
self.primaryAction = primaryAction
4236
}
@@ -60,12 +54,12 @@ private extension CardPresentModalError {
6054
)
6155

6256
static let tryAgain = NSLocalizedString(
63-
"Try collecting payment again",
57+
"Try Collecting Again",
6458
comment: "Button to try to collect a payment again. Presented to users after a collecting a payment fails"
6559
)
6660

6761
static let noThanks = NSLocalizedString(
68-
"No thanks",
62+
"Back to Order",
6963
comment: "Button to dismiss modal overlay. Presented to users after collecting a payment fails"
7064
)
7165
}

WooCommerce/Classes/ViewModels/CardPresentPayments/CardPresentModalSuccess.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import UIKit
33
/// Modal presented when the payment has been collected successfully
44
final class CardPresentModalSuccess: CardPresentPaymentsModalViewModel {
55

6-
/// Amount charged
7-
private let amount: String
8-
96
/// Closure to execute when primary button is tapped
107
private let printReceiptAction: () -> Void
118

@@ -18,9 +15,7 @@ final class CardPresentModalSuccess: CardPresentPaymentsModalViewModel {
1815

1916
let topTitle: String = Localization.paymentSuccessful
2017

21-
var topSubtitle: String? {
22-
amount
23-
}
18+
var topSubtitle: String? = nil
2419

2520
let image: UIImage = .celebrationImage
2621

@@ -34,8 +29,7 @@ final class CardPresentModalSuccess: CardPresentPaymentsModalViewModel {
3429

3530
let bottomSubtitle: String? = nil
3631

37-
init(amount: String, printReceipt: @escaping () -> Void, emailReceipt: @escaping () -> Void) {
38-
self.amount = amount
32+
init(printReceipt: @escaping () -> Void, emailReceipt: @escaping () -> Void) {
3933
self.printReceiptAction = printReceipt
4034
self.emailReceiptAction = emailReceipt
4135
}
@@ -75,7 +69,7 @@ private extension CardPresentModalSuccess {
7569
)
7670

7771
static let noThanks = NSLocalizedString(
78-
"No thanks",
72+
"Back to Order",
7973
comment: "Button to dismiss modal overlay. Presented to users after a payment has been successfully collected"
8074
)
8175
}

WooCommerce/Classes/ViewModels/CardPresentPayments/CardPresentModalSuccessWithoutEmail.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import UIKit
33
/// Modal presented when the payment has been collected successfully
44
final class CardPresentModalSuccessWithoutEmail: CardPresentPaymentsModalViewModel {
55

6-
/// Amount charged
7-
private let amount: String
8-
96
/// Closure to execute when primary button is tapped
107
private let printReceiptAction: () -> Void
118

@@ -14,9 +11,7 @@ final class CardPresentModalSuccessWithoutEmail: CardPresentPaymentsModalViewMod
1411

1512
let topTitle: String = Localization.paymentSuccessful
1613

17-
var topSubtitle: String? {
18-
amount
19-
}
14+
var topSubtitle: String? = nil
2015

2116
let image: UIImage = .celebrationImage
2217

@@ -30,8 +25,7 @@ final class CardPresentModalSuccessWithoutEmail: CardPresentPaymentsModalViewMod
3025

3126
let bottomSubtitle: String? = nil
3227

33-
init(amount: String, printReceipt: @escaping () -> Void) {
34-
self.amount = amount
28+
init(printReceipt: @escaping () -> Void) {
3529
self.printReceiptAction = printReceipt
3630
}
3731

@@ -61,7 +55,7 @@ private extension CardPresentModalSuccessWithoutEmail {
6155
)
6256

6357
static let noThanks = NSLocalizedString(
64-
"No thanks",
58+
"Back to Order",
6559
comment: "Button to dismiss modal overlay. Presented to users after a payment has been successfully collected"
6660
)
6761
}

WooCommerce/Classes/ViewModels/Order Details/OrderDetailsPaymentAlerts.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ final class OrderDetailsPaymentAlerts {
6969
}
7070

7171
func error(error: Error, tryAgain: @escaping () -> Void) {
72-
let viewModel = errorViewModel(amount: amount, error: error, tryAgain: tryAgain)
72+
let viewModel = errorViewModel(error: error, tryAgain: tryAgain)
7373
presentViewModel(viewModel: viewModel)
7474
}
7575

@@ -103,14 +103,14 @@ private extension OrderDetailsPaymentAlerts {
103103

104104
func successViewModel(printReceipt: @escaping () -> Void, emailReceipt: @escaping () -> Void) -> CardPresentPaymentsModalViewModel {
105105
if MFMailComposeViewController.canSendMail() {
106-
return CardPresentModalSuccess(amount: amount, printReceipt: printReceipt, emailReceipt: emailReceipt)
106+
return CardPresentModalSuccess(printReceipt: printReceipt, emailReceipt: emailReceipt)
107107
} else {
108-
return CardPresentModalSuccessWithoutEmail(amount: amount, printReceipt: printReceipt)
108+
return CardPresentModalSuccessWithoutEmail(printReceipt: printReceipt)
109109
}
110110
}
111111

112-
func errorViewModel(amount: String, error: Error, tryAgain: @escaping () -> Void) -> CardPresentPaymentsModalViewModel {
113-
CardPresentModalError(amount: amount, error: error, primaryAction: tryAgain)
112+
func errorViewModel(error: Error, tryAgain: @escaping () -> Void) -> CardPresentPaymentsModalViewModel {
113+
CardPresentModalError(error: error, primaryAction: tryAgain)
114114
}
115115

116116
func retryableErrorViewModel(tryAgain: @escaping () -> Void) -> CardPresentPaymentsModalViewModel {

WooCommerce/Classes/ViewRelated/Dashboard/Settings/SettingsViewController.swift

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import MessageUI
44
import Gridicons
55
import SafariServices
66
import WordPressAuthenticator
7+
import class Networking.UserAgent
78

89

910
// MARK: - SettingsViewController
@@ -84,6 +85,10 @@ final class SettingsViewController: UIViewController {
8485
/// for card present payments
8586
private var canCollectPayments: Bool = false
8687

88+
/// Announcement for the current app version
89+
///
90+
private var announcement: Announcement?
91+
8792
// MARK: - Overridden Methods
8893

8994
override func viewDidLoad() {
@@ -94,7 +99,7 @@ final class SettingsViewController: UIViewController {
9499
})
95100

96101
loadPaymentGatewayAccounts()
97-
102+
loadWhatsNewOnWooCommerce()
98103
configureNavigation()
99104
configureMainView()
100105
configureTableView()
@@ -239,6 +244,17 @@ private extension SettingsViewController {
239244
tableView.reloadData()
240245
}
241246

247+
func loadWhatsNewOnWooCommerce() {
248+
ServiceLocator.stores.dispatch(AnnouncementsAction.loadSavedAnnouncement(onCompletion: { [weak self] result in
249+
guard let self = self else { return }
250+
guard let (announcement, _) = try? result.get(), announcement.appVersionName == UserAgent.bundleShortVersion else {
251+
return DDLogInfo("📣 There are no announcements to show!")
252+
}
253+
254+
self.announcement = announcement
255+
}))
256+
}
257+
242258
func configureSections() {
243259
let selectedStoreTitle = NSLocalizedString(
244260
"Selected Store",
@@ -303,7 +319,11 @@ private extension SettingsViewController {
303319
sections.append(Section(title: appSettingsTitle, rows: [.privacy], footerHeight: UITableView.automaticDimension))
304320

305321
// About the App
306-
sections.append(Section(title: aboutTheAppTitle, rows: [.about, .licenses], footerHeight: UITableView.automaticDimension))
322+
if shouldShowWhatsNew() {
323+
sections.append(Section(title: aboutTheAppTitle, rows: [.about, .whatsNew, .licenses], footerHeight: UITableView.automaticDimension))
324+
} else {
325+
sections.append(Section(title: aboutTheAppTitle, rows: [.about, .licenses], footerHeight: UITableView.automaticDimension))
326+
}
307327

308328
// Other
309329
#if DEBUG
@@ -351,6 +371,8 @@ private extension SettingsViewController {
351371
configureWormholy(cell: cell)
352372
case let cell as BasicTableViewCell where row == .logout:
353373
configureLogout(cell: cell)
374+
case let cell as BasicTableViewCell where row == .whatsNew:
375+
configureWhatsNew(cell: cell)
354376
default:
355377
fatalError()
356378
}
@@ -431,6 +453,12 @@ private extension SettingsViewController {
431453
comment: "Opens an internal library called Wormholy. Not visible to users.")
432454
}
433455

456+
func configureWhatsNew(cell: BasicTableViewCell) {
457+
cell.accessoryType = .disclosureIndicator
458+
cell.selectionStyle = .default
459+
cell.textLabel?.text = NSLocalizedString("What's New in WooCommerce", comment: "Navigates to screen containing the latest WooCommerce Features")
460+
}
461+
434462
func configureLogout(cell: BasicTableViewCell) {
435463
cell.selectionStyle = .default
436464
cell.textLabel?.textAlignment = .center
@@ -459,6 +487,10 @@ private extension SettingsViewController {
459487
func shouldShowPluginsSection() -> Bool {
460488
ServiceLocator.stores.sessionManager.defaultRoles.contains(.administrator)
461489
}
490+
491+
func shouldShowWhatsNew() -> Bool {
492+
ServiceLocator.featureFlagService.isFeatureFlagEnabled(.whatsNewOnWooCommerce) && announcement != nil
493+
}
462494
}
463495

464496

@@ -574,6 +606,14 @@ private extension SettingsViewController {
574606
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "wormholy_fire"), object: nil)
575607
}
576608

609+
func whatsNewWasPressed() {
610+
guard let announcement = announcement else { return }
611+
let viewController = WhatsNewFactory.whatsNew(announcement) { [weak self] in
612+
self?.dismiss(animated: true)
613+
}
614+
present(viewController, animated: true, completion: nil)
615+
}
616+
577617
func logOutUser() {
578618
ServiceLocator.stores.deauthenticate()
579619
navigationController?.popToRootViewController(animated: true)
@@ -677,6 +717,8 @@ extension SettingsViewController: UITableViewDelegate {
677717
deviceSettingsWasPressed()
678718
case .wormholy:
679719
wormholyWasPressed()
720+
case .whatsNew:
721+
whatsNewWasPressed()
680722
case .logout:
681723
logoutWasPressed()
682724
default:
@@ -713,6 +755,7 @@ private enum Row: CaseIterable {
713755
case licenses
714756
case deviceSettings
715757
case wormholy
758+
case whatsNew
716759

717760
var type: UITableViewCell.Type {
718761
switch self {
@@ -742,6 +785,8 @@ private enum Row: CaseIterable {
742785
return BasicTableViewCell.self
743786
case .wormholy:
744787
return BasicTableViewCell.self
788+
case .whatsNew:
789+
return BasicTableViewCell.self
745790
}
746791
}
747792

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
import Combine
2+
import SwiftUI
23

34
/// View Model for the `CountrySelector` view.
45
///
5-
final class CountrySelectorViewModel: ObservableObject {
6+
final class CountrySelectorViewModel: FilterListSelectorViewModelable, ObservableObject {
67

78
/// Current search term entered by the user.
89
/// Each update will trigger an update to the `command` that contains the country data.
9-
@Published var searchTerm = "" {
10+
var searchTerm: String = "" {
1011
didSet {
1112
command.filterCountries(term: searchTerm)
13+
objectWillChange.send()
1214
}
1315
}
1416

1517
/// Command that powers the `ListSelector` view.
1618
///
1719
let command = CountrySelectorCommand()
20+
21+
/// Navigation title
22+
///
23+
let navigationTitle = Localization.title
24+
25+
/// Filter text field placeholder
26+
///
27+
let filterPlaceholder = Localization.placeholder
28+
}
29+
30+
// MARK: Constants
31+
private extension CountrySelectorViewModel {
32+
enum Localization {
33+
static let title = NSLocalizedString("Country", comment: "Title to select country from the edit address screen")
34+
static let placeholder = NSLocalizedString("Filter Countries", comment: "Placeholder on the search field to search for a specific country")
35+
}
1836
}

0 commit comments

Comments
 (0)