-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix part of #5344: Add coming soon topic list UI & fix recommendation…
… logic tests (#5460) <!-- READ ME FIRST: Please fill in the explanation section below and check off every point from the Essential Checklist! --> ## Explanation <!-- - Explain what your PR does. If this PR fixes an existing bug, please include - "Fixes #bugnum:" in the explanation so that GitHub can auto-close the issue - when this PR is merged. --> Fixes part of #5344 This PR adds the coming soon topic list UI and fixes previously ignored promoted stories UI tests by correcting the test setup. ## Screenshots ### Phone |Portrait|Landscape| |--|--| |![image](https://github.com/oppia/oppia-android/assets/84731134/554eeab5-2d9e-40a5-ab01-51c8a0a69661)|![image](https://github.com/oppia/oppia-android/assets/84731134/51a2c638-065e-4d75-92c4-046f8d0609d7)| ### Tablet |Portrait|Landscape| |--|--| |![image](https://github.com/oppia/oppia-android/assets/84731134/1ddd19d6-df04-44dd-8073-f9b77554b2d7)|![image](https://github.com/oppia/oppia-android/assets/84731134/dd680415-c9a5-4996-ae9f-55167cc0f0df)| ## Essential Checklist <!-- Please tick the relevant boxes by putting an "x" in them. --> - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). ## For UI-specific PRs only <!-- Delete these section if this PR does not include UI-related changes. --> If your PR includes UI-related changes, then: - Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes - For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see [RTL guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines)) - Add a video showing the full UX flow with a screen reader enabled (see [accessibility guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide)) - For PRs introducing new UI elements or color changes, both light and dark mode screenshots must be included - Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing --------- Co-authored-by: Adhiambo Peres <[email protected]>
- Loading branch information
1 parent
4b49cd8
commit d2db9df
Showing
9 changed files
with
343 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
181 changes: 181 additions & 0 deletions
181
app/src/main/java/org/oppia/android/app/classroom/promotedlist/ComingSoonTopicList.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
package org.oppia.android.app.classroom.promotedlist | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.aspectRatio | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.lazy.LazyRow | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.Card | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.platform.testTag | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.res.dimensionResource | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import org.oppia.android.R | ||
import org.oppia.android.app.classroom.getDrawableResource | ||
import org.oppia.android.app.home.promotedlist.ComingSoonTopicListViewModel | ||
import org.oppia.android.app.home.promotedlist.ComingSoonTopicsViewModel | ||
import org.oppia.android.util.locale.OppiaLocale | ||
|
||
/** Test tag for the header of the promoted story list. */ | ||
const val COMING_SOON_TOPIC_LIST_HEADER_TEST_TAG = "TEST_TAG.coming_soon_topic_list_header" | ||
|
||
/** Test tag for the promoted story list. */ | ||
const val COMING_SOON_TOPIC_LIST_TEST_TAG = "TEST_TAG.coming_soon_topic_list" | ||
|
||
/** Displays a list of topics to be published soon. */ | ||
@Composable | ||
fun ComingSoonTopicList( | ||
comingSoonTopicListViewModel: ComingSoonTopicListViewModel, | ||
machineLocale: OppiaLocale.MachineLocale, | ||
) { | ||
Text( | ||
text = stringResource(id = R.string.coming_soon), | ||
color = colorResource(id = R.color.component_color_shared_primary_text_color), | ||
fontFamily = FontFamily.SansSerif, | ||
fontWeight = FontWeight.Medium, | ||
fontSize = dimensionResource(id = R.dimen.coming_soon_topic_list_header_text_size).value.sp, | ||
modifier = Modifier | ||
.padding( | ||
start = dimensionResource(id = R.dimen.coming_soon_topic_list_layout_margin_start), | ||
top = dimensionResource(id = R.dimen.coming_soon_topic_list_layout_margin_top), | ||
end = dimensionResource(id = R.dimen.coming_soon_topic_list_layout_margin_end), | ||
) | ||
.testTag(COMING_SOON_TOPIC_LIST_HEADER_TEST_TAG), | ||
) | ||
LazyRow( | ||
modifier = Modifier | ||
.padding( | ||
top = dimensionResource(id = R.dimen.coming_soon_topic_list_padding) | ||
) | ||
.testTag(COMING_SOON_TOPIC_LIST_TEST_TAG), | ||
contentPadding = PaddingValues( | ||
start = dimensionResource(id = R.dimen.coming_soon_topic_list_layout_margin_start), | ||
end = dimensionResource(id = R.dimen.home_padding_end), | ||
), | ||
) { | ||
items(comingSoonTopicListViewModel.comingSoonTopicList) { | ||
ComingSoonTopicCard( | ||
comingSoonTopicsViewModel = it, | ||
machineLocale = machineLocale, | ||
) | ||
} | ||
} | ||
} | ||
|
||
/** Displays a card with the coming soon topic summary information. */ | ||
@Composable | ||
fun ComingSoonTopicCard( | ||
comingSoonTopicsViewModel: ComingSoonTopicsViewModel, | ||
machineLocale: OppiaLocale.MachineLocale, | ||
) { | ||
Card( | ||
modifier = Modifier | ||
.width(dimensionResource(id = R.dimen.coming_soon_topic_card_width)) | ||
.padding( | ||
start = dimensionResource(id = R.dimen.coming_soon_topic_card_layout_margin_start), | ||
end = dimensionResource(id = R.dimen.coming_soon_topic_card_layout_margin_end), | ||
bottom = dimensionResource(id = R.dimen.coming_soon_topic_card_layout_margin_bottom), | ||
), | ||
elevation = dimensionResource(id = R.dimen.topic_card_elevation), | ||
) { | ||
Box( | ||
contentAlignment = Alignment.TopEnd | ||
) { | ||
Column( | ||
verticalArrangement = Arrangement.Center, | ||
) { | ||
Image( | ||
painter = painterResource( | ||
id = comingSoonTopicsViewModel.topicSummary.lessonThumbnail.getDrawableResource() | ||
), | ||
contentDescription = "Picture of a " + | ||
"${comingSoonTopicsViewModel.topicSummary.lessonThumbnail.thumbnailGraphic.name}.", | ||
modifier = Modifier | ||
.aspectRatio(4f / 3f) | ||
.background( | ||
Color( | ||
( | ||
0xff000000L or | ||
comingSoonTopicsViewModel | ||
.topicSummary.lessonThumbnail.backgroundColorRgb.toLong() | ||
).toInt() | ||
) | ||
) | ||
) | ||
ComingSoonTopicCardTextSection(comingSoonTopicsViewModel) | ||
} | ||
Text( | ||
text = machineLocale | ||
.run { stringResource(id = R.string.coming_soon).toMachineUpperCase() }, | ||
modifier = Modifier | ||
.background( | ||
color = colorResource( | ||
id = R.color.component_color_coming_soon_rect_background_start_color | ||
), | ||
shape = RoundedCornerShape(topEnd = 4.dp, bottomStart = 12.dp), | ||
) | ||
.padding( | ||
horizontal = dimensionResource(id = R.dimen.coming_soon_text_padding_horizontal), | ||
vertical = dimensionResource(id = R.dimen.coming_soon_text_padding_vertical), | ||
), | ||
fontSize = 12.sp, | ||
color = colorResource(id = R.color.component_color_shared_secondary_4_text_color), | ||
fontFamily = FontFamily.SansSerif, | ||
textAlign = TextAlign.End, | ||
) | ||
} | ||
} | ||
} | ||
|
||
/** Displays the topic title. */ | ||
@Composable | ||
fun ComingSoonTopicCardTextSection(comingSoonTopicsViewModel: ComingSoonTopicsViewModel) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.background( | ||
color = colorResource( | ||
id = R.color.component_color_shared_topic_card_item_background_color | ||
) | ||
), | ||
verticalArrangement = Arrangement.SpaceBetween, | ||
) { | ||
Text( | ||
text = comingSoonTopicsViewModel.topicTitle, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding( | ||
start = dimensionResource(id = R.dimen.coming_soon_topic_card_text_padding), | ||
top = dimensionResource(id = R.dimen.coming_soon_topic_card_text_padding), | ||
end = dimensionResource(id = R.dimen.coming_soon_topic_card_text_padding), | ||
bottom = dimensionResource(id = R.dimen.coming_soon_topic_card_text_padding_bottom), | ||
), | ||
color = colorResource(id = R.color.component_color_shared_secondary_4_text_color), | ||
fontFamily = FontFamily.SansSerif, | ||
fontSize = dimensionResource(id = R.dimen.topic_list_item_text_size).value.sp, | ||
textAlign = TextAlign.Start, | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis, | ||
) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.