Skip to content

Commit

Permalink
🤖 Update Dependencies (android#116)
Browse files Browse the repository at this point in the history
* 🤖 Update Dependencies

* Fix upgrade

* Apply Spotless

* Upgrade compose compiler

* Disable ConstraintLayout lint checks as its not working. Add jvmToolchain for each module.

---------

Co-authored-by: Rebecca Franks <[email protected]>
Co-authored-by: riggaroo <[email protected]>
  • Loading branch information
3 people authored Jun 26, 2023
1 parent 96bdca8 commit e0e772f
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 58 deletions.
4 changes: 3 additions & 1 deletion bluetoothle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ android {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
jvmToolchain(17)
}
buildTypes {
getByName("debug") {
signingConfig = signingConfigs.getByName("debug")
Expand Down
4 changes: 4 additions & 0 deletions compose/recomposehighlighter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

kotlin {
jvmToolchain(17)
}

buildTypes {
getByName("debug") {
signingConfig = signingConfigs.getByName("debug")
Expand Down
7 changes: 7 additions & 0 deletions compose/snippets/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ android {
targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
jvmToolchain(17)
}

buildFeatures {
compose = true
// Disable unused AGP features
Expand All @@ -67,6 +71,9 @@ android {
excludes += "/META-INF/AL2.0"
excludes += "/META-INF/LGPL2.1"
}
lint {
lintConfig = file("lint.xml")
}
}

dependencies {
Expand Down
6 changes: 6 additions & 0 deletions compose/snippets/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="all">
<ignore regexp="src/.*/ConstraintLayoutSnippets.kt" />
</issue>
</lint>
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import androidx.navigation.compose.navigation
import androidx.navigation.compose.rememberNavController
import androidx.paging.PagingData
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.items
import androidx.paging.compose.itemKey
import coil.compose.rememberAsyncImagePainter
import com.google.android.gms.maps.model.CameraPosition
import com.google.android.gms.maps.model.LatLng
Expand Down Expand Up @@ -248,8 +248,12 @@ private object PagingExample {
fun MyScreen(flow: Flow<PagingData<String>>) {
val lazyPagingItems = flow.collectAsLazyPagingItems()
LazyColumn {
items(lazyPagingItems) {
Text("Item is $it")
items(
lazyPagingItems.itemCount,
key = lazyPagingItems.itemKey { it }
) { index ->
val item = lazyPagingItems[index]
Text("Item is $item")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Image
Expand Down Expand Up @@ -264,8 +265,11 @@ class CoordinatorLayoutActivity : ComponentActivity() {
// [START android_compose_interop_migration_common_scenarios_coordinatorlayout_step3]
composeView.setContent {
Scaffold(Modifier.fillMaxSize()) { contentPadding ->
val pagerState = rememberPagerState {
10
}
HorizontalPager(
pageCount = 10,
state = pagerState,
modifier = Modifier.padding(contentPadding)
) { /* Page contents */ }
}
Expand Down Expand Up @@ -297,8 +301,11 @@ class CoordinatorLayoutActivity : ComponentActivity() {
}
}
) { contentPadding ->
val pagerState = rememberPagerState {
10
}
HorizontalPager(
pageCount = 10,
state = pagerState,
modifier = Modifier.padding(contentPadding)
) { /* Page contents */ }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ import kotlinx.coroutines.launch
fun HorizontalPagerSample() {
// [START android_compose_layouts_pager_horizontal_basic]
// Display 10 items
HorizontalPager(pageCount = 10) { page ->
val pagerState = rememberPagerState(pageCount = {
10
})
HorizontalPager(state = pagerState) { page ->
// Our page content
Text(
text = "Page: $page",
Expand All @@ -106,7 +109,10 @@ fun HorizontalPagerSample() {
fun VerticalPagerSample() {
// [START android_compose_layouts_pager_vertical_basic]
// Display 10 items
VerticalPager(pageCount = 10) { page ->
val pagerState = rememberPagerState(pageCount = {
10
})
VerticalPager(state = pagerState) { page ->
// Our page content
Text(
text = "Page: $page",
Expand All @@ -122,9 +128,10 @@ fun VerticalPagerSample() {
fun PagerScrollToItem() {
Box {
// [START android_compose_layouts_pager_scroll]
val pagerState = rememberPagerState()

HorizontalPager(pageCount = 10, state = pagerState) { page ->
val pagerState = rememberPagerState(pageCount = {
10
})
HorizontalPager(state = pagerState) { page ->
// Our page content
Text(
text = "Page: $page",
Expand Down Expand Up @@ -153,9 +160,11 @@ fun PagerScrollToItem() {
fun PagerAnimateToItem() {
Box {
// [START android_compose_layouts_pager_scroll_animate]
val pagerState = rememberPagerState()
val pagerState = rememberPagerState(pageCount = {
10
})

HorizontalPager(pageCount = 10, state = pagerState) { page ->
HorizontalPager(state = pagerState) { page ->
// Our page content
Text(
text = "Page: $page",
Expand Down Expand Up @@ -183,7 +192,9 @@ fun PagerAnimateToItem() {
@Composable
fun PageChangesSample() {
// [START android_compose_layouts_pager_notify_page_changes]
val pagerState = rememberPagerState()
val pagerState = rememberPagerState(pageCount = {
10
})

LaunchedEffect(pagerState) {
// Collect from the a snapshotFlow reading the currentPage
Expand All @@ -195,7 +206,6 @@ fun PageChangesSample() {
}

VerticalPager(
pageCount = 10,
state = pagerState,
) { page ->
Text(text = "Page: $page")
Expand All @@ -209,7 +219,9 @@ fun PageChangesSample() {
fun PagerWithTabsExample() {
val pages = listOf("Movies", "Books", "Shows", "Fun")
// [START android_compose_layouts_pager_tabs]
val pagerState = rememberPagerState()
val pagerState = rememberPagerState(pageCount = {
pages.size
})

TabRow(
// Our selected tab is our current page
Expand All @@ -226,7 +238,6 @@ fun PagerWithTabsExample() {
}

HorizontalPager(
pageCount = pages.size,
state = pagerState,
) { page ->
Text("Page: ${pages[page]}")
Expand All @@ -238,8 +249,10 @@ fun PagerWithTabsExample() {
@Composable
fun PagerWithEffect() {
// [START android_compose_layouts_pager_transformation]
val pagerState = rememberPagerState()
HorizontalPager(pageCount = 4, state = pagerState) { page ->
val pagerState = rememberPagerState(pageCount = {
4
})
HorizontalPager(state = pagerState) { page ->
Card(
Modifier
.size(200.dp)
Expand Down Expand Up @@ -270,8 +283,11 @@ fun PagerWithEffect() {
@Preview
fun PagerStartPadding() {
// [START android_compose_layouts_pager_padding_start]
val pagerState = rememberPagerState(pageCount = {
4
})
HorizontalPager(
pageCount = 4,
state = pagerState,
contentPadding = PaddingValues(start = 64.dp),
) { page ->
// page content
Expand All @@ -283,8 +299,11 @@ fun PagerStartPadding() {
@Composable
fun PagerHorizontalPadding() {
// [START android_compose_layouts_pager_padding_horizontal]
val pagerState = rememberPagerState(pageCount = {
4
})
HorizontalPager(
pageCount = 4,
state = pagerState,
contentPadding = PaddingValues(horizontal = 32.dp),
) { page ->
// page content
Expand All @@ -296,8 +315,11 @@ fun PagerHorizontalPadding() {
@Composable
fun PagerEndPadding() {
// [START android_compose_layouts_pager_padding_end]
val pagerState = rememberPagerState(pageCount = {
4
})
HorizontalPager(
pageCount = 4,
state = pagerState,
contentPadding = PaddingValues(end = 64.dp),
) { page ->
// page content
Expand All @@ -309,8 +331,11 @@ fun PagerEndPadding() {
@Composable
fun PagerCustomSizes() {
// [START android_compose_layouts_pager_custom_size]
val pagerState = rememberPagerState(pageCount = {
4
})
HorizontalPager(
pageCount = 4,
state = pagerState,
pageSize = PageSize.Fixed(100.dp)
) { page ->
// page content
Expand All @@ -322,8 +347,11 @@ fun PagerCustomSizes() {
@Composable
fun PagerWithTabs() {
// [START android_compose_layouts_pager_with_tabs]
val pagerState = rememberPagerState(pageCount = {
4
})
HorizontalPager(
pageCount = 4
state = pagerState,
) { page ->
// page content
}
Expand All @@ -336,10 +364,10 @@ fun PagerIndicator() {
Box {
// [START android_compose_pager_indicator]
val pageCount = 10
val pagerState = rememberPagerState()

val pagerState = rememberPagerState(pageCount = {
4
})
HorizontalPager(
pageCount = pageCount,
state = pagerState
) { page ->
// Our page content
Expand Down Expand Up @@ -383,11 +411,12 @@ private val threePagesPerViewport = object : PageSize {
}
// [END android_compose_pager_custom_page_size]

@OptIn(ExperimentalFoundationApi::class)
@Preview
@Composable
private fun CustomSnapDistance() {
// [START android_compose_pager_custom_snap_distance]
val pagerState = rememberPagerState()
val pagerState = rememberPagerState(pageCount = { 10 })

val fling = PagerDefaults.flingBehavior(
state = pagerState,
Expand All @@ -397,7 +426,6 @@ private fun CustomSnapDistance() {
Column(modifier = Modifier.fillMaxSize()) {
HorizontalPager(
state = pagerState,
pageCount = 10,
pageSize = PageSize.Fixed(200.dp),
beyondBoundsPageCount = 10,
flingBehavior = fling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import androidx.paging.Pager
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.items
import androidx.paging.compose.itemKey
import coil.compose.AsyncImage
import coil.compose.rememberAsyncImagePainter
import com.example.compose.snippets.tooling.Preview
Expand Down Expand Up @@ -342,7 +342,11 @@ private object ListsSnippetsPaging {
val lazyPagingItems = pager.flow.collectAsLazyPagingItems()

LazyColumn {
items(lazyPagingItems) { message ->
items(
lazyPagingItems.itemCount,
key = lazyPagingItems.itemKey { it.id }
) { index ->
val message = lazyPagingItems[index]
if (message != null) {
MessageRow(message)
} else {
Expand Down
Loading

0 comments on commit e0e772f

Please sign in to comment.