-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from zk-passport/new-ux
New ux
- Loading branch information
Showing
114 changed files
with
10,527 additions
and
2,446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
app/android/app/src/main/java/com/awesomeproject/QRCodeScannerModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.proofofpassport; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.content.pm.PackageManager; | ||
import androidx.annotation.NonNull; | ||
import androidx.core.app.ActivityCompat; | ||
import androidx.core.content.ContextCompat; | ||
import com.facebook.react.bridge.ActivityEventListener; | ||
import com.facebook.react.bridge.BaseActivityEventListener; | ||
import com.facebook.react.bridge.Promise; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
import com.blikoon.qrcodescanner.QrCodeActivity; | ||
import android.Manifest; | ||
|
||
public class QRCodeScannerModule extends ReactContextBaseJavaModule { | ||
|
||
private static final int REQUEST_CODE_QR_SCAN = 101; | ||
private static final int PERMISSION_REQUEST_CAMERA = 1; | ||
private Promise scanPromise; | ||
|
||
private final ActivityEventListener activityEventListener = new BaseActivityEventListener() { | ||
@Override | ||
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { | ||
if (requestCode == REQUEST_CODE_QR_SCAN) { | ||
if (scanPromise != null) { | ||
if (resultCode == Activity.RESULT_OK) { | ||
String result = data.getStringExtra("com.blikoon.qrcodescanner.got_qr_scan_relult"); | ||
scanPromise.resolve(result); | ||
} else { | ||
scanPromise.reject("SCAN_FAILED", "QR Code scanning failed or was cancelled"); | ||
} | ||
scanPromise = null; | ||
} | ||
} | ||
} | ||
}; | ||
|
||
QRCodeScannerModule(ReactApplicationContext reactContext) { | ||
super(reactContext); | ||
reactContext.addActivityEventListener(activityEventListener); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getName() { | ||
return "QRCodeScanner"; | ||
} | ||
|
||
@ReactMethod | ||
public void scanQRCode(Promise promise) { | ||
Activity currentActivity = getCurrentActivity(); | ||
if (currentActivity == null) { | ||
promise.reject("ACTIVITY_DOES_NOT_EXIST", "Activity doesn't exist"); | ||
return; | ||
} | ||
|
||
scanPromise = promise; | ||
|
||
if (ContextCompat.checkSelfPermission(currentActivity, Manifest.permission.CAMERA) | ||
!= PackageManager.PERMISSION_GRANTED) { | ||
ActivityCompat.requestPermissions(currentActivity, | ||
new String[]{Manifest.permission.CAMERA}, | ||
PERMISSION_REQUEST_CAMERA); | ||
} else { | ||
startQRScanner(currentActivity); | ||
} | ||
} | ||
|
||
private void startQRScanner(Activity activity) { | ||
Intent intent = new Intent(activity, QrCodeActivity.class); | ||
activity.startActivityForResult(intent, REQUEST_CODE_QR_SCAN); | ||
} | ||
|
||
// Add this method to handle permission result | ||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { | ||
if (requestCode == PERMISSION_REQUEST_CAMERA) { | ||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | ||
Activity currentActivity = getCurrentActivity(); | ||
if (currentActivity != null) { | ||
startQRScanner(currentActivity); | ||
} | ||
} else { | ||
if (scanPromise != null) { | ||
scanPromise.reject("PERMISSION_DENIED", "Camera permission was denied"); | ||
scanPromise = null; | ||
} | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/android/app/src/main/java/com/awesomeproject/QRCodeScannerPackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.proofofpassport; | ||
|
||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.uimanager.ViewManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class QRCodeScannerPackage implements ReactPackage { | ||
@Override | ||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { | ||
List<NativeModule> modules = new ArrayList<>(); | ||
modules.add(new QRCodeScannerModule(reactContext)); | ||
return modules; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{ | ||
"Deploy_Registry#Formatter": "0x15cAe49aFFD6C9f918BC454A255C05997A74F960", | ||
"Deploy_Registry#PoseidonT3": "0xdfAC8e1AECc55C4c8B8eC55D666A5a5BB8fbAE5c", | ||
"Deploy_Registry#Registry": "0xBabF700EdE592Aa69e14B5BAE1859ee4164C3323", | ||
"Deploy_Registry#Verifier_disclose": "0x36BDB37Ab78feB585B782A734C07D04C4c5A66B4", | ||
"Deploy_Registry#Verifier_dsc_4096": "0x97c7D14A52e1576dADf8a7CCDf92a246aeb0C493", | ||
"Deploy_Registry#Verifier_register_sha1WithRSAEncryption_65537": "0x8392b122Bcbf1eF99dFf1b183C5D4939EDf699A2", | ||
"Deploy_Registry#Verifier_register_sha256WithRSAEncryption_65537": "0x2f5505803a3FCa5322A70A6471C91C34545AEa5D", | ||
"Deploy_Registry#ProofOfPassportRegister": "0xEd7495516a957dD7d378d8A78846646461cFF25f", | ||
"Deploy_Registry#SBT": "0x601Fd54FD11C5E77DE84d877e55B829aff20f0A6" | ||
"Deploy_Registry#Formatter": "0xD73395ad7391a3285d2e2a2259031ED6Eb753a2c", | ||
"Deploy_Registry#PoseidonT3": "0xbc16D1BD4Be33Cff388Bcbd61285b08BDCdeb86C", | ||
"Deploy_Registry#Registry": "0xe2778F3b0302359d947531C2E668b46cFbE97206", | ||
"Deploy_Registry#Verifier_disclose": "0xE2e39e0b823c1290788303094cb75B474899EAf6", | ||
"Deploy_Registry#Verifier_dsc_sha256_rsa_4096": "0xFD3AFBb0E0565cc28E99d9e11629c4c20e1e517D", | ||
"Deploy_Registry#Verifier_register_sha1WithRSAEncryption_65537": "0x434547E86530A583137c9990ffb87682F0d5ca48", | ||
"Deploy_Registry#Verifier_register_sha256WithRSAEncryption_65537": "0xDc5e3E81b4b3bC22f79C3a90dbb57EBB9aEdAAfF", | ||
"Deploy_Registry#ProofOfPassportRegister": "0x3F346FFdC5d583e4126AF01A02Ac5b9CdB3f1909", | ||
"Deploy_Registry#SBT": "0x33f41D706587a7AC6c2061B1893e6eb29615822B" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// LottieView.swift | ||
// FreedomTools | ||
// | ||
// Created by Ivan Lele on 27.02.2024. | ||
// | ||
|
||
import Lottie | ||
import SwiftUI | ||
|
||
struct LottieView: UIViewRepresentable { | ||
var animationFileName: String | ||
let loopMode: LottieLoopMode | ||
|
||
func updateUIView(_ uiView: UIViewType, context: Context) {} | ||
|
||
func makeUIView(context: Context) -> some UIView { | ||
let view = UIView(frame: .zero) | ||
|
||
let animationView = LottieAnimationView(name: animationFileName) | ||
animationView.loopMode = loopMode | ||
animationView.contentMode = .scaleAspectFit | ||
|
||
animationView.play() | ||
|
||
animationView.translatesAutoresizingMaskIntoConstraints = false | ||
view.addSubview(animationView) | ||
|
||
NSLayoutConstraint.activate([ | ||
animationView.widthAnchor.constraint(equalTo: view.widthAnchor), | ||
animationView.heightAnchor.constraint(equalTo: view.heightAnchor) | ||
]) | ||
|
||
return view | ||
} | ||
} | ||
|
||
#Preview { | ||
LottieView(animationFileName: "passport", loopMode: .loop) | ||
.frame(width: 300) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.