From 3c90c76468820e0a515cb6590a989d0c49a21e6f Mon Sep 17 00:00:00 2001 From: mshdabiola Date: Thu, 6 Jun 2024 20:24:32 +0100 Subject: [PATCH] fix major bug --- composeApp/build.gradle.kts | 2 +- .../mshdabiola/skeletonapp/MainActivity.kt | 4 +- .../com/mshdabiola/skeletonapp/ui/SkApp.kt | 250 +++++++++--------- .../{desktop => skeletonapp}/MainApp.kt | 22 +- gradle/libs.versions.toml | 4 +- instuctions | 12 +- 6 files changed, 152 insertions(+), 142 deletions(-) rename composeApp/src/jvmMain/kotlin/com/mshdabiola/{desktop => skeletonapp}/MainApp.kt (74%) diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index f26019b2..284d2721 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -214,7 +214,7 @@ android { compose.desktop { application { - mainClass = "com.mshdabiola.desktop.MainAppKt" + mainClass = "com.mshdabiola.skeletonapp.MainAppKt" buildTypes.release.proguard { diff --git a/composeApp/src/androidMain/kotlin/com/mshdabiola/skeletonapp/MainActivity.kt b/composeApp/src/androidMain/kotlin/com/mshdabiola/skeletonapp/MainActivity.kt index 5b2edabb..a7a4eb20 100644 --- a/composeApp/src/androidMain/kotlin/com/mshdabiola/skeletonapp/MainActivity.kt +++ b/composeApp/src/androidMain/kotlin/com/mshdabiola/skeletonapp/MainActivity.kt @@ -132,8 +132,8 @@ class MainActivity : ComponentActivity() { Color.TRANSPARENT, ) { darkTheme }, navigationBarStyle = SystemBarStyle.auto( - lightScrim, - darkScrim, + Color.TRANSPARENT, + Color.TRANSPARENT, ) { darkTheme }, ) onDispose {} diff --git a/composeApp/src/commonMain/kotlin/com/mshdabiola/skeletonapp/ui/SkApp.kt b/composeApp/src/commonMain/kotlin/com/mshdabiola/skeletonapp/ui/SkApp.kt index 22048dff..b76fb355 100644 --- a/composeApp/src/commonMain/kotlin/com/mshdabiola/skeletonapp/ui/SkApp.kt +++ b/composeApp/src/commonMain/kotlin/com/mshdabiola/skeletonapp/ui/SkApp.kt @@ -112,164 +112,162 @@ fun SkeletonApp() { GradientColors() }, ) { - if (uiState == MainActivityUiState.Loading) { - SplashScreen() - } else { - val snackbarHostState = remember { SnackbarHostState() } - if (appState.shouldShowDrawer) { - PermanentNavigationDrawer( - drawerContent = { - CommonNavigation( - modifier = Modifier - .width(300.dp) - .fillMaxHeight(), - currentNavigation = appState.currentDestination?.route - ?: "", - onNavigate = navigator, - ) - }, - ) { - Scaffold( - modifier = Modifier.semanticsCommon {}, - containerColor = Color.Transparent, - contentWindowInsets = WindowInsets(0, 0, 0, 0), - snackbarHost = { SnackbarHost(snackbarHostState) }, - floatingActionButton = { - if (appState.currentDestination?.route == MAIN_ROUTE) { - ExtendedFloatingActionButton( - modifier = Modifier - .windowInsetsPadding(WindowInsets.safeDrawing) - .testTag("add"), - onClick = { - appState.navController.navigateToDetail( - 0, - ) - }, - ) { - Icon( - imageVector = Icons.Rounded.Add, - contentDescription = "add note", + val snackbarHostState = remember { SnackbarHostState() } + + if (appState.shouldShowDrawer) { + PermanentNavigationDrawer( + drawerContent = { + CommonNavigation( + modifier = Modifier + .width(300.dp) + .fillMaxHeight(), + currentNavigation = appState.currentDestination?.route + ?: "", + onNavigate = navigator, + ) + }, + ) { + Scaffold( + modifier = Modifier.semanticsCommon {}, + containerColor = Color.Transparent, + contentWindowInsets = WindowInsets(0, 0, 0, 0), + snackbarHost = { SnackbarHost(snackbarHostState) }, + floatingActionButton = { + if (appState.currentDestination?.route == MAIN_ROUTE) { + ExtendedFloatingActionButton( + modifier = Modifier + .windowInsetsPadding(WindowInsets.safeDrawing) + .testTag("add"), + onClick = { + appState.navController.navigateToDetail( + 0, ) + }, + ) { + Icon( + imageVector = Icons.Rounded.Add, + contentDescription = "add note", + ) // Spacer(modifier = ) - Text(text = "Add note") - } + Text(text = "Add note") } - }, + } + }, ) { padding -> - Column( - Modifier - .fillMaxSize() - .padding(padding) - .consumeWindowInsets(padding) - .windowInsetsPadding( - WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal), - ), - ) { - when (appState.windowSizeClass.widthSizeClass) { - WindowWidthSizeClass.Compact -> {} - else -> { + Column( + Modifier + .fillMaxSize() + .padding(padding) + .consumeWindowInsets(padding) + .windowInsetsPadding( + WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal), + ), + ) { + when (appState.windowSizeClass.widthSizeClass) { + WindowWidthSizeClass.Compact -> {} + else -> { // Row { // CommonNavigation ( // modifier = Modifier.weight(0.3f), // currentNavigation = appState.currentDestination?.route ?:"" // ) - SkNavHost( + SkNavHost( // modifier = Modifier.weight(0.7f), - appState = appState, - onShowSnackbar = { message, action -> - snackbarHostState.showSnackbar( - message = message, - actionLabel = action, - duration = SnackbarDuration.Short, - ) == SnackbarResult.ActionPerformed - }, - ) + appState = appState, + onShowSnackbar = { message, action -> + snackbarHostState.showSnackbar( + message = message, + actionLabel = action, + duration = SnackbarDuration.Short, + ) == SnackbarResult.ActionPerformed + }, + ) // } - } } } } } - } else { - Row { - if (appState.shouldShowNavRail) { - CommonRail( - modifier = Modifier - .width(100.dp) - .fillMaxHeight(), - currentNavigation = appState.currentDestination?.route - ?: "", - onNavigate = navigator, + } + } else { + Row { + if (appState.shouldShowNavRail) { + CommonRail( + modifier = Modifier + .width(100.dp) + .fillMaxHeight(), + currentNavigation = appState.currentDestination?.route + ?: "", + onNavigate = navigator, ) - } - Scaffold( - modifier = Modifier.semanticsCommon {}, - containerColor = Color.Transparent, - contentColor = MaterialTheme.colorScheme.onBackground, - contentWindowInsets = WindowInsets(0, 0, 0, 0), - snackbarHost = { SnackbarHost(snackbarHostState) }, - floatingActionButton = { - if (appState.currentDestination?.route == MAIN_ROUTE) { - ExtendedFloatingActionButton( - modifier = Modifier - .windowInsetsPadding(WindowInsets.safeDrawing) - .testTag("add"), - onClick = { - appState.navController.navigateToDetail( - 0, - ) - }, - ) { - Icon( - imageVector = Icons.Rounded.Add, - contentDescription = "add note", + } + Scaffold( + modifier = Modifier.semanticsCommon {}, + containerColor = Color.Transparent, + contentColor = MaterialTheme.colorScheme.onBackground, + contentWindowInsets = WindowInsets(0, 0, 0, 0), + snackbarHost = { SnackbarHost(snackbarHostState) }, + floatingActionButton = { + if (appState.currentDestination?.route == MAIN_ROUTE) { + ExtendedFloatingActionButton( + modifier = Modifier + .windowInsetsPadding(WindowInsets.safeDrawing) + .testTag("add"), + onClick = { + appState.navController.navigateToDetail( + 0, ) + }, + ) { + Icon( + imageVector = Icons.Rounded.Add, + contentDescription = "add note", + ) // Spacer(modifier = ) - Text(text = "Add note") - } + Text(text = "Add note") } - }, - bottomBar = { - if (appState.shouldShowBottomBar) { - CommonBar( - currentNavigation = appState.currentDestination?.route - ?: "", - ) { navigator(it) } - } - }, + } + }, + bottomBar = { + if (appState.shouldShowBottomBar) { + CommonBar( + currentNavigation = appState.currentDestination?.route + ?: "", + ) { navigator(it) } + } + }, ) { padding -> - Column( - Modifier - .fillMaxSize() - .padding(padding) - .consumeWindowInsets(padding) - .windowInsetsPadding( - WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal), - ), - ) { - SkNavHost( + Column( + Modifier + .fillMaxSize() + .padding(padding) + .consumeWindowInsets(padding) + .windowInsetsPadding( + WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal), + ), + ) { + SkNavHost( // modifier = Modifier.weight(0.7f), - appState = appState, - onShowSnackbar = { message, action -> - snackbarHostState.showSnackbar( - message = message, - actionLabel = action, - duration = SnackbarDuration.Short, - ) == SnackbarResult.ActionPerformed - }, - ) + appState = appState, + onShowSnackbar = { message, action -> + snackbarHostState.showSnackbar( + message = message, + actionLabel = action, + duration = SnackbarDuration.Short, + ) == SnackbarResult.ActionPerformed + }, + ) // } - } } } } + } } } diff --git a/composeApp/src/jvmMain/kotlin/com/mshdabiola/desktop/MainApp.kt b/composeApp/src/jvmMain/kotlin/com/mshdabiola/skeletonapp/MainApp.kt similarity index 74% rename from composeApp/src/jvmMain/kotlin/com/mshdabiola/desktop/MainApp.kt rename to composeApp/src/jvmMain/kotlin/com/mshdabiola/skeletonapp/MainApp.kt index 75b7f77c..ce6f2408 100644 --- a/composeApp/src/jvmMain/kotlin/com/mshdabiola/desktop/MainApp.kt +++ b/composeApp/src/jvmMain/kotlin/com/mshdabiola/skeletonapp/MainApp.kt @@ -1,6 +1,12 @@ -package com.mshdabiola.desktop +package com.mshdabiola.skeletonapp +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Window @@ -17,6 +23,8 @@ import com.mshdabiola.designsystem.string.appName import com.mshdabiola.model.Writer import com.mshdabiola.skeletonapp.di.appModule import com.mshdabiola.skeletonapp.ui.SkeletonApp +import com.mshdabiola.ui.SplashScreen +import kotlinx.coroutines.delay import org.koin.core.context.GlobalContext.startKoin import org.koin.dsl.module import java.io.File @@ -36,7 +44,17 @@ fun mainApp() { icon = defaultAppIcon, state = windowState, ) { - SkeletonApp() + val show = remember { mutableStateOf(true) } + LaunchedEffect(Unit) { + delay(2000) + show.value = false + } + Box(Modifier.fillMaxSize()) { + SkeletonApp() + if (show.value) { + SplashScreen() + } + } } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2bf4e6e9..4dcffc11 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -98,10 +98,10 @@ compose = "1.6.7" ksp = "2.0.0-1.0.21" androidx-paging = "3.3.0" -androidx-room = "2.7.0-alpha02" +androidx-room = "2.7.0-alpha03" pagingComposeAndroid = "3.3.0" roomKtx = "2.6.1" -sqlite = "2.5.0-alpha02" +sqlite = "2.5.0-alpha03" kermit = "2.0.3" slf4jSimple = "2.0.12" diff --git a/instuctions b/instuctions index 6e16b2f5..e3f9b676 100644 --- a/instuctions +++ b/instuctions @@ -1,15 +1,9 @@ ./gradlew :modules:designsystem:jacocoTestReport - ./gradlew lintDebug - ./gradlew updateDebugBadging - ./gradlew dependencyGuardBaseline - ./gradlew spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache - ./gradlew recordRoborazziDebug + ./gradlew lintDebug; ./gradlew updateReleaseBadging; ./gradlew dependencyGuardBaseline; ./gradlew spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache; ./gradlew recordRoborazziDebug + + ./gradlew dependencyGuard; ./gradlew checkReleaseBadging; ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache; ./gradlew verifyRoborazziDebug - ./gradlew dependencyGuard - ./gradlew checkDebugBadging - ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache - ./gradlew verifyRoborazziDebug ./gradlew assembleDebug -PenableComposeCompilerMetrics=true -PenableComposeCompilerReports=true ./gradlew :composeApp:generateReleaseBaselineProfile