Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Compose 1.3 #1228

Merged
merged 15 commits into from
Jul 29, 2022
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ systemProp.org.gradle.internal.http.socketTimeout=120000

GROUP=com.google.accompanist
# !! No longer need to update this manually when using a Compose SNAPSHOT
VERSION_NAME=0.25.1-SNAPSHOT
VERSION_NAME=0.26.0-SNAPSHOT

POM_DESCRIPTION=Utilities for Jetpack Compose

Expand Down
9 changes: 5 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[versions]
compose = "1.2.0"
composeCompiler = "1.2.0"

compose = "1.3.0-alpha02"
composeCompiler = "1.3.0-rc01"
composesnapshot = "-" # a single character = no snapshot

# gradlePlugin and lint need to be updated together
gradlePlugin = "7.3.0-beta05"
lintMinCompose = "30.0.0"

ktlint = "0.42.1"
kotlin = "1.7.0"
ktlint = "0.46.1"
kotlin = "1.7.10"
coroutines = "1.6.0"
okhttp = "3.12.13"
coil = "1.3.2"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-rc-2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 5 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

lint {
// This lint check is crashing lint on Compose 1.3.0-alpha01
disable "DialogFragmentCallbacksDetector"
bentrengrove marked this conversation as resolved.
Show resolved Hide resolved
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down
11 changes: 6 additions & 5 deletions web/src/main/java/com/google/accompanist/web/WebView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.viewinterop.AndroidView
Expand Down Expand Up @@ -293,7 +294,7 @@ class WebViewState(webContent: WebContent) {
/**
* The content being loaded by the WebView
*/
var content by mutableStateOf<WebContent>(webContent)
var content: WebContent by mutableStateOf(webContent)

/**
* Whether the WebView is currently [LoadingState.Loading] data in its main frame (along with
Expand Down Expand Up @@ -325,7 +326,7 @@ class WebViewState(webContent: WebContent) {
* Errors could be from any resource (iframe, image, etc.), not just for the main page.
* For more fine grained control use the OnError callback of the WebView.
*/
val errorsForCurrentRequest = mutableStateListOf<WebViewError>()
val errorsForCurrentRequest: SnapshotStateList<WebViewError> = mutableStateListOf()
}

/**
Expand Down Expand Up @@ -401,7 +402,7 @@ class WebViewNavigator(private val coroutineScope: CoroutineScope) {
@Composable
fun rememberWebViewNavigator(
coroutineScope: CoroutineScope = rememberCoroutineScope()
) = remember(coroutineScope) { WebViewNavigator(coroutineScope) }
): WebViewNavigator = remember(coroutineScope) { WebViewNavigator(coroutineScope) }

/**
* A wrapper class to hold errors from the WebView.
Expand All @@ -426,7 +427,7 @@ data class WebViewError(
* Note that these headers are used for all subsequent requests of the WebView.
*/
@Composable
fun rememberWebViewState(url: String, additionalHttpHeaders: Map<String, String> = emptyMap()) =
fun rememberWebViewState(url: String, additionalHttpHeaders: Map<String, String> = emptyMap()): WebViewState =
// Rather than using .apply {} here we will recreate the state, this prevents
// a recomposition loop when the webview updates the url itself.
remember(url, additionalHttpHeaders) {
Expand All @@ -444,7 +445,7 @@ fun rememberWebViewState(url: String, additionalHttpHeaders: Map<String, String>
* @param data The uri to load in the WebView
*/
@Composable
fun rememberWebViewStateWithHTMLData(data: String, baseUrl: String? = null) =
fun rememberWebViewStateWithHTMLData(data: String, baseUrl: String? = null): WebViewState =
remember(data, baseUrl) {
WebViewState(WebContent.Data(data, baseUrl))
}