Ian Warwick
01/10/2020, 8:43 AMIan Warwick
01/10/2020, 8:46 AMDropDownPopup
when I click out of the popup anywhere I want it to close 🤔 without passing a listener down the tree would be cool, I guess I could use +ambient
somehow though not sure of the best waymatvei
01/10/2020, 11:09 AM@Composable fun RootComponent() {
var popupOpen by state { false }
Clickable(onClick = { popupOpen = fasel } ) {
SomeLayoutToPositionSomewhere() {
DropDownItem(open = popupOpen, onPopupOpen = { popupOpen = true })
}
Doesn't look that scary, does it? 🙂Ian Warwick
01/10/2020, 11:12 AMmatvei
01/10/2020, 11:12 AMIan Warwick
01/10/2020, 11:13 AMmatvei
01/10/2020, 11:13 AMDropDownItem(open = popupOpen, onPopupOpen = { popupOpen = true })
I think this gives you a lot of flexibility and scalability, TBH.
It's stateless, so you can put it on any screen, with any architecture and its parameter set clearly indicated expectations from the calleematvei
01/10/2020, 11:14 AMIan Warwick
01/10/2020, 11:15 AMSomeLayoutToPositionSomewhere() {
DropDownItem(open = popupOpen, onPopupOpen = { popupOpen = true })
was somewhere else in another file>? would need to pass popupOpen
as an argumentmatvei
01/10/2020, 11:17 AMIan Warwick
01/10/2020, 11:18 AMpopupOpen1
popupOpen2
etc?matvei
01/10/2020, 11:20 AMdata class ScreenState(val popup1Open: Boolean, val popup2Open: Boolean)
and copy and propogate new state every timeIan Warwick
01/10/2020, 11:21 AMIan Warwick
01/10/2020, 11:21 AMmatvei
01/10/2020, 11:23 AM