Dirk Hoffmann
02/10/2021, 4:56 PMIconButton(onClick = scaffoldStateClick())
gives me:
The feature "unit conversion" is disabled
am a bit clueless on how to fix both...jim
02/10/2021, 5:30 PMscaffoldStateClick(), but two questions:
(1) the onClick parameter expects a lambda/function, but you are INVOKING scaffoldStateClick(), not passing it as a parameter. Did you mean ::scaffoldStateClick or scaffoldStateClick ?
(2) If you did intend to invoke scaffoldStateClick() and it returns a lambda, are you sure the returned lambda is of type ()->Unit ?Dirk Hoffmann
02/10/2021, 5:39 PMfun scaffoldStateClick() = {
val adScaffoldState = ADState.ADScaffoldState
if (adScaffoldState.drawerState().isClosed) {
adScaffoldState.drawerState().open()
} else {
adScaffoldState.drawerState().close()
}
}Dirk Hoffmann
02/10/2021, 5:40 PMADState.ADScaffoldState is a singleton Object that keeps all my states and provides methods on them
(don't know if that is good design ... is it??)jim
02/10/2021, 5:46 PMADScaffoldState instance as a parameter, not use a singleton object. You always want to develop your widgets as self-contained reusable chunks that are pure functional transforms of their parameters. Relying on a global singleton violates several of those principles.
Also, your scaffoldStateClick() does not return a unit lambda, so that's why you're getting a type error. You probably want your code to be more like IconButton(onClick = { scaffoldStateClick(adScaffoldState) })