Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Enable e2e. #933

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
android:theme="@style/Theme.Sunflower">
<activity
android:name=".GardenActivity"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.google.samples.apps.sunflower
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.core.view.WindowCompat
import androidx.activity.enableEdgeToEdge
import com.google.samples.apps.sunflower.compose.SunflowerApp
import com.google.samples.apps.sunflower.ui.SunflowerTheme
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -31,12 +31,12 @@ class GardenActivity : ComponentActivity() {
super.onCreate(savedInstanceState)

// Displaying edge-to-edge
WindowCompat.setDecorFitsSystemWindows(window, false)
enableEdgeToEdge()
setContent {
SunflowerTheme {
SunflowerApp()
}
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ fun GalleryScreen(
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun GalleryScreen(
plantPictures: Flow<PagingData<UnsplashPhoto>>,
Expand Down Expand Up @@ -150,4 +149,4 @@ private class GalleryScreenPreviewParamProvider :
)
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
Expand Down Expand Up @@ -98,7 +100,7 @@ private fun GardenList(
ReportDrawnWhen { gridState.layoutInfo.totalItemsCount > 0 }
LazyVerticalGrid(
columns = GridCells.Fixed(2),
modifier,
modifier.imePadding(),
state = gridState,
contentPadding = PaddingValues(
horizontal = dimensionResource(id = R.dimen.card_side_margin),
Expand Down Expand Up @@ -257,4 +259,4 @@ private class GardenScreenPreviewParamProvider :
)
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.google.samples.apps.sunflower.compose.home

import android.util.Log
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.ExperimentalFoundationApi
Expand All @@ -26,7 +27,6 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.pager.rememberPagerState
Expand Down Expand Up @@ -85,11 +85,11 @@ fun HomeScreen(
scrollBehavior = scrollBehavior
)
}
) {
) { contentPadding ->
HomePagerScreen(
onPlantClick = onPlantClick,
pagerState = pagerState,
modifier = Modifier.padding(it)
Modifier.padding(top = contentPadding.calculateTopPadding())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you add padding to the bottom of the screen too so it can scroll the content out from underneath the bar?

Copy link
Contributor Author

@arriolac arriolac Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already padding applied so it offsets correctly when you scroll all the way down in the plant list screen: https://github.com/android/sunflower/blob/main/app/src/main/java/com/google/samples/apps/sunflower/compose/plantlist/PlantListScreen.kt#L58

...though technically it doesn't take into account imePadding so let me add that.

Edit: Done in fedc539

)
}
}
Expand All @@ -102,9 +102,6 @@ fun HomePagerScreen(
modifier: Modifier = Modifier,
pages: Array<SunflowerPage> = SunflowerPage.values()
) {
// Use Modifier.nestedScroll + rememberNestedScrollInteropConnection() here so that this
// composable participates in the nested scroll hierarchy so that HomeScreen can be used in
// use cases like a collapsing toolbar
Column(modifier) {
val coroutineScope = rememberCoroutineScope()

Expand Down Expand Up @@ -181,7 +178,7 @@ private fun HomeTopAppBar(
)
}
},
modifier = modifier.statusBarsPadding(),
modifier = modifier,
actions = {
if (pagerState.currentPage == SunflowerPage.PLANT_LIST.ordinal) {
IconButton(onClick = onFilterClick) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
package com.google.samples.apps.sunflower.compose.plantlist

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
Expand All @@ -37,6 +40,7 @@ import com.google.samples.apps.sunflower.data.Plant
@Composable
fun PlantListScreen(
onPlantClick: (Plant) -> Unit,

modifier: Modifier = Modifier,
viewModel: PlantListViewModel = hiltViewModel(),
) {
Expand All @@ -52,7 +56,8 @@ fun PlantListScreen(
) {
LazyVerticalGrid(
columns = GridCells.Fixed(2),
modifier = modifier.testTag("plant_list"),
modifier = modifier.testTag("plant_list")
.imePadding(),
contentPadding = PaddingValues(
horizontal = dimensionResource(id = R.dimen.card_side_margin),
vertical = dimensionResource(id = R.dimen.header_margin)
Expand Down Expand Up @@ -88,4 +93,4 @@ private class PlantListPreviewParamProvider : PreviewParameterProvider<List<Plan
Plant("4", "Dill", "Dill", growZoneNumber = 3),
)
)
}
}
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
##
[versions]
accessibilityTestFramework = "4.0.0"
activityCompose = "1.7.2"
activityCompose = "1.8.1"
androidGradlePlugin = "8.1.2"
benchmark = "1.1.0"
# @keep
compileSdk = "33"
compileSdk = "34"
composeLatest = "1.4.0-alpha03"
composeBom = "2023.06.01"
compose-compiler = "1.5.3"
Expand Down Expand Up @@ -52,7 +52,7 @@ retrofit = "2.9.0"
room = "2.5.2"
runner = "1.0.1"
# @keep
targetSdk = "33"
targetSdk = "34"
testExtJunit = "1.1.5"
uiAutomator = "2.2.0"
viewModelCompose = "2.5.1"
Expand Down