First Working Revision (#1)
App is now in working order. Reviewed-on: https://gitea.com/Hyperling/example-android-database-room/pulls/1 Co-authored-by: Hyperling <me@hyperling.com> Co-committed-by: Hyperling <me@hyperling.com>
This commit is contained in:
@ -0,0 +1,73 @@
|
||||
package com.hyperling.roomexample
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun AddContactDialog(
|
||||
state: ContactState,
|
||||
onEvent: (ContactEvent) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
onEvent(ContactEvent.HideDialog)
|
||||
},
|
||||
title = { Text(text = "Add Contact") },
|
||||
text = {
|
||||
Column (
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
){
|
||||
TextField(
|
||||
value = state.firstName,
|
||||
onValueChange = {
|
||||
onEvent(ContactEvent.SetFirstName(it))
|
||||
},
|
||||
placeholder = {
|
||||
Text(text = "First Name")
|
||||
}
|
||||
)
|
||||
TextField(
|
||||
value = state.lastName,
|
||||
onValueChange = {
|
||||
onEvent(ContactEvent.SetLastName(it))
|
||||
},
|
||||
placeholder = {
|
||||
Text(text = "Last Name")
|
||||
}
|
||||
)
|
||||
TextField(
|
||||
value = state.phoneNumber,
|
||||
onValueChange = {
|
||||
onEvent(ContactEvent.SetPhoneNumber(it))
|
||||
},
|
||||
placeholder = {
|
||||
Text(text = "Phone Number")
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Button(onClick = {
|
||||
onEvent(ContactEvent.SaveContact)
|
||||
}) {
|
||||
Text(text = "Save")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user