1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-31 03:59:56 +02:00

Modifying the UserDetailScreen to use the localized gender display names.

This commit is contained in:
oliexdev
2025-08-15 11:45:12 +02:00
parent 9e4b7f933f
commit cd991b4f18
5 changed files with 16 additions and 13 deletions

View File

@@ -42,12 +42,16 @@ enum class SupportedLanguage(val code: String, val nativeDisplayName: String) {
}
}
enum class GenderType {
MALE,
FEMALE;
enum class GenderType(@StringRes val displayNameResId: Int) {
MALE(R.string.gender_male),
FEMALE(R.string.gender_female);
fun isMale(): Boolean {
return this == MALE}
fun getDisplayName(context: android.content.Context): String {
return context.getString(displayNameResId)
}
}
enum class ActivityLevel {

View File

@@ -313,8 +313,7 @@ fun UserDetailScreen(
selected = gender == option,
onClick = { gender = option }
)
// Display gender options with first letter capitalized.
Text(option.name.lowercase().replaceFirstChar { it.uppercaseChar().toString() })
Text(option.getDisplayName(LocalContext.current))
}
}
}

View File

@@ -36,6 +36,7 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.health.openscale.R
@@ -97,16 +98,11 @@ fun UserSettingsScreen(
ListItem(
headlineContent = { Text(user.name) },
supportingContent = {
val heightText = if (user.heightCm != null) {
stringResource(R.string.height_value_cm, user.heightCm)
} else {
stringResource(R.string.not_available)
}
Text(
stringResource(
id = R.string.user_settings_item_details_conditional,
age,
heightText
user.gender.getDisplayName(LocalContext.current)
)
)
}

View File

@@ -50,11 +50,13 @@
<string name="user_detail_label_name">Name</string>
<string name="user_detail_label_height">Größe</string>
<string name="user_detail_label_gender">Geschlecht</string>
<string name="gender_male">Männlich</string>
<string name="gender_female">Weiblich</string>
<string name="user_detail_label_activity_level">Aktivitätslevel</string>
<string name="user_detail_label_birth_date">Geburtsdatum</string>
<string name="user_detail_error_invalid_data">Bitte geben Sie gültige Daten ein</string>
<string name="height_value_cm">%.1f cm</string>
<string name="user_settings_item_details_conditional">Alter: %1$d, Größe: %2$s</string>
<string name="user_settings_item_details_conditional">Alter: %1$d, Geschlecht: %2$s</string>
<string name="user_settings_content_description_edit">Benutzer bearbeiten</string>
<string name="user_settings_content_description_delete">Benutzer löschen</string>
<string name="user_settings_content_description_add_user">Neuen Benutzer hinzufügen</string>

View File

@@ -51,11 +51,13 @@
<string name="user_detail_label_name">Name</string>
<string name="user_detail_label_height">Height</string>
<string name="user_detail_label_gender">Gender</string>
<string name="gender_male">Male</string>
<string name="gender_female">Female</string>
<string name="user_detail_label_activity_level">Activity Level</string>
<string name="user_detail_label_birth_date">Birth Date</string>
<string name="user_detail_error_invalid_data">Please enter valid data</string>
<string name="height_value_cm">%.1f cm</string>
<string name="user_settings_item_details_conditional">Age: %1$d, Height: %2$s</string>
<string name="user_settings_item_details_conditional">Age: %1$d, Gender: %2$s</string>
<string name="user_settings_content_description_edit">Edit user</string>
<string name="user_settings_content_description_delete">Delete user</string>
<string name="user_settings_content_description_add_user">Add new user</string>