Hi everyone! :smile: I tried creating Neumorphism ...
# compose
n
Hi everyone! 😄 I tried creating Neumorphism UI with Jetpack Compose. You can take a look at the lib/code here - https://github.com/CuriousNikhil/neumorphic-compose I’m learning this and probability of the code being correct/holding best practices may be less. 😅 I’ve a couple of questions. The idea is simple, I’ve created a custom modifier by extending the
DrawModifier
and I’m drawing the shadows using
contentDrawScope
provided by
DrawModifier
. 1. First of all, Is this a correct to extend the modifiers? 2. To render the shadows(GradientDrawable) smoothly, I’m using RenderScript (I know it’s going to be deprecated in the Android12. I’ll migrate.). I need
context
param to invoke renderscript api. Is it okay to pass
context
param in the Modifier?
💣 4
jetpack compose 6
d
For 2, couldn't you use
LocalContext
instead of having to pass it in as a parameter?
☝🏻 2
☝️ 2
☝🏼 1
n
But
LocalContext.current
needs to be called from another
@Composable
function. This is simple Modifier
d
You can mark your modifier function with
@Composable
c
No, this is incorrect,
composed
Modifier should be used, this will allow you to call the
LocalContext.current
in the Modifier
n
@Chachako Thanks! I missed this. This is nice! I’ll use this^
✌️ 1
131 Views