Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package to.bitkit.ui.screens.wallets.send

import androidx.compose.ui.test.assertHasNoClickAction
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
Expand All @@ -11,6 +12,7 @@ import to.bitkit.test.annotations.ComposeUi
import to.bitkit.viewmodels.SendMethod
import to.bitkit.viewmodels.SendUiState
import to.bitkit.viewmodels.previewAmountInputViewModel
import kotlin.test.assertFalse

@ComposeUi
class SendAmountContentTest {
Expand Down Expand Up @@ -107,14 +109,14 @@ class SendAmountContentTest {
}

@Test
fun whenFundingSourceSwitching_sourceAndContinueButtonsShouldBeDisabled() {
fun whenFundingSourceLoading_sourceAndContinueButtonsShouldBeDisabled() {
composeTestRule.setContent {
SendAmountContent(
nodeLifecycleState = nodeLifecycleState,
uiState = uiState.copy(
isAmountInputValid = true,
canSwitchFundingSource = true,
isSwitchingFundingSource = true,
isFundingSourceLoading = true,
),
amountInputViewModel = previewAmountInputViewModel(),
)
Expand All @@ -123,4 +125,25 @@ class SendAmountContentTest {
composeTestRule.onNodeWithTag("AssetButton-switch").assertIsNotEnabled()
composeTestRule.onNodeWithTag("ContinueAmount").assertIsNotEnabled()
}

@Test
fun whenContinueLoading_sourceButtonKeepsStyleAndIgnoresClicks() {
var eventTriggered = false
composeTestRule.setContent {
SendAmountContent(
nodeLifecycleState = nodeLifecycleState,
uiState = uiState.copy(
isAmountInputValid = true,
canSwitchFundingSource = true,
isLoading = true,
),
amountInputViewModel = previewAmountInputViewModel(),
onClickPayMethod = { eventTriggered = true },
)
}

composeTestRule.onNodeWithTag("AssetButton-switch").assertHasNoClickAction()
composeTestRule.onNodeWithTag("ContinueAmount").assertIsNotEnabled()
assertFalse(eventTriggered)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ fun ConnectionIssuesView(
modifier = Modifier.fillMaxWidth()
) {
GradientCircularProgressIndicator(
strokeWidth = 1.dp,
modifier = Modifier.size(32.dp)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import to.bitkit.ui.theme.Colors
fun GradientCircularProgressIndicator(
modifier: Modifier = Modifier,
strokeWidth: Dp = 1.dp,
tint: Color = Colors.White,
) {
val infiniteTransition = rememberInfiniteTransition(label = "rotation")
val angle by infiniteTransition.animateFloat(
Expand All @@ -35,7 +36,7 @@ fun GradientCircularProgressIndicator(
label = "rotation"
)

val brush = remember { Brush.sweepGradient(listOf(Color.Transparent, Colors.White)) }
val brush = remember { Brush.sweepGradient(listOf(Color.Transparent, tint)) }
Comment thread
ovitrif marked this conversation as resolved.
val strokeWidthPx = with(LocalDensity.current) { strokeWidth.toPx() }
val stroke = remember(strokeWidthPx) { Stroke(width = strokeWidthPx, cap = StrokeCap.Round) }

Expand Down
57 changes: 25 additions & 32 deletions app/src/main/java/to/bitkit/ui/components/NumberPadActionButton.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package to.bitkit.ui.components

import androidx.annotation.DrawableRes
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.tween
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -10,7 +12,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -20,9 +21,8 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import to.bitkit.R
import to.bitkit.ui.shared.modifiers.alphaFeedback
import to.bitkit.ui.shared.modifiers.clickableAlpha
import to.bitkit.ui.shared.util.primaryButtonStyle
import to.bitkit.ui.theme.AppButtonDefaults
import to.bitkit.ui.theme.AppThemeSurface
import to.bitkit.ui.theme.Colors

Expand All @@ -34,54 +34,47 @@ fun NumberPadActionButton(
color: Color = Colors.Brand,
enabled: Boolean = true,
isLoading: Boolean = false,
clickable: Boolean = true,
@DrawableRes icon: Int? = null,
) {
val contentPadding = PaddingValues(horizontal = 8.dp, vertical = 5.dp)
val height = 28.dp
val buttonShape = RoundedCornerShape(8.dp)

if (enabled || isLoading) {
Button(
onClick = onClick,
enabled = enabled && !isLoading,
colors = AppButtonDefaults.primaryColors.copy(
containerColor = Color.Transparent,
disabledContainerColor = Color.Transparent
),
contentPadding = contentPadding,
shape = buttonShape,
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = modifier
.requiredHeight(height)
.primaryButtonStyle(
isEnabled = enabled && !isLoading,
isEnabled = enabled || isLoading,
shape = buttonShape,
)
.alphaFeedback(enabled = enabled && !isLoading)
.animateContentSize(animationSpec = tween(durationMillis = 200))
.clickableAlpha(enabled = enabled && clickable && !isLoading, onClick = onClick)
Comment thread
ovitrif marked this conversation as resolved.
.padding(contentPadding)
) {
if (isLoading) {
GradientCircularProgressIndicator(
strokeWidth = 2.dp,
tint = color,
modifier = Modifier
.size(16.dp)
.padding(3.dp)
)
} else if (icon != null) {
Icon(
painter = painterResource(icon),
contentDescription = text,
tint = color,
modifier = Modifier.size(16.dp)
)
} else {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
if (icon != null) {
Icon(
painter = painterResource(icon),
contentDescription = text,
tint = color,
modifier = Modifier.size(16.dp)
)
}
Caption13Up(
text = text,
color = color,
)
}
}
Caption13Up(
text = text,
color = color,
)
}
} else {
Row(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/to/bitkit/ui/components/SendCell.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fun SendCell(
}
}

@Preview(showSystemUi = true)
@Preview
@Composable
private fun Preview() {
AppThemeSurface {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/to/bitkit/ui/components/SwipeToConfirm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ fun SwipeToConfirm(

val panX = remember { Animatable(0f) }
val loadingOpacity = remember { Animatable(0f) }
val contentAlpha = if (enabled || loading) 1f else 0.5f

LaunchedEffect(loading) {
loadingOpacity.animateTo(
Expand Down Expand Up @@ -110,12 +111,12 @@ fun SwipeToConfirm(
isEnabled = !loading,
shape = CircleShape,
)
.alpha(if (enabled || loading) 1f else 0.5f)
.padding(Padding)
) {
Box(
modifier = Modifier
.fillMaxSize()
.alpha(contentAlpha)
.onSizeChanged { size ->
swiperWidth = size.width.toFloat()
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/to/bitkit/ui/components/SyncNodeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ fun SyncNodeView(modifier: Modifier) {
VerticalSpacer(45.dp)

GradientCircularProgressIndicator(
strokeWidth = 1.dp,
modifier = Modifier.size(24.dp)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private fun SendAmountNodeRunning(

PrimaryButton(
text = stringResource(R.string.common__continue),
enabled = uiState.isAmountInputValid && !uiState.isSwitchingFundingSource,
enabled = uiState.isAmountInputValid && !uiState.isFundingSourceLoading,
isLoading = uiState.isLoading,
onClick = onContinue,
modifier = Modifier.testTag("ContinueAmount")
Expand Down Expand Up @@ -364,8 +364,9 @@ private fun PaymentMethodButton(
},
icon = if (uiState.canSwitchFundingSource) R.drawable.ic_transfer else null,
onClick = onClick,
enabled = uiState.canSwitchFundingSource && !uiState.isLoading,
isLoading = uiState.isSwitchingFundingSource,
enabled = uiState.canSwitchFundingSource,
isLoading = uiState.isFundingSourceLoading,
clickable = !uiState.isLoading,
modifier = Modifier
.height(28.dp)
.testTag("AssetButton-$testId")
Expand Down
Loading
Loading