mirror of
https://github.com/bitwarden/android.git
synced 2025-02-17 04:19:54 +03:00
Apply minor compose optimizations (#967)
This commit is contained in:
parent
8b7d1bfc51
commit
ce9dff7ab2
7 changed files with 22 additions and 19 deletions
|
@ -35,6 +35,7 @@ fun BitwardenCircularCountdownIndicator(
|
|||
delayMillis = 0,
|
||||
easing = LinearOutSlowInEasing,
|
||||
),
|
||||
label = "CircularCountDownAnimation",
|
||||
)
|
||||
|
||||
Box(
|
||||
|
|
|
@ -25,8 +25,8 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
|||
fun BitwardenIconButtonWithResource(
|
||||
iconRes: IconResource,
|
||||
onClick: () -> Unit,
|
||||
isEnabled: Boolean = true,
|
||||
modifier: Modifier = Modifier,
|
||||
isEnabled: Boolean = true,
|
||||
) {
|
||||
FilledIconButton(
|
||||
modifier = modifier.semantics(mergeDescendants = true) {},
|
||||
|
|
|
@ -61,8 +61,8 @@ fun BitwardenMultiSelectButton(
|
|||
options: ImmutableList<String>,
|
||||
selectedOption: String?,
|
||||
onOptionSelected: (String) -> Unit,
|
||||
isEnabled: Boolean = true,
|
||||
modifier: Modifier = Modifier,
|
||||
isEnabled: Boolean = true,
|
||||
supportingText: String? = null,
|
||||
tooltip: TooltipData? = null,
|
||||
) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import androidx.compose.material3.OutlinedTextField
|
|||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
|
@ -63,7 +63,7 @@ fun BitwardenTextField(
|
|||
isError: Boolean = false,
|
||||
visualTransformation: VisualTransformation = VisualTransformation.None,
|
||||
) {
|
||||
var widthPx by remember { mutableStateOf(0) }
|
||||
var widthPx by remember { mutableIntStateOf(0) }
|
||||
|
||||
val currentTextStyle = textStyle ?: LocalTextStyle.current
|
||||
val formattedText = if (shouldAddCustomLineBreaks) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import androidx.compose.material3.TopAppBarScrollBehavior
|
|||
import androidx.compose.material3.rememberTopAppBarState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
|
@ -580,7 +581,7 @@ private fun PasswordLengthSliderItem(
|
|||
minValue: Int,
|
||||
maxValue: Int,
|
||||
) {
|
||||
var sliderValue by remember { mutableStateOf(length.coerceIn(minValue, maxValue)) }
|
||||
var sliderValue by remember { mutableIntStateOf(length.coerceIn(minValue, maxValue)) }
|
||||
var labelTextWidth by remember { mutableStateOf(Dp.Unspecified) }
|
||||
|
||||
val density = LocalDensity.current
|
||||
|
@ -1389,17 +1390,17 @@ private data class PassphraseHandlers(
|
|||
private data class UsernameTypeHandlers(
|
||||
val onUsernameTooltipClicked: () -> Unit,
|
||||
) {
|
||||
companion object {
|
||||
fun create(viewModel: GeneratorViewModel): UsernameTypeHandlers {
|
||||
return UsernameTypeHandlers(
|
||||
onUsernameTooltipClicked = {
|
||||
viewModel.trySendAction(
|
||||
GeneratorAction.MainType.Username.UsernameType.TooltipClick,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
companion object {
|
||||
fun create(viewModel: GeneratorViewModel): UsernameTypeHandlers {
|
||||
return UsernameTypeHandlers(
|
||||
onUsernameTooltipClicked = {
|
||||
viewModel.trySendAction(
|
||||
GeneratorAction.MainType.Username.UsernameType.TooltipClick,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,7 @@ import androidx.compose.material3.MaterialTheme
|
|||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
|
@ -51,7 +51,7 @@ fun PasswordHistoryListItem(
|
|||
) {
|
||||
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
var widthPx by remember(label) { mutableStateOf(0) }
|
||||
var widthPx by remember(label) { mutableIntStateOf(0) }
|
||||
val textStyle = LocalNonMaterialTypography.current.sensitiveInfoMedium
|
||||
val formattedText = label.withLineBreaksAtWidth(
|
||||
widthPx = widthPx.toFloat(),
|
||||
|
|
|
@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.width
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableLongStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
|
@ -45,7 +46,7 @@ fun AddSendCustomDateChooser(
|
|||
// This tracks just the time component (hours and minutes) and ignores the higher level
|
||||
// components. 0 representing midnight and counting up from there.
|
||||
var timeMillis: Long by remember {
|
||||
mutableStateOf(
|
||||
mutableLongStateOf(
|
||||
currentZonedDateTime.orNow().let {
|
||||
it.hour.hours.inWholeMilliseconds + it.minute.minutes.inWholeMilliseconds
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue