Package-level declarations

Overview

Contains all UI pages/screens of the application, their view models, and page navigation logic.

Key Components

  • Page — Sealed interface defining all possible pages in the app

  • ViewModel — Base interface for all page view models

  • createPageView — Factory function to create page composables

  • createViewModel — Factory function to create view models for pages

Sub-packages

  • menu — Main menu page with New Game, Load Game, Settings, Exit options

  • newGamePage — Game creation interface with player configuration

  • lobby — Game lobby for joining/managing multiplayer games

  • game — Active game page with board, controls, and game state display

  • winnerPage — End game screen showing winner and final scores

  • aboutPage — About/credits page

  • settingsPage — Application settings and configuration

Responsibilities

  • Defining the structure of each application screen

  • Managing page-specific state through ViewModels

  • Handling navigation between pages

  • Providing reusable page creation patterns

Types

Link copied to clipboard
enum Page(val level: Int) : Enum<Page>

Represents the different pages in the application along with their hierarchy levels.

Link copied to clipboard
data class ScreenState(val error: ReversiException? = null, val isLoading: Boolean = false)

Represents the state of a screen including error and loading states.

Link copied to clipboard
interface UiState

Base class for UI state with screen state management. Each subclass must implement updateScreenState to define how to copy itself with a new ScreenState.

Link copied to clipboard
abstract class ViewModel<T : UiState>

Abstract base class for view models managing UI state. Each view model holds a mutable UI state and provides error handling capabilities.

Functions

Link copied to clipboard
@Composable
fun Page.createPageView(vm: ViewModel<out UiState>, gameSession: MutableState<GameSession>, pagesState: MutableState<PagesState>): @Composable ReversiScope.() -> Unit

Creates and returns the appropriate composable page view based on the current Page type.

Link copied to clipboard
private inline fun <T : ViewModel<out UiState>> createPageViewIfType(vm: ViewModel<out UiState>, noinline content: @Composable ReversiScope.() -> Unit): @Composable ReversiScope.() -> Unit

Creates a composable page view if the provided ViewModel is of the expected type T.

Link copied to clipboard
fun Page.createViewModel(scope: CoroutineScope, appState: AppStateImpl, gameSession: MutableState<GameSession>, audioThemeState: MutableState<AudioThemeState>, pagesState: MutableState<PagesState>): ViewModel<out UiState>?

Creates and returns the appropriate ViewModel instance based on the current Page type.