createPageView

@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.

This extension function acts as a factory method that maps each page type to its corresponding composable view and ViewModel. It handles navigation callbacks and state management for each page, ensuring proper transitions between different screens in the Reversi application.

The function uses type-safe ViewModel matching through createPageViewIfType to ensure that each page receives the correct ViewModel instance. Navigation is handled through the pagesState parameter, which maintains the current page and back navigation stack.

Receiver

The Page instance representing the current page to be displayed.

Return

A composable function with ReversiScope receiver that renders the appropriate page view. Returns an empty composable if the page type is Page.NONE or if the ViewModel type doesn't match.

Parameters

vm

The ViewModel instance associated with the current page. Must match the expected ViewModel type for the page, otherwise an empty composable is returned.

pagesState

A mutable state holding the current page state, including the current page and back navigation.

See also