Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ComputerSolitaire/Views/Cards/CardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum CardStyle: String, CaseIterable, Identifiable {
case simple
case pixel

static let defaultValue: CardStyle = .classic
static let defaultValue: CardStyle = .simple
Comment thread
austin-smith marked this conversation as resolved.

var id: String { rawValue }

Expand Down
58 changes: 9 additions & 49 deletions ComputerSolitaire/Views/Cards/Styles/SimpleCardViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,8 @@ enum SimpleCardStyle {
static let info = CardStyleInfo(title: "Simple", subtitle: "Clean")
}

/// Royal artwork anchored to the bottom-right corner of the face, replacing
/// the center suit glyph. Cards without art keep the plain glyph face.
private enum SimpleCardArt {
static func imageName(for card: Card) -> String? {
switch (card.rank, card.suit) {
case (.queen, .hearts): "Simple/QueenOfHearts"
case (.queen, .clubs): "Simple/QueenOfClubs"
case (.queen, .spades): "Simple/QueenOfSpades"
case (.queen, .diamonds): "Simple/QueenOfDiamonds"
case (.jack, .hearts): "Simple/JackOfHearts"
case (.jack, .clubs): "Simple/JackOfClubs"
case (.jack, .spades): "Simple/JackOfSpades"
case (.jack, .diamonds): "Simple/JackOfDiamonds"
case (.king, .hearts): "Simple/KingOfHearts"
case (.king, .clubs): "Simple/KingOfClubs"
case (.king, .spades): "Simple/KingOfSpades"
case (.king, .diamonds): "Simple/KingOfDiamonds"
default: nil
}
}
}

private enum SimplePalette {
static let face = Color.white
static let face = Color(red: 1.0, green: 0.989, blue: 0.958)
static let red = Color(red: 0.80, green: 0.12, blue: 0.16)
static let black = Color(red: 0.10, green: 0.10, blue: 0.12)
static let backTrim = Color.white.opacity(0.7)
Expand Down Expand Up @@ -94,32 +72,14 @@ struct SimpleCardFrontView: View {
.padding(cardSize.width * 0.08)
.frame(width: cardSize.width, height: cardSize.height, alignment: Alignment.top)

if let artName = SimpleCardArt.imageName(for: card) {
// Royal figure planted in the bottom-right corner, dress and
// trailing arm trimmed by the card bounds; sized to stay
// clear of the top marks. Jack artwork carries extra headroom
// in its canvas, so it gets a small extra nudge into the
// corner to line up with the kings and queens.
let isJack = card.rank == .jack
Image(artName)
.resizable()
.scaledToFit()
.frame(width: cardSize.width * 0.88)
.offset(x: cardSize.width * (isJack ? 0.19 : 0.17),
y: cardSize.width * (isJack ? 0.36 : 0.32))
.frame(width: cardSize.width, height: cardSize.height, alignment: Alignment.bottomTrailing)
.clipShape(RoundedRectangle(cornerRadius: chrome.cornerRadius, style: .continuous))
.accessibilityHidden(true)
} else {
// Optically centered in the region below the top marks, not
// the full card, so the face doesn't read bottom-heavy.
Image(systemName: card.suit.symbolName)
.font(.system(size: cardSize.width * 0.56, weight: .regular))
.foregroundStyle(inkColor)
.offset(y: cardSize.width * 0.14)
.frame(width: cardSize.width, height: cardSize.height, alignment: Alignment.center)
.accessibilityHidden(true)
}
// Optically centered in the region below the top marks, not
// the full card, so the face doesn't read bottom-heavy.
Image(systemName: card.suit.symbolName)
.font(.system(size: cardSize.width * 0.56, weight: .regular))
.foregroundStyle(inkColor)
.offset(y: cardSize.width * 0.14)
.frame(width: cardSize.width, height: cardSize.height, alignment: Alignment.center)
.accessibilityHidden(true)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions ComputerSolitaireTests/Shared/CardStyleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import XCTest

@MainActor
final class CardStyleTests: XCTestCase {
func testDefaultStyleIsClassic() {
XCTAssertEqual(CardStyle.defaultValue, .classic)
XCTAssertEqual(CardStyle.defaultValue.rawValue, "classic")
func testDefaultStyleIsSimple() {
XCTAssertEqual(CardStyle.defaultValue, .simple)
XCTAssertEqual(CardStyle.defaultValue.rawValue, "simple")
}

func testOnlyCurrentRawValuesResolveToStyles() {
Expand Down