Skip to content

Commit

Permalink
feat(view): add view manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Hoefer committed Dec 17, 2020
1 parent e777d09 commit 0a4c656
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 7 deletions.
18 changes: 18 additions & 0 deletions src/main/kotlin/com/github/xetra11/ck3workbench/app/ViewManager.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.github.xetra11.ck3workbench.app

import androidx.compose.foundation.layout.BoxScope
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import com.github.xetra11.ck3workbench.module.character.view.CharacterModuleView
import kotlin.reflect.KFunction0

object ViewManager {
val currentView = mutableStateOf(View.CHARACTER_VIEW)

enum class View {
CHARACTER_VIEW,
OTHER_VIEW
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.imageResource
import androidx.compose.ui.unit.dp
import com.github.xetra11.ck3workbench.app.NotificationsService
import com.github.xetra11.ck3workbench.app.ViewManager

@Composable
fun WorkbenchPanel() {
Expand All @@ -27,7 +28,9 @@ fun WorkbenchPanel() {
Column(Modifier.fillMaxHeight(0.8F), verticalArrangement = Arrangement.SpaceBetween) {
Box(
boxModifier.clickable(
onClick = { NotificationsService.notify("CLICK") }
onClick = {
ViewManager.currentView.value = ViewManager.View.CHARACTER_VIEW
}
),
contentAlignment = Alignment.Companion.Center,
) {
Expand All @@ -36,7 +39,9 @@ fun WorkbenchPanel() {
}
Box(boxModifier
.clickable(
onClick = { NotificationsService.notify("CLICK 2") }
onClick = {
ViewManager.currentView.value = ViewManager.View.OTHER_VIEW
}
)
) {
Image(squareImage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@ fun CharacterModuleView() {
CharacterList(characterState)
}
}

private fun LOG(): Logger {
return LoggerFactory.getLogger("CharacterImportWindow")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.github.xetra11.ck3workbench.module.character.view

import androidx.compose.foundation.layout.Row
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import com.github.xetra11.ck3workbench.app.StateManager
import com.github.xetra11.ck3workbench.module.character.ui.CharacterList
import org.slf4j.Logger
import org.slf4j.LoggerFactory

@Composable
fun DynastieModuleView() {
Row {
Text("Dyntasty stuff")
}
}
8 changes: 7 additions & 1 deletion src/main/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Menu
import androidx.compose.ui.window.MenuBar
import androidx.compose.ui.window.MenuItem
import com.github.xetra11.ck3workbench.app.ViewManager
import com.github.xetra11.ck3workbench.app.ui.MainUiComponents
import com.github.xetra11.ck3workbench.module.character.importer.CharacterScriptImporter
import com.github.xetra11.ck3workbench.module.character.ui.NotificationPanel
import com.github.xetra11.ck3workbench.module.character.view.CharacterModuleView
import com.github.xetra11.ck3workbench.module.character.view.DynastieModuleView
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.awt.FileDialog
Expand Down Expand Up @@ -62,7 +64,11 @@ fun main() = invokeLater {
) {
Column(Modifier.fillMaxSize()) {
MainUiComponents.MainLayoutRow {
CharacterModuleView()
//CharacterModuleView()
when(ViewManager.currentView.value) {
ViewManager.View.CHARACTER_VIEW -> CharacterModuleView()
ViewManager.View.OTHER_VIEW -> DynastieModuleView()
}
}
MainUiComponents.NotificationPanelRow {
NotificationPanel()
Expand Down

0 comments on commit 0a4c656

Please sign in to comment.