mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Remove BigIcon loading state.
Loading is rendered in the buttons now.
This commit is contained in:
+8
-29
@@ -21,10 +21,8 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.semantics.ProgressBarRangeInfo
|
|
||||||
import androidx.compose.ui.semantics.contentDescription
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
import androidx.compose.ui.semantics.focused
|
import androidx.compose.ui.semantics.focused
|
||||||
import androidx.compose.ui.semantics.progressBarRangeInfo
|
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
@@ -45,7 +43,6 @@ import io.element.android.libraries.designsystem.components.button.BackButton
|
|||||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
import io.element.android.libraries.designsystem.theme.components.Button
|
import io.element.android.libraries.designsystem.theme.components.Button
|
||||||
import io.element.android.libraries.designsystem.theme.components.InvisibleButton
|
|
||||||
import io.element.android.libraries.designsystem.theme.components.Text
|
import io.element.android.libraries.designsystem.theme.components.Text
|
||||||
import io.element.android.libraries.designsystem.theme.components.TextButton
|
import io.element.android.libraries.designsystem.theme.components.TextButton
|
||||||
import io.element.android.libraries.designsystem.theme.components.TopAppBar
|
import io.element.android.libraries.designsystem.theme.components.TopAppBar
|
||||||
@@ -103,19 +100,11 @@ fun IncomingVerificationView(
|
|||||||
private fun IncomingVerificationHeader(step: Step, request: VerificationRequest.Incoming) {
|
private fun IncomingVerificationHeader(step: Step, request: VerificationRequest.Incoming) {
|
||||||
val iconStyle = when (step) {
|
val iconStyle = when (step) {
|
||||||
Step.Canceled -> BigIcon.Style.AlertSolid
|
Step.Canceled -> BigIcon.Style.AlertSolid
|
||||||
is Step.Initial -> if (step.isWaiting) {
|
is Step.Initial -> when (request) {
|
||||||
BigIcon.Style.Loading
|
|
||||||
} else {
|
|
||||||
when (request) {
|
|
||||||
is VerificationRequest.Incoming.OtherSession -> BigIcon.Style.Default(CompoundIcons.LockSolid())
|
is VerificationRequest.Incoming.OtherSession -> BigIcon.Style.Default(CompoundIcons.LockSolid())
|
||||||
is VerificationRequest.Incoming.User -> BigIcon.Style.Default(CompoundIcons.UserProfileSolid())
|
is VerificationRequest.Incoming.User -> BigIcon.Style.Default(CompoundIcons.UserProfileSolid())
|
||||||
}
|
}
|
||||||
}
|
is Step.Verifying -> BigIcon.Style.Default(CompoundIcons.ReactionSolid())
|
||||||
is Step.Verifying -> if (step.isWaiting) {
|
|
||||||
BigIcon.Style.Loading
|
|
||||||
} else {
|
|
||||||
BigIcon.Style.Default(CompoundIcons.ReactionSolid())
|
|
||||||
}
|
|
||||||
Step.Completed -> BigIcon.Style.SuccessSolid
|
Step.Completed -> BigIcon.Style.SuccessSolid
|
||||||
Step.Failure -> BigIcon.Style.AlertSolid
|
Step.Failure -> BigIcon.Style.AlertSolid
|
||||||
}
|
}
|
||||||
@@ -159,10 +148,6 @@ private fun IncomingVerificationHeader(step: Step, request: VerificationRequest.
|
|||||||
.semantics(mergeDescendants = true) {
|
.semantics(mergeDescendants = true) {
|
||||||
contentDescription = timeLimitMessage
|
contentDescription = timeLimitMessage
|
||||||
focused = true
|
focused = true
|
||||||
if (iconStyle == BigIcon.Style.Loading) {
|
|
||||||
// Same code than Modifier.progressSemantics()
|
|
||||||
progressBarRangeInfo = ProgressBarRangeInfo.Indeterminate
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.focusable(),
|
.focusable(),
|
||||||
iconStyle = iconStyle,
|
iconStyle = iconStyle,
|
||||||
@@ -232,45 +217,39 @@ private fun IncomingVerificationBottomMenu(
|
|||||||
|
|
||||||
when (step) {
|
when (step) {
|
||||||
is Step.Initial -> {
|
is Step.Initial -> {
|
||||||
if (step.isWaiting) {
|
|
||||||
// Show nothing
|
|
||||||
} else {
|
|
||||||
VerificationBottomMenu {
|
VerificationBottomMenu {
|
||||||
Button(
|
Button(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
text = stringResource(CommonStrings.action_start_verification),
|
text = stringResource(CommonStrings.action_start_verification),
|
||||||
|
enabled = !step.isWaiting,
|
||||||
|
showProgress = step.isWaiting,
|
||||||
onClick = { eventSink(IncomingVerificationViewEvents.StartVerification) },
|
onClick = { eventSink(IncomingVerificationViewEvents.StartVerification) },
|
||||||
)
|
)
|
||||||
TextButton(
|
TextButton(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
text = stringResource(CommonStrings.action_ignore),
|
text = stringResource(CommonStrings.action_ignore),
|
||||||
|
enabled = !step.isWaiting,
|
||||||
onClick = { eventSink(IncomingVerificationViewEvents.IgnoreVerification) },
|
onClick = { eventSink(IncomingVerificationViewEvents.IgnoreVerification) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
is Step.Verifying -> {
|
is Step.Verifying -> {
|
||||||
if (step.isWaiting) {
|
|
||||||
// Add invisible buttons to keep the same screen layout
|
|
||||||
VerificationBottomMenu {
|
|
||||||
InvisibleButton()
|
|
||||||
InvisibleButton()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
VerificationBottomMenu {
|
VerificationBottomMenu {
|
||||||
Button(
|
Button(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
text = stringResource(R.string.screen_session_verification_they_match),
|
text = stringResource(R.string.screen_session_verification_they_match),
|
||||||
|
enabled = !step.isWaiting,
|
||||||
|
showProgress = step.isWaiting,
|
||||||
onClick = { eventSink(IncomingVerificationViewEvents.ConfirmVerification) },
|
onClick = { eventSink(IncomingVerificationViewEvents.ConfirmVerification) },
|
||||||
)
|
)
|
||||||
TextButton(
|
TextButton(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
text = stringResource(R.string.screen_session_verification_they_dont_match),
|
text = stringResource(R.string.screen_session_verification_they_dont_match),
|
||||||
|
enabled = !step.isWaiting,
|
||||||
onClick = { eventSink(IncomingVerificationViewEvents.DeclineVerification) },
|
onClick = { eventSink(IncomingVerificationViewEvents.DeclineVerification) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Step.Canceled,
|
Step.Canceled,
|
||||||
is Step.Completed,
|
is Step.Completed,
|
||||||
is Step.Failure -> {
|
is Step.Failure -> {
|
||||||
|
|||||||
+8
-21
@@ -24,10 +24,8 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.semantics.ProgressBarRangeInfo
|
|
||||||
import androidx.compose.ui.semantics.contentDescription
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
import androidx.compose.ui.semantics.focused
|
import androidx.compose.ui.semantics.focused
|
||||||
import androidx.compose.ui.semantics.progressBarRangeInfo
|
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@@ -129,21 +127,17 @@ fun OutgoingVerificationView(
|
|||||||
private fun OutgoingVerificationHeader(step: Step, request: VerificationRequest.Outgoing) {
|
private fun OutgoingVerificationHeader(step: Step, request: VerificationRequest.Outgoing) {
|
||||||
val iconStyle = when (step) {
|
val iconStyle = when (step) {
|
||||||
Step.Loading -> error("Should not happen")
|
Step.Loading -> error("Should not happen")
|
||||||
|
Step.AwaitingOtherDeviceResponse,
|
||||||
Step.Initial -> when (request) {
|
Step.Initial -> when (request) {
|
||||||
is VerificationRequest.Outgoing.CurrentSession -> BigIcon.Style.Default(CompoundIcons.Devices())
|
is VerificationRequest.Outgoing.CurrentSession -> BigIcon.Style.Default(CompoundIcons.Devices())
|
||||||
is VerificationRequest.Outgoing.User -> BigIcon.Style.Default(CompoundIcons.LockSolid())
|
is VerificationRequest.Outgoing.User -> BigIcon.Style.Default(CompoundIcons.LockSolid())
|
||||||
}
|
}
|
||||||
Step.AwaitingOtherDeviceResponse -> BigIcon.Style.Loading
|
|
||||||
Step.Canceled -> BigIcon.Style.AlertSolid
|
Step.Canceled -> BigIcon.Style.AlertSolid
|
||||||
Step.Ready -> BigIcon.Style.Default(CompoundIcons.ReactionSolid())
|
Step.Ready -> BigIcon.Style.Default(CompoundIcons.ReactionSolid())
|
||||||
Step.Completed -> BigIcon.Style.SuccessSolid
|
Step.Completed -> BigIcon.Style.SuccessSolid
|
||||||
is Step.Verifying -> {
|
is Step.Verifying -> {
|
||||||
if (step.state is AsyncData.Loading<Unit>) {
|
|
||||||
BigIcon.Style.Loading
|
|
||||||
} else {
|
|
||||||
BigIcon.Style.Default(CompoundIcons.ReactionSolid())
|
BigIcon.Style.Default(CompoundIcons.ReactionSolid())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
is Step.Exit -> return
|
is Step.Exit -> return
|
||||||
}
|
}
|
||||||
val titleTextId = when (step) {
|
val titleTextId = when (step) {
|
||||||
@@ -201,10 +195,6 @@ private fun OutgoingVerificationHeader(step: Step, request: VerificationRequest.
|
|||||||
.semantics(mergeDescendants = true) {
|
.semantics(mergeDescendants = true) {
|
||||||
contentDescription = timeLimitMessage
|
contentDescription = timeLimitMessage
|
||||||
focused = true
|
focused = true
|
||||||
if (iconStyle == BigIcon.Style.Loading) {
|
|
||||||
// Same code than Modifier.progressSemantics()
|
|
||||||
progressBarRangeInfo = ProgressBarRangeInfo.Indeterminate
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.focusable(),
|
.focusable(),
|
||||||
iconStyle = iconStyle,
|
iconStyle = iconStyle,
|
||||||
@@ -264,11 +254,15 @@ private fun OutgoingVerificationViewBottomMenu(
|
|||||||
|
|
||||||
when (verificationViewState) {
|
when (verificationViewState) {
|
||||||
Step.Loading -> error("Should not happen")
|
Step.Loading -> error("Should not happen")
|
||||||
|
is Step.AwaitingOtherDeviceResponse,
|
||||||
is Step.Initial -> {
|
is Step.Initial -> {
|
||||||
VerificationBottomMenu {
|
VerificationBottomMenu {
|
||||||
|
val isWaiting = verificationViewState is Step.AwaitingOtherDeviceResponse
|
||||||
Button(
|
Button(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
text = stringResource(CommonStrings.action_start_verification),
|
text = stringResource(CommonStrings.action_start_verification),
|
||||||
|
enabled = !isWaiting,
|
||||||
|
showProgress = isWaiting,
|
||||||
onClick = { eventSink(OutgoingVerificationViewEvents.RequestVerification) },
|
onClick = { eventSink(OutgoingVerificationViewEvents.RequestVerification) },
|
||||||
)
|
)
|
||||||
InvisibleButton()
|
InvisibleButton()
|
||||||
@@ -298,19 +292,13 @@ private fun OutgoingVerificationViewBottomMenu(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is Step.AwaitingOtherDeviceResponse -> Unit
|
|
||||||
is Step.Verifying -> {
|
is Step.Verifying -> {
|
||||||
if (isVerifying) {
|
|
||||||
// Add invisible buttons to keep the same screen layout
|
|
||||||
VerificationBottomMenu {
|
|
||||||
InvisibleButton()
|
|
||||||
InvisibleButton()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
VerificationBottomMenu {
|
VerificationBottomMenu {
|
||||||
Button(
|
Button(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
text = stringResource(R.string.screen_session_verification_they_match),
|
text = stringResource(R.string.screen_session_verification_they_match),
|
||||||
|
enabled = !isVerifying,
|
||||||
|
showProgress = isVerifying,
|
||||||
onClick = {
|
onClick = {
|
||||||
eventSink(OutgoingVerificationViewEvents.ConfirmVerification)
|
eventSink(OutgoingVerificationViewEvents.ConfirmVerification)
|
||||||
},
|
},
|
||||||
@@ -323,7 +311,6 @@ private fun OutgoingVerificationViewBottomMenu(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
is Step.Completed -> {
|
is Step.Completed -> {
|
||||||
VerificationBottomMenu {
|
VerificationBottomMenu {
|
||||||
Button(
|
Button(
|
||||||
@@ -334,7 +321,7 @@ private fun OutgoingVerificationViewBottomMenu(
|
|||||||
InvisibleButton()
|
InvisibleButton()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is Step.Exit -> return
|
is Step.Exit -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-21
@@ -34,7 +34,6 @@ import io.element.android.compound.theme.ElementTheme
|
|||||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator
|
|
||||||
import io.element.android.libraries.designsystem.theme.components.Icon
|
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||||
import io.element.android.libraries.ui.strings.CommonStrings
|
import io.element.android.libraries.ui.strings.CommonStrings
|
||||||
|
|
||||||
@@ -82,11 +81,6 @@ object BigIcon {
|
|||||||
* A success style with a tinted background.
|
* A success style with a tinted background.
|
||||||
*/
|
*/
|
||||||
data object SuccessSolid : Style
|
data object SuccessSolid : Style
|
||||||
|
|
||||||
/**
|
|
||||||
* A loading style with the default background color.
|
|
||||||
*/
|
|
||||||
data object Loading : Style
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +104,6 @@ object BigIcon {
|
|||||||
Style.Success -> Color.Transparent
|
Style.Success -> Color.Transparent
|
||||||
Style.AlertSolid -> ElementTheme.colors.bgCriticalSubtle
|
Style.AlertSolid -> ElementTheme.colors.bgCriticalSubtle
|
||||||
Style.SuccessSolid -> ElementTheme.colors.bgSuccessSubtle
|
Style.SuccessSolid -> ElementTheme.colors.bgSuccessSubtle
|
||||||
Style.Loading -> ElementTheme.colors.bgSubtleSecondary
|
|
||||||
}
|
}
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
@@ -119,21 +112,12 @@ object BigIcon {
|
|||||||
.background(backgroundColor),
|
.background(backgroundColor),
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
) {
|
) {
|
||||||
if (style is Style.Loading) {
|
|
||||||
CircularProgressIndicator(
|
|
||||||
modifier = Modifier.size(27.dp),
|
|
||||||
color = ElementTheme.colors.iconSecondary,
|
|
||||||
trackColor = Color.Transparent,
|
|
||||||
strokeWidth = 3.dp,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
val icon = when (style) {
|
val icon = when (style) {
|
||||||
is Style.Default -> style.vectorIcon
|
is Style.Default -> style.vectorIcon
|
||||||
Style.Alert,
|
Style.Alert,
|
||||||
Style.AlertSolid -> CompoundIcons.ErrorSolid()
|
Style.AlertSolid -> CompoundIcons.ErrorSolid()
|
||||||
Style.Success,
|
Style.Success,
|
||||||
Style.SuccessSolid -> CompoundIcons.CheckCircleSolid()
|
Style.SuccessSolid -> CompoundIcons.CheckCircleSolid()
|
||||||
Style.Loading -> error("This should never be reached")
|
|
||||||
}
|
}
|
||||||
val contentDescription = when (style) {
|
val contentDescription = when (style) {
|
||||||
is Style.Default -> style.contentDescription
|
is Style.Default -> style.contentDescription
|
||||||
@@ -141,7 +125,6 @@ object BigIcon {
|
|||||||
Style.AlertSolid -> stringResource(CommonStrings.common_error)
|
Style.AlertSolid -> stringResource(CommonStrings.common_error)
|
||||||
Style.Success,
|
Style.Success,
|
||||||
Style.SuccessSolid -> stringResource(CommonStrings.common_success)
|
Style.SuccessSolid -> stringResource(CommonStrings.common_success)
|
||||||
Style.Loading -> error("This should never be reached")
|
|
||||||
}
|
}
|
||||||
val iconTint = when (style) {
|
val iconTint = when (style) {
|
||||||
is Style.Default -> if (style.useCriticalTint) {
|
is Style.Default -> if (style.useCriticalTint) {
|
||||||
@@ -155,9 +138,7 @@ object BigIcon {
|
|||||||
Style.AlertSolid -> ElementTheme.colors.iconCriticalPrimary
|
Style.AlertSolid -> ElementTheme.colors.iconCriticalPrimary
|
||||||
Style.Success,
|
Style.Success,
|
||||||
Style.SuccessSolid -> ElementTheme.colors.iconSuccessPrimary
|
Style.SuccessSolid -> ElementTheme.colors.iconSuccessPrimary
|
||||||
Style.Loading -> error("This should never be reached")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Icon(
|
Icon(
|
||||||
modifier = Modifier.size(32.dp),
|
modifier = Modifier.size(32.dp),
|
||||||
tint = iconTint,
|
tint = iconTint,
|
||||||
@@ -167,7 +148,6 @@ object BigIcon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
@@ -199,6 +179,5 @@ internal class BigIconStyleProvider : PreviewParameterProvider<BigIcon.Style> {
|
|||||||
BigIcon.Style.Default(Icons.Filled.CatchingPokemon, useCriticalTint = true),
|
BigIcon.Style.Default(Icons.Filled.CatchingPokemon, useCriticalTint = true),
|
||||||
BigIcon.Style.Success,
|
BigIcon.Style.Success,
|
||||||
BigIcon.Style.SuccessSolid,
|
BigIcon.Style.SuccessSolid,
|
||||||
BigIcon.Style.Loading,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user