132 lines
6.2 KiB
Java
132 lines
6.2 KiB
Java
package com.discord.widgets.botuikit;
|
|
|
|
import android.view.View;
|
|
import android.widget.LinearLayout;
|
|
import b.a.k.b;
|
|
import com.discord.R;
|
|
import com.discord.api.botuikit.TextComponent;
|
|
import com.discord.databinding.BotUikitTextInputBinding;
|
|
import com.discord.stores.StoreStream;
|
|
import com.google.android.material.button.MaterialButton;
|
|
import com.google.android.material.textfield.TextInputEditText;
|
|
import com.google.android.material.textfield.TextInputLayout;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import kotlin.Pair;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
/* compiled from: ModalComponent.kt */
|
|
/* loaded from: classes2.dex */
|
|
public final class ModalComponent$onViewBound$2 implements View.OnClickListener {
|
|
public final /* synthetic */ List $components;
|
|
public final /* synthetic */ View $view;
|
|
public final /* synthetic */ ModalComponent this$0;
|
|
|
|
/* compiled from: ModalComponent.kt */
|
|
/* renamed from: com.discord.widgets.botuikit.ModalComponent$onViewBound$2$2 reason: invalid class name */
|
|
/* loaded from: classes2.dex */
|
|
public static final class AnonymousClass2 extends o implements Function1<String, Unit> {
|
|
public AnonymousClass2() {
|
|
super(1);
|
|
}
|
|
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Unit invoke(String str) {
|
|
invoke2(str);
|
|
return Unit.a;
|
|
}
|
|
|
|
/* renamed from: invoke reason: avoid collision after fix types in other method */
|
|
public final void invoke2(String str) {
|
|
m.checkNotNullParameter(str, "nonce");
|
|
ModalComponent.access$setSentNonce$p(ModalComponent$onViewBound$2.this.this$0, str);
|
|
}
|
|
}
|
|
|
|
/* compiled from: ModalComponent.kt */
|
|
/* renamed from: com.discord.widgets.botuikit.ModalComponent$onViewBound$2$3 reason: invalid class name */
|
|
/* loaded from: classes2.dex */
|
|
public static final class AnonymousClass3 extends o implements Function0<Unit> {
|
|
|
|
/* compiled from: ModalComponent.kt */
|
|
/* renamed from: com.discord.widgets.botuikit.ModalComponent$onViewBound$2$3$1 reason: invalid class name */
|
|
/* loaded from: classes2.dex */
|
|
public static final class AnonymousClass1 implements Runnable {
|
|
public AnonymousClass1() {
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
ModalComponent.access$setSentNonce$p(ModalComponent$onViewBound$2.this.this$0, null);
|
|
LinearLayout linearLayout = ModalComponent.access$getBinding$p(ModalComponent$onViewBound$2.this.this$0).d;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.error");
|
|
linearLayout.setVisibility(0);
|
|
MaterialButton materialButton = ModalComponent.access$getBinding$p(ModalComponent$onViewBound$2.this.this$0).f;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.submit");
|
|
materialButton.setEnabled(true);
|
|
}
|
|
}
|
|
|
|
public AnonymousClass3() {
|
|
super(0);
|
|
}
|
|
|
|
@Override // kotlin.jvm.functions.Function0
|
|
/* renamed from: invoke reason: avoid collision after fix types in other method */
|
|
public final void invoke2() {
|
|
ModalComponent$onViewBound$2.this.$view.post(new AnonymousClass1());
|
|
}
|
|
}
|
|
|
|
public ModalComponent$onViewBound$2(ModalComponent modalComponent, List list, View view) {
|
|
this.this$0 = modalComponent;
|
|
this.$components = list;
|
|
this.$view = view;
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
ArrayList arrayList = new ArrayList();
|
|
boolean z2 = true;
|
|
for (Pair pair : this.$components) {
|
|
TextComponent textComponent = (TextComponent) pair.component1();
|
|
BotUikitTextInputBinding botUikitTextInputBinding = (BotUikitTextInputBinding) pair.component2();
|
|
TextInputEditText textInputEditText = botUikitTextInputBinding.f2083b;
|
|
m.checkNotNullExpressionValue(textInputEditText, "text.editText");
|
|
String valueOf = String.valueOf(textInputEditText.getText());
|
|
if (valueOf.length() == 0) {
|
|
if (m.areEqual(textComponent.f(), Boolean.TRUE)) {
|
|
TextInputLayout textInputLayout = botUikitTextInputBinding.d;
|
|
m.checkNotNullExpressionValue(textInputLayout, "text.layout");
|
|
textInputLayout.setError(b.k(this.this$0, R.string.form_length_error, new Object[]{Integer.valueOf(textComponent.d()), Integer.valueOf(textComponent.c())}, null, 4));
|
|
z2 = false;
|
|
arrayList.add(new Pair(textComponent.a(), valueOf));
|
|
} else {
|
|
arrayList.add(new Pair(textComponent.a(), valueOf));
|
|
}
|
|
} else if (valueOf.length() < textComponent.d() || valueOf.length() > textComponent.c()) {
|
|
TextInputLayout textInputLayout2 = botUikitTextInputBinding.d;
|
|
m.checkNotNullExpressionValue(textInputLayout2, "text.layout");
|
|
textInputLayout2.setError(b.k(this.this$0, R.string.form_length_error, new Object[]{Integer.valueOf(textComponent.d()), Integer.valueOf(textComponent.c())}, null, 4));
|
|
z2 = false;
|
|
arrayList.add(new Pair(textComponent.a(), valueOf));
|
|
} else {
|
|
arrayList.add(new Pair(textComponent.a(), valueOf));
|
|
}
|
|
}
|
|
if (z2) {
|
|
ModalComponent.access$setSentNonce$p(this.this$0, null);
|
|
LinearLayout linearLayout = ModalComponent.access$getBinding$p(this.this$0).d;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.error");
|
|
linearLayout.setVisibility(8);
|
|
MaterialButton materialButton = ModalComponent.access$getBinding$p(this.this$0).f;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.submit");
|
|
materialButton.setEnabled(false);
|
|
StoreStream.Companion.getInteractions().sendModalInteraction(this.this$0.getArgs().getModal(), arrayList, new AnonymousClass2(), new AnonymousClass3());
|
|
}
|
|
}
|
|
}
|