feat: add feature locked dialog

This commit is contained in:
FunkyMuse 2023-09-29 13:10:40 +02:00
parent cfbd2d5399
commit 5f2568364c
2 changed files with 24 additions and 5 deletions

View File

@ -11,11 +11,13 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.simplemobiletools.calculator.compose.SettingsScreen
import com.simplemobiletools.calculator.extensions.*
import com.simplemobiletools.commons.activities.CustomizationActivity
import com.simplemobiletools.commons.compose.alert_dialog.rememberAlertDialogState
import com.simplemobiletools.commons.compose.extensions.enableEdgeToEdgeSimple
import com.simplemobiletools.commons.compose.extensions.onEventValue
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
import com.simplemobiletools.commons.compose.theme.getAppIconIds
import com.simplemobiletools.commons.compose.theme.getAppLauncherName
import com.simplemobiletools.commons.dialogs.FeatureLockedAlertDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import java.util.Locale
@ -44,6 +46,13 @@ class SettingsActivity : AppCompatActivity() {
}
val isOrWasThankYouInstalled = onEventValue { context.isOrWasThankYouInstalled() }
val displayLanguage = remember { Locale.getDefault().displayLanguage }
val featureLockedDialogState = rememberAlertDialogState().apply {
DialogMember {
FeatureLockedAlertDialog(alertDialogState = this) {
}
}
}
SettingsScreen(
displayLanguage = displayLanguage,
goBack = ::finish,
@ -70,7 +79,8 @@ class SettingsActivity : AppCompatActivity() {
applicationContext.calculatorDB.deleteHistory()
}
},
lockedCustomizeColorText = getCustomizeColorsString()
lockedCustomizeColorText = getCustomizeColorsString(),
featureLockedDialogState = featureLockedDialogState
)
}
}

View File

@ -5,6 +5,8 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.compose.alert_dialog.AlertDialogState
import com.simplemobiletools.commons.compose.alert_dialog.rememberAlertDialogState
import com.simplemobiletools.commons.compose.extensions.MyDevices
import com.simplemobiletools.commons.compose.settings.SettingsCheckBoxComponent
import com.simplemobiletools.commons.compose.settings.SettingsGroup
@ -33,7 +35,8 @@ internal fun SettingsScreen(
useCommaAsDecimalMarkFlow: Boolean,
onUseCommaAsDecimalMarkFlow: (Boolean) -> Unit,
lockedCustomizeColorText: String,
displayLanguage: String
displayLanguage: String,
featureLockedDialogState : AlertDialogState
) {
SettingsScaffold(title = stringResource(id = R.string.settings), goBack = goBack) {
SettingsGroup(title = {
@ -41,8 +44,13 @@ internal fun SettingsScreen(
}) {
SettingsPreferenceComponent(
label = lockedCustomizeColorText,
doOnPreferenceClick = customizeColors,
isPreferenceEnabled = isOrWasThankYouInstalled,
doOnPreferenceClick = {
if (isOrWasThankYouInstalled) {
customizeColors()
} else {
featureLockedDialogState.show()
}
},
preferenceLabelColor = MaterialTheme.colorScheme.onSurface
)
SettingsPreferenceComponent(
@ -115,7 +123,8 @@ private fun SettingsScreenPreview() {
useCommaAsDecimalMarkFlow = false,
onUseCommaAsDecimalMarkFlow = {},
lockedCustomizeColorText = "Customize Colors",
displayLanguage = "English"
displayLanguage = "English",
featureLockedDialogState = rememberAlertDialogState()
)
}
}