Skip to content

Commit 94e2a97

Browse files
authored
Merge branch 'trunk' into fix/splitting-shipment-ui-bugs
2 parents d1f12f4 + f65a395 commit 94e2a97

File tree

26 files changed

+1663
-100
lines changed

26 files changed

+1663
-100
lines changed

Modules/Sources/Experiments/DefaultFeatureFlagService.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
9393
return false
9494
case .pointOfSaleAsATabi1:
9595
return true
96+
case .pointOfSaleAsATabi2:
97+
return buildConfig == .localDeveloper || buildConfig == .alpha
98+
case .pointOfSaleOrdersi1:
99+
return false
96100
default:
97101
return true
98102
}

Modules/Sources/Experiments/FeatureFlag.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,12 @@ public enum FeatureFlag: Int {
195195
/// Enables displaying POS as a tab in the tab bar with the same eligibility as the previous entry point
196196
///
197197
case pointOfSaleAsATabi1
198+
199+
/// Enables displaying POS as a tab in the tab bar for stores in eligible countries
200+
///
201+
case pointOfSaleAsATabi2
202+
203+
/// Enables displaying Point Of Sale details in order list and order details
204+
///
205+
case pointOfSaleOrdersi1
198206
}

Modules/Sources/Storage/Model/MIGRATIONS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This file documents changes in the WCiOS Storage data model. Please explain any changes to the data model as well as any custom migrations.
44

5+
## Model 123 (Release 22.8.0.0)
6+
- @iamgabrielma 2025-06-30
7+
- Added `createdVia` attribute to `Order` entity.
8+
59
## Model 122 (Release 22.7.0.0)
610
- @itsmeichigo 2025-06-20
711
- Added `shipmentID` attribute to `ShippingLabel` entity.

Modules/Sources/Storage/Model/Order+CoreDataProperties.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extension Order {
2020
@NSManaged public var billingPostcode: String?
2121
@NSManaged public var billingState: String?
2222
@NSManaged public var chargeID: String?
23+
@NSManaged public var createdVia: String?
2324
@NSManaged public var currency: String?
2425
@NSManaged public var customerID: Int64
2526
@NSManaged public var customerNote: String?

Modules/Sources/Storage/Resources/WooCommerce.xcdatamodeld/.xccurrentversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<plist version="1.0">
44
<dict>
55
<key>_XCCurrentVersionName</key>
6-
<string>Model 122.xcdatamodel</string>
6+
<string>Model 123.xcdatamodel</string>
77
</dict>
88
</plist>

Modules/Sources/Storage/Resources/WooCommerce.xcdatamodeld/Model 123.xcdatamodel/contents

Lines changed: 1070 additions & 0 deletions
Large diffs are not rendered by default.

Modules/Tests/StorageTests/CoreData/MigrationTests.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3363,6 +3363,41 @@ final class MigrationTests: XCTestCase {
33633363
let updatedShipmentID = migratedLabel.value(forKey: "shipmentID") as? String
33643364
XCTAssertEqual(updatedShipmentID, id)
33653365
}
3366+
3367+
func test_migrating_from_122_to_123_adds_new_attribute_createdVia_to_order() throws {
3368+
// Given
3369+
let sourceContainer = try startPersistentContainer("Model 122")
3370+
let sourceContext = sourceContainer.viewContext
3371+
3372+
let object = sourceContext.insert(entityName: "Order", properties: [
3373+
"orderID": 123,
3374+
"statusKey": "" // statusKey is a required value, unrelated to this migration
3375+
])
3376+
try sourceContext.save()
3377+
3378+
// `createdVia` should not be present in model 122
3379+
XCTAssertNil(object.entity.attributesByName["createdVia"], "Precondition. Attribute does not exist.")
3380+
3381+
// When
3382+
let targetContainer = try migrate(sourceContainer, to: "Model 123")
3383+
3384+
// Then
3385+
let targetContext = targetContainer.viewContext
3386+
let migratedObject = try XCTUnwrap(targetContext.first(entityName: "Order"))
3387+
3388+
// `createdVia` should be present in model 123
3389+
XCTAssertNotNil(migratedObject.entity.attributesByName["createdVia"])
3390+
3391+
// `createdVia` value should default as nil in model 123
3392+
let value = migratedObject.value(forKey: "createdVia") as? String
3393+
XCTAssertNil(value)
3394+
3395+
// `createdVia` must be settable
3396+
migratedObject.setValue("pos-rest-api", forKey: "createdVia")
3397+
try targetContext.save()
3398+
let updatedValue = migratedObject.value(forKey: "createdVia") as? String
3399+
XCTAssertEqual(updatedValue, "pos-rest-api")
3400+
}
33663401
}
33673402

33683403
// MARK: - Persistent Store Setup and Migrations

