https://kotlinlang.org logo
#compose
Title
# compose
a

amar_1995

11/18/2019, 12:59 PM
I want to show a box appeared from bottom after onclick. Tried using
BottomDrawerLayout
and
DropdownPopup
. Is there something else to which I can try to achieve this ?
e

emmax

11/18/2019, 1:38 PM
b

Bruno_

11/18/2019, 5:13 PM
I've asked the same question there https://kotlinlang.slack.com/archives/CJLTWPH7S/p1573481833494900 and I'm trying to implement it right now
in the end I did this
Copy code
AlertDialog(onCloseRequest = {},
            text = {
                Text("Applied successfully to $progress out of $selectedAdsSize ads")
            },
            confirmButton = {
                Button(text = "Go back to ads list", onClick = { navigateTo(Screen.AdsList) })
            }
        )
not really a snackbar but gets the job done
a

amar_1995

11/19/2019, 5:34 AM
I don't really want to implement
snackbar
. I want to implement something like
BottomSheetDialog
. So, Is there anything in compsoe ui.
m

matvei

11/19/2019, 11:41 AM
Hey 🙂 Thanks for this question. Any reason why BottomDrawerLayout didn't work for you? It's essentially a simpler version of BottomSheet, which to be implemented later.
a

amar_1995

11/19/2019, 11:50 AM
First is I am getting this error
Drawer shouldn't have infinite height
. It is solved after binding inside container. Second I cannot able to decide what to put inside
bodyContent
as I need to show bottom drawer after onClick method.
I required multiple drawer in single activity. So cannot able to decide what the body content will be
m

matvei

11/19/2019, 12:08 PM
By multiply drawers you mean Left and Bottom? Or you need several Bottom Drawers for some reason?
Glad that you solved issue with infinite height. as Body content you can put whatever you want. If your content is lazy, you can created a state and compose different UIs in BottomDrawer based on that state, e.g.
Copy code
enum class DrawerTypes { None, Settings, UserProfile}
@Composable fun Test() {
   val bottomDrawerState = +state { None }
   BottomDrawerLayout{
        ...,
        drawerContent = {
            when (bottomDrawerState) {
                Settings -> Settings()
                None -> @Composable {}
                ...
            }
        },
        bodyContent = YourAppContent({ newDrawerState:DrawerTypes ->  bottomDrawerState.value = newDrawerState })
   }
}
a

amar_1995

11/19/2019, 12:13 PM
Several bottom drawer which will open when a click will trigger.
Copy code
setContent {
		MaterialTheme(
			colors = lightThemeColors,
			typography = themeTypography
		) {
			 EditScreen()
		}
}

@Composable
fun EditScreen() {
	VerticalScroller() {
		Padding(padding = 4.dp) {
			Column {
				EditView1()
				EditView2()
			}
		}
	}|
}
In Above code editView1 and editview2 will trigger onClick which will open bottomDrawer
m

matvei

11/19/2019, 12:14 PM
So you can define different types of Drawer UIs and pass lambda to control it to your app to choose what to do on Click (you also need to open it right now)
Got it. In general IMO it makes sense to have one bottom drawer (or one BottomSheet) and provide different content for it. It definitely should be easier than it is right now, but for now approach I've described above should work
a

amar_1995

11/19/2019, 12:16 PM
Okay, Will give a try. Thanks.
@matvei BottomDrawer internally implements
StateDraggable
and BottomDrawer can open while dragging and also with onClick event. So i am not able to provide two drawerContent
m

matvei

11/22/2019, 11:20 AM
Hm, not sure I follow. Do you want to open it only on click? Then we have
gestureEnabled: Boolean
param in BotomDrawerLayout, maybe that can help.
a

amar_1995

11/22/2019, 11:49 AM
Ohh making gestureEnabled false worked for me.
m

matvei

11/22/2019, 11:54 AM
Glad it helped! Anyway it's still a Drawer and not a proper BottomSheet, but might work right now for you 🙂
a

amar_1995

11/22/2019, 11:58 AM
Yeah thanks man 🙂
7 Views