#1420 Code cleanup

Closes #1420
This commit is contained in:
Milan Cerovsky 2024-09-04 17:21:55 +02:00
parent f03fc08a8b
commit 31d98eb0a4
3 changed files with 9 additions and 40 deletions

View File

@ -93,7 +93,7 @@ class AndroidPreferenceProvider private constructor(
.map { getString(key) } .map { getString(key) }
companion object { companion object {
fun newStandard( suspend fun newStandard(
context: Context, context: Context,
filename: String filename: String
): PreferenceProvider { ): PreferenceProvider {
@ -103,7 +103,10 @@ class AndroidPreferenceProvider private constructor(
*/ */
val singleThreadedDispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher() val singleThreadedDispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
val sharedPreferences = context.getSharedPreferences(filename, Context.MODE_PRIVATE) val sharedPreferences =
withContext(singleThreadedDispatcher) {
context.getSharedPreferences(filename, Context.MODE_PRIVATE)
}
return AndroidPreferenceProvider(sharedPreferences, singleThreadedDispatcher) return AndroidPreferenceProvider(sharedPreferences, singleThreadedDispatcher)
} }

View File

@ -47,7 +47,6 @@ import co.electriccoin.zcash.ui.design.theme.internal.ButtonColors
import co.electriccoin.zcash.ui.design.theme.internal.DarkTertiaryButtonColors import co.electriccoin.zcash.ui.design.theme.internal.DarkTertiaryButtonColors
import co.electriccoin.zcash.ui.design.theme.internal.LightTertiaryButtonColors import co.electriccoin.zcash.ui.design.theme.internal.LightTertiaryButtonColors
import co.electriccoin.zcash.ui.design.util.StringResource import co.electriccoin.zcash.ui.design.util.StringResource
import co.electriccoin.zcash.ui.design.util.getValue
@Preview @Preview
@Composable @Composable
@ -270,37 +269,6 @@ fun PrimaryButton(
} }
} }
@Composable
@Suppress("LongParameterList", "LongMethod")
fun PrimaryButton(
state: ButtonState,
modifier: Modifier = Modifier,
minWidth: Dp = ZcashTheme.dimens.buttonWidth,
minHeight: Dp = ZcashTheme.dimens.buttonHeight,
buttonColors: ButtonColors = ZcashTheme.colors.primaryButtonColors,
textStyle: TextStyle = ZcashTheme.extendedTypography.buttonText,
outerPaddingValues: PaddingValues =
PaddingValues(
horizontal = ZcashTheme.dimens.spacingNone,
vertical = ZcashTheme.dimens.spacingSmall
),
contentPaddingValues: PaddingValues = PaddingValues(all = 17.dp)
) {
PrimaryButton(
onClick = state.onClick,
text = state.text.getValue(),
enabled = state.isEnabled,
showProgressBar = state.isLoading,
modifier = modifier,
minWidth = minWidth,
minHeight = minHeight,
buttonColors = buttonColors,
textStyle = textStyle,
outerPaddingValues = outerPaddingValues,
contentPaddingValues = contentPaddingValues,
)
}
@Composable @Composable
@Suppress("LongParameterList", "LongMethod") @Suppress("LongParameterList", "LongMethod")
fun SecondaryButton( fun SecondaryButton(

View File

@ -158,8 +158,10 @@ data class RadioButtonState(
val onClick: () -> Unit, val onClick: () -> Unit,
) )
@Suppress("UnusedPrivateMember")
@PreviewScreens
@Composable @Composable
private fun RadioButtonPreview() = private fun RadioButtonPreview() = ZcashTheme {
BlankBgColumn { BlankBgColumn {
var isChecked by remember { mutableStateOf(false) } var isChecked by remember { mutableStateOf(false) }
@ -184,8 +186,4 @@ private fun RadioButtonPreview() =
), ),
) )
} }
}
@Suppress("UnusedPrivateMember")
@PreviewScreens
@Composable
private fun RadioButtonPreviewLight() = ZcashTheme { RadioButtonPreview() }