A SwiftUI-based iOS demo application that simulates a shopping checkout process with item scanning functionality. Built using MVVM architecture and following modern iOS development practices.
- Item Scanning: Simulates camera-based item scanning with random food items
- Real-time Total: Automatically calculates total price of scanned items
- Checkout Process: Simple payment simulation with success confirmation
- Tab-based Navigation: Easy switching between scanning and checkout
- State Management: Proper state handling using MVVM architecture
- Unit Tests: Comprehensive test coverage for view models
- UI Tests: End-to-end testing of main user flows
- iOS 15.0+
- Xcode 14.0+
- Swift 5.5+
- Clone the repository:
git clone https://github.com/yourusername/CheckoutDemo.git- Open the project in Xcode:
cd CheckoutDemo
open CheckoutDemo.xcodeproj- Build and run the project in Xcode
The project follows the MVVM (Model-View-ViewModel) architecture:
FoodItem: Represents a scanned item with properties like name, price, and category
ScanViewModel: Handles scanning simulation and item generationCheckoutViewModel: Manages checkout process and payment handling
ScanView: UI for scanning itemsCheckoutView: Displays scanned items and handles paymentContentView: Main tab-based navigation
The project includes both unit tests and UI tests:
CheckoutViewModelTests: Tests for checkout functionalityScanViewModelTests: Tests for scanning functionality
CheckoutDemoUITests: End-to-end tests for main user flows
Run tests in Xcode using:
- ⌘U (Command-U) to run all tests
- Navigate to Test Navigator (⌘6) to run specific tests
- Launch the app
- In the Scan tab, tap the camera button to simulate scanning
- After scanning, items will appear in the Checkout tab
- Continue scanning or proceed to payment
- Tap "Pay Now" to complete the transaction
CheckoutDemo/
├── Models/
│ └── FoodItem.swift
├── ViewModels/
│ ├── ScanViewModel.swift
│ └── CheckoutViewModel.swift
├── Views/
│ ├── ContentView.swift
│ ├── ScanView.swift
│ └── CheckoutView.swift
└── Tests/
├── CheckoutDemoTests/
└── CheckoutDemoUITests/
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details
- SwiftUI for modern UI development
- XCTest for testing framework
- Apple's iOS development guidelines