I applied `horizontalScroll` modifier to the `androidx.wear.compose.material.dialog.Alert` and got ...
y
I applied
horizontalScroll
modifier to the
androidx.wear.compose.material.dialog.Alert
and got an
IllegalArgumentException
It appears to me,
horizontalScroll
modifier applied on the parent composable of a
ScalingLazyColumn
will raise the IllegalArgumentException, what is the reason for that? On the contrary, the
horizontalScroll
modifier applied on the child composable in the
item
of SLC is fine.
j
Code sample?
@Steve Bower [G]
y
The composable code is at https://github.com/yingding/hScrollSLC/blob/main/app/src/main/java/com/example/android/wearable/composeforwearos/MainActivity.kt#L56 The repo can be downloaded from https://github.com/yingding/hScrollSLC, please switch
Copy code
val hasChildSLC = false
to
Copy code
val hasChildSLC = true
and see the different effects.
s
Hi - please could you explain what you're trying to achieve with the Box containing both a ScalingLazyColumn and an Alert? The expected model for using Alert is as content for a Dialog, where the Dialog becomes modal when shown and can either be swiped away or dismissed with a click on one of the Buttons/Chips displayed in the Alert. See AlertDialogSample here, where we have a Box showing either a Chip or an alert, controlled by the showDialog boolean - https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:wear/com[…]a/androidx/wear/compose/material/samples/DialogSample.kt;l=58
y
@stevebower I see your point of the Alert which is not Intended for
horizontalScroll
modifier. What I would like to do is something like a horizontal scrollable calendar or heart rate graphic with multiple scrollable column. I prototyped with a horizontal scrollable
Box
and
ScalingLazyColumn
inside the Box. It doesn’t seem to compile. Now I switched to the implementation with a
ScalingLazyColumn
with multiple horizontalScroll graphic inside. I am just curious whether it is technically feasible to do a horizontalScroll and then use multiple SLC for vertical Scrolling in general.
s
It is technically feasible to do it - you could use the Accompanist HorizontalPager to handle the horizontal scrolling between pages and then put one SLC on each pages. However, I don't think having both horizontal and vertical scrolling on a page is recommended. For a start, additional vertical content conflicts with having a page indicator (like HorizontalPageIndicator).
y
I see, i thought of using multiple horizontal page, then i need to chunk the graphics either way. Is it possible to do something about the
Illegal ArgumentException
when
SLC
is wrapped inside a parent composable with
horizontalScroll
, it is sometimes difficult to find out which composable contains SLC. Can SLC just ignore the horizontalScroll conflict, and print a Warning instead of raise an exception? Does this make sense?
s
Please can you post a snippet of code that reproduces the IllegalArgumentException?
y
@stevebower Here is the repository for the IllegalArgumentException https://github.com/yingding/hScrollSLC Basically, something like this while composition will trigger the IllegalArgumentException on an Emulator.
Copy code
Box(
            modifier = Modifier.horizontalScroll(horizontalScrollState), // doesn't work
        ) {
                ScalingLazyColumn {
                    item {
                        Text("hi")
                    }
               }
        }
s
I've raised a bug for us to take a look at this next week.