package com.discord.widgets.stickers; import android.content.Context; import android.os.Bundle; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentViewModelLazyKt; import c.a.d.f0; import c.a.d.h0; import c.a.k.b; import c.d.b.a.a; import com.discord.R; import com.discord.api.channel.Channel; import com.discord.api.premium.PremiumTier; import com.discord.api.sticker.Sticker; import com.discord.api.sticker.StickerType; import com.discord.app.AppBottomSheet; import com.discord.databinding.WidgetStickerSheetBinding; import com.discord.models.sticker.dto.ModelStickerPack; import com.discord.stores.StoreStream; import com.discord.utilities.analytics.Traits; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.stickers.StickerUtils; import com.discord.utilities.viewbinding.FragmentViewBindingDelegate; import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt; import com.discord.views.LoadingButton; import com.discord.widgets.stickers.StickerSheetViewModel; import com.google.android.material.button.MaterialButton; import com.google.android.material.chip.Chip; import d0.z.d.a0; import d0.z.d.m; import kotlin.Lazy; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.reflect.KProperty; import rx.Observable; import rx.subscriptions.CompositeSubscription; /* compiled from: WidgetStickerSheet.kt */ public final class WidgetStickerSheet extends AppBottomSheet { public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetStickerSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetStickerSheetBinding;", 0)}; private static final String ANALYTICS_LOCATION = "widget_sticker_sheet_analytics_location"; public static final Companion Companion = new Companion(null); private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetStickerSheet$binding$2.INSTANCE, null, 2, null); private final Lazy viewModel$delegate; /* compiled from: WidgetStickerSheet.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final void show(FragmentManager fragmentManager, Sticker sticker, long j) { Channel findChannelById; m.checkNotNullParameter(fragmentManager, "fragmentManager"); m.checkNotNullParameter(sticker, "sticker"); if (sticker.k() == StickerType.STANDARD && (findChannelById = StoreStream.Companion.getChannels().findChannelById(j)) != null) { String str = findChannelById.f() == 0 ? "DM Channel" : Traits.Location.Page.GUILD_CHANNEL; WidgetStickerSheet widgetStickerSheet = new WidgetStickerSheet(); Bundle bundle = new Bundle(); bundle.putSerializable("com.discord.intent.extra.EXTRA_STICKER", sticker); bundle.putString(WidgetStickerSheet.ANALYTICS_LOCATION, str); widgetStickerSheet.setArguments(bundle); widgetStickerSheet.show(fragmentManager, WidgetStickerSheet.class.getName()); } } } public WidgetStickerSheet() { super(false, 1, null); WidgetStickerSheet$viewModel$2 widgetStickerSheet$viewModel$2 = new WidgetStickerSheet$viewModel$2(this); f0 f0Var = new f0(this); this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(StickerSheetViewModel.class), new WidgetStickerSheet$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetStickerSheet$viewModel$2)); } public static final /* synthetic */ void access$configureUI(WidgetStickerSheet widgetStickerSheet, StickerSheetViewModel.ViewState viewState) { widgetStickerSheet.configureUI(viewState); } public static final /* synthetic */ Bundle access$getArgumentsOrDefault$p(WidgetStickerSheet widgetStickerSheet) { return widgetStickerSheet.getArgumentsOrDefault(); } private final void configureUI(StickerSheetViewModel.ViewState viewState) { ModelStickerPack component1 = viewState.component1(); Sticker component2 = viewState.component2(); PremiumTier component3 = viewState.component3(); boolean component4 = viewState.component4(); TextView textView = getBinding().d; m.checkNotNullExpressionValue(textView, "binding.stickerSheetStickerName"); textView.setText(component2.h()); if (!viewState.isUserPremiumTier2()) { getBinding().f2090c.setOnClickListener(new WidgetStickerSheet$configureUI$1(this)); } TextView textView2 = getBinding().f2090c; m.checkNotNullExpressionValue(textView2, "binding.stickerSheetStickerInfo"); boolean z2 = true; int i = 0; textView2.setText((component4 || viewState.isUserPremiumTier2() || component1.isPremiumPack()) ? b.k(this, R.string.sticker_popout_pack_info_premium, new Object[]{component1.getName()}, null, 4) : !component1.canBePurchased() ? b.k(this, R.string.sticker_popout_pack_info_unavailable, new Object[]{component1.getName()}, null, 4) : b.e(this, R.string.sticker_popout_pack_info, new Object[]{component1.getName(), String.valueOf(StickerUtils.INSTANCE.calculatePremiumStickerPackDiscount())}, WidgetStickerSheet$configureUI$2.INSTANCE)); try { getBinding().h.d(component1.getStickers().get(0), 0); getBinding().i.d(component1.getStickers().get(1), 0); getBinding().j.d(component1.getStickers().get(2), 0); getBinding().k.d(component1.getStickers().get(3), 0); } catch (IndexOutOfBoundsException unused) { } Bundle arguments = getArguments(); String string = arguments != null ? arguments.getString(ANALYTICS_LOCATION) : null; StickerUtils stickerUtils = StickerUtils.INSTANCE; Context requireContext = requireContext(); m.checkNotNullExpressionValue(requireContext, "requireContext()"); getBinding().b.setText(stickerUtils.getStickerPackPremiumPriceLabel(requireContext, component1, component3, component4)); getBinding().b.setIsLoading(false); getBinding().b.setOnClickListener(new WidgetStickerSheet$configureUI$3(this, component4, component3)); LoadingButton loadingButton = getBinding().b; m.checkNotNullExpressionValue(loadingButton, "binding.stickerSheetBuyButton"); if (!component4 || component3 == PremiumTier.TIER_2) { z2 = false; } loadingButton.setVisibility(z2 ? 0 : 8); MaterialButton materialButton = getBinding().e; m.checkNotNullExpressionValue(materialButton, "binding.stickerSheetViewButton"); materialButton.setVisibility(component4 ? 0 : 8); getBinding().e.setOnClickListener(new WidgetStickerSheet$configureUI$4(this, component4, component3, component2, string, component1)); RelativeLayout relativeLayout = getBinding().g; m.checkNotNullExpressionValue(relativeLayout, "binding.stickerSheetViewLimitedContainer"); if (!component1.isLimitedPack()) { i = 8; } relativeLayout.setVisibility(i); Chip chip = getBinding().f; m.checkNotNullExpressionValue(chip, "binding.stickerSheetViewLimitedChip"); Context requireContext2 = requireContext(); m.checkNotNullExpressionValue(requireContext2, "requireContext()"); chip.setText(stickerUtils.getLimitedTimeLeftString(requireContext2, component1.getStoreListing())); } private final WidgetStickerSheetBinding getBinding() { return (WidgetStickerSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]); } private final StickerSheetViewModel getViewModel() { return (StickerSheetViewModel) this.viewModel$delegate.getValue(); } public static final void show(FragmentManager fragmentManager, Sticker sticker, long j) { Companion.show(fragmentManager, sticker, j); } @Override // com.discord.app.AppBottomSheet public void bindSubscriptions(CompositeSubscription compositeSubscription) { m.checkNotNullParameter(compositeSubscription, "compositeSubscription"); Observable q = ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null).q(); m.checkNotNullExpressionValue(q, "viewModel\n .obser… .distinctUntilChanged()"); ObservableExtensionsKt.appSubscribe$default(q, WidgetStickerSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetStickerSheet$bindSubscriptions$1(this), 62, (Object) null); } @Override // com.discord.app.AppBottomSheet public int getContentViewResId() { return R.layout.widget_sticker_sheet; } }