Skip to content

Instantly share code, notes, and snippets.

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.*
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.animation.core.animateDp
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.updateTransition
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.material.Button
import androidx.compose.material.Text
@Before
fun beforeAll() {
composeRule.setContent {
var flag by remember {
mutableStateOf(false)
}
if (flag) {
throw IllegalArgumentException()
}
Button(onClick = { flag = true }) {
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@OptIn(ExperimentalMaterialNavigationApi::class)
@Composable
private fun AppNavigation() {
val navController = rememberNavController()
val bottomSheetNavigator = rememberBottomSheetNavigator()
navController.navigatorProvider += bottomSheetNavigator
ModalBottomSheetLayout(
bottomSheetNavigator = bottomSheetNavigator,
) {
NavHost(navController = navController, startDestination = Screen.A.route) { // Open 'A'
sealed class Screen(val route: String) {
object A : Screen("A")
object B : Screen("B") // bottomSheet
object C : Screen("C") // bottomSheet
object D : Screen("D")
}
@OptIn(ExperimentalMaterialNavigationApi::class)
@Composable
@OptIn(ExperimentalMaterialNavigationApi::class)
@Composable
private fun AppNavigation() {
val navController = rememberNavController()
val bottomSheetNavigator = rememberBottomSheetNavigator()
navController.navigatorProvider += bottomSheetNavigator
ModalBottomSheetLayout(
bottomSheetNavigator = bottomSheetNavigator,
) {
@theapache64
theapache64 / gen-cfd-icon.sh
Created March 19, 2021 15:05
To generate launcher icons for compose desktop
function gen-cfd-icon(){
ICON_DIR="src/main/resources/drawables/launcher_icons"
mkdir -p $ICON_DIR
ORIGINAL_ICON="$ICON_DIR/original.png"
cp "$1" "$ORIGINAL_ICON"
# Linux
echo "🌀 Creating icon for Linux..."
convert -resize x128 "$ORIGINAL_ICON" "$ICON_DIR/linux.png"
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.desktop.Window
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.size
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.material.TextField
enum class Screens {
Red, Green, Blue
}
fun main(args: Array<String>) {
Window {
var currentScreen by remember { mutableStateOf(Screens.Red) }
Row {