RELEASE-NOTES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
22.8
55
-----
66
- [*] Shipping Labels: Improve UI of Split shipments screen. [https://github.com/woocommerce/woocommerce-ios/pull/15838]
7-
7+
- [*] POS: icon button with confirmation step used for clearing the cart [https://github.com/woocommerce/woocommerce-ios/pull/15829]
88

99
22.7
1010
-----
@@ -19,6 +19,7 @@
1919
- [*] POS: Prevent card reader connection success alert flashing when connecting during a payment [https://github.com/woocommerce/woocommerce-ios/pull/15784]
2020
- [**] Shipping Labels: Support UPS extra services [https://github.com/woocommerce/woocommerce-ios/pull/15819, https://github.com/woocommerce/woocommerce-ios/pull/15821]
2121
- [*] Shipping Labels: Pre-fill custom forms with item description, value, and weight [https://github.com/woocommerce/woocommerce-ios/pull/15811]
22+
- [*] Shipping Labels: Pre-fill custom forms with item origin country [https://github.com/woocommerce/woocommerce-ios/pull/15835]
2223
- [internal] POS: Improved scrolling and animation performance by refactoring the shadow implementation and updating the cart and checkout views. [https://github.com/woocommerce/woocommerce-ios/pull/15817]
2324

2425
22.6
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import UIKit
2+
3+
extension UILabel {
4+
/// Applies the appropriate style to sales channel label
5+
///
6+
func applySalesChannelStyle() {
7+
applyFootnoteStyle()
8+
applyLayerSettings()
9+
backgroundColor = .lightGray
10+
textColor = .black
11+
}
12+
13+
/// Setup: Layer
14+
///
15+
private func applyLayerSettings() {
16+
layer.masksToBounds = true
17+
layer.borderWidth = Layout.borderWidth
18+
layer.cornerRadius = Layout.cornerRadius
19+
}
20+
}
21+
22+
private extension UILabel {
23+
enum Layout {
24+
static let borderWidth = CGFloat(0.0)
25+
static let cornerRadius = CGFloat(4.0)
26+
}
27+
}

WooCommerce/Classes/POS/Presentation/CartView.swift

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct CartView: View {
3232
POSPageHeaderView(title: Localization.cartTitle,
3333
backButtonConfiguration: backButtonConfiguration,
3434
trailingContent: {
35-
DynamicHStack(horizontalAlignment: .trailing, verticalAlignment: .center, spacing: Constants.cartHeaderElementSpacing) {
35+
HStack(spacing: Constants.cartHeaderElementSpacing) {
3636
if let itemsInCartLabel = viewHelper.itemsInCartLabel(for: posModel.cart.purchasableItems.count) {
3737
Text(itemsInCartLabel)
3838
.font(Constants.itemsFont)
@@ -42,13 +42,9 @@ struct CartView: View {
4242
.foregroundColor(Color.posOnSurfaceVariantLowest)
4343
}
4444

45-
Button {
45+
CartClearMenuButton(removeAllItemsFromCart: {
4646
posModel.removeAllItemsFromCart()
47-
ServiceLocator.analytics.track(.pointOfSaleClearCartTapped)
48-
} label: {
49-
Text(Localization.clearButtonTitle)
50-
}
51-
.buttonStyle(POSOutlinedButtonStyle(size: .extraSmall))
47+
})
5248
.renderedIf(shouldShowClearCartButton)
5349
}
5450
})
@@ -137,10 +133,6 @@ private extension CartView {
137133
"pos.cartView.cartTitle",
138134
value: "Cart",
139135
comment: "Title at the header for the Cart view.")
140-
static let clearButtonTitle = NSLocalizedString(
141-
"pos.cartView.clearButtonTitle",
142-
value: "Clear",
143-
comment: "Title for the 'Clear' button to remove all products from the Cart.")
144136
static let addItemsToCartHint = NSLocalizedString(
145137
"pos.cartView.addItemsToCartHint",
146138
value: "Tap on a product to \n add it to the cart",
@@ -221,6 +213,37 @@ private extension CartView {
221213

222214
}
223215

216+
@available(iOS 17.0, *)
217+
private struct CartClearMenuButton: View {
218+
let removeAllItemsFromCart: () -> Void
219+
220+
var body: some View {
221+
Menu {
222+
Button(role: .destructive,
223+
action: {
224+
removeAllItemsFromCart()
225+
ServiceLocator.analytics.track(.pointOfSaleClearCartTapped)
226+
}) {
227+
Text(Localization.clearButtonTitle)
228+
}
229+
230+
} label: {
231+
Image(systemName: "trash")
232+
.font(.posButtonSymbolMedium)
233+
.foregroundStyle(Color.posOnSurface)
234+
.dynamicTypeSize(...POSHeaderLayoutConstants.maximumDynamicTypeSize)
235+
.accessibilityLabel(Localization.clearButtonTitle)
236+
}
237+
}
238+
239+
enum Localization {
240+
static let clearButtonTitle = NSLocalizedString(
241+
"pos.cartView.clearButtonTitle.1",
242+
value: "Clear cart",
243+
comment: "Title for the 'Clear cart' confirmation button to remove all products from the Cart.")
244+
}
245+
}
246+
224247
@available(iOS 17.0, *)
225248
private struct CartScrollViewContent: View {
226249
@Environment(PointOfSaleAggregateModel.self) private var posModel

0 commit comments

Comments
 (0)