Skip to content

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.

License

Notifications You must be signed in to change notification settings

severeduck/checkout_demo

Repository files navigation

CheckoutDemo

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.

Features

  • 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

Requirements

  • iOS 15.0+
  • Xcode 14.0+
  • Swift 5.5+

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/CheckoutDemo.git
  1. Open the project in Xcode:
cd CheckoutDemo
open CheckoutDemo.xcodeproj
  1. Build and run the project in Xcode

Architecture

The project follows the MVVM (Model-View-ViewModel) architecture:

Models

  • FoodItem: Represents a scanned item with properties like name, price, and category

ViewModels

  • ScanViewModel: Handles scanning simulation and item generation
  • CheckoutViewModel: Manages checkout process and payment handling

Views

  • ScanView: UI for scanning items
  • CheckoutView: Displays scanned items and handles payment
  • ContentView: Main tab-based navigation

Testing

The project includes both unit tests and UI tests:

Unit Tests

  • CheckoutViewModelTests: Tests for checkout functionality
  • ScanViewModelTests: Tests for scanning functionality

UI Tests

  • 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

Usage

  1. Launch the app
  2. In the Scan tab, tap the camera button to simulate scanning
  3. After scanning, items will appear in the Checkout tab
  4. Continue scanning or proceed to payment
  5. Tap "Pay Now" to complete the transaction

Project Structure

CheckoutDemo/
├── Models/
│   └── FoodItem.swift
├── ViewModels/
│   ├── ScanViewModel.swift
│   └── CheckoutViewModel.swift
├── Views/
│   ├── ContentView.swift
│   ├── ScanView.swift
│   └── CheckoutView.swift
└── Tests/
    ├── CheckoutDemoTests/
    └── CheckoutDemoUITests/

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

  • SwiftUI for modern UI development
  • XCTest for testing framework
  • Apple's iOS development guidelines

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages