[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.compose.setContent
|
||||||
import androidx.activity.result.ActivityResult
|
import androidx.activity.result.ActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@ -133,7 +132,12 @@ internal class MainActivity : ComponentActivity
|
|||||||
selectProductPlugins
|
selectProductPlugins
|
||||||
)
|
)
|
||||||
MetaPluginVerifyTask(metaPlugin)
|
MetaPluginVerifyTask(metaPlugin)
|
||||||
.setOnPostExecuteCallback(metaPluginVerifyCallback(metaPlugin))
|
.setOnPostExecuteCallback(
|
||||||
|
metaPluginVerifyCallback(
|
||||||
|
metaPlugin = metaPlugin,
|
||||||
|
themingChoice = themingChoice
|
||||||
|
)
|
||||||
|
)
|
||||||
.execute(actionId)
|
.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 ->
|
return { result ->
|
||||||
if (result.errorResult == EApiResult.SUCCESS) {
|
if (result.errorResult == EApiResult.SUCCESS) {
|
||||||
try {
|
try {
|
||||||
metaPlugin.startPlugin(
|
when (themingChoice) {
|
||||||
this,
|
ThemingChoice.XML -> {
|
||||||
activityResultLauncher,
|
metaPlugin.startPlugin(
|
||||||
true,
|
this,
|
||||||
)
|
activityResultLauncher,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
ThemingChoice.COMPOSE -> {
|
||||||
|
metaPlugin.startPlugin(
|
||||||
|
this,
|
||||||
|
activityResultLauncher,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (e: WebIdMobileAppSdkException) {
|
} catch (e: WebIdMobileAppSdkException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
writeLog(e.message.toString())
|
writeLog(e.message.toString())
|
||||||
|
|||||||
@ -30,12 +30,11 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import de.webidsolutions.metaplugindemo.R
|
import de.webidsolutions.metaplugindemo.R
|
||||||
|
|
||||||
enum class ThemingChoice {
|
enum class ThemingChoice(val useXml: Boolean) {
|
||||||
CODE,
|
COMPOSE(false),
|
||||||
XML
|
XML(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -53,7 +52,7 @@ fun MetaPluginDemoScreen(
|
|||||||
var usePayOnServer by remember { mutableStateOf(false) }
|
var usePayOnServer by remember { mutableStateOf(false) }
|
||||||
var useEidOnServer by remember { mutableStateOf(false) }
|
var useEidOnServer by remember { mutableStateOf(false) }
|
||||||
var useVideo 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(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -107,8 +106,8 @@ fun MetaPluginDemoScreen(
|
|||||||
modifier = Modifier.padding(start = 10.dp),
|
modifier = Modifier.padding(start = 10.dp),
|
||||||
) {
|
) {
|
||||||
CheckboxWithLabel(
|
CheckboxWithLabel(
|
||||||
checked = themingChoice == ThemingChoice.CODE,
|
checked = themingChoice == ThemingChoice.COMPOSE,
|
||||||
onCheckedChange = { themingChoice = ThemingChoice.CODE },
|
onCheckedChange = { themingChoice = ThemingChoice.COMPOSE },
|
||||||
label = "Code-Theming"
|
label = "Code-Theming"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user