feat: add feature locked dialog
This commit is contained in:
parent
cfbd2d5399
commit
5f2568364c
|
@ -11,11 +11,13 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.simplemobiletools.calculator.compose.SettingsScreen
|
import com.simplemobiletools.calculator.compose.SettingsScreen
|
||||||
import com.simplemobiletools.calculator.extensions.*
|
import com.simplemobiletools.calculator.extensions.*
|
||||||
import com.simplemobiletools.commons.activities.CustomizationActivity
|
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.enableEdgeToEdgeSimple
|
||||||
import com.simplemobiletools.commons.compose.extensions.onEventValue
|
import com.simplemobiletools.commons.compose.extensions.onEventValue
|
||||||
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
||||||
import com.simplemobiletools.commons.compose.theme.getAppIconIds
|
import com.simplemobiletools.commons.compose.theme.getAppIconIds
|
||||||
import com.simplemobiletools.commons.compose.theme.getAppLauncherName
|
import com.simplemobiletools.commons.compose.theme.getAppLauncherName
|
||||||
|
import com.simplemobiletools.commons.dialogs.FeatureLockedAlertDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
@ -44,6 +46,13 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
val isOrWasThankYouInstalled = onEventValue { context.isOrWasThankYouInstalled() }
|
val isOrWasThankYouInstalled = onEventValue { context.isOrWasThankYouInstalled() }
|
||||||
val displayLanguage = remember { Locale.getDefault().displayLanguage }
|
val displayLanguage = remember { Locale.getDefault().displayLanguage }
|
||||||
|
val featureLockedDialogState = rememberAlertDialogState().apply {
|
||||||
|
DialogMember {
|
||||||
|
FeatureLockedAlertDialog(alertDialogState = this) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
SettingsScreen(
|
SettingsScreen(
|
||||||
displayLanguage = displayLanguage,
|
displayLanguage = displayLanguage,
|
||||||
goBack = ::finish,
|
goBack = ::finish,
|
||||||
|
@ -70,7 +79,8 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
applicationContext.calculatorDB.deleteHistory()
|
applicationContext.calculatorDB.deleteHistory()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lockedCustomizeColorText = getCustomizeColorsString()
|
lockedCustomizeColorText = getCustomizeColorsString(),
|
||||||
|
featureLockedDialogState = featureLockedDialogState
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import com.simplemobiletools.commons.R
|
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.extensions.MyDevices
|
||||||
import com.simplemobiletools.commons.compose.settings.SettingsCheckBoxComponent
|
import com.simplemobiletools.commons.compose.settings.SettingsCheckBoxComponent
|
||||||
import com.simplemobiletools.commons.compose.settings.SettingsGroup
|
import com.simplemobiletools.commons.compose.settings.SettingsGroup
|
||||||
|
@ -33,7 +35,8 @@ internal fun SettingsScreen(
|
||||||
useCommaAsDecimalMarkFlow: Boolean,
|
useCommaAsDecimalMarkFlow: Boolean,
|
||||||
onUseCommaAsDecimalMarkFlow: (Boolean) -> Unit,
|
onUseCommaAsDecimalMarkFlow: (Boolean) -> Unit,
|
||||||
lockedCustomizeColorText: String,
|
lockedCustomizeColorText: String,
|
||||||
displayLanguage: String
|
displayLanguage: String,
|
||||||
|
featureLockedDialogState : AlertDialogState
|
||||||
) {
|
) {
|
||||||
SettingsScaffold(title = stringResource(id = R.string.settings), goBack = goBack) {
|
SettingsScaffold(title = stringResource(id = R.string.settings), goBack = goBack) {
|
||||||
SettingsGroup(title = {
|
SettingsGroup(title = {
|
||||||
|
@ -41,8 +44,13 @@ internal fun SettingsScreen(
|
||||||
}) {
|
}) {
|
||||||
SettingsPreferenceComponent(
|
SettingsPreferenceComponent(
|
||||||
label = lockedCustomizeColorText,
|
label = lockedCustomizeColorText,
|
||||||
doOnPreferenceClick = customizeColors,
|
doOnPreferenceClick = {
|
||||||
isPreferenceEnabled = isOrWasThankYouInstalled,
|
if (isOrWasThankYouInstalled) {
|
||||||
|
customizeColors()
|
||||||
|
} else {
|
||||||
|
featureLockedDialogState.show()
|
||||||
|
}
|
||||||
|
},
|
||||||
preferenceLabelColor = MaterialTheme.colorScheme.onSurface
|
preferenceLabelColor = MaterialTheme.colorScheme.onSurface
|
||||||
)
|
)
|
||||||
SettingsPreferenceComponent(
|
SettingsPreferenceComponent(
|
||||||
|
@ -115,7 +123,8 @@ private fun SettingsScreenPreview() {
|
||||||
useCommaAsDecimalMarkFlow = false,
|
useCommaAsDecimalMarkFlow = false,
|
||||||
onUseCommaAsDecimalMarkFlow = {},
|
onUseCommaAsDecimalMarkFlow = {},
|
||||||
lockedCustomizeColorText = "Customize Colors",
|
lockedCustomizeColorText = "Customize Colors",
|
||||||
displayLanguage = "English"
|
displayLanguage = "English",
|
||||||
|
featureLockedDialogState = rememberAlertDialogState()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue