Progress bar added - #7
Conversation
Pull Request Review: Progress Bar AddedSummaryThis PR adds visual progress bars to the middle divider and implements a danger state (red color) when a player is 30+ points behind, indicating they're at risk of being skunked. It also fixes the skunk animation orientation to display correctly for the skunked player. ✅ Strengths
🐛 Potential Issues1. Hardcoded Magic Number (Cribbage Scorer/ContentView.swift:116)let dangerColor = Color(red: 0xEE / 255.0, green: 0x00 / 255.0, blue: 0x00 / 255.0)The hex color extension Color {
static let dangerRed = Color(red: 0xEE / 255.0, green: 0x00 / 255.0, blue: 0x00 / 255.0)
}2. Duplicated Danger Logic (Cribbage Scorer/ContentView.swift:119-125)The danger calculation is duplicated in two computed properties. Consider extracting to a helper method in // In GameViewModel
func isDangerOfSkunk(player: Int) -> Bool {
let playerScore = player == 1 ? player1MainScore : player2MainScore
let opponentScore = player == 1 ? player2MainScore : player1MainScore
return opponentScore - playerScore >= skunkDifference
}3. Fallback Value Risk (Cribbage Scorer/ContentView.swift:205)SkunkView(skunkedPlayer: viewModel.skunkedPlayer ?? 2)The fallback to player 2 is arbitrary. This should never be
4. Progress Bar Calculation Duplication (Cribbage Scorer/ContentView.swift:151-172)The progress bar geometry calculation is duplicated. Consider extracting to a reusable view: struct ProgressBar: View {
let score: Int
let maxScore: Int
let backgroundColor: Color
let foregroundColor: Color
var body: some View {
GeometryReader { geometry in
HStack(spacing: 0) {
Rectangle()
.fill(foregroundColor)
.frame(width: geometry.size.width * CGFloat(min(score, maxScore)) / CGFloat(maxScore))
Spacer(minLength: 0)
}
}
.background(backgroundColor)
}
}⚡ Performance Considerations
🔒 Security ConcernsNo security issues identified. This is UI-only code with no:
🧪 Test CoverageNote: No tests are included in this PR. Consider adding:
📋 RecommendationsHigh Priority:
Medium Priority: Low Priority: 📊 Version BumpThe version bump from 2.0.0 to 2.1.0 is appropriate for a minor feature addition. This follows semantic versioning correctly. Overall, this is a solid PR that adds a nice UX improvement to the game! The main suggestions are around reducing code duplication and improving robustness with the optional handling. Great work! 🎉 |
No description provided.