Skip to content

Commit 2980bf2

Browse files
authored
Merge branch 'trunk' into issue/7745-account-mismatch-login-site-credentials
2 parents dde4dfa + 7986122 commit 2980bf2

File tree

6 files changed

+153
-56
lines changed

6 files changed

+153
-56
lines changed

RELEASE-NOTES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
-----
55
- [**] Products: Now you can duplicate products from the More menu of the product detail screen. [https://github.com/woocommerce/woocommerce-ios/pull/7727]
66
- [**] Login: Added Jetpack connection support from the Account Mismatch error screen. [https://github.com/woocommerce/woocommerce-ios/pull/7748]
7-
7+
- [*] Orders: We are bringing back the ability to add/edit customer notes and addresses from the main order screen [https://github.com/woocommerce/woocommerce-ios/pull/7750]
88
- [*] Help center: Added help center web page with FAQs for "Wrong WordPress.com account error" screen. [https://github.com/woocommerce/woocommerce-ios/pull/7747]
9+
- [*] Widgets: The Today's Stat Widget adds support for bigger fonts. [https://github.com/woocommerce/woocommerce-ios/pull/7752]
910

1011
10.4
1112
-----

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,16 @@ private extension OrderDetailsDataSource {
458458
cell.selectionStyle = .none
459459
if customerNote.isNotEmpty {
460460
cell.body = customerNote.quoted
461+
cell.onEditTapped = { [weak self] in
462+
self?.onCellAction?(.editCustomerNote, nil)
463+
}
461464
} else {
462465
cell.body = nil
466+
cell.onAddTapped = { [weak self] in
467+
self?.onCellAction?(.editCustomerNote, nil)
468+
}
463469
}
464470

465-
cell.onEditTapped = nil
466-
cell.onAddTapped = nil
467471
cell.addButtonTitle = NSLocalizedString("Add Customer Note", comment: "Title for the button to add the Customer Provided Note in Order Details")
468472
cell.editButtonAccessibilityLabel = NSLocalizedString(
469473
"Update Note",
@@ -890,12 +894,16 @@ private extension OrderDetailsDataSource {
890894

891895
if let formattedPostalAddress = shippingAddress?.formattedPostalAddress {
892896
cell.address = formattedPostalAddress
897+
cell.onEditTapped = { [weak self] in
898+
self?.onCellAction?(.editShippingAddress, nil)
899+
}
893900
} else {
894901
cell.address = nil
902+
cell.onAddTapped = { [weak self] in
903+
self?.onCellAction?(.editShippingAddress, nil)
904+
}
895905
}
896906

897-
cell.onEditTapped = nil
898-
cell.onAddTapped = nil
899907
cell.addButtonTitle = NSLocalizedString("Add Shipping Address", comment: "Title for the button to add the Shipping Address in Order Details")
900908
cell.editButtonAccessibilityLabel = NSLocalizedString(
901909
"Update Address",
@@ -1095,12 +1103,17 @@ extension OrderDetailsDataSource {
10951103
var rows: [Row] = []
10961104

10971105
/// Customer Note
1098-
if order.customerNote?.isNotEmpty == true {
1099-
rows.append(.customerNote)
1100-
}
1106+
/// Always visible to allow adding & editing.
1107+
rows.append(.customerNote)
11011108

11021109
/// Shipping Address
1103-
if order.shippingAddress?.isEmpty == false {
1110+
/// Almost always visible to allow editing.
1111+
let orderContainsOnlyVirtualProducts = self.products.filter { (product) -> Bool in
1112+
return items.first(where: { $0.productID == product.productID}) != nil
1113+
}.allSatisfy { $0.virtual == true }
1114+
1115+
1116+
if order.shippingAddress != nil && orderContainsOnlyVirtualProducts == false {
11041117
rows.append(.shippingAddress)
11051118
}
11061119

@@ -1110,9 +1123,8 @@ extension OrderDetailsDataSource {
11101123
}
11111124

11121125
/// Billing Address
1113-
if order.billingAddress?.isEmpty == false {
1114-
rows.append(.billingDetail)
1115-
}
1126+
/// Always visible to allow editing.
1127+
rows.append(.billingDetail)
11161128

11171129
/// Return `nil` if there is no rows to display.
11181130
guard rows.isNotEmpty else {
@@ -1599,6 +1611,8 @@ extension OrderDetailsDataSource {
15991611
case createShippingLabel
16001612
case shippingLabelTrackingMenu(shippingLabel: ShippingLabel, sourceView: UIView)
16011613
case viewAddOns(addOns: [OrderItemAttribute])
1614+
case editCustomerNote
1615+
case editShippingAddress
16021616
}
16031617

16041618
enum Constants {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ extension OrderDetailsViewModel {
395395
viewController.show(productListVC, sender: nil)
396396
case .billingDetail:
397397
ServiceLocator.analytics.track(.orderDetailShowBillingTapped)
398-
let billingInformationViewController = BillingInformationViewController(order: order, editingEnabled: false)
398+
let billingInformationViewController = BillingInformationViewController(order: order, editingEnabled: true)
399399
viewController.navigationController?.pushViewController(billingInformationViewController, animated: true)
400400
case .customFields:
401401
ServiceLocator.analytics.track(.orderViewCustomFieldsTapped)

WooCommerce/Classes/ViewRelated/Orders/Order Details/Customer Section/CustomerNoteTableViewCell.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ final class CustomerNoteTableViewCell: UITableViewCell {
2929
}
3030
set {
3131
bodyTextView.text = newValue
32+
bodyTextView.isHidden = newValue == nil || newValue?.isEmpty == true
3233
}
3334
}
3435

WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ private extension OrderDetailsViewController {
386386
shippingLabelTrackingMoreMenuTapped(shippingLabel: shippingLabel, sourceView: sourceView)
387387
case let .viewAddOns(addOns):
388388
itemAddOnsButtonTapped(addOns: addOns)
389+
case .editCustomerNote:
390+
editCustomerNoteTapped()
391+
case .editShippingAddress:
392+
editShippingAddressTapped()
389393
}
390394
}
391395

@@ -542,6 +546,20 @@ private extension OrderDetailsViewController {
542546
present(actionSheet, animated: true)
543547
}
544548

549+
func editCustomerNoteTapped() {
550+
let editNoteViewController = EditCustomerNoteHostingController(viewModel: viewModel.editNoteViewModel)
551+
present(editNoteViewController, animated: true)
552+
553+
ServiceLocator.analytics.track(event: WooAnalyticsEvent.OrderDetailsEdit.orderDetailEditFlowStarted(subject: .customerNote))
554+
}
555+
556+
func editShippingAddressTapped() {
557+
let viewModel = EditOrderAddressFormViewModel(order: viewModel.order, type: .shipping)
558+
let editAddressViewController = EditOrderAddressHostingController(viewModel: viewModel)
559+
let navigationController = WooNavigationController(rootViewController: editAddressViewController)
560+
present(navigationController, animated: true, completion: nil)
561+
}
562+
545563
@objc private func collectPaymentTapped() {
546564
collectPayment()
547565

WooCommerce/StoreWidgets/StoreInfoWidget.swift

Lines changed: 106 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -33,72 +33,118 @@ private struct StoreInfoView: View {
3333
// Entry to render
3434
let entry: StoreInfoData
3535

36+
// Current size category
37+
@Environment(\.sizeCategory) var category
38+
3639
var body: some View {
3740
ZStack {
3841
// Background
3942
Color(.brand)
4043

41-
VStack(spacing: Layout.sectionSpacing) {
44+
VStack(alignment: .leading, spacing: Layout.sectionSpacing) {
45+
46+
VStack(alignment: .leading, spacing: Layout.cardSpacing) {
47+
// Store Name
48+
HStack {
49+
Text(entry.name)
50+
.storeNameStyle()
4251

43-
// Store Name
44-
HStack {
45-
Text(entry.name)
46-
.storeNameStyle()
52+
Spacer()
4753

48-
Spacer()
54+
Text(entry.range)
55+
.statRangeStyle()
56+
}
4957

50-
Text(entry.range)
58+
// Updated at
59+
Text(Localization.updatedAt(entry.updatedTime))
5160
.statRangeStyle()
5261
}
5362

54-
// Revenue & Visitors
55-
HStack() {
56-
VStack(alignment: .leading, spacing: Layout.cardSpacing) {
57-
Text(Localization.revenue)
58-
.statTitleStyle()
63+
if category > .extraLarge {
64+
AccessibilityStatsCard(entry: entry)
65+
} else {
66+
StatsCard(entry: entry)
67+
}
68+
}
69+
.padding(.horizontal)
70+
}
71+
}
72+
}
5973

60-
Text(entry.revenue)
61-
.statValueStyle()
74+
/// Stats card sub view.
75+
/// To be used inside `StoreInfoView`.
76+
///
77+
private struct StatsCard: View {
78+
// Entry to render
79+
let entry: StoreInfoData
6280

63-
}
64-
.frame(maxWidth: .infinity, alignment: .leading)
81+
var body: some View {
82+
Group {
83+
// Revenue & Visitors
84+
HStack() {
85+
VStack(alignment: .leading, spacing: StoreInfoView.Layout.cardSpacing) {
86+
Text(StoreInfoView.Localization.revenue)
87+
.statTitleStyle()
6588

66-
VStack(alignment: .leading, spacing: Layout.cardSpacing) {
67-
Text(Localization.visitors)
68-
.statTitleStyle()
89+
Text(entry.revenue)
90+
.statValueStyle()
6991

70-
Text(entry.visitors)
71-
.statValueStyle()
72-
}
73-
.frame(maxWidth: .infinity, alignment: .leading)
7492
}
93+
.frame(maxWidth: .infinity, alignment: .leading)
7594

76-
// Orders & Conversion
77-
HStack {
78-
VStack(alignment: .leading, spacing: Layout.cardSpacing) {
79-
Text(Localization.orders)
80-
.statTitleStyle()
95+
VStack(alignment: .leading, spacing: StoreInfoView.Layout.cardSpacing) {
96+
Text(StoreInfoView.Localization.visitors)
97+
.statTitleStyle()
8198

82-
Text(entry.orders)
83-
.statValueStyle()
84-
}
85-
.frame(maxWidth: .infinity, alignment: .leading)
99+
Text(entry.visitors)
100+
.statValueStyle()
101+
}
102+
.frame(maxWidth: .infinity, alignment: .leading)
103+
}
86104

87-
VStack(alignment: .leading, spacing: Layout.cardSpacing) {
88-
Text(Localization.conversion)
89-
.statTitleStyle()
105+
// Orders & Conversion
106+
HStack {
107+
VStack(alignment: .leading, spacing: StoreInfoView.Layout.cardSpacing) {
108+
Text(StoreInfoView.Localization.orders)
109+
.statTitleStyle()
90110

91-
Text(entry.conversion)
92-
.statValueStyle()
93-
}
94-
.frame(maxWidth: .infinity, alignment: .leading)
111+
Text(entry.orders)
112+
.statValueStyle()
95113
}
114+
.frame(maxWidth: .infinity, alignment: .leading)
115+
116+
VStack(alignment: .leading, spacing: StoreInfoView.Layout.cardSpacing) {
117+
Text(StoreInfoView.Localization.conversion)
118+
.statTitleStyle()
96119

97-
Text(Localization.updatedAt(entry.updatedTime))
98-
.statRangeStyle()
99-
.frame(maxWidth: .infinity, alignment: .leading)
120+
Text(entry.conversion)
121+
.statValueStyle()
122+
}
123+
.frame(maxWidth: .infinity, alignment: .leading)
100124
}
101-
.padding(.horizontal)
125+
}
126+
}
127+
}
128+
129+
/// Accessibility card sub view. Shows only revenue and a `View More` button.
130+
/// To be used inside `StoreInfoView`.
131+
///
132+
private struct AccessibilityStatsCard: View {
133+
// Entry to render
134+
let entry: StoreInfoData
135+
136+
var body: some View {
137+
Group {
138+
VStack(alignment: .leading, spacing: StoreInfoView.Layout.cardSpacing) {
139+
Text(StoreInfoView.Localization.revenue)
140+
.statTitleStyle()
141+
142+
Text(entry.revenue)
143+
.statValueStyle()
144+
}
145+
146+
Text(StoreInfoView.Localization.viewMore)
147+
.statButtonStyle()
102148
}
103149
}
104150
}
@@ -195,6 +241,11 @@ private extension StoreInfoView {
195241
value: "Conversion",
196242
comment: "Conversion title label for the store info widget"
197243
)
244+
static let viewMore = AppLocalizedString(
245+
"storeWidgets.infoView.viewMore",
246+
value: "View More",
247+
comment: "Title for the button indicator to display more stats in the Today's Stat widget when using accessibility fonts."
248+
)
198249
static func updatedAt(_ updatedTime: String) -> LocalizedString {
199250
let format = AppLocalizedString("storeWidgets.infoView.updatedAt",
200251
value: "As of %1$@",
@@ -263,6 +314,18 @@ struct StoreWidgets_Previews: PreviewProvider {
263314
)
264315
.previewContext(WidgetPreviewContext(family: .systemMedium))
265316

317+
StoreInfoView(
318+
entry: StoreInfoData(range: "Today",
319+
name: "Ernest Shop",
320+
revenue: "$132.234",
321+
visitors: "67",
322+
orders: "23",
323+
conversion: "37%",
324+
updatedTime: "10:24 PM")
325+
)
326+
.previewContext(WidgetPreviewContext(family: .systemMedium))
327+
.environment(\.sizeCategory, .extraExtraLarge)
328+
266329
NotLoggedInView()
267330
.previewContext(WidgetPreviewContext(family: .systemMedium))
268331

0 commit comments

Comments
 (0)