Skip to content

Commit 05a0164

Browse files
committed
Merge branch 'trunk' into issue/6127-order-sync-protocol
2 parents 43d6502 + 0b840fd commit 05a0164

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
8.6
44
-----
5+
- [*] Enlarged the tap area for the action button on the notice view. [https://github.com/woocommerce/woocommerce-ios/pull/6146]
56

67

78
8.5

WooCommerce/Classes/Tools/Notices/NoticeView.swift

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class NoticeView: UIView {
88

99
private let backgroundContainerView = UIView()
1010
private let backgroundView: UIVisualEffectView
11-
private let actionBackgroundView = UIView()
1211
private let shadowLayer = CAShapeLayer()
1312
private let shadowMaskLayer = CAShapeLayer()
1413

@@ -138,26 +137,19 @@ private extension NoticeView {
138137
}
139138

140139
func configureActionButton() {
141-
contentStackView.addArrangedSubview(actionBackgroundView)
142-
actionBackgroundView.translatesAutoresizingMaskIntoConstraints = false
143-
144-
actionBackgroundView.layoutMargins = Metrics.layoutMargins
145-
actionBackgroundView.backgroundColor = Appearance.actionBackgroundColor
146-
147-
actionBackgroundView.addSubview(actionButton)
148-
actionButton.translatesAutoresizingMaskIntoConstraints = false
140+
contentStackView.addArrangedSubview(actionButton)
149141

150142
NSLayoutConstraint.activate([
151-
actionBackgroundView.topAnchor.constraint(equalTo: backgroundView.contentView.topAnchor),
152-
actionBackgroundView.bottomAnchor.constraint(equalTo: backgroundView.contentView.bottomAnchor),
143+
actionButton.topAnchor.constraint(equalTo: backgroundView.contentView.topAnchor),
144+
actionButton.bottomAnchor.constraint(equalTo: backgroundView.contentView.bottomAnchor),
153145
])
154146

155-
actionBackgroundView.pinSubviewToAllEdgeMargins(actionButton)
156-
157147
actionButton.titleLabel?.font = Fonts.actionButtonFont
158148
actionButton.setTitleColor(Appearance.actionColor, for: .normal)
159149
actionButton.addTarget(self, action: #selector(actionButtonTapped), for: .touchUpInside)
160150
actionButton.setContentCompressionResistancePriority(.required, for: .horizontal)
151+
actionButton.contentEdgeInsets = Metrics.actionButtonContentInsets
152+
actionButton.backgroundColor = Appearance.actionBackgroundColor
161153
}
162154

163155
func configureDismissRecognizer() {
@@ -184,8 +176,9 @@ private extension NoticeView {
184176

185177
if let actionTitle = notice.actionTitle {
186178
actionButton.setTitle(actionTitle, for: .normal)
179+
actionButton.isHidden = false
187180
} else {
188-
actionBackgroundView.isHidden = true
181+
actionButton.isHidden = true
189182
}
190183
}
191184
}
@@ -213,6 +206,7 @@ private extension NoticeView {
213206
enum Metrics {
214207
static let cornerRadius: CGFloat = 13.0
215208
static let layoutMargins = UIEdgeInsets(top: 16.0, left: 16.0, bottom: 16.0, right: 16.0)
209+
static let actionButtonContentInsets = UIEdgeInsets(top: 22.0, left: 16.0, bottom: 22.0, right: 16.0)
216210
static let labelLineSpacing: CGFloat = 18.0
217211
}
218212

WooCommerce/WooCommerceTests/ViewRelated/Orders/Order Creation/AddProductToOrderViewModelTests.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,29 +169,33 @@ class AddProductToOrderViewModelTests: XCTestCase {
169169
XCTAssertEqual(viewModel.productRows.count, 1)
170170
}
171171

172-
func test_searching_products_returns_expected_results() {
172+
func test_searching_products_filters_product_list_as_expected() {
173173
// Given
174+
let hoodie = Product.fake().copy(siteID: sampleSiteID, productID: 1, name: "Hoodie", purchasable: true)
175+
let shirt = Product.fake().copy(siteID: sampleSiteID, productID: 2, name: "T-shirt", purchasable: true)
176+
insert([hoodie, shirt])
177+
174178
let viewModel = AddProductToOrderViewModel(siteID: sampleSiteID, storageManager: storageManager, stores: stores)
175179
let expectation = expectation(description: "Completed product search")
176-
let product = Product.fake().copy(siteID: sampleSiteID, purchasable: true)
177-
insert([product.copy(name: "T-shirt"), product.copy(name: "Hoodie")])
178180
stores.whenReceivingAction(ofType: ProductAction.self) { action in
179181
switch action {
180182
case let .searchProducts(_, _, _, _, _, onCompletion):
181-
self.insert(product.copy(name: "T-shirt"), withSearchTerm: "shirt")
183+
self.insert(shirt, withSearchTerm: "shirt")
182184
onCompletion(.success(()))
183185
expectation.fulfill()
184186
default:
185187
XCTFail("Unsupported Action")
186188
}
187189
}
188190

191+
XCTAssertEqual(viewModel.productRows.count, 2, "Full product list is not loaded before search")
192+
189193
// When
190194
viewModel.searchTerm = "shirt"
191195
waitForExpectations(timeout: Constants.expectationTimeout, handler: nil)
192196

193197
// Then
194-
XCTAssertEqual(viewModel.productRows.count, 1)
198+
XCTAssertEqual(viewModel.productRows.count, 1, "Product list is not filtered after search")
195199
XCTAssertEqual(viewModel.productRows[0].name, "T-shirt")
196200
}
197201

0 commit comments

Comments
 (0)