This file contains hidden or 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
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun HomeScreen( | |
navigateTo: (route: String) -> Unit | |
) { | |
val topLevelDestinations = listOf( | |
TopLevelDestination( | |
route = NavRoute.Screen1.route, | |
selectedIcon = R.drawable.home, |
This file contains hidden or 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
@Composable | |
fun Screen1() { | |
Column(modifier = Modifier.fillMaxSize()) { | |
Text(text = "One Screen", fontSize = 20.sp) | |
} | |
} | |
@Composable | |
fun Screen2() { | |
Column(modifier = Modifier.fillMaxSize()) { |
This file contains hidden or 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
@Composable | |
private fun HomeBottomBar( | |
destinations: List<TopLevelDestination>, | |
currentDestination: NavDestination?, | |
onNavigateToDestination: (route: String) -> Unit | |
) { | |
NavigationBar( | |
modifier = Modifier | |
.windowInsetsPadding( |
This file contains hidden or 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
implementation "androidx.compose.ui:ui:1.6.0-alpha03" |
This file contains hidden or 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
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() |
This file contains hidden or 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
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) |
This file contains hidden or 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
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 |