-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
<!-- 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 #5631 This PR introduces a new `ThumbnailImage` composable that integrates the `LessonThumbnailImageView` within a Compose layout. The changes include: - Adding the basic structure for `ThumbnailImage` composable. - Updating various UI components to use the new `ThumbnailImage` composable. - Adding classroom thumbnail drawables to `LessonThumbnailImageView`. Note: Initial attempts were made to use the Glide Compose library, but was found to be incompatible with other dependencies #5631 (comment). ## Screenshots |Light Mode|Dark Mode| |--|--| |![image](https://github.com/user-attachments/assets/84d7447e-cde1-4ef5-b08b-a05dce7c6243)|![image](https://github.com/user-attachments/assets/a37ad536-46be-470d-96b6-e953282bc800)| |![image](https://github.com/user-attachments/assets/c4ad9439-d071-4b73-8c6b-f927a45e420b)|![image](https://github.com/user-attachments/assets/8e472114-5e97-4327-a13f-46cb31f739d9)| ## 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: Ben Henning <[email protected]>
- Loading branch information
1 parent
f3c6dff
commit 968a18d
Showing
12 changed files
with
97 additions
and
76 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
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
46 changes: 46 additions & 0 deletions
46
app/src/main/java/org/oppia/android/app/classroom/ThumbnailImage.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,46 @@ | ||
package org.oppia.android.app.classroom | ||
|
||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.viewinterop.AndroidView | ||
import org.oppia.android.app.customview.LessonThumbnailImageView | ||
import org.oppia.android.app.model.LessonThumbnail | ||
|
||
/** | ||
* A composable function that displays a lesson thumbnail image using a custom Android view. | ||
* | ||
* This function integrates the [LessonThumbnailImageView] within a Compose layout, allowing it | ||
* to render a lesson thumbnail image based on the provided parameters. The implementation | ||
* currently relies on a traditional Android View approach due to compatibility issues with the | ||
* Glide Compose library. | ||
* | ||
* @param entityId the unique identifier for the entity associated with the thumbnail | ||
* @param entityType the type of the entity (e.g., classroom, topic, story) | ||
* @param lessonThumbnail the [LessonThumbnail] containing metadata required to load the image | ||
* @param modifier the [Modifier] to be applied to the layout, defaulting to [Modifier] | ||
*/ | ||
@Composable | ||
fun ThumbnailImage( | ||
entityId: String, | ||
entityType: String, | ||
lessonThumbnail: LessonThumbnail?, | ||
modifier: Modifier = Modifier, | ||
) { | ||
// TODO(#5422): Migrate to Jetpack Compose once the Glide Compose library becomes compatible. | ||
AndroidView( | ||
modifier = modifier.fillMaxSize(), | ||
factory = { context -> | ||
LessonThumbnailImageView(context).apply { | ||
setLessonThumbnail(lessonThumbnail) | ||
setEntityId(entityId) | ||
setEntityType(entityType) | ||
} | ||
}, | ||
update = { view -> | ||
view.setLessonThumbnail(lessonThumbnail) | ||
view.setEntityId(entityId) | ||
view.setEntityType(entityType) | ||
} | ||
) | ||
} |
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
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
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