Complete native rewrite of the web-based SoliCards game as a SwiftUI multiplatform app targeting iOS 17+, iPadOS 17+, and macOS 14+. Three solitaire variants (Klondike, Spider, FreeCell) with full game rules, drag & drop, smart zoom layout, 6 themes, 4 difficulty levels, SwiftData persistence, VoiceOver accessibility, and 57 unit tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
60 lines
2 KiB
Swift
60 lines
2 KiB
Swift
import SwiftUI
|
|
|
|
struct MainMenuView: View {
|
|
@Binding var selectedVariant: GameVariant
|
|
let onStart: () -> Void
|
|
|
|
var body: some View {
|
|
VStack(spacing: 32) {
|
|
Text("SoliCards")
|
|
.font(.largeTitle.bold())
|
|
|
|
VStack(spacing: 16) {
|
|
ForEach(GameVariant.allCases) { variant in
|
|
Button {
|
|
selectedVariant = variant
|
|
onStart()
|
|
} label: {
|
|
HStack {
|
|
Image(systemName: iconName(for: variant))
|
|
.font(.title2)
|
|
.frame(width: 30)
|
|
VStack(alignment: .leading) {
|
|
Text(variant.displayName)
|
|
.font(.headline)
|
|
Text(subtitle(for: variant))
|
|
.font(.caption)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
Spacer()
|
|
Image(systemName: "chevron.right")
|
|
.foregroundStyle(.tertiary)
|
|
}
|
|
.padding()
|
|
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: 12))
|
|
}
|
|
.buttonStyle(.plain)
|
|
}
|
|
}
|
|
.frame(maxWidth: 400)
|
|
}
|
|
.padding()
|
|
}
|
|
|
|
private func iconName(for variant: GameVariant) -> String {
|
|
switch variant {
|
|
case .klondike: "suit.spade.fill"
|
|
case .spider: "suit.club.fill"
|
|
case .freeCell: "suit.diamond.fill"
|
|
}
|
|
}
|
|
|
|
private func subtitle(for variant: GameVariant) -> String {
|
|
switch variant {
|
|
case .klondike: "Classic solitaire with stock and waste"
|
|
case .spider: "Build same-suit sequences with two decks"
|
|
case .freeCell: "Strategic play with four free cells"
|
|
}
|
|
}
|
|
}
|