Skip to content

Commit

Permalink
Merge branch 'main' into renovate/google-5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ashdavies authored May 24, 2024
2 parents a568158 + e519623 commit af83e48
Show file tree
Hide file tree
Showing 17 changed files with 347 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:

- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.8.3
terraform_version: 1.8.4

- id: init
run: terraform -chdir=terraform init
Expand Down
3 changes: 3 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=17.0.10-tem
3 changes: 2 additions & 1 deletion after-party/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ kotlin {
implementation(projects.httpClient)
implementation(projects.httpCommon)
implementation(projects.identityManager)
implementation(projects.pagingCompose)
implementation(projects.platformScaffold)
implementation(projects.platformSupport)
implementation(projects.sqlDriver)
Expand All @@ -29,6 +30,7 @@ kotlin {
implementation(compose.runtime)
implementation(compose.ui)

implementation(libs.androidx.paging.common)
implementation(libs.coil.compose)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.kotlinx.datetime)
Expand All @@ -37,7 +39,6 @@ kotlin {
implementation(libs.ktor.client.mock)
implementation(libs.ktor.http)
implementation(libs.ktor.io)
implementation(libs.paging.compose.common)
implementation(libs.slack.circuit.foundation)
implementation(libs.sqldelight.runtime)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package io.ashdavies.activity

import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import app.cash.paging.PagingData
import app.cash.paging.compose.LazyPagingItems
import app.cash.paging.compose.collectAsLazyPagingItems
import androidx.paging.PagingData
import io.ashdavies.events.AndroidMakers
import io.ashdavies.events.DroidconBerlin
import io.ashdavies.events.DroidconLondon
import io.ashdavies.events.Event
import io.ashdavies.paging.LazyPagingItems
import io.ashdavies.paging.collectAsLazyPagingItems
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package io.ashdavies.activity
import androidx.compose.runtime.Composable
import androidx.compose.runtime.RememberObserver
import androidx.compose.runtime.Stable
import app.cash.paging.ExperimentalPagingApi
import app.cash.paging.Pager
import app.cash.paging.cachedIn
import app.cash.paging.compose.collectAsLazyPagingItems
import androidx.paging.ExperimentalPagingApi
import androidx.paging.Pager
import androidx.paging.cachedIn
import com.slack.circuit.retained.rememberRetained
import io.ashdavies.events.Event
import io.ashdavies.events.rememberEventPager
import io.ashdavies.paging.collectAsLazyPagingItems
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,22 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import app.cash.paging.LoadStateError
import app.cash.paging.LoadStateLoading
import app.cash.paging.compose.LazyPagingItems
import androidx.paging.LoadState
import com.slack.circuit.runtime.CircuitUiState
import com.slack.circuit.runtime.screen.Screen
import io.ashdavies.android.fade
import io.ashdavies.events.Event
import io.ashdavies.paging.LazyPagingItems
import io.ashdavies.parcelable.Parcelable
import io.ashdavies.parcelable.Parcelize

private val <T : Any> LazyPagingItems<T>.errorMessage: String?
get() = (loadState.append as? LoadStateError)
get() = (loadState.append as? LoadState.Error)
?.error
?.message

private val <T : Any> LazyPagingItems<T>.isRefreshing: Boolean
get() = loadState.refresh is LoadStateLoading
get() = loadState.refresh is LoadState.Loading

@Parcelize
internal object ActivityScreen : Parcelable, Screen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package io.ashdavies.events

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import app.cash.paging.ExperimentalPagingApi
import app.cash.paging.Pager
import app.cash.paging.PagingConfig
import androidx.paging.ExperimentalPagingApi
import androidx.paging.Pager
import androidx.paging.PagingConfig
import io.ashdavies.compose.LocalPlaygroundDatabase
import io.ashdavies.http.LocalHttpClient
import io.ashdavies.network.todayAsString
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.ashdavies.events

import app.cash.paging.PagingSource
import app.cash.paging.PagingState
import androidx.paging.PagingSource
import androidx.paging.PagingState
import io.ashdavies.network.todayAsString

internal class EventsPagingSource(private val queries: EventsQueries) : PagingSource<String, Event>() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.ashdavies.events

import app.cash.paging.ExperimentalPagingApi
import app.cash.paging.LoadType
import app.cash.paging.PagingState
import app.cash.paging.RemoteMediator
import androidx.paging.ExperimentalPagingApi
import androidx.paging.LoadType
import androidx.paging.PagingState
import androidx.paging.RemoteMediator
import io.ktor.client.network.sockets.SocketTimeoutException
import io.ashdavies.events.Event as DatabaseEvent
import io.ashdavies.http.common.models.Event as ApiEvent
Expand Down
3 changes: 2 additions & 1 deletion dominion-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ kotlin {
sourceSets.commonMain.dependencies {
implementation(projects.circuitSupport)
implementation(projects.httpClient)
implementation(projects.pagingCompose)
implementation(projects.platformScaffold)
implementation(projects.platformSupport)
implementation(projects.sqlDriver)
Expand All @@ -23,11 +24,11 @@ kotlin {
implementation(compose.runtime)
implementation(compose.ui)

implementation(libs.androidx.paging.common)
implementation(libs.coil.compose)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.kotlinx.serialization.json)
implementation(libs.ktor.client.core)
implementation(libs.paging.compose.common)
implementation(libs.slack.circuit.foundation)
}
}
Expand Down
9 changes: 4 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
android-compileSdk = "34"
android-minSdk = "24"
androidx-activity = "1.9.0"
androidx-paging = "3.3.0"
apollo-graphql = "2.5.14"
cash-sqldelight = "2.0.2"
coil-kt = "3.0.0-alpha06"
Expand All @@ -17,7 +18,6 @@ kotlin-jvmTarget = "17"
kotlinx-coroutines = "1.8.1"
kotlinx-serialization = "1.6.3"
ktor = "2.3.11"
paging-compose = "3.2.0-alpha05-0.2.3"
pinterest-ktlint = "0.50.0"
slack-circuit = "0.20.0"

Expand All @@ -28,6 +28,7 @@ androidx-activity-compose = { module = "androidx.activity:activity-compose", ver
androidx-annotation = "androidx.annotation:annotation:1.8.0"
androidx-core-splashscreen = "androidx.core:core-splashscreen:1.0.1"
androidx-credentials-auth = "androidx.credentials:credentials-play-services-auth:1.2.2"
androidx-paging-common = { module = "androidx.paging:paging-common", version.ref = "androidx-paging" }

apollo-graphql-coroutines-support = { module = "com.apollographql.apollo:apollo-coroutines-support", version.ref = "apollo-graphql" }
apollo-graphql-runtime = { module = "com.apollographql.apollo:apollo-runtime", version.ref = "apollo-graphql" }
Expand Down Expand Up @@ -60,7 +61,7 @@ google-auth-http = "com.google.auth:google-auth-library-oauth2-http:1.23.0"
google-cloud-bom = "com.google.cloud:libraries-bom:26.39.0"
google-cloud-firestore = { module = "com.google.cloud:google-cloud-firestore" }

google-firebase-admin = "com.google.firebase:firebase-admin:9.2.0"
google-firebase-admin = "com.google.firebase:firebase-admin:9.3.0"
google-firebase-bom = "com.google.firebase:firebase-bom:33.0.0"
google-firebase-appcheck-playintegrity = { module = "com.google.firebase:firebase-appcheck-playintegrity" }

Expand Down Expand Up @@ -103,8 +104,6 @@ ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.
ktor-server-test-host = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" }

mosaic-runtime = "com.jakewharton.mosaic:mosaic-runtime:0.11.0"

paging-compose-common = { module = "app.cash.paging:paging-compose-common", version.ref = "paging-compose" }
pinterest-ktlint-bom = "com.pinterest.ktlint:ktlint-bom:1.2.1"

slack-circuit-foundation = { module = "com.slack.circuit:circuit-foundation", version.ref = "slack-circuit" }
Expand All @@ -128,7 +127,7 @@ android-library = { id = "com.android.library", version.ref = "google-android" }
apollo-graphql = { id = "com.apollographql.apollo", version.ref = "apollo-graphql" }
build-config = "com.github.gmazzo.buildconfig:5.3.5"
cash-sqldelight = { id = "app.cash.sqldelight", version.ref = "cash-sqldelight" }
dependency-analysis = "com.autonomousapps.dependency-analysis:1.31.0"
dependency-analysis = "com.autonomousapps.dependency-analysis:1.32.0"
detekt = "io.gitlab.arturbosch.detekt:1.23.6"
google-services = { id = "com.google.gms.google-services", version.ref = "google-services" }
gradle-doctor = "com.osacky.doctor:0.10.0"
Expand Down
16 changes: 16 additions & 0 deletions paging-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id("io.ashdavies.compose")
id("io.ashdavies.default")
}

android {
namespace = "io.ashdavies.paging.compose"
}

kotlin {
sourceSets.commonMain.dependencies {
implementation(compose.runtime)

implementation(libs.androidx.paging.common)
}
}
2 changes: 2 additions & 0 deletions paging-compose/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />
101 changes: 101 additions & 0 deletions paging-compose/src/commonMain/kotlin/io/ashdavies/paging/LazyList.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package io.ashdavies.paging

/*
* Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import androidx.compose.runtime.Composable

@DslMarker
public annotation class LazyScopeMarker

/**
* Receiver scope being used by the item content parameter of [LazyColumn].
*/
@LazyScopeMarker
public interface LazyItemScope

/**
* Receiver scope.
*/
@LazyScopeMarker
public interface LazyListScope {
/**
* Adds a single item.
*
* @param itemId a stable and unique id representing the item. The value may not be less than
* or equal to -2^62, as these values are reserved by the Glance API. Specifying the list
* item ids will maintain the scroll position through app widget updates in Android S and
* higher devices.
* @param content the content of the item
*/
public fun item(itemId: Long = UNSPECIFIED_ITEM_ID, content: @Composable LazyItemScope.() -> Unit)

/**
* Adds a [count] of items.
*
* @param count the count of items
* @param itemId a factory of stable and unique ids representing the item. The value may not be
* less than or equal to -2^62, as these values are reserved by the Glance API. Specifying
* the list item ids will maintain the scroll position through app widget updates in Android
* S and higher devices.
* @param itemContent the content displayed by a single item
*/
public fun items(
count: Int,
itemId: ((index: Int) -> Long) = { UNSPECIFIED_ITEM_ID },
itemContent: @Composable LazyItemScope.(index: Int) -> Unit,
)

public companion object {
internal const val UNSPECIFIED_ITEM_ID: Long = Long.MIN_VALUE
}
}

/**
* Adds a list of items.
*
* @param items the data list
* @param itemId a factory of stable and unique ids representing the item. The value may not be
* less than or equal to -2^62, as these values are reserved by the Glance API. Specifying
* the list item ids will maintain the scroll position through app widget updates in Android
* S and higher devices.
* @param itemContent the content displayed by a single item
*/
internal inline fun <T> LazyListScope.items(
items: List<T>,
crossinline itemId: ((item: T) -> Long) = { LazyListScope.UNSPECIFIED_ITEM_ID },
crossinline itemContent: @Composable LazyItemScope.(item: T) -> Unit,
) = items(items.size, { index: Int -> itemId(items[index]) }) {
itemContent(items[it])
}

/**
* Adds an array of items.
*
* @param items the data array
* @param itemId a factory of stable and unique list item ids. Using the same itemId for multiple
* items in the array is not allowed. When you specify the itemId, the scroll position will be
* maintained based on the itemId, which means if you add/remove items before the current visible
* item the item with the given itemId will be kept as the first visible one.
* @param itemContent the content displayed by a single item
*/
internal inline fun <T> LazyListScope.items(
items: Array<T>,
noinline itemId: ((item: T) -> Long) = { LazyListScope.UNSPECIFIED_ITEM_ID },
crossinline itemContent: @Composable LazyItemScope.(item: T) -> Unit,
) = items(items.size, { index: Int -> itemId(items[index]) }) {
itemContent(items[it])
}
Loading

0 comments on commit af83e48

Please sign in to comment.