refactor: read alert dialog state from simple commons
This commit is contained in:
parent
9f4979ce9d
commit
456bb7a0c8
|
@ -14,6 +14,8 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
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.extensions.enableEdgeToEdgeSimple
|
||||||
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
||||||
import com.simplemobiletools.commons.compose.theme.Shapes
|
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.launchChangeAppLanguageIntent
|
||||||
import com.simplemobiletools.thankyou.extensions.startCustomizationActivity
|
import com.simplemobiletools.thankyou.extensions.startCustomizationActivity
|
||||||
import com.simplemobiletools.thankyou.screens.SettingsScreen
|
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 java.util.Locale
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
|
|
@ -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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,7 @@
|
||||||
#jetbrains
|
#jetbrains
|
||||||
kotlin = "1.9.10"
|
kotlin = "1.9.10"
|
||||||
#Simple tools
|
#Simple tools
|
||||||
simple-commons = "985e1da5f9"
|
simple-commons = "5598de895b"
|
||||||
#Compose
|
#Compose
|
||||||
composeActivity = "1.8.0-beta01"
|
composeActivity = "1.8.0-beta01"
|
||||||
compose = "1.6.0-alpha05"
|
compose = "1.6.0-alpha05"
|
||||||
|
|
Loading…
Reference in New Issue