Code cleanup.
This commit is contained in:
@@ -140,12 +140,12 @@ private fun IncomingVerificationHeader(step: Step, request: VerificationRequest.
|
||||
}
|
||||
IconTitleSubtitleMolecule(
|
||||
modifier = Modifier
|
||||
.padding(bottom = 16.dp)
|
||||
.semantics(mergeDescendants = true) {
|
||||
contentDescription = timeLimitMessage
|
||||
focused = true
|
||||
}
|
||||
.focusable(),
|
||||
.padding(bottom = 16.dp)
|
||||
.semantics(mergeDescendants = true) {
|
||||
contentDescription = timeLimitMessage
|
||||
focused = true
|
||||
}
|
||||
.focusable(),
|
||||
iconStyle = iconStyle,
|
||||
title = stringResource(id = titleTextId),
|
||||
subTitle = stringResource(id = subtitleTextId),
|
||||
@@ -166,7 +166,7 @@ private fun IncomingVerificationContent(
|
||||
|
||||
@Composable
|
||||
private fun ContentInitial(
|
||||
initialIncoming: Step.Initial,
|
||||
stepInitial: Step.Initial,
|
||||
request: VerificationRequest.Incoming,
|
||||
) {
|
||||
when (request) {
|
||||
@@ -176,14 +176,14 @@ private fun ContentInitial(
|
||||
verticalArrangement = Arrangement.spacedBy(24.dp),
|
||||
) {
|
||||
SessionDetailsView(
|
||||
deviceName = initialIncoming.deviceDisplayName,
|
||||
deviceId = initialIncoming.deviceId,
|
||||
signInFormattedTimestamp = initialIncoming.formattedSignInTime,
|
||||
deviceName = stepInitial.deviceDisplayName,
|
||||
deviceId = stepInitial.deviceId,
|
||||
signInFormattedTimestamp = stepInitial.formattedSignInTime,
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.padding(bottom = 16.dp),
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.padding(bottom = 16.dp),
|
||||
text = stringResource(R.string.screen_session_verification_request_footer),
|
||||
style = ElementTheme.typography.fontBodyMdMedium,
|
||||
textAlign = TextAlign.Center,
|
||||
@@ -193,8 +193,8 @@ private fun ContentInitial(
|
||||
is VerificationRequest.Incoming.User -> {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 24.dp),
|
||||
.fillMaxWidth()
|
||||
.padding(top = 24.dp),
|
||||
) {
|
||||
VerificationUserProfileContent(
|
||||
user = request.details.senderProfile,
|
||||
@@ -208,10 +208,8 @@ private fun ContentInitial(
|
||||
private fun IncomingVerificationBottomMenu(
|
||||
state: IncomingVerificationState,
|
||||
) {
|
||||
val step = state.step
|
||||
val eventSink = state.eventSink
|
||||
|
||||
when (step) {
|
||||
when (val step = state.step) {
|
||||
is Step.Initial -> {
|
||||
VerificationBottomMenu {
|
||||
Button(
|
||||
@@ -236,7 +234,9 @@ private fun IncomingVerificationBottomMenu(
|
||||
text = stringResource(R.string.screen_session_verification_they_match),
|
||||
enabled = !step.isWaiting,
|
||||
showProgress = step.isWaiting,
|
||||
onClick = { eventSink(IncomingVerificationViewEvents.ConfirmVerification) },
|
||||
onClick = {
|
||||
eventSink(IncomingVerificationViewEvents.ConfirmVerification)
|
||||
},
|
||||
)
|
||||
TextButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
@@ -253,7 +253,9 @@ private fun IncomingVerificationBottomMenu(
|
||||
Button(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(CommonStrings.action_done),
|
||||
onClick = { eventSink(IncomingVerificationViewEvents.GoBack) },
|
||||
onClick = {
|
||||
eventSink(IncomingVerificationViewEvents.GoBack)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import io.element.android.features.verifysession.impl.R
|
||||
import io.element.android.features.verifysession.impl.outgoing.OutgoingVerificationState.Step
|
||||
import io.element.android.features.verifysession.impl.ui.VerificationBottomMenu
|
||||
import io.element.android.features.verifysession.impl.ui.VerificationContentVerifying
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.designsystem.atomic.molecules.IconTitleSubtitleMolecule
|
||||
import io.element.android.libraries.designsystem.atomic.pages.HeaderFooterPage
|
||||
import io.element.android.libraries.designsystem.components.BigIcon
|
||||
@@ -97,15 +96,15 @@ fun OutgoingVerificationView(
|
||||
navigationIcon = {
|
||||
BackButton(onClick = ::cancelOrResetFlow)
|
||||
},
|
||||
colors = topAppBarColors(containerColor = Color.Transparent)
|
||||
colors = topAppBarColors(containerColor = Color.Transparent),
|
||||
)
|
||||
},
|
||||
header = {
|
||||
OutgoingVerificationHeader(step = step, request = state.request)
|
||||
},
|
||||
footer = {
|
||||
OutgoingVerificationViewBottomMenu(
|
||||
screenState = state,
|
||||
OutgoingVerificationBottomMenu(
|
||||
state = state,
|
||||
onCancelClick = ::cancelOrResetFlow,
|
||||
onContinueClick = onFinish,
|
||||
)
|
||||
@@ -113,7 +112,7 @@ fun OutgoingVerificationView(
|
||||
isScrollable = true,
|
||||
) {
|
||||
OutgoingVerificationContent(
|
||||
flowState = step,
|
||||
step = step,
|
||||
request = state.request,
|
||||
onLearnMoreClick = onLearnMoreClick,
|
||||
)
|
||||
@@ -203,20 +202,16 @@ private fun OutgoingVerificationHeader(step: Step, request: VerificationRequest.
|
||||
|
||||
@Composable
|
||||
private fun OutgoingVerificationContent(
|
||||
flowState: Step,
|
||||
step: Step,
|
||||
request: VerificationRequest.Outgoing,
|
||||
onLearnMoreClick: () -> Unit,
|
||||
) {
|
||||
when (flowState) {
|
||||
is Step.Initial -> {
|
||||
when (request) {
|
||||
is VerificationRequest.Outgoing.CurrentSession -> Unit
|
||||
is VerificationRequest.Outgoing.User -> ContentInitial(onLearnMoreClick)
|
||||
}
|
||||
}
|
||||
is Step.Verifying -> {
|
||||
VerificationContentVerifying(flowState.data)
|
||||
when (step) {
|
||||
is Step.Initial -> when (request) {
|
||||
is VerificationRequest.Outgoing.CurrentSession -> Unit
|
||||
is VerificationRequest.Outgoing.User -> ContentInitial(onLearnMoreClick)
|
||||
}
|
||||
is Step.Verifying -> VerificationContentVerifying(step.data)
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
@@ -240,22 +235,18 @@ private fun ContentInitial(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun OutgoingVerificationViewBottomMenu(
|
||||
screenState: OutgoingVerificationState,
|
||||
private fun OutgoingVerificationBottomMenu(
|
||||
state: OutgoingVerificationState,
|
||||
onCancelClick: () -> Unit,
|
||||
onContinueClick: () -> Unit,
|
||||
) {
|
||||
val verificationViewState = screenState.step
|
||||
val eventSink = screenState.eventSink
|
||||
|
||||
val isVerifying = (verificationViewState as? Step.Verifying)?.state is AsyncData.Loading<Unit>
|
||||
|
||||
when (verificationViewState) {
|
||||
val eventSink = state.eventSink
|
||||
when (val step = state.step) {
|
||||
Step.Loading -> error("Should not happen")
|
||||
is Step.AwaitingOtherDeviceResponse,
|
||||
is Step.Initial -> {
|
||||
VerificationBottomMenu {
|
||||
val isWaiting = verificationViewState is Step.AwaitingOtherDeviceResponse
|
||||
val isWaiting = step is Step.AwaitingOtherDeviceResponse
|
||||
Button(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(CommonStrings.action_start_verification),
|
||||
@@ -291,6 +282,7 @@ private fun OutgoingVerificationViewBottomMenu(
|
||||
}
|
||||
}
|
||||
is Step.Verifying -> {
|
||||
val isVerifying = step.state.isLoading()
|
||||
VerificationBottomMenu {
|
||||
Button(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
@@ -305,7 +297,9 @@ private fun OutgoingVerificationViewBottomMenu(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(R.string.screen_session_verification_they_dont_match),
|
||||
enabled = !isVerifying,
|
||||
onClick = { eventSink(OutgoingVerificationViewEvents.DeclineVerification) },
|
||||
onClick = {
|
||||
eventSink(OutgoingVerificationViewEvents.DeclineVerification)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user