-
-
Save ashar-7/a0127714d9f94112426474b4b0cb808b to your computer and use it in GitHub Desktop.
BottomDrawerLayout with FAB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Bundle | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.compose.foundation.Text | |
import androidx.compose.foundation.clickable | |
import androidx.compose.foundation.layout.Arrangement | |
import androidx.compose.foundation.layout.Column | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.material.* | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.platform.setContent | |
import androidx.ui.tooling.preview.Preview | |
import com.example.bottomdrawerwithfab.ui.BottomDrawerWithFabTheme | |
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
BottomDrawerWithFabTheme { | |
// A surface container using the 'background' color from the theme | |
Surface(color = MaterialTheme.colors.background) { | |
val drawerState = rememberBottomDrawerState(initialValue = BottomDrawerValue.Closed) | |
BottomDrawerLayout( | |
drawerContent = { Greeting("Drawer") }, | |
drawerState = drawerState | |
) { | |
Column( | |
modifier = Modifier.fillMaxSize(), | |
verticalArrangement = Arrangement.SpaceBetween | |
) { | |
Greeting("BottomDrawerLayout", onClick = { drawerState.open() }) | |
ExtendedFloatingActionButton( | |
text = { Greeting("FAB") }, | |
onClick = { drawerState.open() } | |
) | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
@Composable | |
fun Greeting(name: String, onClick: () -> Unit = {}) { | |
Text(text = "Hello $name!", modifier = Modifier.clickable(onClick = onClick)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment