Skip to content

Commit afd5a2d

Browse files
Merge branch 'trunk' into task/15304-split-shipment-navigation
2 parents 8ddb741 + 1269cd4 commit afd5a2d

File tree

18 files changed

+249
-89
lines changed

18 files changed

+249
-89
lines changed

Experiments/Experiments/DefaultFeatureFlagService.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
7171
return false
7272
case .pointOfSale:
7373
return buildConfig == .localDeveloper || buildConfig == .alpha
74+
case .enableCouponsInPointOfSale:
75+
return buildConfig == .localDeveloper || buildConfig == .alpha
7476
case .googleAdsCampaignCreationOnWebView:
7577
return true
7678
case .backgroundTasks:

Experiments/Experiments/FeatureFlag.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ public enum FeatureFlag: Int {
157157
///
158158
case pointOfSale
159159

160+
/// Enables coupons in Point of Sale
161+
///
162+
case enableCouponsInPointOfSale
163+
160164
/// Enables Google ads campaign creation on web view
161165
///
162166
case googleAdsCampaignCreationOnWebView

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [*] Product Form: Fix crash related to picking photos [https://github.com/woocommerce/woocommerce-ios/pull/15275]
77
- [internal] Assign `siteID` and `productID` to image product upload statuses. [https://github.com/woocommerce/woocommerce-ios/pull/15196]
88
- [*] Payments: Improved payment views' adaptability to larger accessibility font sizes [https://github.com/woocommerce/woocommerce-ios/pull/15328].
9+
- [internal] Add site related properties to crowdsignal surveys. [https://github.com/woocommerce/woocommerce-ios/pull/15353]
910

1011
21.9
1112
-----

WooCommerce/Classes/POS/Controllers/PointOfSaleItemsController.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protocol PointOfSaleItemsControllerProtocol {
141141
parentItem: parent,
142142
pageNumber: pageNumber,
143143
appendToExistingItems: appendToExistingItems)
144-
case .simpleProduct, .variation:
144+
case .simpleProduct, .variation, .coupon:
145145
assertionFailure("Unsupported parent type for loading child items: \(parent)")
146146
return false
147147
}
@@ -158,6 +158,14 @@ protocol PointOfSaleItemsControllerProtocol {
158158
}
159159
}
160160

161+
@available(iOS 17.0, *)
162+
private extension PointOfSaleItemsController {
163+
func loadPointOfSaleCoupons() {
164+
let posCoupons = itemProvider.providePointOfSaleCoupons()
165+
debugPrint(posCoupons)
166+
}
167+
}
168+
161169
@available(iOS 17.0, *)
162170
private extension PointOfSaleItemsController {
163171
func setLoadingState(base: ItemListBaseItem) {

WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ private extension POSItem {
119119
return CartItem(id: UUID(), item: variation, title: variation.parentProductName, subtitle: variation.name, quantity: 1)
120120
case .variableParentProduct:
121121
return nil
122+
case .coupon:
123+
return nil
122124
}
123125
}
124126
}

WooCommerce/Classes/POS/Presentation/Item Selector/ItemList.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ private struct ItemListRow: View {
116116
}, label: {
117117
VariationCardView(variation: variation)
118118
})
119+
case .coupon:
120+
EmptyView()
119121
}
120122
}
121123
}

WooCommerce/Classes/POS/Utils/PreviewHelpers.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ final class PointOfSalePreviewItemService: PointOfSaleItemServiceProtocol {
5656
name: "Product 1",
5757
formattedPrice: "$1.00")
5858
}
59+
60+
func providePointOfSaleCoupons() -> [POSItem] {
61+
[]
62+
}
5963
}
6064

6165
@available(iOS 17.0, *)

WooCommerce/Classes/ViewRelated/Hub Menu/HubMenuViewModel.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,13 @@ final class HubMenuViewModel: ObservableObject {
9595
private let googleAdsEligibilityChecker: GoogleAdsEligibilityChecker
9696

9797
private(set) lazy var posItemProvider: PointOfSaleItemServiceProtocol = {
98+
let storage = ServiceLocator.storageManager
9899
let currencySettings = ServiceLocator.currencySettings
99100

100101
return PointOfSaleItemService(siteID: siteID,
101102
currencySettings: currencySettings,
102-
credentials: credentials)
103+
credentials: credentials,
104+
storage: storage)
103105
}()
104106

105107
private(set) lazy var inboxViewModel = InboxViewModel(siteID: siteID)

WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatDetailView.swift

Lines changed: 74 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,78 +12,99 @@ struct WooShippingHazmatDetailView: View {
1212
}
1313

