buttercup / buttercup-mobile

:iphone: React-Native mobile application for Buttercup
https://buttercup.pw
GNU General Public License v3.0
400 stars 71 forks source link

Feature: add qr scanner #357

Open QuinsZouls opened 7 months ago

QuinsZouls commented 7 months ago

This PR Solves #310

What's includes:

Tested on Android SDK 30 and iOS 16 emulators.

What's next:

Notes:

julianpoemp commented 7 months ago

About the CDN script: What about installing jsqr via npm and copying the js file to the assets directory as part of the postinstall/prebuild step?

perry-mitchell commented 7 months ago

This looks awesome! I honestly thought this would have been more of a headache but you proved otherwise.

I agree with @julianpoemp - would be best if we could build the ugly parts (minified) of that HTML at build time if possible. What do you think?

QuinsZouls commented 7 months ago

It's not possible import a local JavaScript file from HTML, the only viable option is create a custom script that embed jsqr library from node_modules. Probably a post install script. I'm working on that.

julianpoemp commented 7 months ago

It's not possible import a local JavaScript file from HTML, the only viable option is create a custom script that embed jsqr library from node_modules. Probably a post install script. I'm working on that.

perhaps a static web server would be possible (https://github.com/futurepress/react-native-static-server). You could serve the html file and its assets using a static web server.

Don't know if this is a solution since resources are consumed to run a webserver that are not needed if the script is directly embedded to the HTML file. On the other hand it would makes handling the html file easier. Just an idea to throw in :)

QuinsZouls commented 7 months ago

I just added a nodejs script that builds the HTML file with jsqr dependency, also excluded HTML bundled from git

perry-mitchell commented 7 months ago

Thank you @QuinsZouls - I hope you'll bear with me, I'm not able to review and merge this yet but will try to get to it at the start of this coming week. Very excited for this.

perry-mitchell commented 7 months ago

And if you'd have time to check the podfile lock conflict too, that'd be great. I had to do a larger update to get the new 2.6.2 build working, so it might be wise to just delete the lock and install from scratch again.

QuinsZouls commented 7 months ago

Unfortunately, my Xcode has updated, so I'm not longer able to compile and run for IOS. I'm investigating this issue.

perry-mitchell commented 7 months ago

Ok, it didn't run when I started it.. lots of pod issues. I merged in master, killed ios/Pods and the podfile lock, killed node_modules and installed everything again.

After building the webview manually, I get the following error..

image

Seems the new modal view isn't stable across all environments (I'm on Mac Sonoma, latest xcode).

perry-mitchell commented 7 months ago

I pushed the merge from master.

QuinsZouls commented 7 months ago

It's working now without issues on lasted xcode with Sonoma, make sure the HTML is builded before running ios command. Simulator Screenshot - iPhone 15 Pro Max - 2024-04-29 at 12 27 42

perry-mitchell commented 7 months ago

Tested on my iPhone 14 Pro and the camera never starts:

image

Running from Xcode straight on my device. No errors that I can see that'd be relevant.

perry-mitchell commented 6 months ago

To clarify: It worked on the simulator as you showed, but not on a real device.

QuinsZouls commented 6 months ago

I think it's a permission problem, probably on a bare metal devices need camera permission to work properly. Maybe my approach is ask for camera permission before Camera modal shows. I'm working on that.

AlecMcCutcheon commented 5 months ago

Hope to see this in the app soon :)