Skip to content

Commit

Permalink
Capitalize text using MachineLocale
Browse files Browse the repository at this point in the history
  • Loading branch information
theMr17 committed Jun 23, 2024
1 parent 0264c8e commit a4943ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import org.oppia.android.domain.oppialogger.OppiaLogger
import org.oppia.android.domain.profile.ProfileManagementController
import org.oppia.android.domain.topic.TopicListController
import org.oppia.android.domain.translation.TranslationController
import org.oppia.android.util.locale.OppiaLocale
import org.oppia.android.util.parser.html.StoryHtmlParserEntityType
import org.oppia.android.util.parser.html.TopicHtmlParserEntityType
import javax.inject.Inject
Expand All @@ -68,6 +69,7 @@ class ClassroomListFragmentPresenter @Inject constructor(
private val resourceHandler: AppLanguageResourceHandler,
private val dateTimeUtil: DateTimeUtil,
private val translationController: TranslationController,
private val machineLocale: OppiaLocale.MachineLocale,
) {
private val routeToTopicPlayStoryListener = activity as RouteToTopicPlayStoryListener
private lateinit var binding: ClassroomListFragmentBinding
Expand Down Expand Up @@ -177,7 +179,10 @@ class ClassroomListFragmentPresenter @Inject constructor(
}
PromotedStoryListViewModel::class -> items.forEach { item ->
item {
PromotedStoryList(promotedStoryListViewModel = item as PromotedStoryListViewModel)
PromotedStoryList(
promotedStoryListViewModel = item as PromotedStoryListViewModel,
machineLocale = machineLocale
)
}
}
ClassroomSummaryViewModel::class -> stickyHeader {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ import org.oppia.android.R
import org.oppia.android.app.classroom.getDrawableResource
import org.oppia.android.app.home.promotedlist.PromotedStoryListViewModel
import org.oppia.android.app.home.promotedlist.PromotedStoryViewModel
import org.oppia.android.util.locale.OppiaLocale

/** Displays a list of promoted stories. */
@Composable
fun PromotedStoryList(promotedStoryListViewModel: PromotedStoryListViewModel) {
fun PromotedStoryList(
promotedStoryListViewModel: PromotedStoryListViewModel,
machineLocale: OppiaLocale.MachineLocale,
) {
Row(
modifier = Modifier
.fillMaxWidth()
Expand All @@ -62,7 +66,7 @@ fun PromotedStoryList(promotedStoryListViewModel: PromotedStoryListViewModel) {
)
if (promotedStoryListViewModel.getViewAllButtonVisibility() == View.VISIBLE) {
Text(
text = stringResource(id = R.string.view_all).uppercase(),
text = machineLocale.run { stringResource(id = R.string.view_all).toMachineUpperCase() },
color = colorResource(id = R.color.component_color_home_activity_view_all_text_color),
fontFamily = FontFamily.SansSerif,
fontWeight = FontWeight.Medium,
Expand All @@ -86,14 +90,20 @@ fun PromotedStoryList(promotedStoryListViewModel: PromotedStoryListViewModel) {
),
) {
items(promotedStoryListViewModel.promotedStoryList) {
PromotedStoryCard(promotedStoryViewModel = it)
PromotedStoryCard(
promotedStoryViewModel = it,
machineLocale = machineLocale
)
}
}
}

/** Displays a single promoted story card with an image, title, and handling click events. */
@Composable
fun PromotedStoryCard(promotedStoryViewModel: PromotedStoryViewModel) {
fun PromotedStoryCard(
promotedStoryViewModel: PromotedStoryViewModel,
machineLocale: OppiaLocale.MachineLocale,
) {
val cardLayoutWidth = promotedStoryViewModel.computeLayoutWidth()
val cardColumnModifier =
if (cardLayoutWidth == ViewGroup.LayoutParams.MATCH_PARENT) Modifier.fillMaxWidth()
Expand Down Expand Up @@ -144,9 +154,11 @@ fun PromotedStoryCard(promotedStoryViewModel: PromotedStoryViewModel) {
overflow = TextOverflow.Ellipsis
)
Text(
text = promotedStoryViewModel.topicTitle.uppercase(),
text = machineLocale.run { promotedStoryViewModel.topicTitle.toMachineUpperCase() },
modifier = Modifier.padding(start = 16.dp, top = 8.dp, end = 16.dp),
color = colorResource(id = R.color.component_color_shared_story_card_topic_name_text_color),
color = colorResource(
id = R.color.component_color_shared_story_card_topic_name_text_color
),
fontFamily = FontFamily.SansSerif,
fontWeight = FontWeight.Light,
fontSize = 14.sp,
Expand All @@ -155,7 +167,7 @@ fun PromotedStoryCard(promotedStoryViewModel: PromotedStoryViewModel) {
overflow = TextOverflow.Ellipsis,
)
Text(
text = promotedStoryViewModel.classroomTitle.uppercase(),
text = machineLocale.run { promotedStoryViewModel.classroomTitle.toMachineUpperCase() },
modifier = Modifier
.padding(start = 16.dp, top = 8.dp, end = 16.dp, bottom = 8.dp)
.border(
Expand Down

0 comments on commit a4943ce

Please sign in to comment.