Skip to content

Commit

Permalink
feat(settings): add settings menu and checkbox for autosave
Browse files Browse the repository at this point in the history
relates to #35
  • Loading branch information
Patrick Hoefer committed Jan 6, 2021
1 parent c4dd2a5 commit da2f6c7
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.github.xetra11.ck3workbench.app

import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import com.github.xetra11.ck3workbench.module.character.CK3Character

/**
* Holds all the app wide settings state
*/
object SettingsHolder {
val characters: SnapshotStateList<CK3Character> = mutableStateListOf()
var autosave by mutableStateOf(false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ object ViewManager {
CHARACTER_VIEW,
CHARACTER_CREATE_VIEW,
ENTRY_VIEW,
DYNASTY_VIEW
DYNASTY_VIEW,
SETTINGS_VIEW
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.github.xetra11.ck3workbench.module.character.view
import androidx.compose.runtime.Composable
import com.github.xetra11.ck3workbench.app.ViewManager
import com.github.xetra11.ck3workbench.app.view.EntryView
import com.github.xetra11.ck3workbench.app.view.SettingsView

@Composable
fun CurrentMainView() {
Expand All @@ -11,5 +12,6 @@ fun CurrentMainView() {
ViewManager.View.DYNASTY_VIEW -> DynastieModuleView()
ViewManager.View.CHARACTER_VIEW -> CharacterModuleView()
ViewManager.View.CHARACTER_CREATE_VIEW -> CharacterFactoryView()
ViewManager.View.SETTINGS_VIEW -> SettingsView()
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
package com.github.xetra11.ck3workbench.app.view

class SettingsView {
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Checkbox
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.github.xetra11.ck3workbench.app.SettingsHolder

@Composable
fun SettingsView() {
Column(
Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(Modifier.padding(top = 100.dp))
Row(
Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly
) {
Text("Activate Autosave")
Checkbox(
checked = SettingsHolder.autosave,
onCheckedChange = { SettingsHolder.autosave = it }
)
}
}
}
9 changes: 9 additions & 0 deletions src/main/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ private fun AppMenu(): MenuBar {
// DialogManager.openDialog(DialogManager.Dialog.CHARACTER_EXPORT)
}
)
),
Menu(
"Settings",
MenuItem(
"Application Settings",
onClick = {
ViewManager.changeView(ViewManager.View.SETTINGS_VIEW)
}
)
)
)
}
Expand Down

0 comments on commit da2f6c7

Please sign in to comment.