Rabbit-R1/switch port/java/sources/androidx/compose/foundation/ScrollKt.java
2024-05-21 17:08:36 -04:00

336 lines
22 KiB
Java

package androidx.compose.foundation;
import androidx.compose.foundation.gestures.FlingBehavior;
import androidx.compose.foundation.gestures.Orientation;
import androidx.compose.foundation.gestures.ScrollExtensionsKt;
import androidx.compose.foundation.gestures.ScrollableDefaults;
import androidx.compose.foundation.gestures.ScrollableKt;
import androidx.compose.runtime.Composer;
import androidx.compose.runtime.ComposerKt;
import androidx.compose.runtime.CompositionScopedCoroutineScopeCanceller;
import androidx.compose.runtime.EffectsKt;
import androidx.compose.runtime.ProvidableCompositionLocal;
import androidx.compose.runtime.saveable.RememberSaveableKt;
import androidx.compose.runtime.saveable.Saver;
import androidx.compose.ui.ComposedModifierKt;
import androidx.compose.ui.Modifier;
import androidx.compose.ui.platform.CompositionLocalsKt;
import androidx.compose.ui.platform.InspectableValueKt;
import androidx.compose.ui.platform.InspectorInfo;
import androidx.compose.ui.semantics.ScrollAxisRange;
import androidx.compose.ui.semantics.SemanticsModifierKt;
import androidx.compose.ui.semantics.SemanticsPropertiesKt;
import androidx.compose.ui.semantics.SemanticsPropertyReceiver;
import androidx.compose.ui.unit.LayoutDirection;
import io.sentry.protocol.SentryThread;
import kotlin.Metadata;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.EmptyCoroutineContext;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.functions.Function3;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;
import kotlinx.coroutines.CoroutineScope;
/* compiled from: Scroll.kt */
@Metadata(d1 = {"\u0000&\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\u001a\u0017\u0010\u0000\u001a\u00020\u00012\b\b\u0002\u0010\u0002\u001a\u00020\u0003H\u0007¢\u0006\u0002\u0010\u0004\u001a2\u0010\u0005\u001a\u00020\u0006*\u00020\u00062\u0006\u0010\u0007\u001a\u00020\u00012\b\b\u0002\u0010\b\u001a\u00020\t2\n\b\u0002\u0010\n\u001a\u0004\u0018\u00010\u000b2\b\b\u0002\u0010\f\u001a\u00020\t\u001a6\u0010\r\u001a\u00020\u0006*\u00020\u00062\u0006\u0010\u0007\u001a\u00020\u00012\u0006\u0010\f\u001a\u00020\t2\b\u0010\n\u001a\u0004\u0018\u00010\u000b2\u0006\u0010\u000e\u001a\u00020\t2\u0006\u0010\u000f\u001a\u00020\tH\u0002\u001a2\u0010\u0010\u001a\u00020\u0006*\u00020\u00062\u0006\u0010\u0007\u001a\u00020\u00012\b\b\u0002\u0010\b\u001a\u00020\t2\n\b\u0002\u0010\n\u001a\u0004\u0018\u00010\u000b2\b\b\u0002\u0010\f\u001a\u00020\\u0006\u0011"}, d2 = {"rememberScrollState", "Landroidx/compose/foundation/ScrollState;", "initial", "", "(ILandroidx/compose/runtime/Composer;II)Landroidx/compose/foundation/ScrollState;", "horizontalScroll", "Landroidx/compose/ui/Modifier;", SentryThread.JsonKeys.STATE, "enabled", "", "flingBehavior", "Landroidx/compose/foundation/gestures/FlingBehavior;", "reverseScrolling", "scroll", "isScrollable", "isVertical", "verticalScroll", "foundation_release"}, k = 2, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public final class ScrollKt {
public static final ScrollState rememberScrollState(final int i, Composer composer, int i2, int i3) {
composer.startReplaceableGroup(-1464256199);
ComposerKt.sourceInformation(composer, "C(rememberScrollState)73@3370L46,73@3326L90:Scroll.kt#71ulvw");
if ((i3 & 1) != 0) {
i = 0;
}
if (ComposerKt.isTraceInProgress()) {
ComposerKt.traceEventStart(-1464256199, i2, -1, "androidx.compose.foundation.rememberScrollState (Scroll.kt:72)");
}
Object[] objArr = new Object[0];
Saver<ScrollState, ?> saver = ScrollState.INSTANCE.getSaver();
Integer valueOf = Integer.valueOf(i);
composer.startReplaceableGroup(1157296644);
ComposerKt.sourceInformation(composer, "CC(remember)P(1):Composables.kt#9igjgp");
boolean changed = composer.changed(valueOf);
Object rememberedValue = composer.rememberedValue();
if (changed || rememberedValue == Composer.INSTANCE.getEmpty()) {
rememberedValue = (Function0) new Function0<ScrollState>() { // from class: androidx.compose.foundation.ScrollKt$rememberScrollState$1$1
/* JADX INFO: Access modifiers changed from: package-private */
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // kotlin.jvm.functions.Function0
public final ScrollState invoke() {
return new ScrollState(i);
}
};
composer.updateRememberedValue(rememberedValue);
}
composer.endReplaceableGroup();
ScrollState scrollState = (ScrollState) RememberSaveableKt.m2286rememberSaveable(objArr, (Saver) saver, (String) null, (Function0) rememberedValue, composer, 72, 4);
if (ComposerKt.isTraceInProgress()) {
ComposerKt.traceEventEnd();
}
composer.endReplaceableGroup();
return scrollState;
}
public static /* synthetic */ Modifier verticalScroll$default(Modifier modifier, ScrollState scrollState, boolean z, FlingBehavior flingBehavior, boolean z2, int i, Object obj) {
if ((i & 2) != 0) {
z = true;
}
if ((i & 4) != 0) {
flingBehavior = null;
}
if ((i & 8) != 0) {
z2 = false;
}
return verticalScroll(modifier, scrollState, z, flingBehavior, z2);
}
public static final Modifier verticalScroll(Modifier modifier, ScrollState state, boolean z, FlingBehavior flingBehavior, boolean z2) {
Intrinsics.checkNotNullParameter(modifier, "<this>");
Intrinsics.checkNotNullParameter(state, "state");
return scroll(modifier, state, z2, flingBehavior, z, true);
}
public static /* synthetic */ Modifier horizontalScroll$default(Modifier modifier, ScrollState scrollState, boolean z, FlingBehavior flingBehavior, boolean z2, int i, Object obj) {
if ((i & 2) != 0) {
z = true;
}
if ((i & 4) != 0) {
flingBehavior = null;
}
if ((i & 8) != 0) {
z2 = false;
}
return horizontalScroll(modifier, scrollState, z, flingBehavior, z2);
}
public static final Modifier horizontalScroll(Modifier modifier, ScrollState state, boolean z, FlingBehavior flingBehavior, boolean z2) {
Intrinsics.checkNotNullParameter(modifier, "<this>");
Intrinsics.checkNotNullParameter(state, "state");
return scroll(modifier, state, z2, flingBehavior, z, false);
}
private static final Modifier scroll(Modifier modifier, final ScrollState scrollState, final boolean z, final FlingBehavior flingBehavior, final boolean z2, final boolean z3) {
return ComposedModifierKt.composed(modifier, InspectableValueKt.isDebugInspectorInfoEnabled() ? new Function1<InspectorInfo, Unit>() { // from class: androidx.compose.foundation.ScrollKt$scroll$$inlined$debugInspectorInfo$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(InspectorInfo inspectorInfo) {
invoke2(inspectorInfo);
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2(InspectorInfo inspectorInfo) {
Intrinsics.checkNotNullParameter(inspectorInfo, "$this$null");
inspectorInfo.setName("scroll");
inspectorInfo.getProperties().set(SentryThread.JsonKeys.STATE, ScrollState.this);
inspectorInfo.getProperties().set("reverseScrolling", Boolean.valueOf(z));
inspectorInfo.getProperties().set("flingBehavior", flingBehavior);
inspectorInfo.getProperties().set("isScrollable", Boolean.valueOf(z2));
inspectorInfo.getProperties().set("isVertical", Boolean.valueOf(z3));
}
} : InspectableValueKt.getNoInspectorInfo(), new Function3<Modifier, Composer, Integer, Modifier>() { // from class: androidx.compose.foundation.ScrollKt$scroll$2
/* JADX INFO: Access modifiers changed from: package-private */
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(3);
}
@Override // kotlin.jvm.functions.Function3
public /* bridge */ /* synthetic */ Modifier invoke(Modifier modifier2, Composer composer, Integer num) {
return invoke(modifier2, composer, num.intValue());
}
public final Modifier invoke(Modifier composed, Composer composer, int i) {
Intrinsics.checkNotNullParameter(composed, "$this$composed");
composer.startReplaceableGroup(1478351300);
ComposerKt.sourceInformation(composer, "C267@9967L18,268@10015L24,301@11508L7:Scroll.kt#71ulvw");
if (ComposerKt.isTraceInProgress()) {
ComposerKt.traceEventStart(1478351300, i, -1, "androidx.compose.foundation.scroll.<anonymous> (Scroll.kt:266)");
}
OverscrollEffect overscrollEffect = ScrollableDefaults.INSTANCE.overscrollEffect(composer, 6);
composer.startReplaceableGroup(773894976);
ComposerKt.sourceInformation(composer, "CC(rememberCoroutineScope)488@20446L144:Effects.kt#9igjgp");
composer.startReplaceableGroup(-492369756);
ComposerKt.sourceInformation(composer, "CC(remember):Composables.kt#9igjgp");
Object rememberedValue = composer.rememberedValue();
if (rememberedValue == Composer.INSTANCE.getEmpty()) {
CompositionScopedCoroutineScopeCanceller compositionScopedCoroutineScopeCanceller = new CompositionScopedCoroutineScopeCanceller(EffectsKt.createCompositionCoroutineScope(EmptyCoroutineContext.INSTANCE, composer));
composer.updateRememberedValue(compositionScopedCoroutineScopeCanceller);
rememberedValue = compositionScopedCoroutineScopeCanceller;
}
composer.endReplaceableGroup();
final CoroutineScope coroutineScope = ((CompositionScopedCoroutineScopeCanceller) rememberedValue).getCoroutineScope();
composer.endReplaceableGroup();
Modifier.Companion companion = Modifier.INSTANCE;
final boolean z4 = z;
final boolean z5 = z3;
final boolean z6 = z2;
final ScrollState scrollState2 = scrollState;
Modifier semantics$default = SemanticsModifierKt.semantics$default(companion, false, new Function1<SemanticsPropertyReceiver, Unit>() { // from class: androidx.compose.foundation.ScrollKt$scroll$2$semantics$1
/* JADX INFO: Access modifiers changed from: package-private */
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(SemanticsPropertyReceiver semanticsPropertyReceiver) {
invoke2(semanticsPropertyReceiver);
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2(SemanticsPropertyReceiver semantics) {
Intrinsics.checkNotNullParameter(semantics, "$this$semantics");
SemanticsPropertiesKt.setTraversalGroup(semantics, true);
final ScrollState scrollState3 = scrollState2;
Function0<Float> function0 = new Function0<Float>() { // from class: androidx.compose.foundation.ScrollKt$scroll$2$semantics$1$accessibilityScrollState$1
/* JADX INFO: Access modifiers changed from: package-private */
{
super(0);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // kotlin.jvm.functions.Function0
public final Float invoke() {
return Float.valueOf(ScrollState.this.getValue());
}
};
final ScrollState scrollState4 = scrollState2;
ScrollAxisRange scrollAxisRange = new ScrollAxisRange(function0, new Function0<Float>() { // from class: androidx.compose.foundation.ScrollKt$scroll$2$semantics$1$accessibilityScrollState$2
/* JADX INFO: Access modifiers changed from: package-private */
{
super(0);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // kotlin.jvm.functions.Function0
public final Float invoke() {
return Float.valueOf(ScrollState.this.getMaxValue());
}
}, z4);
if (z5) {
SemanticsPropertiesKt.setVerticalScrollAxisRange(semantics, scrollAxisRange);
} else {
SemanticsPropertiesKt.setHorizontalScrollAxisRange(semantics, scrollAxisRange);
}
if (z6) {
final CoroutineScope coroutineScope2 = coroutineScope;
final boolean z7 = z5;
final ScrollState scrollState5 = scrollState2;
SemanticsPropertiesKt.scrollBy$default(semantics, null, new Function2<Float, Float, Boolean>() { // from class: androidx.compose.foundation.ScrollKt$scroll$2$semantics$1.1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(2);
}
@Override // kotlin.jvm.functions.Function2
public /* bridge */ /* synthetic */ Boolean invoke(Float f, Float f2) {
return invoke(f.floatValue(), f2.floatValue());
}
public final Boolean invoke(float f, float f2) {
BuildersKt__Builders_commonKt.launch$default(CoroutineScope.this, null, null, new C00031(z7, scrollState5, f2, f, null), 3, null);
return true;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* compiled from: Scroll.kt */
@Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002H\u008a@"}, d2 = {"<anonymous>", "", "Lkotlinx/coroutines/CoroutineScope;"}, k = 3, mv = {1, 8, 0}, xi = 48)
@DebugMetadata(c = "androidx.compose.foundation.ScrollKt$scroll$2$semantics$1$1$1", f = "Scroll.kt", i = {}, l = {288, 290}, m = "invokeSuspend", n = {}, s = {})
/* renamed from: androidx.compose.foundation.ScrollKt$scroll$2$semantics$1$1$1, reason: invalid class name and collision with other inner class name */
/* loaded from: classes.dex */
public static final class C00031 extends SuspendLambda implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
final /* synthetic */ boolean $isVertical;
final /* synthetic */ ScrollState $state;
final /* synthetic */ float $x;
final /* synthetic */ float $y;
int label;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
C00031(boolean z, ScrollState scrollState, float f, float f2, Continuation<? super C00031> continuation) {
super(2, continuation);
this.$isVertical = z;
this.$state = scrollState;
this.$y = f;
this.$x = f2;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
return new C00031(this.$isVertical, this.$state, this.$y, this.$x, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation<? super Unit> continuation) {
return ((C00031) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
if (this.$isVertical) {
ScrollState scrollState = this.$state;
Intrinsics.checkNotNull(scrollState, "null cannot be cast to non-null type androidx.compose.foundation.gestures.ScrollableState");
this.label = 1;
if (ScrollExtensionsKt.animateScrollBy$default(scrollState, this.$y, null, this, 2, null) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
ScrollState scrollState2 = this.$state;
Intrinsics.checkNotNull(scrollState2, "null cannot be cast to non-null type androidx.compose.foundation.gestures.ScrollableState");
this.label = 2;
if (ScrollExtensionsKt.animateScrollBy$default(scrollState2, this.$x, null, this, 2, null) == coroutine_suspended) {
return coroutine_suspended;
}
}
} else {
if (i != 1 && i != 2) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
return Unit.INSTANCE;
}
}
}, 1, null);
}
}
}, 1, null);
Orientation orientation = z3 ? Orientation.Vertical : Orientation.Horizontal;
Modifier.Companion companion2 = Modifier.INSTANCE;
ScrollableDefaults scrollableDefaults = ScrollableDefaults.INSTANCE;
ProvidableCompositionLocal<LayoutDirection> localLayoutDirection = CompositionLocalsKt.getLocalLayoutDirection();
ComposerKt.sourceInformationMarkerStart(composer, 2023513938, "CC:CompositionLocal.kt#9igjgp");
Object consume = composer.consume(localLayoutDirection);
ComposerKt.sourceInformationMarkerEnd(composer);
Modifier then = OverscrollKt.overscroll(ClipScrollableContainerKt.clipScrollableContainer(semantics$default, orientation), overscrollEffect).then(ScrollableKt.scrollable(companion2, scrollState, orientation, overscrollEffect, z2, scrollableDefaults.reverseDirection((LayoutDirection) consume, orientation, z), flingBehavior, scrollState.getInternalInteractionSource())).then(new ScrollingLayoutElement(scrollState, z, z3));
if (ComposerKt.isTraceInProgress()) {
ComposerKt.traceEventEnd();
}
composer.endReplaceableGroup();
return then;
}
});
}
}