diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/App.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/App.kt index 650c8d0..c455b4d 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/App.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/App.kt @@ -7,80 +7,44 @@ import androidx.compose.material.SnackbarHostState import androidx.compose.material.Surface import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.Stable -import androidx.compose.runtime.State import androidx.compose.runtime.compositionLocalOf -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.compose.ui.window.ApplicationScope import androidx.compose.ui.window.Window import androidx.compose.ui.window.rememberWindowState -import com.pixelized.desktop.lwa.navigation.MainNavHost -import com.pixelized.desktop.lwa.navigation.destination.CharacterSheetDestination -import com.pixelized.desktop.lwa.navigation.destination.CharacterSheetEditDestination +import com.pixelized.desktop.lwa.navigation.screen.MainNavHost +import com.pixelized.desktop.lwa.navigation.screen.destination.CharacterSheetDestination +import com.pixelized.desktop.lwa.navigation.screen.destination.CharacterSheetEditDestination +import com.pixelized.desktop.lwa.navigation.window.WindowController +import com.pixelized.desktop.lwa.navigation.window.WindowsNavHost +import com.pixelized.desktop.lwa.navigation.window.destination.CharacterSheetCreateWindow +import com.pixelized.desktop.lwa.navigation.window.destination.CharacterSheetWindow import com.pixelized.desktop.lwa.screen.characterSheet.CharacterSheetMainNavHost -import com.pixelized.desktop.lwa.screen.main.CharacterUio import com.pixelized.desktop.lwa.theme.LwaTheme -import lwacharactersheet.composeapp.generated.resources.Res -import lwacharactersheet.composeapp.generated.resources.character_sheet_edit__title -import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview -val LocalSnackHost = compositionLocalOf { - error("Local Snack Controller is not yet ready") -} val LocalWindowController = compositionLocalOf { error("Local Window Controller is not yet ready") } -@Stable -data class WindowController( - private val onCloseRequest: () -> Unit -) { - val sheet: State> get() = _sheet - - val create: State> get() = _create - - fun showCreateCharacterSheet() { - _create.value = _create.value.toMutableSet().apply { add(size) } - } - - fun hideCreateCharacterSheet(id: Int) { - _create.value = _create.value.toMutableSet().apply { remove(id) } - } - - fun showCharacterSheet(sheet: CharacterUio) { - _sheet.value = _sheet.value.toMutableSet().apply { add(sheet) } - } - - fun hideCharacterSheet(sheet: CharacterUio) { - _sheet.value = _sheet.value.toMutableSet().apply { remove(sheet) } - } - - fun closeWindows() = onCloseRequest() - - companion object { - private val _sheet = mutableStateOf>(emptySet()) - private val _create = mutableStateOf>(emptySet()) - } +val LocalSnackHost = compositionLocalOf { + error("Local Snack Controller is not yet ready") } @Composable @Preview fun ApplicationScope.App() { - val controller = remember { WindowController(onCloseRequest = ::exitApplication) } val snackHostState = remember { SnackbarHostState() } + val windowController = remember { WindowController() } CompositionLocalProvider( - LocalWindowController provides controller, LocalSnackHost provides snackHostState, + LocalWindowController provides windowController, ) { Window( - onCloseRequest = { - controller.closeWindows() - }, + onCloseRequest = ::exitApplication, state = rememberWindowState( width = 320.dp + 64.dp, height = 900.dp, @@ -101,13 +65,8 @@ fun ApplicationScope.App() { MainNavHost() } ) - HandleCharacterSheet( - sheets = controller.sheet, - onCloseRequest = { controller.hideCharacterSheet(sheet = it) } - ) - HandleCharacterSheetCreation( - sheets = controller.create, - onCloseRequest = { controller.hideCreateCharacterSheet(id = it) }, + WindowsHandler( + windowController = windowController, ) } } @@ -116,64 +75,26 @@ fun ApplicationScope.App() { } @Composable -fun HandleCharacterSheet( - sheets: State>, - onCloseRequest: (id: CharacterUio) -> Unit, +private fun WindowsHandler( + windowController: WindowController ) { - sheets.value.forEach { sheet -> - val controller = remember { - WindowController( - onCloseRequest = { onCloseRequest(sheet) } - ) - } - CompositionLocalProvider( - LocalWindowController provides controller, - ) { - Window( - onCloseRequest = { onCloseRequest(sheet) }, - state = rememberWindowState( - width = 400.dp + 64.dp, - height = 900.dp, - ), - title = sheet.name, - ) { - CharacterSheetMainNavHost( - startDestination = CharacterSheetDestination.navigationRoute(id = sheet.id) + WindowsNavHost( + controller = windowController, + content = { window -> + when (window) { + is CharacterSheetWindow -> CharacterSheetMainNavHost( + startDestination = CharacterSheetDestination.navigationRoute( + id = window.characterId, + ), ) - } - } - } -} -@Composable -fun HandleCharacterSheetCreation( - sheets: State>, - onCloseRequest: (id: Int) -> Unit, -) { - sheets.value.forEach { sheet -> - val controller = remember { - WindowController( - onCloseRequest = { onCloseRequest(sheet) } - ) - } - CompositionLocalProvider( - LocalWindowController provides controller, - ) { - Window( - onCloseRequest = { controller.closeWindows() }, - state = rememberWindowState( - width = 400.dp + 64.dp, - height = 900.dp, - ), - title = stringResource(Res.string.character_sheet_edit__title), - ) { - CharacterSheetMainNavHost( + is CharacterSheetCreateWindow -> CharacterSheetMainNavHost( startDestination = CharacterSheetEditDestination.navigationRoute( id = null, enableBack = false, - ) + ), ) } } - } + ) } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/MainNavHost.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/MainNavHost.kt similarity index 68% rename from composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/MainNavHost.kt rename to composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/MainNavHost.kt index 6a9e995..90a8c28 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/MainNavHost.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/MainNavHost.kt @@ -1,4 +1,4 @@ -package com.pixelized.desktop.lwa.navigation +package com.pixelized.desktop.lwa.navigation.screen import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider @@ -6,11 +6,10 @@ import androidx.compose.runtime.compositionLocalOf import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.rememberNavController -import com.pixelized.desktop.lwa.navigation.destination.MainDestination -import com.pixelized.desktop.lwa.navigation.destination.composableMainPage -import com.pixelized.desktop.lwa.navigation.destination.composableNetworkPage -import com.pixelized.desktop.lwa.navigation.destination.composableRollHistory -import com.pixelized.desktop.lwa.screen.main.MainPageViewModel +import com.pixelized.desktop.lwa.navigation.screen.destination.MainDestination +import com.pixelized.desktop.lwa.navigation.screen.destination.composableMainPage +import com.pixelized.desktop.lwa.navigation.screen.destination.composableNetworkPage +import com.pixelized.desktop.lwa.navigation.screen.destination.composableRollHistory val LocalScreenController = compositionLocalOf { error("MainNavHost controller is not yet ready") diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/CharacterSheetDestination.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/CharacterSheetDestination.kt similarity index 95% rename from composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/CharacterSheetDestination.kt rename to composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/CharacterSheetDestination.kt index 6e35273..682f94a 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/CharacterSheetDestination.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/CharacterSheetDestination.kt @@ -1,4 +1,4 @@ -package com.pixelized.desktop.lwa.navigation.destination +package com.pixelized.desktop.lwa.navigation.screen.destination import androidx.lifecycle.SavedStateHandle import androidx.navigation.NavGraphBuilder diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/CharacterSheetEditDestination.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/CharacterSheetEditDestination.kt similarity index 96% rename from composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/CharacterSheetEditDestination.kt rename to composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/CharacterSheetEditDestination.kt index 2429a1f..4d122ac 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/CharacterSheetEditDestination.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/CharacterSheetEditDestination.kt @@ -1,4 +1,4 @@ -package com.pixelized.desktop.lwa.navigation.destination +package com.pixelized.desktop.lwa.navigation.screen.destination import androidx.lifecycle.SavedStateHandle import androidx.navigation.NavGraphBuilder diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/MainDestination.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/MainDestination.kt similarity index 90% rename from composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/MainDestination.kt rename to composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/MainDestination.kt index f65d578..4ca662b 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/MainDestination.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/MainDestination.kt @@ -1,4 +1,4 @@ -package com.pixelized.desktop.lwa.navigation.destination +package com.pixelized.desktop.lwa.navigation.screen.destination import androidx.navigation.NavGraphBuilder import androidx.navigation.NavHostController diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/NetworkDestination.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/NetworkDestination.kt similarity index 90% rename from composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/NetworkDestination.kt rename to composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/NetworkDestination.kt index edd3b41..e0395f0 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/NetworkDestination.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/NetworkDestination.kt @@ -1,4 +1,4 @@ -package com.pixelized.desktop.lwa.navigation.destination +package com.pixelized.desktop.lwa.navigation.screen.destination import androidx.navigation.NavGraphBuilder import androidx.navigation.NavHostController diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/RollHistoryDestination.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/RollHistoryDestination.kt similarity index 90% rename from composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/RollHistoryDestination.kt rename to composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/RollHistoryDestination.kt index c3373ac..d7d795b 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/destination/RollHistoryDestination.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/screen/destination/RollHistoryDestination.kt @@ -1,4 +1,4 @@ -package com.pixelized.desktop.lwa.navigation.destination +package com.pixelized.desktop.lwa.navigation.screen.destination import androidx.navigation.NavGraphBuilder import androidx.navigation.NavHostController diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/WindowNavHost.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/WindowNavHost.kt new file mode 100644 index 0000000..e709679 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/WindowNavHost.kt @@ -0,0 +1,56 @@ +package com.pixelized.desktop.lwa.navigation.window + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.Stable +import androidx.compose.runtime.State +import androidx.compose.runtime.compositionLocalOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.rememberWindowState +import com.pixelized.desktop.lwa.navigation.window.destination.Window + +val LocalWindow = compositionLocalOf { + error("Local Window is not yet ready") +} + +@Stable +class WindowController { + private val _windows = mutableStateOf>(emptySet()) + val windows: State> get() = _windows + + fun showWindow(window: Window) { + _windows.value = _windows.value.toMutableSet().apply { add(window) } + } + + fun hideWindow(window: Window) { + hideWindow(id = window.id) + } + + fun hideWindow(id: String) { + _windows.value = _windows.value.toMutableSet().apply { removeIf { it.id == id } } + } +} + +@Composable +fun WindowsNavHost( + controller: WindowController, + content: @Composable (Window) -> Unit, +) { + controller.windows.value.forEach { window -> + CompositionLocalProvider( + LocalWindow provides window, + ) { + Window( + onCloseRequest = { controller.hideWindow(id = window.id) }, + state = rememberWindowState( + width = window.width, + height = window.height, + ), + title = window.title, + ) { + content.invoke(window) + } + } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/destination/CharacterSheetCreateWindow.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/destination/CharacterSheetCreateWindow.kt new file mode 100644 index 0000000..ff5e966 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/destination/CharacterSheetCreateWindow.kt @@ -0,0 +1,6 @@ +package com.pixelized.desktop.lwa.navigation.window.destination + +import androidx.compose.runtime.Stable + +@Stable +class CharacterSheetCreateWindow : Window(title = "") \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/destination/CharacterSheetWindow.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/destination/CharacterSheetWindow.kt new file mode 100644 index 0000000..ee7009b --- /dev/null +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/destination/CharacterSheetWindow.kt @@ -0,0 +1,12 @@ +package com.pixelized.desktop.lwa.navigation.window.destination + +import androidx.compose.runtime.Stable + +@Stable +class CharacterSheetWindow( + val characterId: String, + characterName: String, +) : Window( + title = characterName, +) + diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/destination/Window.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/destination/Window.kt new file mode 100644 index 0000000..c3412bb --- /dev/null +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/navigation/window/destination/Window.kt @@ -0,0 +1,14 @@ +package com.pixelized.desktop.lwa.navigation.window.destination + +import androidx.compose.runtime.Stable +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import java.util.UUID + +@Stable +sealed class Window( + val id: String = UUID.randomUUID().toString(), + val title: String, + val width: Dp = 400.dp + 64.dp, + val height: Dp = 900.dp, +) \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/CharacterSheetNavHost.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/CharacterSheetNavHost.kt index 5257758..c366ed4 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/CharacterSheetNavHost.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/CharacterSheetNavHost.kt @@ -8,9 +8,9 @@ import androidx.compose.ui.Modifier import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.rememberNavController -import com.pixelized.desktop.lwa.navigation.LocalScreenController -import com.pixelized.desktop.lwa.navigation.destination.composableCharacterSheetEditPage -import com.pixelized.desktop.lwa.navigation.destination.composableCharacterSheetPage +import com.pixelized.desktop.lwa.navigation.screen.LocalScreenController +import com.pixelized.desktop.lwa.navigation.screen.destination.composableCharacterSheetEditPage +import com.pixelized.desktop.lwa.navigation.screen.destination.composableCharacterSheetPage @Composable fun CharacterSheetMainNavHost( diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/detail/CharacterSheetPage.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/detail/CharacterSheetPage.kt index bf151ab..888cc62 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/detail/CharacterSheetPage.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/detail/CharacterSheetPage.kt @@ -51,8 +51,9 @@ import com.pixelized.desktop.lwa.LocalWindowController import com.pixelized.desktop.lwa.composable.blur.BlurContent import com.pixelized.desktop.lwa.composable.blur.BlurContentController import com.pixelized.desktop.lwa.composable.decoratedBox.DecoratedBox -import com.pixelized.desktop.lwa.navigation.LocalScreenController -import com.pixelized.desktop.lwa.navigation.destination.navigateToCharacterSheetEdit +import com.pixelized.desktop.lwa.navigation.screen.LocalScreenController +import com.pixelized.desktop.lwa.navigation.screen.destination.navigateToCharacterSheetEdit +import com.pixelized.desktop.lwa.navigation.window.LocalWindow import com.pixelized.desktop.lwa.screen.characterSheet.detail.dialog.CharacterSheetDeleteConfirmationDialog import com.pixelized.desktop.lwa.screen.characterSheet.detail.dialog.CharacterSheetStatDialog import com.pixelized.desktop.lwa.screen.roll.RollPage @@ -107,7 +108,8 @@ fun CharacterSheetPage( }, rollViewModel: RollViewModel = viewModel { RollViewModel() }, ) { - val window = LocalWindowController.current + val windowController = LocalWindowController.current + val window = LocalWindow.current val screen = LocalScreenController.current val scope = rememberCoroutineScope() val blurController = remember { BlurContentController() } @@ -189,7 +191,7 @@ fun CharacterSheetPage( scope.launch { viewModel.deleteCharacter(id = it.id) if (screen.popBackStack().not()) { - window.closeWindows() + windowController.hideWindow(window = window) } } }, diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/detail/CharacterSheetViewModel.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/detail/CharacterSheetViewModel.kt index 8134d14..53609c9 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/detail/CharacterSheetViewModel.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/detail/CharacterSheetViewModel.kt @@ -8,7 +8,7 @@ import androidx.compose.ui.text.TextRange import androidx.compose.ui.text.input.TextFieldValue import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel -import com.pixelized.desktop.lwa.navigation.destination.CharacterSheetDestination +import com.pixelized.desktop.lwa.navigation.screen.destination.CharacterSheetDestination import com.pixelized.desktop.lwa.repository.characterSheet.CharacterSheetRepository import com.pixelized.desktop.lwa.screen.characterSheet.detail.dialog.CharacterSheetDeleteConfirmationDialogUio import com.pixelized.desktop.lwa.screen.characterSheet.detail.dialog.StatChangeDialogUio diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/edit/CharacterSheetEditPage.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/edit/CharacterSheetEditPage.kt index 2f66917..3bc43f2 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/edit/CharacterSheetEditPage.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/edit/CharacterSheetEditPage.kt @@ -32,7 +32,8 @@ import androidx.lifecycle.createSavedStateHandle import androidx.lifecycle.viewmodel.compose.viewModel import com.pixelized.desktop.lwa.LocalWindowController import com.pixelized.desktop.lwa.composable.decoratedBox.DecoratedBox -import com.pixelized.desktop.lwa.navigation.LocalScreenController +import com.pixelized.desktop.lwa.navigation.screen.LocalScreenController +import com.pixelized.desktop.lwa.navigation.window.LocalWindow import com.pixelized.desktop.lwa.screen.characterSheet.edit.composable.FieldUio import com.pixelized.desktop.lwa.screen.characterSheet.edit.composable.Form import kotlinx.coroutines.launch @@ -77,7 +78,8 @@ fun CharacterSheetEditPage( ) }, ) { - val window = LocalWindowController.current + val windowController = LocalWindowController.current + val window = LocalWindow.current val screen = LocalScreenController.current val scope = rememberCoroutineScope() @@ -99,7 +101,7 @@ fun CharacterSheetEditPage( scope.launch { viewModel.save() if (screen.popBackStack().not()) { - window.closeWindows() + windowController.hideWindow(window = window) } } }, diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/edit/CharacterSheetEditViewModel.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/edit/CharacterSheetEditViewModel.kt index ff01c8f..a327271 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/edit/CharacterSheetEditViewModel.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/characterSheet/edit/CharacterSheetEditViewModel.kt @@ -4,7 +4,7 @@ import androidx.compose.runtime.State import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel -import com.pixelized.desktop.lwa.navigation.destination.CharacterSheetEditDestination +import com.pixelized.desktop.lwa.navigation.screen.destination.CharacterSheetEditDestination import com.pixelized.desktop.lwa.repository.characterSheet.CharacterSheetRepository import com.pixelized.desktop.lwa.screen.characterSheet.edit.CharacterSheetEditPageUio.SkillGroup import com.pixelized.desktop.lwa.screen.characterSheet.edit.composable.FieldUio diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/main/MainPage.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/main/MainPage.kt index 6a5f456..9c817c7 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/main/MainPage.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/main/MainPage.kt @@ -12,28 +12,21 @@ import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.material.TextButton import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Stable import androidx.compose.runtime.State -import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.Window -import androidx.compose.ui.window.rememberWindowState import androidx.lifecycle.viewmodel.compose.viewModel import com.pixelized.desktop.lwa.LocalWindowController -import com.pixelized.desktop.lwa.WindowController -import com.pixelized.desktop.lwa.navigation.LocalScreenController -import com.pixelized.desktop.lwa.navigation.destination.CharacterSheetDestination -import com.pixelized.desktop.lwa.navigation.destination.CharacterSheetEditDestination -import com.pixelized.desktop.lwa.navigation.destination.navigateToNetwork -import com.pixelized.desktop.lwa.navigation.destination.navigateToRollHistory -import com.pixelized.desktop.lwa.screen.characterSheet.CharacterSheetMainNavHost +import com.pixelized.desktop.lwa.navigation.screen.LocalScreenController +import com.pixelized.desktop.lwa.navigation.screen.destination.navigateToNetwork +import com.pixelized.desktop.lwa.navigation.screen.destination.navigateToRollHistory +import com.pixelized.desktop.lwa.navigation.window.destination.CharacterSheetCreateWindow +import com.pixelized.desktop.lwa.navigation.window.destination.CharacterSheetWindow import lwacharactersheet.composeapp.generated.resources.Res -import lwacharactersheet.composeapp.generated.resources.character_sheet_edit__title import lwacharactersheet.composeapp.generated.resources.main_page__create_action import lwacharactersheet.composeapp.generated.resources.main_page__network_action import lwacharactersheet.composeapp.generated.resources.main_page__roll_history_action @@ -65,10 +58,15 @@ fun MainPage( MainPageContent( characters = viewModel.characters, onCharacter = { - window.showCharacterSheet(sheet = it) + window.showWindow( + window = CharacterSheetWindow( + characterId = it.id, + characterName = it.name, + ) + ) }, onCreateCharacter = { - window.showCreateCharacterSheet() + window.showWindow(window = CharacterSheetCreateWindow()) }, onRollHistory = { screen.navigateToRollHistory() diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/network/NetworkPage.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/network/NetworkPage.kt index 8a1f644..55a04b1 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/network/NetworkPage.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/network/NetworkPage.kt @@ -29,7 +29,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel -import com.pixelized.desktop.lwa.navigation.LocalScreenController +import com.pixelized.desktop.lwa.navigation.screen.LocalScreenController import lwacharactersheet.composeapp.generated.resources.Res import lwacharactersheet.composeapp.generated.resources.network__host__label import lwacharactersheet.composeapp.generated.resources.network__player_name__label diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/rollhistory/RollHistoryPage.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/rollhistory/RollHistoryPage.kt index e20677f..38e6e25 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/rollhistory/RollHistoryPage.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/screen/rollhistory/RollHistoryPage.kt @@ -21,7 +21,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel -import com.pixelized.desktop.lwa.navigation.LocalScreenController +import com.pixelized.desktop.lwa.navigation.screen.LocalScreenController import lwacharactersheet.composeapp.generated.resources.Res import lwacharactersheet.composeapp.generated.resources.roll_history__title import org.jetbrains.compose.resources.stringResource diff --git a/composeApp/src/desktopMain/kotlin/com/pixelized/desktop/lwa/main.kt b/composeApp/src/desktopMain/kotlin/com/pixelized/desktop/lwa/main.kt index 65bd261..c3c5267 100644 --- a/composeApp/src/desktopMain/kotlin/com/pixelized/desktop/lwa/main.kt +++ b/composeApp/src/desktopMain/kotlin/com/pixelized/desktop/lwa/main.kt @@ -4,9 +4,6 @@ import androidx.compose.ui.window.application import com.pixelized.desktop.lwa.business.SkillStepUseCase fun main() { - - SkillStepUseCase.exportTest() - application { App() }