-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PM-8217] New device notice email access UI #4400
Conversation
# Conflicts: # app/src/main/res/values/strings.xml
No New Or Fixed Issues Found |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4400 +/- ##
=========================================
+ Coverage 0 88.92% +88.92%
=========================================
Files 0 457 +457
Lines 0 39668 +39668
Branches 0 5610 +5610
=========================================
+ Hits 0 35276 +35276
- Misses 0 2432 +2432
- Partials 0 1960 +1960 ☔ View full report in Codecov by Sentry. |
* The top level composable for the new device notice email access screen. | ||
*/ | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Suppress("LongMethod") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look like the method is too long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right
BitwardenScaffold( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.nestedScroll(scrollBehavior.nestedScrollConnection), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no toolbar, do we need this at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing it
private fun MainContent( | ||
email: String, | ||
isEmailAccessEnabled: Boolean = false, | ||
onEmailAccessToggleChanged: (Boolean) -> Unit = {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these have default values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just left them after a layout rework. Removing them.
isEmailAccessEnabled: Boolean = false, | ||
onEmailAccessToggleChanged: (Boolean) -> Unit = {}, | ||
) { | ||
Spacer(modifier = Modifier.size(24.dp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be height, not size
* The main content of the screen. | ||
*/ | ||
@Composable | ||
private fun MainContent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this does not have a wrapping contain with a modifier, I believe the pattern requires us to scope the function to provide that extra context.
private fun ColumnScope.MainContent(
.padding(horizontal = 22.dp) | ||
.fillMaxWidth() | ||
.clip(RoundedCornerShape(size = 4.dp)) | ||
.background(BitwardenTheme.colorScheme.background.secondary), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be using custom stuff like this, we already have BitwardenContentCard
to handle stuff like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BitwardenContentCard
didn't seem to adapt to what I wanted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems to indicate that the UI is non-standard, I don't think we should be doing that.
@andrebispo5 Could you link the Figma files for this? This does not seem to match current design patterns used in the app. |
|
||
private fun handleEmailAccessToggle(action: EmailAccessToggle) { | ||
mutableStateFlow.update { | ||
it.copy(isEmailAccessEnabled = action.newState) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the intended purpose of the switch?
Do we not send the code if they do not have access to their email?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user has access to the email we can dismiss this flow.
…. Add modifier parameter for composables.
Image( | ||
painter = rememberVectorPainter(id = R.drawable.warning), | ||
contentDescription = null, | ||
modifier = Modifier.size(120.dp), | ||
modifier = modifier.size(120.dp), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Modifier
should only ever be applied to the top level component, if you wanted to pass one in like this, you would want to wrap it in a column.
onEmailAccessToggleChanged: (Boolean) -> Unit = {}, | ||
onContinueClick: () -> Unit = {}, | ||
) { | ||
Column( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you went the route of adding a top-level column, be sure to pass in a modifier.
We also do not need default params for the onEmailAccessToggleChanged
and onContinueClick
) { | ||
Column( | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
modifier = modifier.padding(horizontal = 24.dp), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this using a non-standard amount of padding?
Can we discuss this with design because this screen is going to be difficult to maintain since it uses so many non-standard design patterns.
@david-livefront Layout was updated to reflect the new designs. |
…warden/android into pm-8217/new-device-notice-ui
/** | ||
* Header content containing the warning icon and title. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
}, | ||
onContinueClick = { viewModel.trySendAction(ContinueClick) }, | ||
modifier = Modifier, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessary since there's a default Modifier
declared.
/** | ||
* User tapped the email access toggle. | ||
*/ | ||
data class EmailAccessToggle(val newState: Boolean) : NewDeviceNoticeEmailAccessAction() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ isEnabled
reads better. Not a blocker though. Just my OCD flaring up. 😆
/** | ||
* Manages application state for the new device notice email access screen. | ||
*/ | ||
@Suppress("TooManyFunctions") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed. There are only a handful of functions. 🤔
email = email, | ||
isEmailAccessEnabled = isEmailAccessEnabled, | ||
onEmailAccessToggleChanged = onEmailAccessToggleChanged, | ||
modifier = Modifier, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed since the same default Modifier
is declared in the function signature.
private fun HeaderContent( | ||
modifier: Modifier = Modifier, | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎨 If you scope this it will inherit the modifier
and other context from its parent Column scope. That would mean you don't need a wrapping Column
within HeaderContent
to set the modifier
and horizontalAlignment
. It would look like...
fun NewDeviceNoticeEmailAccessContent(...) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = modifier
.standardHorizontalMargin()
.fillMaxSize()
.verticalScroll(state = rememberScrollState()),
) {
Spacer(...)
HeaderContent()
// other components
}
}
private fun ColumnScope.HeaderContent() {
Image(...)
Spacer(...)
// other components
}
This works because HeaderContent
is using the same modifier
and horizontalAlignment
from the parent Column scope. It doesn't work quite as cleanly for MainContent
because you're not using the same horizontal alignment as its parent Column scope.
Consider this more of a FYI than an actual change request since there's nothing technically wrong with the way you've done it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I got it and thanks for the explanation, it makes sense specially the part that it's the same as the parent. I'll change it since it clears a lot of unnecessary code lines 👍
🎟️ Tracking
PM-8217 Add notice to users with no 2FA
📔 Objective
Add first screen for the notice to users with no 2FA
📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmedissue and could potentially benefit from discussion
:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes