Skip to content

Commit 395429b

Browse files
committed
chore(lint): loosen MagicNumber checks
1 parent 7030d57 commit 395429b

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

app/src/main/java/to/bitkit/ui/screens/transfer/SpendingAmountScreen.kt

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ fun SpendingAmountScreen(
9999
.replace("{amount}", "$max"),
100100
)
101101
}
102-
val quarterAmount = min(quarter, max)
103-
viewModel.updateLimits(quarterAmount)
104-
amountInputViewModel.setSats(quarterAmount, currencies)
102+
val cappedQuarter = min(quarter, max)
103+
viewModel.updateLimits(cappedQuarter)
104+
amountInputViewModel.setSats(cappedQuarter, currencies)
105105
},
106106
onClickMaxAmount = {
107107
val newAmountSats = uiState.maxAllowedToSend
@@ -165,7 +165,6 @@ private fun SpendingAmountNodeRunning(
165165
modifier = Modifier
166166
.padding(horizontal = 16.dp)
167167
.fillMaxSize()
168-
.imePadding()
169168
.testTag("SpendingAmount")
170169
) {
171170
val amountUiState by amountInputViewModel.uiState.collectAsStateWithLifecycle()
@@ -225,15 +224,11 @@ private fun SpendingAmountNodeRunning(
225224
modifier = Modifier.testTag("SpendingAmountMax")
226225
)
227226
}
228-
HorizontalDivider()
229227

228+
HorizontalDivider()
230229
VerticalSpacer(16.dp)
231-
NumberPad(
232-
viewModel = amountInputViewModel,
233-
modifier = Modifier.fillMaxWidth()
234-
)
235230

236-
VerticalSpacer(8.dp)
231+
NumberPad(viewModel = amountInputViewModel)
237232

238233
PrimaryButton(
239234
text = stringResource(R.string.common__continue),
@@ -247,13 +242,13 @@ private fun SpendingAmountNodeRunning(
247242
}
248243
}
249244

250-
@Preview(showBackground = true)
245+
@Preview(showSystemUi = true)
251246
@Composable
252247
private fun Preview() {
253248
AppThemeSurface {
254249
Content(
255250
isNodeRunning = true,
256-
uiState = TransferToSpendingUiState(),
251+
uiState = TransferToSpendingUiState(maxAllowedToSend = 158_234, balanceAfterFee = 158_234),
257252
amountInputViewModel = previewAmountInputViewModel(),
258253
currencies = CurrencyState(),
259254
onBackClick = {},
@@ -265,13 +260,13 @@ private fun Preview() {
265260
}
266261
}
267262

268-
@Preview(showBackground = true, device = NEXUS_5)
263+
@Preview(showSystemUi = true, device = NEXUS_5)
269264
@Composable
270265
private fun PreviewSmall() {
271266
AppThemeSurface {
272267
Content(
273268
isNodeRunning = true,
274-
uiState = TransferToSpendingUiState(),
269+
uiState = TransferToSpendingUiState(maxAllowedToSend = 158_234, balanceAfterFee = 158_234),
275270
amountInputViewModel = previewAmountInputViewModel(),
276271
currencies = CurrencyState(),
277272
onBackClick = {},
@@ -283,7 +278,7 @@ private fun PreviewSmall() {
283278
}
284279
}
285280

286-
@Preview(showBackground = true, device = NEXUS_5)
281+
@Preview(showSystemUi = true, device = NEXUS_5)
287282
@Composable
288283
private fun PreviewInitializing() {
289284
AppThemeSurface {

app/src/main/java/to/bitkit/viewmodels/TransferViewModel.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import kotlin.time.Duration.Companion.seconds
4949
const val RETRY_INTERVAL_MS = 1 * 60 * 1000L // 1 minutes in ms
5050
const val GIVE_UP_MS = 30 * 60 * 1000L // 30 minutes in ms
5151
private const val EUR_CURRENCY = "EUR"
52-
private const val QUARTER = 0.25
5352

5453
@HiltViewModel
5554
class TransferViewModel @Inject constructor(
@@ -494,7 +493,7 @@ data class TransferToSpendingUiState(
494493
val balanceAfterFee: Long = 0,
495494
val isLoading: Boolean = false,
496495
) {
497-
fun balanceAfterFeeQuarter() = (balanceAfterFee.toDouble() * QUARTER).roundToLong()
496+
fun balanceAfterFeeQuarter() = (balanceAfterFee.toDouble() * 0.25).roundToLong()
498497
}
499498

500499
data class TransferValues(

config/detekt/detekt.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,14 +631,16 @@ style:
631631
ignoreNumbers:
632632
- '-1'
633633
- '0'
634+
- '0.25'
635+
- '0.5'
634636
- '1'
635637
- '2'
636638
ignoreHashCodeFunction: true
637639
ignorePropertyDeclaration: true
638-
ignoreLocalVariableDeclaration: false
640+
ignoreLocalVariableDeclaration: true
639641
ignoreConstantDeclaration: true
640642
ignoreCompanionObjectPropertyDeclaration: true
641-
ignoreAnnotation: false
643+
ignoreAnnotation: true
642644
ignoreNamedArgument: true
643645
ignoreEnums: true
644646
ignoreRanges: true

0 commit comments

Comments
 (0)