Skip to content
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

QR Code Scanner #4897

Merged
merged 39 commits into from
Aug 10, 2018
Merged

QR Code Scanner #4897

merged 39 commits into from
Aug 10, 2018

Conversation

brunobar79
Copy link
Contributor

@brunobar79 brunobar79 commented Jul 27, 2018

Fixes #686

@alextsg @danjm @whymarrh Whenever any of you have a chance, please take a look at this PR.

Please check out this comment before looking at the code to understand the motivation behind certain parts of the code and the different scenarios that needs to be supported.

Thanks!

@brunobar79 brunobar79 added the DO-NOT-MERGE Pull requests that should not be merged label Jul 27, 2018
@metamaskbot
Copy link
Collaborator

Builds ready [acfcdf5]: mascara, chrome, firefox, edge, opera

@metamaskbot
Copy link
Collaborator

Builds ready [4339f04]: mascara, chrome, firefox, edge, opera

@metamaskbot
Copy link
Collaborator

Builds ready [34617a2]: mascara, chrome, firefox, edge, opera

@cjeria
Copy link
Contributor

cjeria commented Aug 3, 2018

We should be careful with colors and make sure we are following web accessibility standards for the color blind. Looks like #f1f1f1 is the lightest we should go per the us gov standards. https://designsystem.digital.gov/components/colors/

The color I used in this mock was one color code decimal off. Here's the updated at #f1f1f1.
image

@cjeria
Copy link
Contributor

cjeria commented Aug 3, 2018

So let's make the QR button gray on hover and add a tool tip(?) for additional context since desktop webcam access to scan QR codes is a new-ish blockchain-y ux pattern.

@brunobar79 brunobar79 changed the title [DO NOT MERGE] - QR Code Scanner QR Code Scanner Aug 4, 2018
@brunobar79 brunobar79 added needs review and removed DO-NOT-MERGE Pull requests that should not be merged labels Aug 4, 2018
@metamaskbot
Copy link
Collaborator

Builds ready [b1ddaaf]: mascara, chrome, firefox, edge, opera

@metamaskbot
Copy link
Collaborator

Builds ready [ef9435e]: mascara, chrome, firefox, edge, opera

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a couple very minor blocking requests. Otherwise, my comments relate to improvements that can be made separate to this PR.

Overall, really great PR. Very solid and smooth integration with the existing codebase.

I am not able to properly QA as I don't have a working smartphone right now.

static checkStatus () {
return new Promise((resolve, reject) => {
const isPopup = getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think isFirefox and isBrave would make sense as methods in '../../app/scripts/lib/util'

This is not a blocking request, can be done in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. It wasn't too hard so I did it on this PR.

<div className={'qr-scanner__error'}>
{msg}
</div>
<div className={'qr-scanner__footer'}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small issue that should be fixed before the PR is merged: CANCEL and TRY AGAIN should be translated.

A slightly bigger issue that could be fixed after this PR is merged: code duplication between this <div className={'qr-scanner__footer'}> and metamask-extension/ui/app/components/page-container/page-container-footer/page-container-footer.component.js. This need not be a blocker and is really beyond the scope of this PR, but we should create a github issue (or PR) immediately after this to the needed change isn't forgotten.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware of that component. Thanks for letting me know!


return (
<div className="qr-scanner">
<div className="qr-scanner__close" onClick={this.stopAndClose}></div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all an issue with this PR, but we should not have to implement one of these closing 'X's for every modal. I have created a github issue to improve the modal component to provide this feature: #4956

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% agree with you and thank you for creating the issue!

@@ -1806,6 +1832,12 @@ function hideAlert () {
}
}

function qrCodeDetected (qrCodeData) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty small, nit-picky request, but could you make it explicit what properties are in qrCodeData? In the absence of both tests and formal documentation for this file, make properties explicit makes the code a bit more self documenting. See, for example, the showQrView, updateSendTo or setCurrentCurrency functions in this file.

In this case I am thinking of some variation of:

function qrCodeDetected ({ type, values }) {
  return {
    type: actions.QR_CODE_DETECTED,
    value: { type, values },
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @danjm this is a good suggestion. The main reason why I can't do that it's because I have 2 types of values: {type, values} and also null.

I need to set it to null once the view handled the code. If you have any other suggestion / workaround for that I'm happy to do it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option might be to add a docblock to the function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ended up following @whymarrh's suggestion. Thanks!

@brunobar79
Copy link
Contributor Author

brunobar79 commented Aug 8, 2018

@danjm I made all the requested changes.
BTW, I've also added support for normal ethereum addresses. Initially I was supporting only the format "ethereum:0x...." and now we're also supporting "0x..." (Kudos to @estebanmino for testing and finding that bug!)

@metamaskbot
Copy link
Collaborator

Builds ready [cbbd0d3]: mascara, chrome, firefox, edge, opera

@metamaskbot
Copy link
Collaborator

Builds ready [d0ccc59]: mascara, chrome, firefox, edge, opera

@brunobar79 brunobar79 merged commit e2be22a into develop Aug 10, 2018
@whymarrh whymarrh deleted the qr-code-scan branch August 10, 2018 21:03
@tmashuang tmashuang mentioned this pull request Aug 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants