-
Notifications
You must be signed in to change notification settings - Fork 2
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 #14 from IdentityBlock/implementation/approve-reje…
…ct-information-sharing Closes #13
- Loading branch information
Showing
9 changed files
with
244 additions
and
58 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,15 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:bloc/bloc.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
part 'verify_event.dart'; | ||
part 'verify_state.dart'; | ||
|
||
class VerifyBloc extends Bloc<VerifyEvent, VerifyState> { | ||
VerifyBloc() : super(VerifyInitial()) { | ||
on<VerifyEvent>((event, emit) { | ||
// TODO: implement event handler | ||
}); | ||
} | ||
} |
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,4 @@ | ||
part of 'verify_bloc.dart'; | ||
|
||
@immutable | ||
abstract class VerifyEvent {} |
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,6 @@ | ||
part of 'verify_bloc.dart'; | ||
|
||
@immutable | ||
abstract class VerifyState {} | ||
|
||
class VerifyInitial extends VerifyState {} |
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,81 +1,106 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:iblock/services/secure_storage_service.dart'; | ||
import 'package:iblock/services/user_contract_service.dart'; | ||
import 'package:qr_code_scanner/qr_code_scanner.dart'; | ||
|
||
import './error_page.dart'; | ||
import '../widgets/forms/button.dart'; | ||
|
||
class QRResultPage extends StatelessWidget { | ||
class QRResultPage extends StatefulWidget { | ||
final Barcode result; | ||
const QRResultPage(this.result, {Key? key}) : super(key: key); | ||
|
||
@override | ||
State<QRResultPage> createState() => _QRResultPageState(); | ||
} | ||
|
||
class _QRResultPageState extends State<QRResultPage> { | ||
Map<String, dynamic> processQR(Barcode qr) { | ||
Map<String, dynamic> data = jsonDecode(qr.code!); | ||
return data; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
try{ | ||
print((jsonDecode(result.code!) as Map<String, dynamic>)['information'] | ||
as List); | ||
try { | ||
return SafeArea( | ||
child: Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Requesting Information'), | ||
), | ||
body: | ||
SizedBox( | ||
body: SizedBox( | ||
width: double.infinity, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
Expanded( | ||
flex: MediaQuery.of(context).size.width > MediaQuery.of(context).size.height? 1:4, | ||
child: SingleChildScrollView( | ||
child: Column( | ||
children: ((jsonDecode(result.code!) | ||
as Map<String, dynamic>)['information'] | ||
as List<dynamic>) | ||
.map((e) => Padding( | ||
padding: const EdgeInsets.all(4.0), | ||
child: Text( | ||
e, | ||
style: const TextStyle(fontSize: 14), | ||
child: Column(crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
Expanded( | ||
flex: MediaQuery.of(context).size.width > | ||
MediaQuery.of(context).size.height | ||
? 1 | ||
: 4, | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: SingleChildScrollView( | ||
child: SizedBox( | ||
height: MediaQuery.of(context).size.height * 0.6, | ||
child: Column( | ||
mainAxisSize: MainAxisSize.max, | ||
children: [ | ||
const Expanded( | ||
flex: 1, | ||
child: Text( | ||
"Following service provider request your approval for access your personal information")), | ||
Expanded( | ||
flex: 1, | ||
child: Text( | ||
processQR(widget.result)["verifier-name"], | ||
style: const TextStyle( | ||
fontWeight: FontWeight.bold, | ||
fontSize: 20), | ||
), | ||
), | ||
const Expanded( | ||
flex: 3, | ||
child: SizedBox( | ||
width: 300, | ||
child: Image( | ||
image: AssetImage( | ||
'assets/images/contract-agreement.png')), | ||
), | ||
), | ||
], | ||
), | ||
)) | ||
.toList(), | ||
), | ||
), | ||
)), | ||
Expanded( | ||
flex: 1, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.all(2.0), | ||
child: Button( | ||
"Approve", | ||
onPressed: () {}, | ||
)), | ||
Padding( | ||
padding: const EdgeInsets.all(2.0), | ||
child: Button( | ||
"Decline", | ||
onPressed: () {}, | ||
color: Colors.red, | ||
)), | ||
], | ||
), | ||
) | ||
], | ||
), | ||
) | ||
// Center( | ||
// child: Text(result.code != null ? 'Barcode Type: ${describeEnum(result.format)} Data: ${result.code}': 'No result'), | ||
// ), | ||
), | ||
Expanded(flex: 1, | ||
child: Column(crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
Padding(padding: const EdgeInsets.all(2.0), | ||
child: Button("Approve", onPressed: () async{ | ||
var data = processQR(widget.result); | ||
var contractService = UserContractService(); | ||
var contractAddress = await SecureStorageService.get("contract-address") as String; | ||
var privateKey = await SecureStorageService.get("private-key") as String; | ||
await contractService.verify(data['verifier-contract'], data['token'], contractAddress: contractAddress, privateKey: privateKey); | ||
},)), | ||
Padding(padding: const EdgeInsets.all(2.0), | ||
child: Button("Decline", onPressed: () { | ||
Navigator.popUntil( | ||
context, ModalRoute.withName("/home")); | ||
}, color: Colors.red,)), | ||
],),) | ||
],),) | ||
// Center( | ||
// child: Text(result.code != null ? 'Barcode Type: ${describeEnum(result.format)} Data: ${result.code}': 'No result'), | ||
// ), | ||
),); | ||
} catch(e){ | ||
print(e); | ||
return const ErrorPage( | ||
message: "QR code not recognized!", | ||
); | ||
} | ||
catch(e){ | ||
return const ErrorPage(message: "QR code not recognized!",); | ||
} | ||
|
||
} | ||
} |
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