[MWA-5265] Meta Demo: Theming via xml testen
{addAdd Compose theming option to MetaPl}ugin
This commit is contained in:
parent
e847e303ba
commit
c1c0f80b19
@ -11,7 +11,6 @@ import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.result.ActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@ -133,7 +132,12 @@ internal class MainActivity : ComponentActivity
|
||||
selectProductPlugins
|
||||
)
|
||||
MetaPluginVerifyTask(metaPlugin)
|
||||
.setOnPostExecuteCallback(metaPluginVerifyCallback(metaPlugin))
|
||||
.setOnPostExecuteCallback(
|
||||
metaPluginVerifyCallback(
|
||||
metaPlugin = metaPlugin,
|
||||
themingChoice = themingChoice
|
||||
)
|
||||
)
|
||||
.execute(actionId)
|
||||
}
|
||||
|
||||
@ -175,15 +179,31 @@ internal class MainActivity : ComponentActivity
|
||||
)
|
||||
}
|
||||
|
||||
private fun metaPluginVerifyCallback(metaPlugin: WebIdMetaPlugin): (AsyncTaskResultGeneric<VerifyActionIdResult?, EApiResult>) -> Unit {
|
||||
private fun metaPluginVerifyCallback(metaPlugin: WebIdMetaPlugin,
|
||||
themingChoice: ThemingChoice
|
||||
): (AsyncTaskResultGeneric<VerifyActionIdResult?, EApiResult>) -> Unit {
|
||||
|
||||
return { result ->
|
||||
if (result.errorResult == EApiResult.SUCCESS) {
|
||||
try {
|
||||
when (themingChoice) {
|
||||
ThemingChoice.XML -> {
|
||||
metaPlugin.startPlugin(
|
||||
this,
|
||||
activityResultLauncher,
|
||||
true,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
ThemingChoice.COMPOSE -> {
|
||||
metaPlugin.startPlugin(
|
||||
this,
|
||||
activityResultLauncher,
|
||||
null,
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (e: WebIdMobileAppSdkException) {
|
||||
e.printStackTrace()
|
||||
writeLog(e.message.toString())
|
||||
|
||||
@ -30,12 +30,11 @@ import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import de.webidsolutions.metaplugindemo.R
|
||||
|
||||
enum class ThemingChoice {
|
||||
CODE,
|
||||
XML
|
||||
enum class ThemingChoice(val useXml: Boolean) {
|
||||
COMPOSE(false),
|
||||
XML(true)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@ -53,7 +52,7 @@ fun MetaPluginDemoScreen(
|
||||
var usePayOnServer by remember { mutableStateOf(false) }
|
||||
var useEidOnServer by remember { mutableStateOf(false) }
|
||||
var useVideo by remember { mutableStateOf(false) }
|
||||
var themingChoice by remember { mutableStateOf(ThemingChoice.CODE) }
|
||||
var themingChoice by remember { mutableStateOf(ThemingChoice.COMPOSE) }
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@ -107,8 +106,8 @@ fun MetaPluginDemoScreen(
|
||||
modifier = Modifier.padding(start = 10.dp),
|
||||
) {
|
||||
CheckboxWithLabel(
|
||||
checked = themingChoice == ThemingChoice.CODE,
|
||||
onCheckedChange = { themingChoice = ThemingChoice.CODE },
|
||||
checked = themingChoice == ThemingChoice.COMPOSE,
|
||||
onCheckedChange = { themingChoice = ThemingChoice.COMPOSE },
|
||||
label = "Code-Theming"
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user