Skip to content

Commit

Permalink
[Woo POS] [Design System] Apply straightforward color updates (#15068)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclync authored Feb 10, 2025
2 parents 138f010 + 8d038e7 commit 01b89b7
Show file tree
Hide file tree
Showing 27 changed files with 57 additions and 139 deletions.
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()
.environment(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 @@ -152,12 +152,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)
.task {
guard state.items.isEmpty else {
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 SwiftUI

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)
}
.accessibilityElement(children: .contain)
.posModal(isPresented: $showSimpleProductsModal) {
Expand Down Expand Up @@ -81,7 +81,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 @@ -105,7 +105,7 @@ private extension ItemListView {
}, label: {
Image(systemName: "xmark")
.font(.posBodyRegular)
.foregroundColor(Color.posTertiaryText)
.foregroundColor(Color.posOnSurfaceVariantLowest)
.accessibilityLabel(Localization.dismissBannerAccessibilityLabel)
})
.padding(Constants.iconPadding)
Expand All @@ -114,7 +114,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 @@ -67,19 +67,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 @@ -59,7 +59,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 @@ -55,7 +55,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 @@ -178,8 +178,14 @@ private extension PointOfSaleDashboardView {
#if DEBUG
@available(iOS 17.0, *)
#Preview {
let posModel = PointOfSaleAggregateModel(
itemsController: PointOfSalePreviewItemsController(),
cardPresentPaymentService: CardPresentPaymentPreviewService(),
orderController: PointOfSalePreviewOrderController())
return NavigationStack {
PointOfSaleDashboardView()
.environment(posModel)
.environmentObject(POSModalManager())
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ struct POSRootModalViewModifier: ViewModifier {
func body(content: Content) -> some View {
ZStack {
content
.blur(radius: modalManager.isPresented ? 3 : 0)
.blur(radius: modalManager.isPresented ? 8 : 0)
.disabled(modalManager.isPresented)
.accessibilityElement(children: modalManager.isPresented ? .ignore : .contain)

if modalManager.isPresented {
Color.posOverlayFill
Color.posSurfaceContainerLowest.opacity(0.8)
.edgesIgnoringSafeArea(.all)
.onTapGesture {
if modalManager.allowsInteractiveDismissal {
Expand All @@ -25,9 +25,12 @@ 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)
.shadow(color: Color.posShadow.opacity(0.02), radius: 43, x: 0, y: 50) // 0px 50px 43px 0px #00000005
.shadow(color: Color.posShadow.opacity(0.04), radius: 36, x: 0, y: 30) // 0px 30px 36px 0px #0000000A
.shadow(color: Color.posShadow.opacity(0.07), radius: 27, x: 0, y: 15) // 0px 15px 27px 0px #00000012
.shadow(color: Color.posShadow.opacity(0.08), radius: 15, x: 0, y: 5) // 0px 5px 15px 0px #00000014
.padding()
}
.zIndex(1)
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
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

0 comments on commit 01b89b7

Please sign in to comment.