Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
28 changes: 28 additions & 0 deletions app/src/main/java/to/bitkit/ext/DateTime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,34 @@ fun Long.toRelativeTimeString(
}
}

fun formatInvoiceExpiryRelative(
expirySeconds: ULong,
locale: Locale = Locale.getDefault(),
): String {
val seconds = expirySeconds.toLong()
if (seconds <= 0) return ""

val uLocale = ULocale.forLocale(locale)
val numberFormat = NumberFormat.getNumberInstance(uLocale)?.apply { maximumFractionDigits = 0 }
val formatter = RelativeDateTimeFormatter.getInstance(
uLocale,
numberFormat,
RelativeDateTimeFormatter.Style.LONG,
DisplayContext.CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,
) ?: return ""

val minutes = seconds / Factor.SECONDS_TO_MINUTES.toLong()
val hours = minutes / Factor.MINUTES_TO_HOURS.toLong()
val days = hours / Factor.HOURS_TO_DAYS.toLong()

return when {
minutes < 1 -> formatter.format(seconds.toDouble(), Direction.NEXT, RelativeUnit.SECONDS)
hours < 1 -> formatter.format(minutes.toDouble(), Direction.NEXT, RelativeUnit.MINUTES)
days < 1 -> formatter.format(hours.toDouble(), Direction.NEXT, RelativeUnit.HOURS)
else -> formatter.format(days.toDouble(), Direction.NEXT, RelativeUnit.DAYS)
}
}

fun getDaysInMonth(month: LocalDate): List<LocalDate?> {
val firstDayOfMonth = LocalDate(month.year, month.month, Constants.FIRST_DAY_OF_MONTH)
val daysInMonth = month.month.toJavaMonth().length(isLeapYear(month.year))
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/to/bitkit/models/FeeRate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ enum class FeeRate(
@DrawableRes val icon: Int,
val color: Color,
) {
INSTANT(
title = R.string.fee__instant__title,
description = R.string.fee__instant__description,
shortDescription = R.string.fee__instant__shortDescription,
color = Colors.Purple,
icon = R.drawable.ic_lightning,
),
FAST(
title = R.string.fee__fast__title,
description = R.string.fee__fast__description,
Expand Down Expand Up @@ -53,7 +60,7 @@ enum class FeeRate(

fun toSpeed(): TransactionSpeed {
return when (this) {
FAST -> TransactionSpeed.Fast
INSTANT, FAST -> TransactionSpeed.Fast
NORMAL -> TransactionSpeed.Medium
MINIMUM, SLOW -> TransactionSpeed.Slow
CUSTOM -> TransactionSpeed.Custom(0u)
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/to/bitkit/ui/components/SendSectionView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package to.bitkit.ui.components

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.HorizontalDivider
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import to.bitkit.ui.theme.Colors

@Composable
fun SendSectionView(
caption: String,
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
) {
Column(modifier = modifier.fillMaxWidth()) {
Caption13Up(text = caption, color = Colors.White64)
VerticalSpacer(8.dp)
content()
VerticalSpacer(16.dp)
HorizontalDivider(modifier = Modifier.fillMaxWidth())
}
}
9 changes: 8 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 @@ -23,6 +23,8 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableFloatState
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -61,15 +63,16 @@ private val Padding = 8.dp

@Composable
fun SwipeToConfirm(
modifier: Modifier = Modifier,
text: String = stringResource(R.string.other__swipe),
color: Color = Colors.Brand,
icon: ImageVector = Icons.AutoMirrored.Default.ArrowForward,
@DrawableRes endIcon: Int = R.drawable.ic_check,
endIconTint: Color = Colors.Black,
loading: Boolean = false,
confirmed: Boolean = false,
progress: MutableFloatState? = null,
onConfirm: () -> Unit,
modifier: Modifier = Modifier,
) {
val scope = rememberCoroutineScope()
val trailColor = remember(color) { color.copy(alpha = 0.24f) }
Expand All @@ -94,6 +97,10 @@ fun SwipeToConfirm(
)
}

SideEffect {
progress?.floatValue = (panX.value / maxPanX).coerceIn(0f, 1f)
}

Box(
modifier = modifier
.requiredHeight(CircleSize + Padding * 2)
Expand Down
Loading
Loading