Skip to Content
FeaturesBooksDesktop implementation

Books Module - Desktop Implementation

Overview

The Books module has been fully implemented for desktop using Koin for dependency injection and a desktop-optimized UI.

Implementation Details

Architecture

Desktop-specific components:

  • BooksRepositoryDesktop - In-memory implementation (can be replaced with SQLite/file storage)
  • BooksViewModel - Desktop ViewModel using Koin
  • BooksScreen - Desktop-optimized UI with grid layout
  • BooksScreenDestination - Navigation destination composable

Key Files

Data Layer:

  • composeApp/src/desktopMain/.../data/BooksRepositoryDesktop.kt - Desktop repository implementation

ViewModels:

  • composeApp/src/desktopMain/.../viewmodels/BooksViewModel.kt - Desktop ViewModel

UI:

  • composeApp/src/desktopMain/.../screens/BooksScreen.kt - Main books screen
  • composeApp/src/desktopMain/.../composables/AddBookDialog.kt - Add book dialog
  • composeApp/src/desktopMain/.../composables/BookDetailDialog.kt - Book detail dialog with stats

Navigation:

  • composeApp/src/desktopMain/.../navigation/BooksScreenDestination.kt - Navigation destination
  • AppNavHost.kt - Added Books route

DI:

  • Modules.kt - Koin module providing Books dependencies

Features

Desktop-optimized UI:

  • Grid layout with adaptive columns
  • Large clickable cards
  • Search bar with instant filtering
  • Status filter chips
  • Modal dialogs for add/edit operations

Full functionality:

  • Add books (title + optional author)
  • Filter by status (All, Want, Reading, Finished, Dropped)
  • Search by title/author
  • View book details with stats
  • Log reading minutes
  • Change book status
  • View reading statistics

Storage

Current Implementation:

  • Uses in-memory storage (ConcurrentHashMap)
  • Data is lost on app restart

Future Improvements:

  • Replace with SQLite for persistence
  • Or use SQLDelight for multiplatform database support
  • Or implement file-based JSON storage

Access the Books screen:

navController.navigate(Screen.Books.route)

Route: "books"

Usage

  1. Add a Book:

    • Click “Add Book” button
    • Enter title (required)
    • Optionally enter author
    • Click “Add”
  2. View Book Details:

    • Click on any book card
    • View stats and actions in modal dialog
  3. Log Reading Time:

    • Open book detail
    • Click “Log Minutes”
    • Enter minutes and date
    • Click “Log”
  4. Change Status:

    • From book detail dialog:
      • “Start Reading” → READING
      • “Finish Book” → FINISHED
      • “Drop Book” → DROPPED
  5. Filter & Search:

    • Use status chips to filter
    • Use search bar for instant filtering

Dependencies

  • Koin - Dependency injection
  • Compose Desktop - UI framework
  • Books Domain - Use cases and models

Notes

  • Storage: Currently in-memory only. For production, implement persistent storage.
  • Data Sharing: Desktop and mobile use separate storage (no sync in current implementation).
  • UI Patterns: Follows desktop design patterns with modals, grids, and larger touch targets.

Future Enhancements

  1. Persistent Storage:

    • Implement SQLite or SQLDelight
    • Or file-based JSON storage
  2. Data Sync:

    • Add server-side API
    • Sync between desktop and mobile
  3. Enhanced Stats:

    • Charts and graphs
    • Reading trends
    • Goal tracking