Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Show Modal Dialog on Jetpack Compose

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            JetpackComposeDemoTheme {
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colors.background
                ) {
                    HomePage()
                }
            }
        }
    }
}

@Composable
fun HomePage(){

    val showDialog =  remember { mutableStateOf(false) }

    if(showDialog.value)
        CustomDialog(value = "", setShowDialog = {
            showDialog.value = it
        }) {
            Log.i("HomePage","HomePage : $it")
        }

    Scaffold(
        topBar = {
            TopAppBar(
                title = {
                    Text(text = "Home")
                }
            )
        }) {
        Box(modifier = Modifier.background(Color.White)) {
            Column(
                modifier = Modifier
                    .fillMaxSize()
                    .background(Color.White),
                verticalArrangement = Arrangement.Center,
                horizontalAlignment = Alignment.CenterHorizontally,
            ) {
                Button(onClick = {
                    showDialog.value = true
                }) {
                    Text(text = "Open Dialog")
                }
            }
        }
    }
}


@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
    JetpackComposeDemoTheme {
        HomePage()
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: ForEach Element with Function or Lambda 
Javascript :: Browser Events Livewire 
Javascript :: js dictionary contains key 
Javascript :: count duplicate array javascript 
Javascript :: double ?? js 
Javascript :: how to find remainder in javascript 
Javascript :: Uncaught (in promise): NotReadableError: Could not start video source 
Javascript :: node.js http server 
Javascript :: moment js date between two dates 
Javascript :: box shadow generador react native 
Javascript :: javascript addeventlistener 
Javascript :: how to get the children of an element in cypress 
Javascript :: npm modal 
Javascript :: where to initialize state in react 
Javascript :: how to fetch data from another website in javascript 
Javascript :: ReactComponent as Icon 
Javascript :: ng-true-value 
Javascript :: [Object: null prototype] appolo 
Javascript :: temporal dead zone in es6 
Javascript :: promise.all in javascript 
Javascript :: add another column without delete table sequelize 
Javascript :: how to add class in javascript dynamically 
Javascript :: Pass string using a function 
Javascript :: GET FORM VALUE 
Javascript :: Clone Array Using Spread Operator 
Javascript :: form handling in react 
Javascript :: document get element by id hover 
Javascript :: express 
Javascript :: javascript get response payload 
Javascript :: sequilze REACTJS 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =