I have seen that `shadow` has a different source o...
# compose-desktop
j
I have seen that
shadow
has a different source of light in desktop (left top) respect to Android (center top). I think the common
Modifier
should have the same behavior in both platform and if a design system like Material needs to change the position, should create an additional modifier, but not sure if
shadow
should be renamed to
basicShadow
similar to
BasicText
and
Button
2
c
Hmm did JetBrains change the light source?
i
As far as I remember, we configured the light source to be similar to the Android implementation. But we could easily have made a mistake. So if the light source is different on desktop, we should fix that.
j
I can try to create a minimum repro, if I remember well, I am using the last version 1.0.1
I have tried to reproduce it in a minimum project but I am not getting the same issue, I will research on Monday. Thank you 🙂
I reproduced it
Copy code
fun main() = application {
    Window(onCloseRequest = ::exitApplication) {
        MaterialTheme {
            Box(modifier = Modifier.padding(32.dp)) {
                Card {
                    Column(modifier = Modifier.padding(16.dp)) {
                        Button(
                            modifier = Modifier.fillMaxWidth(),
                            onClick = {},
                        ) { Text("Button") }
                    }
                }
            }
        }
    }
}
The problem is caused when the
Button
has the modifier
fillMaxWidth
. In Android it is not happening, only on desktop
As you can see, the Card has the shadow in the right
with mouse hover, the shadow is in the right in the button
If I set the
Button
width to an specific value, for example,
200.dp
, it is not happening anymore
message has been deleted
g
I really hope that at some point we will get a generic shadow modifier for compose, not material one which is unfortunately not flexible enough outside of pure material design
j
Yeah, I am following the issue in the issue tracker and there is an external contribution to allow modifying colors and more things, not sure if the canvas approach which is coming to Compose will allow Compose teams creating composables quicker than the current approach
g
What do you mean "quicker"? In terms of performance?
j
no, in terms of adding new composables to all platforms easily. In terms of performance I guess it will be worse in certain platforms, but not sure if it would be worse on Android, because legacy UI was writing to the canvas under the hood I thnk
t
Right now the shadow implementation is a graphics layer property, which is not Canvas but RenderNode on Android, because Android uses HW acceleration in most cases to render shadows. The Skiko graphics layer does call Canvas under the hood to draw shadows, and it would be pretty straightforward to copy that code to a Modifier implementation: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/platform/SkiaLayer.skiko.kt;drc=26a918e2fb455ede23c9e16f94ef503590d8ffdb;l=277