Skip to content

Commit

Permalink
Add view for selected package and shipment weight
Browse files Browse the repository at this point in the history
  • Loading branch information
rachelmcr committed Nov 29, 2024
1 parent 432d5e9 commit b32a287
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import SwiftUI

struct SelectedPackageView: View {
let package: WooShippingPackageDataRepresentable
let weightUnit: String
@Binding var totalWeight: String

var body: some View {
VStack(alignment: .leading) {
HStack {
Text(Localization.package)
.headlineStyle()
Spacer()
PencilEditButton {
// TODO: Edit selected package
}
.buttonStyle(TextButtonStyle())
}
PackageOptionView(package: package,
showTopDivider: false,
showSource: true,
tapAction: {})
.roundedBorder(cornerRadius: Constants.cornerRadius, lineColor: Constants.lineColor, lineWidth: Constants.lineWidth)
.padding(.bottom)
shipmentWeight
}
}

private var shipmentWeight: some View {
VStack(alignment: .leading) {
Text(Localization.totalWeight)
.bodyStyle()
HStack {
TextField("", text: $totalWeight)
.keyboardType(.decimalPad)
.bodyStyle()
Text(weightUnit)
.font(.subheadline)
.foregroundStyle(.secondary)
}
.padding()
.roundedBorder(cornerRadius: Constants.cornerRadius, lineColor: Constants.lineColor, lineWidth: Constants.lineWidth)
}
}
}

private extension SelectedPackageView {
enum Constants {
static let cornerRadius: CGFloat = 8
static let lineColor = Color(.separator)
static let lineWidth: CGFloat = 0.5
}

enum Localization {
static let package = NSLocalizedString("wooShipping.createLabels.package.title",
value: "Package",
comment: "Heading for the package section in the shipping label creation screen.")
static let totalWeight = NSLocalizedString("wooShipping.createLabels.package.totalWeight",
value: "Total shipment weight (with package)",
comment: "Label for the total shipment weight input field in the shipping label creation screen.")
}
}

#Preview {
SelectedPackageView(package: WooShippingPackageData(name: "Small Flat Rate Box",
length: "12",
width: "6",
height: "6",
dimensionsUnit: "in",
weight: "4",
weightUnit: "oz",
source: .predefined("USPS Priority Mail Flat Rate Boxes"),
packageType: "box"),
weightUnit: "oz",
totalWeight: .constant("6"))
}
4 changes: 4 additions & 0 deletions WooCommerce/WooCommerce.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,7 @@
CEE006082077D14C0079161F /* OrderDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEE006072077D14C0079161F /* OrderDetailsViewController.swift */; };
CEE02AF82C1859B400B0B6AB /* MessageComposeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEE02AF72C1859B400B0B6AB /* MessageComposeView.swift */; };
CEE1138F2CFA2D8900F53E30 /* PackageOptionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEE1138E2CFA2D8900F53E30 /* PackageOptionView.swift */; };
CEE113952CFA2F7700F53E30 /* SelectedPackageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEE113942CFA2F7700F53E30 /* SelectedPackageView.swift */; };
CEE125512CC66C8700D3183D /* WooShippingServiceCardViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEE125502CC66C8100D3183D /* WooShippingServiceCardViewModel.swift */; };
CEE482D52B83A9A300FAC8C5 /* AnalyticsCard+UI.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEE482D42B83A9A300FAC8C5 /* AnalyticsCard+UI.swift */; };
CEEC9B6021E79CAA0055EEF0 /* FeatureFlagTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEEC9B5F21E79CAA0055EEF0 /* FeatureFlagTests.swift */; };
Expand Down Expand Up @@ -5442,6 +5443,7 @@
CEE006072077D14C0079161F /* OrderDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderDetailsViewController.swift; sourceTree = "<group>"; };
CEE02AF72C1859B400B0B6AB /* MessageComposeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageComposeView.swift; sourceTree = "<group>"; };
CEE1138E2CFA2D8900F53E30 /* PackageOptionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackageOptionView.swift; sourceTree = "<group>"; };
CEE113942CFA2F7700F53E30 /* SelectedPackageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectedPackageView.swift; sourceTree = "<group>"; };
CEE125502CC66C8100D3183D /* WooShippingServiceCardViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooShippingServiceCardViewModel.swift; sourceTree = "<group>"; };
CEE482D42B83A9A300FAC8C5 /* AnalyticsCard+UI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AnalyticsCard+UI.swift"; sourceTree = "<group>"; };
CEEC9B5F21E79CAA0055EEF0 /* FeatureFlagTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureFlagTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -12114,6 +12116,7 @@
CEE113902CFA2E6500F53E30 /* Rate Selection */,
CE315DC52CC93CCE00A06748 /* WooShippingCarrier.swift */,
CECEFA6C2CA2CEB50071C7DB /* WooShippingPackageAndRatePlaceholder.swift */,
CEE113942CFA2F7700F53E30 /* SelectedPackageView.swift */,
);
path = "WooShipping Package and Rate Selection";
sourceTree = "<group>";
Expand Down Expand Up @@ -15370,6 +15373,7 @@
028296EC237D28B600E84012 /* TextViewViewController.swift in Sources */,
02B8650F24A9E2D800265779 /* Product+SwiftUIPreviewHelpers.swift in Sources */,
203163B92C1C5F42001C96DA /* PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressView.swift in Sources */,
CEE113952CFA2F7700F53E30 /* SelectedPackageView.swift in Sources */,
454B28BE23BF63C600CD2091 /* DateIntervalFormatter+Helpers.swift in Sources */,
AE6DBE3B2732CAAD00957E7A /* AdaptiveStack.swift in Sources */,
03A6C18628B8CC7F00AADF23 /* InPersonPaymentsOnboardingErrorButtonViewModel.swift in Sources */,
Expand Down

0 comments on commit b32a287

Please sign in to comment.