diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3350683..f83845a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,6 +19,7 @@ android:name="com.mobiledevpro.apptemplate.MainActivity" android:exported="true" android:label="@string/app_name" + android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.AppTemplateCompose"> diff --git a/app/src/main/kotlin/com/mobiledevpro/apptemplate/MainActivity.kt b/app/src/main/kotlin/com/mobiledevpro/apptemplate/MainActivity.kt index ff5417e..815eb0d 100644 --- a/app/src/main/kotlin/com/mobiledevpro/apptemplate/MainActivity.kt +++ b/app/src/main/kotlin/com/mobiledevpro/apptemplate/MainActivity.kt @@ -4,6 +4,7 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.runtime.getValue +import androidx.core.view.WindowCompat import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.mobiledevpro.apptemplate.ui.MainApp import com.mobiledevpro.ui.theme.AppTheme @@ -13,6 +14,10 @@ class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + + //False - allows to drawing the content "edge-to-edge" + WindowCompat.setDecorFitsSystemWindows(window, false) + setContent { val darkModeState by darkModeState.collectAsStateWithLifecycle() diff --git a/app/src/main/kotlin/com/mobiledevpro/apptemplate/ui/MainApp.kt b/app/src/main/kotlin/com/mobiledevpro/apptemplate/ui/MainApp.kt index 3acd1b0..626b423 100644 --- a/app/src/main/kotlin/com/mobiledevpro/apptemplate/ui/MainApp.kt +++ b/app/src/main/kotlin/com/mobiledevpro/apptemplate/ui/MainApp.kt @@ -17,9 +17,7 @@ */ package com.mobiledevpro.apptemplate.ui -import androidx.compose.foundation.layout.safeContentPadding import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier import androidx.navigation.compose.rememberNavController import com.mobiledevpro.navigation.Screen import com.mobiledevpro.navigation.graph.RootNavGraph @@ -31,7 +29,6 @@ fun MainApp() { RootNavGraph( navController = navController, - modifier = Modifier.safeContentPadding(), startDestination = Screen.Home ) diff --git a/core/navigation/src/main/kotlin/com/mobiledevpro/navigation/Navigation.kt b/core/navigation/src/main/kotlin/com/mobiledevpro/navigation/Navigation.kt index ad67d2a..0d37a41 100644 --- a/core/navigation/src/main/kotlin/com/mobiledevpro/navigation/Navigation.kt +++ b/core/navigation/src/main/kotlin/com/mobiledevpro/navigation/Navigation.kt @@ -18,11 +18,9 @@ package com.mobiledevpro.navigation import android.util.Log -import androidx.compose.foundation.layout.safeContentPadding import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier import androidx.lifecycle.viewmodel.compose.viewModel import androidx.navigation.NavGraphBuilder import androidx.navigation.NavType @@ -83,7 +81,6 @@ fun NavGraphBuilder.homeNavGraph(onNavigateToRoot: (Screen) -> Unit) { Log.d("navigation", "homeNavGraph:nestedNavGraph") HomeNavGraph( navController = navController, - modifier = Modifier.safeContentPadding(), onNavigateToRoot = onNavigateToRoot ) } @@ -109,8 +106,7 @@ fun NavGraphBuilder.onBoardingNavGraph(onNavigateToRoot: (Screen) -> Unit) { val nestedNavGraph: @Composable () -> Unit = { OnBoardingNavGraph( - navController = navController, - modifier = Modifier.safeContentPadding() + navController = navController ) } @@ -138,8 +134,7 @@ fun NavGraphBuilder.peopleNavGraph() { val nestedNavGraph: @Composable () -> Unit = { PeopleNavGraph( - navController = navController, - modifier = Modifier.safeContentPadding() + navController = navController ) } diff --git a/core/ui/src/main/kotlin/com/mobiledevpro/ui/theme/Theme.kt b/core/ui/src/main/kotlin/com/mobiledevpro/ui/theme/Theme.kt index 8273cb4..b5ebd2c 100644 --- a/core/ui/src/main/kotlin/com/mobiledevpro/ui/theme/Theme.kt +++ b/core/ui/src/main/kotlin/com/mobiledevpro/ui/theme/Theme.kt @@ -11,6 +11,7 @@ import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalView import androidx.compose.ui.unit.dp @@ -90,11 +91,6 @@ fun AppTheme( content: @Composable () -> Unit ) { val colorScheme = when { - /*dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { - val context = LocalContext.current - if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) - }*/ - darkTheme -> DarkColorScheme else -> LightColorScheme } @@ -102,7 +98,7 @@ fun AppTheme( if (!view.isInEditMode) { SideEffect { val window = (view.context as Activity).window - window.statusBarColor = colorScheme.background.toArgb() + window.statusBarColor = Color.Transparent.toArgb() window.navigationBarColor = colorScheme.surfaceColorAtElevation(4.dp).toArgb() WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme WindowCompat.getInsetsController(window, view).isAppearanceLightNavigationBars = !darkTheme diff --git a/feature/home/src/main/kotlin/com/mobiledevpro/home/view/HomeScreen.kt b/feature/home/src/main/kotlin/com/mobiledevpro/home/view/HomeScreen.kt index 8a6e9fe..7c2749d 100644 --- a/feature/home/src/main/kotlin/com/mobiledevpro/home/view/HomeScreen.kt +++ b/feature/home/src/main/kotlin/com/mobiledevpro/home/view/HomeScreen.kt @@ -17,25 +17,25 @@ */ package com.mobiledevpro.home.view -import android.util.Log +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.foundation.layout.systemBars import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.mobiledevpro.ui.component.ScreenBackground -@OptIn(ExperimentalMaterial3Api::class) @Composable fun HomeScreen( nestedNavGraph: @Composable () -> Unit, bottomBar: @Composable () -> Unit ) { - Log.d("navigation", "HomeScreen") - - Scaffold(bottomBar = bottomBar) { paddingValues -> + Scaffold( + bottomBar = bottomBar, + contentWindowInsets = WindowInsets.systemBars + ) { paddingValues -> ScreenBackground( modifier = Modifier .fillMaxSize() diff --git a/feature/onboarding/src/main/kotlin/com/mobiledevpro/onboarding/view/OnBoardingFirstScreen.kt b/feature/onboarding/src/main/kotlin/com/mobiledevpro/onboarding/view/OnBoardingFirstScreen.kt index 9d9227d..a9d3313 100644 --- a/feature/onboarding/src/main/kotlin/com/mobiledevpro/onboarding/view/OnBoardingFirstScreen.kt +++ b/feature/onboarding/src/main/kotlin/com/mobiledevpro/onboarding/view/OnBoardingFirstScreen.kt @@ -41,7 +41,6 @@ fun OnBoardingFirstScreen() { Box( modifier = Modifier .fillMaxSize() - .padding(16.dp) .background(color = Color(0x80FFCC99)) ) { Text( diff --git a/feature/subscription/src/main/kotlin/com/mobiledevpro/subscription/SubscriptionScreen.kt b/feature/subscription/src/main/kotlin/com/mobiledevpro/subscription/SubscriptionScreen.kt index 6dfb93f..1838323 100644 --- a/feature/subscription/src/main/kotlin/com/mobiledevpro/subscription/SubscriptionScreen.kt +++ b/feature/subscription/src/main/kotlin/com/mobiledevpro/subscription/SubscriptionScreen.kt @@ -21,10 +21,12 @@ import android.widget.Toast import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.systemBars import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold @@ -47,7 +49,9 @@ fun SubscriptionScreen(onNavigateBack: () -> Unit) { Toast.makeText(context, message, Toast.LENGTH_SHORT).show() } - Scaffold { paddingValues -> + Scaffold( + contentWindowInsets = WindowInsets.systemBars + ) { paddingValues -> ScreenBackground( modifier = Modifier .fillMaxSize() @@ -111,11 +115,87 @@ fun SubscriptionScreen(onNavigateBack: () -> Unit) { } } + + /* + + Column( + modifier = Modifier + .padding(16.dp) + .verticalScroll(rememberScrollState()) + .height(IntrinsicSize.Max) + ) { + + Header() + + //If you remove Items, Footer will be centered at the screen as you could see on attached screenshots + Item(text = "Item 1") + Item(text = "Item 2") + Item(text = "Item 3") + + Box( + modifier = Modifier + .fillMaxSize() + //.background(color = Color.Blue) + ) { + Footer(modifier = Modifier.align(Alignment.Center)) + } + } + + */ + } } } +/* +@Composable +fun Header() { + Box( + modifier = Modifier + .fillMaxWidth() + .height(100.dp) + .background(color = Color.Yellow) + ) +} + +@Composable +fun Item(text: String) { + Box( + modifier = Modifier + .padding(vertical = 8.dp) + .fillMaxWidth() + .height(50.dp) + .background(color = Color.White) + + ) { + Text( + text = text, + modifier = Modifier.align(Alignment.Center), + style = MaterialTheme.typography.bodyLarge + ) + } +} + +@Composable +fun Footer(modifier: Modifier) { + Box( + modifier = modifier + .padding(vertical = 8.dp) + .fillMaxWidth() + .height(100.dp) + .background(color = Color.Gray) + + ) { + Text( + text = "Optional block", + modifier = Modifier.align(Alignment.Center), + style = MaterialTheme.typography.bodyLarge + ) + } +} + + */ @Composable fun SubsButton( diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 07d6fc9..95afc41 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,10 +19,10 @@ navigation = "2.5.3" retrofit = "2.9.0" room = "2.4.3" lifecycle = "2.6.0" -compose-bom = "2023.01.00" +compose-bom = "2023.06.01" compose-compiler = "1.4.0" coil = "2.2.2" -material3 = "1.1.0-alpha08" +material3 = "1.2.0-alpha04" koin = "3.4.2" koin-compose = "3.4.5"