Store show logs preference in config
This commit is contained in:
+6
-5
@@ -42,8 +42,8 @@ class AppViewModel(
|
||||
/**
|
||||
* Determines if the Debug Logs tab should be visible in the navigation bar.
|
||||
*/
|
||||
private val _showLogs = MutableStateFlow(false)
|
||||
val showLogs: StateFlow<Boolean> = _showLogs
|
||||
private val _showLogs = mutableStateOf(storage.load<Boolean>(ReferKeys.SHOW_LOGS) ?: false)
|
||||
val showLogs: State<Boolean> = _showLogs
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
@@ -77,9 +77,10 @@ class AppViewModel(
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables the visibility of diagnostic logs.
|
||||
* Toggles between visible and hidden logs and persists the choice.
|
||||
*/
|
||||
fun setShowLogs(enabled: Boolean) {
|
||||
_showLogs.value = enabled
|
||||
fun toggleShowLogs(isVisible: Boolean) {
|
||||
_showLogs.value = isVisible
|
||||
storage.save(ReferKeys.SHOW_LOGS, isVisible)
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -18,4 +18,5 @@ object ReferKeys {
|
||||
|
||||
/** User preference for automatic reconnection to bonded devices (Boolean). */
|
||||
const val DEVICE_AUTO_CONNECT = "device_auto_connect"
|
||||
const val SHOW_LOGS = "show_logs"
|
||||
}
|
||||
|
||||
+1
-2
@@ -12,7 +12,6 @@ import androidx.compose.material3.NavigationBarItemDefaults
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -53,7 +52,7 @@ fun MainScreen(
|
||||
isLoggedIn: Boolean,
|
||||
viewModel: AppViewModel = koinInject()
|
||||
) {
|
||||
val showLogs by viewModel.showLogs.collectAsState()
|
||||
val showLogs by viewModel.showLogs
|
||||
val destinations = buildList {
|
||||
add(HomeDestination)
|
||||
add(ScannerDestination)
|
||||
|
||||
+2
-2
@@ -69,13 +69,13 @@ fun SettingScreen(
|
||||
val serverUrl by viewModel.serverUrl.collectAsState()
|
||||
val token by viewModel.refreshToken.collectAsState()
|
||||
val autoConnect by viewModel.autoConnect.collectAsState()
|
||||
val showLogs by appViewModel.showLogs.collectAsState()
|
||||
val showLogs by appViewModel.showLogs
|
||||
|
||||
SettingContent(
|
||||
isDarkTheme = isDarkTheme,
|
||||
onThemeToggle = onThemeToggle,
|
||||
isShowLogs = showLogs,
|
||||
onToggleLogs = { appViewModel.setShowLogs(it) },
|
||||
onToggleLogs = { appViewModel.toggleShowLogs(it) },
|
||||
serverUrl = serverUrl,
|
||||
onServerUrlChange = { viewModel.updateServerUrl(it) },
|
||||
token = token,
|
||||
|
||||
Reference in New Issue
Block a user