-
Notifications
You must be signed in to change notification settings - Fork 599
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
[Placeholder] Prototype for new library #457
Conversation
Thanks, I'll take a look at this tomorrow once the next release is out. |
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.
Great start! 👏 👏 👏 👏 👏
Left a few comments but its not far off!
placeholder/src/main/java/com/google/accompanist/placeholder/Placeholder.kt
Outdated
Show resolved
Hide resolved
placeholder/src/main/java/com/google/accompanist/placeholder/Placeholder.kt
Outdated
Show resolved
Hide resolved
placeholder/src/main/java/com/google/accompanist/placeholder/Placeholder.kt
Outdated
Show resolved
Hide resolved
return result | ||
} | ||
|
||
override fun equals(other: Any?): Boolean { |
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.
No need for equals/hashcode here.
import androidx.compose.ui.graphics.lerp | ||
|
||
internal object PlaceholderDefaults { | ||
val PlaceholderColor = Color.Gray.copy(alpha = 0.5f) |
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.
Did you use Gray
here to avoid a dependency on Material? Ideally this would be set to contentColor()
but I'm not sure that we want to depend on Material
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.
Yes, I used Gray to avoid dependency on Material.
But if it's better to rely on the material, I'll change.
placeholder/src/main/java/com/google/accompanist/placeholder/PlaceholderAnimatedBrush.kt
Outdated
Show resolved
Hide resolved
placeholder/src/main/java/com/google/accompanist/placeholder/PlaceholderAnimatedBrush.kt
Show resolved
Hide resolved
placeholder/src/main/java/com/google/accompanist/placeholder/PlaceholderAnimatedBrush.kt
Outdated
Show resolved
Hide resolved
placeholder/src/main/java/com/google/accompanist/placeholder/PlaceholderAnimatedBrush.kt
Outdated
Show resolved
Hide resolved
placeholder/src/main/java/com/google/accompanist/placeholder/PlaceholderAnimatedBrush.kt
Outdated
Show resolved
Hide resolved
- Add the explicit return type. - Only create one modifier on every animation frame. - Remove equals/hashcode in Placeholder. - Use default easing instead of LinearEasing. - Change PlaceholderDefaults to public class. - Move functions for PlaceholderAnimatedBrush inside the companion object. - Add kdoc.
I applied all comments. 🙇 |
Omg 😍 |
I created a prototype for content placeholders.
If it's okay to go ahead, I'll add some test code.
Or, if you advise on the direction, I will correct it.
New APIs:
Modifier.placeholder(visible: Boolean)
to show a content placeholder.using
PlaceholderAnimatedBrush
likefadeBrush()
orshimmerBrush()
.Fixes #336
Demo