Skip to content

mp-c0de/ChipStackVisualizer-iPad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Chip Stack Visualizer - iPad

Overview

An innovative iPad application that provides real-time visual representation of casino chip stacks with intuitive counting controls. Designed specifically for casino floor operations, this app displays eight different chip denominations as vertical stacks that grow and shrink dynamically as chips are added or removed. Features include long-press rapid counting, percentage capacity indicators, and a visually appealing interface optimized for iPad's larger screen with horizontal scrolling support.

Features

  • 8 Chip Denominations: Track Purple (120), Blue (90), Green (60), Red (180), Orange (150), Pink (30), Gray (75), and Cyan (110) chips
  • Visual Stack Representation: Real-time vertical stacking animation showing chip accumulation
  • Long-Press Rapid Count: Hold increment/decrement buttons for fast continuous counting (100 chips/second)
  • Percentage Display: Shows stack capacity as percentage of maximum (200 chips per frame)
  • Horizontal Scrolling: Smooth horizontal scroll view for easy access to all chip types
  • Color-Coded Design: Each chip type has unique color matching casino standards
  • Tap Counting: Single tap for precise one-chip adjustments
  • Custom Background: Decorative background image for enhanced visual appeal
  • Shadow Effects: 3D card shadows for depth and professional appearance
  • Disabled State Handling: Buttons intelligently disable at min (0) and max (200) limits

Technical Stack

  • Language: Swift 5.9+
  • Framework: SwiftUI
  • Platform: iPadOS 15.0+
  • Architecture: Component-based view composition
  • UI Components: ScrollView, VStack, HStack, ForEach
  • Gestures: LongPressGesture, DragGesture, simultaneousGesture
  • Animation: Implicit animations for stack growth

Key Learning Concepts

Advanced Gesture Recognition

  • LongPressGesture for hold-to-increment functionality
  • DragGesture for release detection
  • simultaneousGesture modifier for gesture composition
  • Minimum duration configuration for long press
  • Gesture state management and cleanup

Timer-Based Rapid Counting

  • Timer.scheduledTimer for repeating actions
  • High-frequency timers (0.01s intervals) for smooth counting
  • Timer invalidation and memory management
  • Start/stop timer control methods
  • Preventing timer overlap with cleanup

Dynamic Visual Feedback

  • ForEach with range-based iteration for stack rendering
  • Rectangle shapes for chip visualization
  • Dynamic height calculation based on count
  • Color opacity for visual hierarchy
  • Frame clipping for contained stacks

State Management & UI Updates

  • @State for local component state
  • Real-time UI updates from state changes
  • Computed property formatting for percentages
  • Conditional rendering based on count
  • Button state management (enabled/disabled)

ScrollView & Layout

  • Horizontal ScrollView configuration
  • HStack alignment for bottom-aligned cards
  • Spacing and padding optimization for iPad
  • Background image integration
  • Frame sizing for consistent card dimensions

Project Structure

ChipStackVisualizer-iPad/
├── ChipCount/
│   ├── ChipCountApp.swift                     # Main app entry point
│   ├── ContentView.swift                      # Main container with background
│   ├── ChipCardView.swift                     # Individual chip stack card
│   └── Assets.xcassets/
│       ├── background.imageset               # Background image
│       └── AppIcon.appiconset                # App icon

Code Highlights

Long-Press Rapid Counting

Sophisticated gesture handling for fast chip counting:

Button {
    increment()
} label: {
    Image(systemName: "plus.circle.fill")
        .font(.largeTitle)
}
.foregroundColor(.green)
.disabled(chipCount >= maxChipsInFrame)
.simultaneousGesture(
    LongPressGesture(minimumDuration: 0.3)
        .onEnded { _ in startIncrementing() }
)
.simultaneousGesture(
    DragGesture(minimumDistance: 0)
        .onEnded { _ in stopIncrementing() }
)

func startIncrementing() {
    stopIncrementing() // Prevent multiple timers
    incrementTimer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) { _ in
        increment()
    }
}

func stopIncrementing() {
    incrementTimer?.invalidate()
    incrementTimer = nil
}

Dynamic Chip Stack Visualization

Real-time visual representation of chip counts:

VStack(spacing: 0) {
    Spacer()
    if chipCount > 0 {
        ForEach(0..<chipCount, id: \.self) { _ in
            ChipVisual(color: chipColor)
        }
    }
}
.frame(width: chipStackWidth, height: chipStackHeight)
.background(chipColor.opacity(0.2))
.cornerRadius(8)
.clipped() // Prevent overflow beyond container

struct ChipVisual: View {
    var color: Color
    var body: some View {
        Rectangle()
            .fill(color)
            .frame(height: 0.44) // Thin chip representation
    }
}

Percentage Capacity Display

Clear visual feedback on stack capacity:

Text("\(chipCount)")
    .font(.title2)
    .fontWeight(.medium)

Text("\(String(format: "%.0f%% full", (Double(chipCount) / Double(maxChipsInFrame)) * 100))")

Horizontal Scrolling Container

iPad-optimized layout with smooth scrolling:

ScrollView(.horizontal, showsIndicators: false) {
    HStack(alignment: .bottom, spacing: 16) {
        ForEach(0..<chipConfigs.count, id: \.self) { index in
            let config = chipConfigs[index]
            ChipCardView(chipColor: config.0, chipCount: config.1)
        }
    }
    .padding(.horizontal)
}

Skills Demonstrated

  • Advanced Gestures: Complex gesture composition with long press and drag detection
  • Timer Programming: High-frequency timer management for smooth rapid counting
  • Visual Design: Creative use of shapes and colors for intuitive data visualization
  • iPad Development: Horizontal scrolling layout optimized for tablet form factor
  • State Management: Local component state with real-time UI synchronization
  • Accessibility: Disabled states and clear visual feedback for user actions
  • Animation: Implicit animations for dynamic stack growth
  • Component Architecture: Reusable card components with configurable properties
  • Memory Management: Proper timer cleanup to prevent leaks

Use Cases

Casino Floor Chip Counting

Dealers and pit bosses quickly visualize and count chip stacks at tables with intuitive touch controls.

Inventory Management

Track chip inventory across multiple denominations with visual percentage indicators showing capacity.

Training Tool

New casino staff learn chip denominations and counting procedures with visual feedback.

Quick Verification

Floor managers perform rapid chip audits by visually comparing actual stacks to app representation.

Future Enhancements

  • Total Value Calculation: Display monetary total based on chip denominations and values
  • Save/Load Sessions: Persist chip counts for later reference
  • Multiple Table Support: Track chips across different tables simultaneously
  • Export Functionality: Generate reports of chip distributions
  • Custom Denominations: User-configurable chip types and colors
  • Sound Effects: Audio feedback for tap and long-press actions
  • Undo/Redo: Revert counting mistakes
  • Comparison Mode: Side-by-side comparison of multiple chip sets
  • Dark Mode: Alternative color scheme for different lighting conditions
  • History Timeline: Track chip count changes over time
  • Barcode Integration: Scan chip racks for automatic count import
  • Multi-User Sync: Share chip counts across multiple iPads in real-time

Author: Martynas Prascevicius Contact: mpcode@icloud.com Project Type: Business Application - Casino Operations (iPad) Frameworks: SwiftUI, Foundation (Timer)

About

Casino chip stack visualization tool for iPad - SwiftUI, iPadOS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages