Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
33d5b02781 | |||
e0cfc0c728 | |||
890e50a2c9 | |||
3cd3f3eba1 | |||
bcf0e0333e | |||
8447122c89 | |||
1b839010c6 |
@ -15,8 +15,8 @@ android {
|
||||
applicationId = "com.hyperling.roomexample"
|
||||
minSdk = 21
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
versionCode = 2
|
||||
versionName = "1.03"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ 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.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Text
|
||||
@ -11,6 +12,9 @@ import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.input.KeyboardCapitalization
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.style.TextGeometricTransform
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
@ -35,7 +39,8 @@ fun AddContactDialog(
|
||||
},
|
||||
placeholder = {
|
||||
Text(text = "First Name")
|
||||
}
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.Words)
|
||||
)
|
||||
TextField(
|
||||
value = state.lastName,
|
||||
@ -44,7 +49,8 @@ fun AddContactDialog(
|
||||
},
|
||||
placeholder = {
|
||||
Text(text = "Last Name")
|
||||
}
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.Words)
|
||||
)
|
||||
TextField(
|
||||
value = state.phoneNumber,
|
||||
@ -53,7 +59,8 @@ fun AddContactDialog(
|
||||
},
|
||||
placeholder = {
|
||||
Text(text = "Phone Number")
|
||||
}
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Phone)
|
||||
)
|
||||
}
|
||||
},
|
||||
|
@ -22,9 +22,21 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
fun getEnumStringResourceID(enumName: String): Int {
|
||||
return (
|
||||
when (enumName) {
|
||||
SortType.FIRST_NAME.toString() -> R.string.FIRST_NAME
|
||||
SortType.LAST_NAME.toString() -> R.string.LAST_NAME
|
||||
SortType.PHONE_NUMBER.toString() -> R.string.PHONE_NUMBER
|
||||
else -> 0
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ContactScreen(
|
||||
state: ContactState,
|
||||
@ -52,6 +64,9 @@ fun ContactScreen(
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
){
|
||||
item {
|
||||
Row (){
|
||||
Text(text = "Sort ascending by:")
|
||||
}
|
||||
Row (
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@ -72,10 +87,13 @@ fun ContactScreen(
|
||||
onEvent(ContactEvent.SortContacts(sortType))
|
||||
}
|
||||
)
|
||||
Text(text = sortType.name)
|
||||
Text(text = stringResource(getEnumStringResourceID(sortType.name)))
|
||||
}
|
||||
}
|
||||
}
|
||||
Row (){
|
||||
Text(text = "Contacts:")
|
||||
}
|
||||
}
|
||||
items(state.contacts) {contact ->
|
||||
Row (
|
||||
|
@ -58,7 +58,9 @@ class MainActivity : ComponentActivity() {
|
||||
@Composable
|
||||
fun GreetingPreview() {
|
||||
ExampleRoomDatabase21EmptyTheme {
|
||||
Greeting("Android")
|
||||
ContactScreen (
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
// */
|
@ -1,3 +1,6 @@
|
||||
<resources>
|
||||
<string name="app_name">Room Database Testing</string>
|
||||
<string name="FIRST_NAME">First Name</string>
|
||||
<string name="LAST_NAME">Last Name</string>
|
||||
<string name="PHONE_NUMBER">Phone Number</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user