Untitled
unknown
plain_text
13 days ago
9.4 kB
3
Indexable
package com.example.signinjetpack import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExposedDropdownMenuBox import androidx.compose.material3.Icon import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextFieldDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.example.signinjetpack.ui.theme.SigninJetPackTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { SigninJetPackTheme { PopUpFilterContent() } } } } @OptIn(ExperimentalMaterial3Api::class) @Composable fun PopUpFilterContent(nodeConnections: Map<String, List<String>>) { val typeList = nodeConnections.keys.filter { key -> nodeConnections.values.none{it.contains(key)} } var type by remember { mutableStateOf("") } var zone by remember { mutableStateOf("") } var dma by remember { mutableStateOf("") } var expandedType by remember { mutableStateOf(false) } var expandedZone by remember { mutableStateOf(false) } var expandedDma by remember { mutableStateOf(false) } Column(verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier .fillMaxSize() .background(Color.White)) { Text(text = "Select Options", color = Color.Gray,fontWeight = FontWeight.Bold, fontSize = 18.sp, modifier = Modifier.padding(bottom = 5.dp)) Spacer(modifier = Modifier.height(8.dp)) Text(text = "Type", color = Color.Black,fontWeight = FontWeight.Bold, fontSize = 18.sp, modifier = Modifier.padding(bottom = 5.dp)) Spacer(modifier = Modifier.height(8.dp)) ExposedDropdownMenuBox(expanded = expandedType, onExpandedChange ={expandedType = !expandedType} ) { OutlinedTextField(value = type, onValueChange = {},readOnly = true, modifier = Modifier .fillMaxWidth() .menuAnchor(), trailingIcon = { Icon(painter = painterResource(id = R.mipmap.ic_dropdown), contentDescription ="Drop down color" ) // ExposedDropdownMenuDefaults.TrailingIcon(expanded = expandedStart) }, colors = OutlinedTextFieldDefaults.colors( focusedContainerColor = Color.White, unfocusedContainerColor = Color.White, focusedBorderColor = Color.Gray, unfocusedBorderColor = Color.Gray, focusedTextColor = Color.Black, unfocusedTextColor = Color.Black ) ) ExposedDropdownMenu(expanded = expandedType, onDismissRequest = { expandedType = false }) { typeList.forEach { DropdownMenuItem(text = { Text(it, fontFamily = FontFamily.Default)}, onClick = { type = it expandedType = false} ) } } } Text(text = "Zone", color = Color.Gray,fontWeight = FontWeight.Bold, fontSize = 18.sp, modifier = Modifier.padding(bottom = 5.dp)) Spacer(modifier = Modifier.height(8.dp)) ExposedDropdownMenuBox(expanded = expandedZone, onExpandedChange ={expandedZone = !expandedZone} ) { OutlinedTextField(value = zone, onValueChange = {},readOnly = true, modifier = Modifier .fillMaxWidth() .menuAnchor(), trailingIcon = { Icon(painter = painterResource(id = R.mipmap.ic_dropdown), contentDescription ="Drop down" ) // ExposedDropdownMenuDefaults.TrailingIcon(expanded = expandedStart) }, colors = OutlinedTextFieldDefaults.colors( focusedContainerColor = Color.White, unfocusedContainerColor = Color.White, focusedTextColor = Color.Black, unfocusedTextColor = Color.Black ) ) ExposedDropdownMenu(expanded = expandedZone, onDismissRequest = { expandedZone = false }) { typeList.forEach { DropdownMenuItem(text = { Text(it, fontFamily = FontFamily.Default)}, onClick = { zone = it expandedZone = false} ) } } } Text(text = "DMA", color = Color.Gray,fontWeight = FontWeight.Bold, fontSize = 18.sp, modifier = Modifier.padding(bottom = 5.dp)) Spacer(modifier = Modifier.height(8.dp)) ExposedDropdownMenuBox(expanded = expandedDma, onExpandedChange ={expandedDma = !expandedDma} ) { OutlinedTextField(value = dma, onValueChange = {},readOnly = true, modifier = Modifier .fillMaxWidth() .menuAnchor(), trailingIcon = { Icon(painter = painterResource(id = R.mipmap.ic_dropdown), contentDescription ="Drop down" ) // ExposedDropdownMenuDefaults.TrailingIcon(expanded = expandedStart) }, colors = OutlinedTextFieldDefaults.colors( focusedContainerColor = Color.White, unfocusedContainerColor = Color.White, focusedTextColor = Color.Black, unfocusedTextColor = Color.Black ) ) ExposedDropdownMenu(expanded = expandedDma, onDismissRequest = { expandedDma = false }) { typeList.forEach { DropdownMenuItem(text = { Text(it, fontFamily = FontFamily.Default)}, onClick = { dma = it expandedDma = false} ) } } } Spacer(modifier = Modifier.height(8.dp)) Button(onClick = { /* TODO: Implement continue action */ }, colors = ButtonDefaults.buttonColors( containerColor = Color(0xFF008577), contentColor = Color(0xFFFAFAFA), ), shape = RectangleShape, modifier = Modifier .padding(8.dp) .align(Alignment.CenterHorizontally)) { Text("SELECT") } } } @Preview(showBackground = true) @Composable fun GreetingPreview() { SigninJetPackTheme { // FormScreen() PopUpFilterContent() } }
Editor is loading...
Leave a Comment