diff --git a/app/src/main/java/com/hyperling/roomexample/ContactScreen.kt b/app/src/main/java/com/hyperling/roomexample/ContactScreen.kt index 542dc58..52c716c 100644 --- a/app/src/main/java/com/hyperling/roomexample/ContactScreen.kt +++ b/app/src/main/java/com/hyperling/roomexample/ContactScreen.kt @@ -22,9 +22,20 @@ 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 getEnumStringResource(enumName: String): Int { + val resourceID: Int = 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 + } + return resourceID +} + @Composable fun ContactScreen( state: ContactState, @@ -72,7 +83,8 @@ fun ContactScreen( onEvent(ContactEvent.SortContacts(sortType)) } ) - Text(text = sortType.name) + val sortTypeString: String = stringResource(getEnumStringResource(sortType.name)) + Text(text = sortTypeString) } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0dca96f..f92fedc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,6 @@ Room Database Testing + First Name + Last Name + Phone Number \ No newline at end of file