Skip to content

Instantly share code, notes, and snippets.

View chiragthummar's full-sized avatar
🎯
Focusing

Chirag Thummar chiragthummar

🎯
Focusing
View GitHub Profile
@Composable
fun BottomNavWithScaffold(
) {
val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = NavRoute.Home.route,
modifier = Modifier.fillMaxSize()
) {
composable(route = NavRoute.Home.route) {
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HomeScreen(
navigateTo: (route: String) -> Unit
) {
val topLevelDestinations = listOf(
TopLevelDestination(
route = NavRoute.Screen1.route,
selectedIcon = R.drawable.home,
@Composable
fun HomeNavHost(
modifier: Modifier,
navController: NavHostController,
startDestination: String,
navigateTo: (route: String) -> Unit
) {
NavHost(
navController = navController, startDestination = startDestination, modifier = modifier
@Composable
fun Screen1() {
Column(modifier = Modifier.fillMaxSize()) {
Text(text = "One Screen", fontSize = 20.sp)
}
}
@Composable
fun Screen2() {
Column(modifier = Modifier.fillMaxSize()) {
@Composable
private fun HomeBottomBar(
destinations: List<TopLevelDestination>,
currentDestination: NavDestination?,
onNavigateToDestination: (route: String) -> Unit
) {
NavigationBar(
modifier = Modifier
.windowInsetsPadding(
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
implementation "androidx.compose.ui:ui:1.6.0-alpha03"
val picture = remember { Picture() }
Column(
modifier = Modifier
.padding(padding)
.fillMaxSize()
.drawWithCache {
// Example that shows how to redirect rendering to an Android Picture and then
// draw the picture into the original destination
val width = this.size.width.toInt()
val height = this.size.height.toInt()
private fun createBitmapFromPicture(picture: Picture): Bitmap {
val bitmap = Bitmap.createBitmap(
picture.width,
picture.height,
Bitmap.Config.ARGB_8888
)
val canvas = android.graphics.Canvas(bitmap)
canvas.drawColor(android.graphics.Color.WHITE)
canvas.drawPicture(picture)
package com.example.jetpackcomposeplayground
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Picture
import android.net.Uri
import android.os.Environment
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding