-
Notifications
You must be signed in to change notification settings - Fork 265
Update the placeholders for Compose Preview for HomeScreen.kt #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ef96ffc
Preview Placeholders for HomeScreen.kt
pedrosax f6b61f4
Add placeholder images for HomeScreen.kt
pedrosax e82e465
Add files via upload
pedrosax c4cea48
Create dancing_droid_gif_placeholder.png
pedrosax 3008f7c
Moving placeholder images to debug folder
pedrosax ef87135
Remove asset from main folder
pedrosax f2c3b51
remove promo_video_placeholder.png from main folder
pedrosax 5f4324e
Create tmp file
pedrosax 9e1e6bf
Moved pptimized PNG paceholder images
pedrosax 7184a41
Delete feature/home/src/debug/res/drawable directory
pedrosax a7a7058
Delete feature/home/src/main/res/drawable-nodpi/tmp
pedrosax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -75,6 +75,7 @@ import androidx.compose.ui.graphics.Color | |
| import androidx.compose.ui.graphics.graphicsLayer | ||
| import androidx.compose.ui.graphics.vector.ImageVector | ||
| import androidx.compose.ui.graphics.vector.rememberVectorPainter | ||
| import androidx.compose.ui.layout.ContentScale | ||
| import androidx.compose.ui.layout.onLayoutRectChanged | ||
| import androidx.compose.ui.layout.onVisibilityChanged | ||
| import androidx.compose.ui.platform.LocalContext | ||
|
|
@@ -456,11 +457,19 @@ private fun DancingBot( | |
| dancingBotLink: String?, | ||
| modifier: Modifier, | ||
| ) { | ||
| AsyncImage( | ||
| model = dancingBotLink, | ||
| modifier = modifier, | ||
| contentDescription = null, | ||
| ) | ||
| if (LocalInspectionMode.current) { | ||
| Image( | ||
| painter = painterResource(id = R.drawable.dancing_droid_gif_placeholder), | ||
| contentDescription = null, | ||
| modifier = modifier | ||
| ) | ||
| } else { | ||
| AsyncImage( | ||
| model = dancingBotLink, | ||
| modifier = modifier, | ||
| contentDescription = null, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
|
|
@@ -520,23 +529,31 @@ private fun VideoPlayer( | |
| videoLink: String?, | ||
| modifier: Modifier = Modifier, | ||
| ) { | ||
| if (LocalInspectionMode.current) return // Layoutlib does not support ExoPlayer | ||
|
|
||
| val context = LocalContext.current | ||
| var player by remember { mutableStateOf<Player?>(null) } | ||
| LifecycleStartEffect(videoLink) { | ||
| if (videoLink != null) { | ||
| player = ExoPlayer.Builder(context).build().apply { | ||
| setMediaItem(MediaItem.fromUri(videoLink)) | ||
| repeatMode = Player.REPEAT_MODE_ONE | ||
| prepare() | ||
| if (LocalInspectionMode.current) { | ||
| Image( | ||
| painter = painterResource(id = R.drawable.promo_video_placeholder), | ||
| contentDescription = null, | ||
| contentScale = ContentScale.Crop, | ||
| modifier = modifier, | ||
| ) | ||
| return | ||
|
Comment on lines
+532
to
+539
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider extracting the @Composable
private fun VideoPlaceholder(modifier: Modifier = Modifier) {
Image(
painter = painterResource(id = R.drawable.promo_video_placeholder),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = modifier,
)
}
// Usage in VideoPlayer:
if (LocalInspectionMode.current) {
VideoPlaceholder(modifier = modifier)
return
} |
||
| } else { | ||
| val context = LocalContext.current | ||
| var player by remember { mutableStateOf<Player?>(null) } | ||
| LifecycleStartEffect(videoLink) { | ||
| if (videoLink != null) { | ||
| player = ExoPlayer.Builder(context).build().apply { | ||
| setMediaItem(MediaItem.fromUri(videoLink)) | ||
| repeatMode = Player.REPEAT_MODE_ONE | ||
| prepare() | ||
| } | ||
| } | ||
| onStopOrDispose { | ||
| player?.release() | ||
| player = null | ||
| } | ||
| } | ||
| onStopOrDispose { | ||
| player?.release() | ||
| player = null | ||
| } | ||
| } | ||
|
|
||
|
|
||
| var videoFullyOnScreen by remember { mutableStateOf(false) } | ||
| val isWindowOccluded = LocalOcclusion.current | ||
|
|
@@ -582,3 +599,4 @@ private fun VideoPlayer( | |
| } | ||
| } | ||
| } | ||
| } | ||
Binary file added
BIN
+55.2 KB
feature/home/src/main/res/drawable-nodpi/dancing_droid_gif_placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting the
Imagecomposable into a separate function for better readability and maintainability. This would encapsulate the placeholder logic and make theDancingBotfunction cleaner.