1414
var body: some View {
15-
ScrollView {
16-
VStack(spacing: Constants.verticalSpacing) {
17-
HStack {
18-
Button(Localization.cancel) {
19-
dismiss()
20-
}
21-
.padding(.top)
22-
Spacer()
23-
}
15+
NavigationStack {
16+
ScrollView {
17+
VStack(spacing: Constants.verticalSpacing) {
2418

25-
Text(Localization.title)
26-
.secondaryTitleStyle()
27-
.bold()
19+
Text(Localization.title)
20+
.secondaryTitleStyle()
21+
.bold()
22+
.frame(maxWidth: .infinity, alignment: .leading)
2823

29-
Toggle(isOn: $isHazardous) {
30-
Text(Localization.toggleLabel)
31-
}
24+
Toggle(isOn: $isHazardous) {
25+
Text(Localization.toggleLabel)
26+
}
3227

33-
Button(Localization.selectCategory) {
34-
// TODO: navigate to category list
35-
}
36-
.buttonStyle(PrimaryButtonStyle())
37-
.renderedIf(isHazardous)
28+
Button(Localization.selectCategory) {
29+
// TODO: navigate to category list
30+
}
31+
.buttonStyle(PrimaryButtonStyle())
32+
.renderedIf(isHazardous)
3833

39-
Divider()
34+
Divider()
4035

41-
Text(Localization.detailLine1)
42-
AttributedText(detailLine2AttributedString, enablesLinkUnderline: true)
43-
AttributedText(detailLine3AttributedString, enablesLinkUnderline: true)
36+
Text(Localization.detailLine1)
37+
.frame(maxWidth: .infinity, alignment: .leading)
38+
Text(detailLine2AttributedString)
39+
.frame(maxWidth: .infinity, alignment: .leading)
40+
Text(detailLine3AttributedString)
41+
.frame(maxWidth: .infinity, alignment: .leading)
4442

45-
Spacer()
43+
Spacer()
44+
}
45+
.environment(\.openURL, OpenURLAction { url in
46+
detailURL = url
47+
return .handled
48+
})
49+
.safariSheet(url: $detailURL)
50+
.padding(.horizontal)
51+
.toolbar {
52+
ToolbarItem(placement: .cancellationAction) {
53+
Button(Localization.cancel) {
54+
dismiss()
55+
}
56+
}
57+
}
58+
.toolbarBackground(Color.clear, for: .navigationBar)
4659
}
47-
.frame(maxWidth: .infinity, alignment: .leading)
48-
.environment(\.openURL, OpenURLAction { url in
49-
detailURL = url
50-
return .handled
51-
})
52-
.safariSheet(url: $detailURL)
53-
.padding(.horizontal)
5460
}
5561
}
5662
}
5763

5864
private extension WooShippingHazmatDetailView {
59-
var detailLine2AttributedString: NSAttributedString {
65+
var detailLine2AttributedString: AttributedString {
6066
let content = String.localizedStringWithFormat(Localization.detailLine2, Constants.hazmatURL, Localization.searchTool)
67+
var attributedText = AttributedString(content)
68+
attributedText.font = .body
69+
attributedText.foregroundColor = Color(.text)
70+
71+
if let range1 = attributedText.range(of: Constants.hazmatURL),
72+
let url = URL(string: Constants.hazmatURL) {
73+
var linkContainer = AttributeContainer()
74+
.link(url)
75+
.foregroundColor(Color.accentColor)
76+
linkContainer.underlineStyle = .single
77+
attributedText[range1].mergeAttributes(linkContainer)
78+
}
6179

62-
let mutableAttributedText = NSMutableAttributedString(
63-
string: content,
64-
attributes: [.font: UIFont.body,
65-
.foregroundColor: UIColor.text]
66-
)
67-
68-
mutableAttributedText.setAsLink(textToFind: Constants.hazmatURL,
69-
linkURL: Constants.hazmatURL)
70-
mutableAttributedText.setAsLink(textToFind: Localization.searchTool,
71-
linkURL: Constants.searchToolURL)
72-
return mutableAttributedText
80+
if let range2 = attributedText.range(of: Localization.searchTool),
81+
let url = URL(string: Constants.searchToolURL) {
82+
var linkContainer = AttributeContainer()
83+
.link(url)
84+
.foregroundColor(Color.accentColor)
85+
linkContainer.underlineStyle = .single
86+
attributedText[range2].mergeAttributes(linkContainer)
87+
}
88+
return attributedText
7389
}
7490

75-
var detailLine3AttributedString: NSAttributedString {
91+
var detailLine3AttributedString: AttributedString {
7692
let content = String.localizedStringWithFormat(Localization.detailLine3, Constants.DHLExpressName)
7793

78-
let mutableAttributedText = NSMutableAttributedString(
79-
string: content,
80-
attributes: [.font: UIFont.body,
81-
.foregroundColor: UIColor.text]
82-
)
94+
var attributedText = AttributedString(content)
95+
attributedText.font = .body
96+
attributedText.foregroundColor = Color(.text)
97+
98+
if let range = attributedText.range(of: Constants.DHLExpressName),
99+
let url = URL(string: Constants.DHLExpressURL) {
100+
var linkContainer = AttributeContainer()
101+
.link(url)
102+
.foregroundColor(Color.accentColor)
103+
linkContainer.underlineStyle = .single
104+
attributedText[range].mergeAttributes(linkContainer)
105+
}
83106

84-
mutableAttributedText.setAsLink(textToFind: Constants.DHLExpressName,
85-
linkURL: Constants.DHLExpressURL)
86-
return mutableAttributedText
107+
return attributedText
87108
}
88109
}
89110

WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Hazmat Section/WooShippingHazmatRow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private extension WooShippingHazmatRow {
4444
}
4545

4646
enum Localization {
47-
static let hazmatLabel = NSLocalizedString("wooShipping.createLabel.hazmatLabel",
47+
static let hazmatLabel = NSLocalizedString("wooShipping.createLabel.hazmatRow.label",
4848
value: "Are you shipping dangerous goods or hazardous materials?",
4949
comment: "Label for section in shipping label creation to declare when a package contains hazardous materials.")
5050
static let yes = NSLocalizedString(

0 commit comments

Comments
 (0)