Skip to content

Commit 9b70b7b

Browse files
committed
Support HTML error message for Coupons
1 parent 2cf3148 commit 9b70b7b

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

WooCommerce/Classes/POS/Presentation/Order Messages/PointOfSaleOrderSyncCouponsErrorMessageView.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ struct PointOfSaleOrderSyncCouponsErrorMessageView: View {
66
let retryHandler: () -> Void
77

88
@Environment(PointOfSaleAggregateModel.self) private var posModel
9+
@Environment(\.dynamicTypeSize) var dynamicTypeSize
10+
11+
private var attributedMessage: AttributedString {
12+
if let data = message.data(using: .utf8),
13+
let nsAttributedString = try? NSAttributedString(
14+
data: data,
15+
options: [.documentType: NSAttributedString.DocumentType.html],
16+
documentAttributes: nil) {
17+
var attributedString = AttributedString(nsAttributedString)
18+
attributedString.font = POSFontStyle.posBodyLargeRegular().font()
19+
attributedString.foregroundColor = UIColor(Color.posOnSurface)
20+
return attributedString
21+
}
22+
return AttributedString(message)
23+
}
924

1025
var body: some View {
1126
HStack(alignment: .center) {
@@ -19,9 +34,7 @@ struct PointOfSaleOrderSyncCouponsErrorMessageView: View {
1934
.foregroundStyle(Color.posOnSurface)
2035
.font(.posHeadingBold)
2136

22-
Text(message)
23-
.foregroundStyle(Color.posOnSurface)
24-
.font(.posBodyLargeRegular())
37+
Text(attributedMessage)
2538
.padding([.leading, .trailing])
2639
}
2740
Spacer().frame(height: PointOfSaleCardPresentPaymentLayout.textAndButtonSpacing)

WooCommerce/Classes/POS/Utils/POSFontStyle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ enum POSFontStyle {
1818
case posButtonSymbolMedium
1919
case posButtonSymbolLarge
2020

21-
fileprivate func font(maximumContentSizeCategory: UIContentSizeCategory? = nil) -> Font {
21+
func font(maximumContentSizeCategory: UIContentSizeCategory? = nil) -> Font {
2222
switch self {
2323
case .posHeadingBold:
2424
Font.system(size: scaledValue(FontSize.heading, maximumContentSizeCategory: maximumContentSizeCategory ?? .accessibilityLarge), weight: .bold)

0 commit comments

Comments
 (0)