From d9cb8f5e7ac14e7faaeee0a9cf22ee6cba1dd6e6 Mon Sep 17 00:00:00 2001 From: Mehmedalija Karisik Date: Fri, 31 Jan 2025 16:02:22 +0100 Subject: [PATCH 1/2] Add loading while fetching payment instruction --- .../become/PremiumBecomeLegendViewModel.kt | 1 - .../become/amount/BecomeLegendAmountStage.kt | 27 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/net/primal/android/premium/legend/become/PremiumBecomeLegendViewModel.kt b/app/src/main/kotlin/net/primal/android/premium/legend/become/PremiumBecomeLegendViewModel.kt index 8035e6899..20c6d92cb 100644 --- a/app/src/main/kotlin/net/primal/android/premium/legend/become/PremiumBecomeLegendViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/premium/legend/become/PremiumBecomeLegendViewModel.kt @@ -14,7 +14,6 @@ import kotlinx.coroutines.flow.getAndUpdate import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock -import kotlinx.serialization.encodeToString import net.primal.android.core.serialization.json.NostrJson import net.primal.android.navigation.FROM_ORIGIN_PREMIUM_BADGE import net.primal.android.navigation.buyingPremiumFromOrigin diff --git a/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt b/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt index a86038450..61343bed1 100644 --- a/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt +++ b/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt @@ -34,6 +34,7 @@ import androidx.compose.ui.unit.sp import java.time.Year import net.primal.android.R import net.primal.android.core.compose.NostrUserText +import net.primal.android.core.compose.PrimalLoadingSpinner import net.primal.android.core.compose.PrimalSliderThumb import net.primal.android.core.compose.PrimalTopAppBar import net.primal.android.core.compose.UniversalAvatarThumbnail @@ -118,15 +119,23 @@ fun BecomeLegendAmountStage( Spacer(modifier = Modifier.height(48.dp)) - if (state.arePaymentInstructionsAvailable() || state.isFetchingPaymentInstructions) { - SelectAmountSlider( - state = state, - eventPublisher = eventPublisher, - ) - } else { - NoPaymentInstructionsColumn( - onRetryClick = { eventPublisher(PremiumBecomeLegendContract.UiEvent.FetchPaymentInstructions) }, - ) + Column( + modifier = Modifier.height(200.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + if (state.arePaymentInstructionsAvailable()) { + SelectAmountSlider( + state = state, + eventPublisher = eventPublisher, + ) + } else if (state.isFetchingPaymentInstructions) { + PrimalLoadingSpinner() + } else { + NoPaymentInstructionsColumn( + onRetryClick = { eventPublisher(PremiumBecomeLegendContract.UiEvent.FetchPaymentInstructions) }, + ) + } } Spacer(modifier = Modifier.height(48.dp)) From 69ba51bcc1f80aa25cc0239f6cfe2c0ea5907738 Mon Sep 17 00:00:00 2001 From: Mehmedalija Karisik Date: Fri, 31 Jan 2025 16:05:51 +0100 Subject: [PATCH 2/2] Fix detekt issues --- .../premium/legend/become/amount/BecomeLegendAmountStage.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt b/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt index 61343bed1..3733ed33d 100644 --- a/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt +++ b/app/src/main/kotlin/net/primal/android/premium/legend/become/amount/BecomeLegendAmountStage.kt @@ -125,10 +125,7 @@ fun BecomeLegendAmountStage( horizontalAlignment = Alignment.CenterHorizontally, ) { if (state.arePaymentInstructionsAvailable()) { - SelectAmountSlider( - state = state, - eventPublisher = eventPublisher, - ) + SelectAmountSlider(state = state, eventPublisher = eventPublisher) } else if (state.isFetchingPaymentInstructions) { PrimalLoadingSpinner() } else {