Update compose snapshot and r8
This commit is contained in:
1 parent
675eb1b7e2
commit
fb577dc026
5 files changed
+5
-149
No files matched your search
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package androidx.compose.material3
|
||||
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Shape
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
/**
|
||||
* <a href="https://m3.material.io/components/snackbar/overview" class="external" target="_blank">Material Design snackbar</a>.
|
||||
*
|
||||
* Snackbars provide brief messages about app processes at the bottom of the screen.
|
||||
*
|
||||
* 
|
||||
*
|
||||
* Snackbars inform users of a process that an app has performed or will perform. They appear
|
||||
* temporarily, towards the bottom of the screen. They shouldn’t interrupt the user experience,
|
||||
* and they don’t require user input to disappear.
|
||||
*
|
||||
* A Snackbar can contain a single action. "Dismiss" or "cancel" actions are optional.
|
||||
*
|
||||
* Snackbars with an action should not timeout or self-dismiss until the user performs another
|
||||
* action. Here, moving the keyboard focus indicator to navigate through interactive elements in a
|
||||
* page is not considered an action.
|
||||
*
|
||||
* This version of snackbar is designed to work with [SnackbarData] provided by the
|
||||
* [SnackbarHost], which is usually used inside of the [Scaffold].
|
||||
*
|
||||
* This components provides only the visuals of the Snackbar. If you need to show a Snackbar
|
||||
* with defaults on the screen, use [SnackbarHostState.showSnackbar]:
|
||||
*
|
||||
* @sample androidx.compose.material3.samples.ScaffoldWithSimpleSnackbar
|
||||
*
|
||||
* If you want to customize appearance of the Snackbar, you can pass your own version as a child
|
||||
* of the [SnackbarHost] to the [Scaffold]:
|
||||
*
|
||||
* @sample androidx.compose.material3.samples.ScaffoldWithCustomSnackbar
|
||||
*
|
||||
* When a [SnackbarData.visuals] sets the Snackbar's duration as [SnackbarDuration.Indefinite], it's
|
||||
* recommended to display an additional close affordance action.
|
||||
* See [SnackbarVisuals.withDismissAction]:
|
||||
*
|
||||
* @sample androidx.compose.material3.samples.ScaffoldWithIndefiniteSnackbar
|
||||
*
|
||||
* @param snackbarData data about the current snackbar showing via [SnackbarHostState]
|
||||
* @param modifier the [Modifier] to be applied to this snackbar
|
||||
* @param actionOnNewLine whether or not action should be put on a separate line. Recommended for
|
||||
* action with long action text.
|
||||
* @param shape defines the shape of this snackbar's container
|
||||
* @param containerColor the color used for the background of this snackbar. Use [Color.Transparent]
|
||||
* to have no color.
|
||||
* @param contentColor the preferred color for content inside this snackbar
|
||||
* @param actionColor the color of the snackbar's action
|
||||
* @param actionContentColor the preferred content color for the optional action inside this
|
||||
* snackbar. See [SnackbarVisuals.actionLabel].
|
||||
* @param dismissActionContentColor the preferred content color for the optional dismiss action
|
||||
* inside this snackbar. See [SnackbarVisuals.withDismissAction].
|
||||
*/
|
||||
@Composable
|
||||
fun Snackbar2(
|
||||
snackbarData: SnackbarData,
|
||||
modifier: Modifier = Modifier,
|
||||
actionOnNewLine: Boolean = false,
|
||||
shape: Shape = SnackbarDefaults.shape,
|
||||
containerColor: Color = SnackbarDefaults.color,
|
||||
contentColor: Color = SnackbarDefaults.contentColor,
|
||||
actionColor: Color = SnackbarDefaults.actionColor,
|
||||
actionContentColor: Color = SnackbarDefaults.actionContentColor,
|
||||
dismissActionContentColor: Color = SnackbarDefaults.dismissActionContentColor,
|
||||
) {
|
||||
val actionLabel = snackbarData.visuals.actionLabel
|
||||
val actionComposable: (@Composable () -> Unit)? = if (actionLabel != null) {
|
||||
@Composable {
|
||||
TextButton(
|
||||
colors = ButtonDefaults.textButtonColors(contentColor = actionColor),
|
||||
onClick = { snackbarData.performAction() },
|
||||
content = { Text(actionLabel) },
|
||||
)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val dismissActionComposable: (@Composable () -> Unit)? =
|
||||
if (snackbarData.visuals.withDismissAction) {
|
||||
@Composable {
|
||||
IconButton(
|
||||
onClick = { snackbarData.dismiss() },
|
||||
content = {
|
||||
Icon(
|
||||
Icons.Filled.Close,
|
||||
contentDescription = null,
|
||||
// Workaround for regression of https://android-review.googlesource.com/c/platform/frameworks/support/+/2881006
|
||||
tint = dismissActionContentColor,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
Snackbar(
|
||||
modifier = modifier.padding(12.dp),
|
||||
action = actionComposable,
|
||||
dismissAction = dismissActionComposable,
|
||||
actionOnNewLine = actionOnNewLine,
|
||||
shape = shape,
|
||||
containerColor = containerColor,
|
||||
contentColor = contentColor,
|
||||
actionContentColor = actionContentColor,
|
||||
dismissActionContentColor = dismissActionContentColor,
|
||||
content = { Text(snackbarData.visuals.message) },
|
||||
)
|
||||
}
|
||||
@@ -59,7 +59,6 @@ import androidx.compose.material3.NavigationDrawerItem
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.ShapeDefaults
|
||||
import androidx.compose.material3.SideDrawer
|
||||
import androidx.compose.material3.Snackbar2
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.SnackbarResult
|
||||
@@ -341,7 +340,7 @@ class MainActivity : EhActivity() {
|
||||
LocalDrawerLockHandle provides lockDrawerHandle,
|
||||
LocalSnackbarHostState provides snackbarState,
|
||||
) {
|
||||
Scaffold(snackbarHost = { SnackbarHost(snackbarState) { Snackbar2(it) } }) {
|
||||
Scaffold(snackbarHost = { SnackbarHost(snackbarState) }) {
|
||||
LocalTouchSlopProvider(Settings.touchSlopFactor.toFloat()) {
|
||||
ModalNavigationDrawer(
|
||||
drawerContent = {
|
||||
|
||||
@@ -49,7 +49,6 @@ import androidx.compose.material3.pulltorefresh.PullToRefreshContainer
|
||||
import androidx.compose.material3.pulltorefresh.PullToRefreshState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
@@ -63,12 +62,10 @@ import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.layout
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.util.lerp
|
||||
import androidx.core.view.SoftwareKeyboardControllerCompat
|
||||
import com.hippo.ehviewer.EhApplication.Companion.searchDatabase
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
@@ -237,17 +234,9 @@ fun SearchBarScreen(
|
||||
}
|
||||
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
if (isAtLeastP) {
|
||||
// Workaround IME not hiding after performing search
|
||||
// https://github.com/FooIbar/EhViewer/pull/412
|
||||
val view = LocalView.current
|
||||
val keyboardManager = remember { SoftwareKeyboardControllerCompat(view) }
|
||||
SideEffect {
|
||||
if (!active) keyboardManager.hide()
|
||||
}
|
||||
} else {
|
||||
if (!isAtLeastP) {
|
||||
// Workaround unable to exit search field
|
||||
// https://android.googlesource.com/platform/frameworks/support/+/8f81d46e2c3f37564d0b7515ec9411314645e187
|
||||
// https://issuetracker.google.com/issues/318968220
|
||||
Box(Modifier.size(1.dp).focusable())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[versions]
|
||||
aboutlibraries = "10.10.0"
|
||||
agp = "8.2.1"
|
||||
android-tools-r8 = "8.3.16-dev"
|
||||
android-tools-r8 = "8.3.31"
|
||||
androidx-activity = "1.8.2"
|
||||
androidx-appcompat = "1.6.1"
|
||||
androidx-biometric = "1.2.0-alpha05"
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ dependencyResolutionManagement {
|
||||
mavenCentral()
|
||||
maven("https://jitpack.io")
|
||||
maven("https://androidx.dev/storage/compose-compiler/repository/")
|
||||
maven("https://androidx.dev/snapshots/builds/11271125/artifacts/repository")
|
||||
maven("https://androidx.dev/snapshots/builds/11311962/artifacts/repository")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user