Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Woo POS] [Design System] Apply straightforward color updates #15068

Merged
merged 25 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0d82d75
Rename POS text colors to replace the existing primary/secondary/tert…
jaclync Feb 6, 2025
a445269
Replace `Color.posPrimaryTextInverted` with `Color.posOnInverseSurfac…
jaclync Feb 6, 2025
0d0e84b
Remove unused color `posOverlayFillInverted`.
jaclync Feb 6, 2025
a4049c2
Replace previous `posPrimaryBackground` color with DS colors.
jaclync Feb 6, 2025
6f84b09
Consolidate background color for cards using a constant and set it to…
jaclync Feb 6, 2025
690d36b
Revert use of clear background color to fix clear background area not…
jaclync Feb 6, 2025
da37b47
Update colors in cart view.
jaclync Feb 6, 2025
e6ca856
Update colors in POS modal base.
jaclync Feb 6, 2025
ed832c5
Update colors in product type banner view. This will be extracted to …
jaclync Feb 6, 2025
21fa12a
Update some colors in floating control. The views will also be update…
jaclync Feb 6, 2025
f9b515e
Replace remaining `posSecondaryBackground` usage with colors in design.
jaclync Feb 6, 2025
25a77a5
Remove unused color constant.
jaclync Feb 6, 2025
a405984
Replace `posSuccessColor` with `posSuccess` and update checkmark colo…
jaclync Feb 6, 2025
c1d5de4
Use 0.6 opacity in modal background overlay to allow content below to…
jaclync Feb 6, 2025
26d1fc8
Fix SwiftUI preview crash by passing environment object.
jaclync Feb 6, 2025
ac009e8
Update text colors in payment processing view.
jaclync Feb 6, 2025
6a67d6d
Remove unused color `posOverlayFill`.
jaclync Feb 6, 2025
5aed9e9
Remove debug code to show banner.
jaclync Feb 6, 2025
b2529ec
Polishes.
jaclync Feb 6, 2025
4010bf7
Merge branch 'trunk' into feat/15061-replace-colors
jaclync Feb 7, 2025
41ac7aa
Fix environment variables for previews from adopting Observation for …
jaclync Feb 7, 2025
5dd6465
Update to import SwiftUI for consistency.
jaclync Feb 7, 2025
ac3c0e0
Add shadow layers to product card border modifier based on design.
jaclync Feb 7, 2025
b727822
Update color and related design in modal after design confirmation.
jaclync Feb 7, 2025
8d038e7
Revert "Add shadow layers to product card border modifier based on de…
jaclync Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions WooCommerce/Classes/POS/Colors/Color+POSColorPalette.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ extension Color {
static var posOnAlert: Color { Color(.posOnAlert) }

// MARK: - Text Colors
static var posTextPrimary: Color { Color(.posTextPrimary) }
static var posTextSecondary: Color { Color(.posTextSecondary) }
static var posTextTertiary: Color { Color(.posTextTertiary) }
static var posPrimaryText: Color { Color(.posPrimaryText) }
static var posSecondaryText: Color { Color(.posSecondaryText) }
static var posTertiaryText: Color { Color(.posTertiaryText) }

// MARK: - Other
static var posShadow: Color { Color(.posShadow) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct CardReaderConnectionStatusView: View {
}
} label: {
HStack(spacing: Constants.buttonImageAndTextSpacing) {
circleIcon(with: Color(.wooCommerceEmerald(.shade40)))
circleIcon(with: Color.posSuccess)
Text(Localization.readerConnected)
.foregroundColor(connectedFontColor)
}
Expand Down Expand Up @@ -97,7 +97,7 @@ private extension CardReaderConnectionStatusView {
var disconnectedFontColor: Color {
switch backgroundAppearance {
case .primary:
Color(.wooCommercePurple(.shade60))
.posPrimaryText
case .secondary:
POSFloatingControlView.secondaryFontColor
}
Expand Down Expand Up @@ -163,8 +163,14 @@ private extension CardReaderConnectionStatusView {

@available(iOS 17.0, *)
#Preview {
let posModel = PointOfSaleAggregateModel(
itemsController: PointOfSalePreviewItemsController(),
cardPresentPaymentService: CardPresentPaymentPreviewService(),
orderController: PointOfSalePreviewOrderController()
)
VStack {
CardReaderConnectionStatusView()
.environmentObject(posModel)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct PointOfSaleCardPresentPaymentFoundMultipleReadersView: View {
List(readerIDs, id: \.self) { readerID in
readerRow(readerID: readerID)
.listRowSeparator(.hidden)
.listRowBackground(Color.posPrimaryBackground)
.listRowBackground(Color.posSurface)
}
.listStyle(.plain)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ struct PointOfSaleCardPresentPaymentProcessingMessageView: View {

VStack(alignment: .center, spacing: Layout.textSpacing) {
Text(viewModel.title)
.foregroundStyle(.white)
.foregroundStyle(Color.posOnPrimaryContainer)
.font(.posBodyRegular)
.matchedGeometryEffect(id: animation.titleTransitionId, in: animation.namespace, properties: .position)

Text(viewModel.message)
.font(.posTitleEmphasized)
.foregroundStyle(Color.posDarkGray.opacity(0.16))
.foregroundStyle(Color.posOnPrimaryContainer)
.accessibilityAddTraits(.isHeader)
.matchedGeometryEffect(id: animation.messageTransitionId, in: animation.namespace, properties: .position)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct PointOfSalePaymentSuccessView: View {
.frame(width: Constants.imageSize.width, height: Constants.imageSize.height)
.shadow(color: Color(.wooCommerceEmerald(.shade80)).opacity(Constants.shadowOpacity),
radius: Constants.shadowRadius, x: Constants.shadowSize.width, y: Constants.shadowSize.height)
.foregroundColor(.posSuccessColor)
.foregroundColor(.posSuccess)
Image(PointOfSaleAssets.successCheck.imageName)
.renderingMode(.template)
.foregroundColor(checkmarkColor)
Expand All @@ -85,7 +85,7 @@ struct PointOfSalePaymentSuccessView: View {
}

private var checkmarkColor: Color {
Color.primary
.posOnSuccess
}
}

Expand Down
7 changes: 1 addition & 6 deletions WooCommerce/Classes/POS/Presentation/CartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,7 @@ private struct ScrollOffSetPreferenceKey: PreferenceKey {
@available(iOS 17.0, *)
private extension CartView {
var backgroundColor: Color {
switch colorScheme {
case .dark:
return Color.posSecondaryBackground
default:
return posModel.cart.isEmpty ? Color.posTertiaryBackground : Color.posSecondaryBackground
}
.posSurfaceBright
}

var shouldPreventCartEditing: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct ChildItemList: View {
errorView(error: error)
}
}
.background(Color.posPrimaryBackground)
.background(Color.posSurface)
.toolbar(.hidden, for: .navigationBar)
.refreshable {
await Task {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct ItemListErrorCardView: View {
.padding(Constants.accessoryButtonPadding * (1 / scale))
}
.frame(maxWidth: .infinity, idealHeight: Constants.productCardSize * scale)
.background(Color.posSecondaryBackground)
.background(Constants.backgroundColor)
.posItemCardBorderStyles()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct ParentProductCardView: View {
Spacer()
}
.frame(maxWidth: .infinity, idealHeight: dimension)
.background(Color.posSecondaryBackground)
.background(Constants.backgroundColor)
.posItemCardBorderStyles()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import SwiftUICore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 👀 was this a SwiftUI import maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was from an auto-fix action in Xcode, but I agree SwiftUI import is more standard and avoid confusion in the future why it's SwiftUICore here. Updated in 5dd6465


enum PointOfSaleItemListCardConstants {
static let productCardSize: CGFloat = 112
Expand All @@ -11,4 +12,5 @@ enum PointOfSaleItemListCardConstants {
static let itemDetailFont: POSFontStyle = .posLargeDetailRegular
static let accessoryButtonMaxWidth: CGFloat = 136
static let accessoryButtonPadding: CGFloat = 16
static let backgroundColor: Color = .posSurfaceContainerLowest
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct SimpleProductCardView: View {
Spacer()
}
.frame(maxWidth: .infinity, idealHeight: dimension)
.background(Color.posSecondaryBackground)
.background(Constants.backgroundColor)
.posItemCardBorderStyles()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct VariationCardView: View {
Spacer()
}
.frame(maxWidth: .infinity, idealHeight: dimension)
.background(Color.posSecondaryBackground)
.background(Constants.backgroundColor)
.posItemCardBorderStyles()
}
}
Expand Down
8 changes: 4 additions & 4 deletions WooCommerce/Classes/POS/Presentation/ItemListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct ItemListView: View {
.navigationDestination(for: POSItem.self, destination: { item in
childListView(parentItem: item)
})
.background(Color.posPrimaryBackground)
.background(Color.posSurface)
}
.refreshable {
await Task {
Expand Down Expand Up @@ -85,7 +85,7 @@ private extension ItemListView {
.aspectRatio(contentMode: .fit)
.frame(width: Constants.bannerInfoIconSize, height: Constants.bannerInfoIconSize)
.padding(Constants.iconPadding)
.foregroundColor(Color(uiColor: .wooCommercePurple(.shade30)))
.foregroundColor(Color.posOnSurface)
.accessibilityHidden(true)
Spacer()
}
Expand All @@ -109,7 +109,7 @@ private extension ItemListView {
}, label: {
Image(systemName: "xmark")
.font(.posBodyRegular)
.foregroundColor(Color.posTertiaryText)
.foregroundColor(Color.posOnSurfaceVariantLowest)
.accessibilityLabel(Localization.dismissBannerAccessibilityLabel)
})
.padding(Constants.iconPadding)
Expand All @@ -118,7 +118,7 @@ private extension ItemListView {
}
.frame(maxWidth: .infinity)
.fixedSize(horizontal: false, vertical: true)
.background(Color.posSecondaryBackground)
.background(Color.posSurfaceBright)
.cornerRadius(Constants.bannerCornerRadius)
.shadow(color: Color.black.opacity(0.08), radius: 4, y: 2)
.accessibilityAddTraits(.isButton)
Expand Down
13 changes: 2 additions & 11 deletions WooCommerce/Classes/POS/Presentation/ItemRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ struct ItemRowView: View {
})
.accessibilityLabel(Localization.removeFromCartAccessibilityLabel)
.padding(.trailing, Constants.cardContentHorizontalPadding)
.foregroundColor(Color.posTertiaryText)
.foregroundColor(Color.posOnSurfaceVariantLowest)
}
}
.frame(maxWidth: .infinity, idealHeight: Constants.productCardSize * scale)
.background(backgroundColor)
.background(Color.posSurfaceContainerLowest)
.overlay {
RoundedRectangle(cornerRadius: Constants.productCardCornerRadius)
.stroke(Color.posCartItemOutline, lineWidth: cardOutlineWidth)
Expand Down Expand Up @@ -88,15 +88,6 @@ private extension ItemRowView {
return Constants.cardOutlineWidth
}
}

var backgroundColor: Color {
switch colorScheme {
case .dark:
return Color.posTertiaryBackground
default:
return Color.posSecondaryBackground
}
}
}

private extension ItemRowView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,14 @@ private extension POSFloatingControlView {
var backgroundColor: Color {
switch backgroundAppearance {
case .primary:
colorScheme == .light ? .posSecondaryBackground : .posTertiaryBackground
.posSurfaceContainerLow
case .secondary:
colorScheme == .light ? Color(.wooCommercePurple(.shade80)) : Color(.wooCommercePurple(.shade20))
}
}

var fontColor: Color {
switch backgroundAppearance {
case .primary:
.posPrimaryText
case .secondary:
Self.secondaryFontColor
}
.posOnSurface
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct POSReceiptEligibilityBanner: View {
.foregroundColor(Color.posPrimaryText)
}
.padding()
.background(Color.posPrimaryBackground)
.background(Color.posSurface)
.cornerRadius(Constants.cornerRadius)
.padding(.horizontal, Constants.bannerPadding)
.onTapGesture {
Expand Down
2 changes: 1 addition & 1 deletion WooCommerce/Classes/POS/Presentation/PaymentButtons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private extension PaymentsActionButtons {
.frame(minWidth: UIScreen.main.bounds.width / 2)
})
.padding(Constants.buttonPadding)
.foregroundColor(Color.posPrimaryTextInverted)
.foregroundColor(Color.posOnInverseSurface)
.background(Color.posPrimaryButtonBackground)
.cornerRadius(Constants.buttonCornerRadius)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct PointOfSaleCollectCashView: View {
if isLoading {
ProgressView()
.progressViewStyle(CircularProgressViewStyle())
.tint(Color.posPrimaryTextInverted)
.tint(Color.posOnInverseSurface)
} else {
Text(Localization.markPaymentCompletedButtonTitle)
.font(Constants.buttonFont)
Expand Down Expand Up @@ -185,12 +185,7 @@ private extension PointOfSaleCollectCashView {
}

private var backgroundColor: Color {
switch colorScheme {
case .dark:
return Color.posSecondaryBackground
default:
return .clear
}
.posSurface
}

private var navigationForegroundColor: Color {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct PointOfSaleDashboardView: View {
floatingSize.height + Constants.floatingControlVerticalOffset))
.environment(\.posBackgroundAppearance, posModel.paymentState != .card(.processingPayment) ? .primary : .secondary)
.animation(.easeInOut, value: posModel.itemsViewState.containerState == .loading)
.background(Color.posPrimaryBackground)
.background(Color.posSurface)
.navigationBarBackButtonHidden(true)
.posModal(item: $posModel.cardPresentPaymentOnboardingViewModel, onDismiss: {
posModel.cancelCardPaymentsOnboarding()
Expand Down Expand Up @@ -177,8 +177,13 @@ private extension PointOfSaleDashboardView {
#if DEBUG
@available(iOS 17.0, *)
#Preview {
let posModel = PointOfSaleAggregateModel(
itemsController: PointOfSalePreviewItemsController(),
cardPresentPaymentService: CardPresentPaymentPreviewService(),
orderController: PointOfSalePreviewOrderController())
return NavigationStack {
PointOfSaleDashboardView()
}
.environmentObject(posModel)
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct POSRootModalViewModifier: ViewModifier {
.accessibilityElement(children: modalManager.isPresented ? .ignore : .contain)

if modalManager.isPresented {
Color.posOverlayFill
Color.posSurfaceContainerLowest.opacity(0.6)
.edgesIgnoringSafeArea(.all)
.onTapGesture {
if modalManager.allowsInteractiveDismissal {
Expand All @@ -25,7 +25,7 @@ struct POSRootModalViewModifier: ViewModifier {
.animation(nil, value: modalManager.isPresented)
ZStack {
modalManager.getContent()
.background(Color.posPrimaryBackground)
.background(Color.posSurfaceBright)
.cornerRadius(24)
.shadow(color: Color.black.opacity(0.08), radius: 24, x: 0, y: 8)
.padding()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct POSSecondaryButtonStyle: ButtonStyle {
RoundedRectangle(cornerRadius: POSButtonStyleConstants.framedButtonCornerRadius)
.stroke(Color.posSecondaryButtonForeground,
lineWidth: POSButtonStyleConstants.secondaryButtonBorderStrokeWidth)
.background(Color.posPrimaryBackground))
.background(Color.posSurface))
.foregroundColor(.posSecondaryButtonForeground)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct POSSendReceiptView: View {
.dynamicTypeSize(...DynamicTypeSize.accessibility3)
.padding(conditionalPadding(Constants.buttonPadding))
.frame(maxWidth: .infinity)
.foregroundColor(Color.posPrimaryTextInverted)
.foregroundColor(Color.posOnInverseSurface)
.background(isEmailValid ? Color.posPrimaryButtonBackground : Color.posBackgroundButtonDisabled)
.cornerRadius(Constants.buttonCornerRadius)
.contentShape(Rectangle())
Expand Down
8 changes: 4 additions & 4 deletions WooCommerce/Classes/POS/Presentation/TotalsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ struct TotalsView: View {
private var backgroundColor: Color {
switch posModel.paymentState {
case .card(.cardPaymentSuccessful), .cash(.paymentSuccess):
.posSecondaryBackground
.posSurfaceContainerLowest
case .card(.processingPayment):
colorScheme == .light ? Color(.wooCommercePurple(.shade70)) : Color(.wooCommercePurple(.shade10))
.posPrimary
Copy link
Contributor

@staskus staskus Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Just checking. With this change processing... view appears in the same color in both light and dark mode. Is this intentional? The only thing that changes then is the floating menu.

Simulator Screenshot - iPad Pro 11-inch (M4) - 2025-02-07 at 10 14 35
Simulator Screenshot - iPad Pro 11-inch (M4) - 2025-02-07 at 10 14 32

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the color used in the design system: 1qcjzXitBHU7xPnpCOWnNM-fi-256_15446

The previous primary button (now called "filled" style in the design system) color is also the same in both light and dark mode now.

case .cash(.collectingCash):
colorScheme == .light ? .clear : Color.posSecondaryBackground
.posSurface
default:
.clear
}
Expand Down Expand Up @@ -357,7 +357,7 @@ private extension TotalsView {
static let subtotalAmountFont: POSFontStyle = .posBodyRegular
static let totalTitleFont: POSFontStyle = .posTitleRegular
static let totalAmountFont: POSFontStyle = .posTitleEmphasized
static let separatorColor: Color = Color(.systemGray3)
static let separatorColor: Color = Color.posOutlineVariant

static let shimmeringCornerRadius: CGFloat = 4
static let shimmeringWidth: CGFloat = 334
Expand Down
Loading