Merge "Adding device class breakopints (http://b/216019537)" into main

pull/2/head
Ran Nachmany 3 years ago committed by Gerrit Code Review
commit 668d6cc91c

@ -121,10 +121,12 @@ dependencies {
coreLibraryDesugaring libs.android.desugarJdkLibs
implementation libs.androidx.activity.compose
implementation libs.androidx.core.ktx
implementation libs.androidx.appcompat
implementation libs.androidx.core.ktx
implementation libs.androidx.compose.material.window
implementation libs.androidx.hilt.navigation.compose
implementation libs.androidx.navigation.compose
implementation libs.androidx.window.manager
implementation libs.material3
implementation libs.hilt.android

@ -16,6 +16,7 @@
package com.google.samples.apps.nowinandroid.ui
import androidx.compose.material.window.ExperimentalMaterialWindowApi
import androidx.compose.ui.test.assertIsOn
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
@ -36,6 +37,7 @@ import org.junit.rules.TemporaryFolder
/**
* Tests all the navigation flows that are handled by the navigation library.
*/
@ExperimentalMaterialWindowApi
@HiltAndroidTest
class NavigationTest {

@ -19,10 +19,13 @@ package com.google.samples.apps.nowinandroid
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material.window.ExperimentalMaterialWindowApi
import androidx.compose.material.window.rememberSizeClass
import androidx.core.view.WindowCompat
import com.google.samples.apps.nowinandroid.ui.NiaApp
import dagger.hilt.android.AndroidEntryPoint
@ExperimentalMaterialWindowApi
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@ -32,6 +35,6 @@ class MainActivity : ComponentActivity() {
// including IME animations
WindowCompat.setDecorFitsSystemWindows(window, false)
setContent { NiaApp() }
setContent { NiaApp(rememberSizeClass()) }
}
}

@ -17,6 +17,7 @@
package com.google.samples.apps.nowinandroid.ui
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.captionBarPadding
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBarsPadding
@ -32,11 +33,15 @@ import androidx.compose.material.icons.outlined.Bookmarks
import androidx.compose.material.icons.outlined.Grid3x3
import androidx.compose.material.icons.outlined.Upcoming
import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material.window.SizeClass
import androidx.compose.material.window.WidthSizeClass
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationRail
import androidx.compose.material3.NavigationRailItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
@ -56,7 +61,7 @@ import com.google.samples.apps.nowinandroid.core.ui.theme.NiaTheme
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun NiaApp() {
fun NiaApp(windowSizeClass: SizeClass) {
NiaTheme {
val navController = rememberNavController()
val navigationActions = remember(navController) {
@ -70,20 +75,51 @@ fun NiaApp() {
Scaffold(
modifier = Modifier,
bottomBar = {
// TODO: Only show on small screens
NiABottomBar(navigationActions, currentRoute)
},
if (windowSizeClass.width == WidthSizeClass.Compact) NiABottomBar(
navigationActions = navigationActions,
currentRoute = currentRoute
)
}
) { padding ->
Surface(Modifier.fillMaxSize()) {
Surface(Modifier.fillMaxSize().statusBarsPadding()) {
Row {
if (windowSizeClass.width != WidthSizeClass.Compact) {
NiANavRail(
navigationActions = navigationActions,
currentRoute = currentRoute
)
}
NiaNavGraph(
navController = navController,
modifier = Modifier
.statusBarsPadding()
.padding(padding)
modifier = Modifier.padding(padding)
)
}
}
}
}
}
@Composable
private fun NiANavRail(
navigationActions: NiaNavigationActions,
currentRoute: String
) {
NavigationRail {
TOP_LEVEL_DESTINATIONS.forEach { destination ->
val selected = currentRoute == destination.route
NavigationRailItem(
selected = selected,
onClick = { navigationActions.navigateToTopLevelDestination(destination.route) },
icon = {
Icon(
if (selected) destination.selectedIcon else destination.unselectedIcon,
contentDescription = null
)
},
label = { Text(stringResource(destination.iconTextId)) }
)
}
}
}
@Composable

@ -27,6 +27,7 @@ buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://androidx.dev/snapshots/builds/8273139/artifacts/repository' }
}
dependencies {

@ -5,6 +5,7 @@ androidGradlePlugin = "7.0.3"
androidxActivity = "1.4.0"
androidxAppCompat = "1.3.0"
androidxCompose = "1.2.0-alpha03"
androidxMaterialWindow = "1.2.0-SNAPSHOT"
androidxComposeMaterial3 = "1.0.0-alpha03"
androidxCore = "1.7.0"
androidxDataStore = "1.0.0"
@ -12,6 +13,7 @@ androidxEspresso = "3.3.0"
androidxHiltNavigationCompose = "1.0.0-rc01"
androidxLifecycle = "2.4.0"
androidxNavigation = "2.4.0-rc01"
androidxWindowManager = "1.0.0"
androidxTest = "1.4.0"
androidxTestExt = "1.1.2"
hilt = "2.41"
@ -42,6 +44,7 @@ androidx-activity-compose = { group = "androidx.activity", name = "activity-comp
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" }
androidx-compose-foundation-layout = { group = "androidx.compose.foundation", name = "foundation-layout", version.ref = "androidxCompose" }
androidx-compose-material = { group = "androidx.compose.material", name = "material", version.ref = "androidxCompose" }
androidx-compose-material-window = {group = "androidx.compose.material", name = "material-window", version.ref="androidxMaterialWindow"}
androidx-compose-material-iconsExtended = { group = "androidx.compose.material", name = "material-icons-extended", version.ref = "androidxCompose" }
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "androidxComposeMaterial3" }
androidx-compose-runtime = { group = "androidx.compose.runtime", name = "runtime", version.ref = "androidxCompose" }
@ -56,6 +59,7 @@ androidx-dataStore = { group = "androidx.datastore", name = "datastore", version
androidx-hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" }
androidx-lifecycle-viewModelCompose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "androidxLifecycle" }
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "androidxNavigation" }
androidx-window-manager = {module = "androidx.window:window", version.ref = "androidxWindowManager"}
androidx-test-core = { group = "androidx.test", name = "core", version.ref = "androidxTest" }
androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidxEspresso" }
androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidxTest" }

@ -24,6 +24,7 @@ dependencyResolutionManagement {
google()
mavenCentral()
gradlePluginPortal()
maven { url 'https://androidx.dev/snapshots/builds/8273139/artifacts/repository' }
}
}
rootProject.name = "nowinandroid"

Loading…
Cancel
Save