codeslubber
04/11/2020, 2:55 PMdev05
but under 8 it says failed to cast to MutableState:
*val* position = _state_ *{* _SliderPosition_(valueRange = sliderRange, initial = range.*first*.toFloat(), steps = 9) }
Adam Powell
04/11/2020, 2:57 PMcodeslubber
04/11/2020, 2:58 PMAdam Powell
04/11/2020, 3:00 PMSliderPosition
is itself a @Composable
factory function call in dev08 so it can't be called in a state {}
or remember {}
initializer block and we're just not catching it.Adam Powell
04/11/2020, 3:01 PMremember {}
itself internally, you should be able to just use
val position = SliderPosition(...)
instead.Adam Powell
04/11/2020, 3:01 PMAdam Powell
04/11/2020, 3:02 PMsuspend
is fully operational, for animation clock subscription stuff like this we shouldn't need itAdam Powell
04/11/2020, 3:03 PMAdam Powell
04/11/2020, 3:03 PMAdam Powell
04/11/2020, 3:05 PMScrollerPosition
since it wants to read the density; the standard android fling scrolling curve depends on it (even though perhaps it never should have)Adam Powell
04/11/2020, 3:06 PMZach Klippenstein (he/him) [MOD]
04/11/2020, 3:21 PMinitial
parameter instead of just a "current value" that's always passed in is confusing to me. It's not clear why the initial value needs to be passed in after the first composition pass, what it would mean to change the "initial" value after the user has adjusted it, or why you'd want to. It also seems awkward with declarative code already stores the numeric slider position in its own state, since that initial state seems to need to be duplicated (set the initial state in parent, and also always be passing it to the slider). It seems inconsistent with other similar composables. Maybe I just have the wrong mental model of how this composable works?Adam Powell
04/11/2020, 3:23 PMAdam Powell
04/11/2020, 3:25 PMAdam Powell
04/11/2020, 3:26 PMAdam Powell
04/11/2020, 3:28 PMZach Klippenstein (he/him) [MOD]
04/11/2020, 3:32 PMLabeledSlider
is more like the API I would expect (minus the text bits): https://gist.github.com/zach-klippenstein/e2c8e6edf0d950d8ba527cd0681c5b60#file-drawlayerdemo-kt-L92Adam Powell
04/11/2020, 3:33 PMScrollerPosition
looks similar in the presence of the component changing itself for touch scrolling.Adam Powell
04/11/2020, 3:33 PMAdam Powell
04/11/2020, 3:34 PMAdam Powell
04/11/2020, 3:37 PMmatvei
04/11/2020, 6:53 PMSlider
with value: Float
and onValueChange: (Float) -> Unit
params, fwiw ๐matvei
04/11/2020, 6:53 PMAdam Powell
04/11/2020, 7:49 PMcodeslubber
04/12/2020, 5:12 AMstate {}
made it work..