refactor: read alert dialog state from simple commons

This commit is contained in:
FunkyMuse 2023-09-20 12:27:49 +02:00
parent 9f4979ce9d
commit 456bb7a0c8
3 changed files with 3 additions and 42 deletions

View File

@ -14,6 +14,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.window.DialogProperties
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.simplemobiletools.commons.compose.alert_dialog.AlertDialogState
import com.simplemobiletools.commons.compose.alert_dialog.rememberAlertDialogState
import com.simplemobiletools.commons.compose.extensions.enableEdgeToEdgeSimple
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
import com.simplemobiletools.commons.compose.theme.Shapes
@ -26,8 +28,6 @@ import com.simplemobiletools.thankyou.extensions.config
import com.simplemobiletools.thankyou.extensions.launchChangeAppLanguageIntent
import com.simplemobiletools.thankyou.extensions.startCustomizationActivity
import com.simplemobiletools.thankyou.screens.SettingsScreen
import com.simplemobiletools.thankyou.screens.alert_dialog.AlertDialogState
import com.simplemobiletools.thankyou.screens.alert_dialog.rememberAlertDialogState
import java.util.Locale
import kotlin.system.exitProcess

View File

@ -1,39 +0,0 @@
package com.simplemobiletools.thankyou.screens.alert_dialog
import androidx.compose.runtime.*
@Composable
fun rememberAlertDialogState(
isShownInitially: Boolean = false
) = remember { AlertDialogState(isShownInitially) }
@Stable
class AlertDialogState(isShownInitially: Boolean = false) {
var isShown by mutableStateOf(isShownInitially)
private set
fun show() {
isShown = true
}
fun hide() {
isShown = false
}
fun toggle() {
isShown = !isShown
}
fun changeValue(predicate: Boolean) {
isShown = predicate
}
@Composable
fun DialogMember(
content: @Composable () -> Unit
) {
if (isShown) {
content()
}
}
}

View File

@ -2,7 +2,7 @@
#jetbrains
kotlin = "1.9.10"
#Simple tools
simple-commons = "985e1da5f9"
simple-commons = "5598de895b"
#Compose
composeActivity = "1.8.0-beta01"
compose = "1.6.0-alpha05"