Store show logs preference in config
This commit is contained in:
@@ -89,7 +89,7 @@ android {
|
|||||||
applicationId = "com.digitoolsolutions.app.torquevaultkmp"
|
applicationId = "com.digitoolsolutions.app.torquevaultkmp"
|
||||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||||
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
||||||
versionCode = 3
|
versionCode = 4
|
||||||
versionName = "1.0.2"
|
versionName = "1.0.2"
|
||||||
}
|
}
|
||||||
packaging {
|
packaging {
|
||||||
|
|||||||
+6
-5
@@ -42,8 +42,8 @@ class AppViewModel(
|
|||||||
/**
|
/**
|
||||||
* Determines if the Debug Logs tab should be visible in the navigation bar.
|
* Determines if the Debug Logs tab should be visible in the navigation bar.
|
||||||
*/
|
*/
|
||||||
private val _showLogs = MutableStateFlow(false)
|
private val _showLogs = mutableStateOf(storage.load<Boolean>(ReferKeys.SHOW_LOGS) ?: false)
|
||||||
val showLogs: StateFlow<Boolean> = _showLogs
|
val showLogs: State<Boolean> = _showLogs
|
||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
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) {
|
fun toggleShowLogs(isVisible: Boolean) {
|
||||||
_showLogs.value = enabled
|
_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). */
|
/** User preference for automatic reconnection to bonded devices (Boolean). */
|
||||||
const val DEVICE_AUTO_CONNECT = "device_auto_connect"
|
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.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@@ -53,7 +52,7 @@ fun MainScreen(
|
|||||||
isLoggedIn: Boolean,
|
isLoggedIn: Boolean,
|
||||||
viewModel: AppViewModel = koinInject()
|
viewModel: AppViewModel = koinInject()
|
||||||
) {
|
) {
|
||||||
val showLogs by viewModel.showLogs.collectAsState()
|
val showLogs by viewModel.showLogs
|
||||||
val destinations = buildList {
|
val destinations = buildList {
|
||||||
add(HomeDestination)
|
add(HomeDestination)
|
||||||
add(ScannerDestination)
|
add(ScannerDestination)
|
||||||
|
|||||||
+2
-2
@@ -69,13 +69,13 @@ fun SettingScreen(
|
|||||||
val serverUrl by viewModel.serverUrl.collectAsState()
|
val serverUrl by viewModel.serverUrl.collectAsState()
|
||||||
val token by viewModel.refreshToken.collectAsState()
|
val token by viewModel.refreshToken.collectAsState()
|
||||||
val autoConnect by viewModel.autoConnect.collectAsState()
|
val autoConnect by viewModel.autoConnect.collectAsState()
|
||||||
val showLogs by appViewModel.showLogs.collectAsState()
|
val showLogs by appViewModel.showLogs
|
||||||
|
|
||||||
SettingContent(
|
SettingContent(
|
||||||
isDarkTheme = isDarkTheme,
|
isDarkTheme = isDarkTheme,
|
||||||
onThemeToggle = onThemeToggle,
|
onThemeToggle = onThemeToggle,
|
||||||
isShowLogs = showLogs,
|
isShowLogs = showLogs,
|
||||||
onToggleLogs = { appViewModel.setShowLogs(it) },
|
onToggleLogs = { appViewModel.toggleShowLogs(it) },
|
||||||
serverUrl = serverUrl,
|
serverUrl = serverUrl,
|
||||||
onServerUrlChange = { viewModel.updateServerUrl(it) },
|
onServerUrlChange = { viewModel.updateServerUrl(it) },
|
||||||
token = token,
|
token = token,
|
||||||
|
|||||||
Reference in New Issue
Block a user