From ec1d33bee0e3d5657035be5d177640a9afdde622 Mon Sep 17 00:00:00 2001 From: Shivam Goyal Date: Sun, 24 Nov 2019 06:21:04 +0530 Subject: [PATCH] v0.7.0-beta-withoutVoice --- lib/components/appBar.dart | 13 +- lib/components/constant.dart | 12 - .../{row_item.dart => rowItem.dart} | 0 lib/global.dart | 119 +++++ lib/main.dart | 10 +- lib/models/transactionModel.dart | 207 --------- lib/screens/DrawerScreens/appDrawer.dart | 436 ++++++++++++++++++ .../DrawerScreens/drawerUserController.dart | 232 ++++++++++ .../DrawerScreens/navigationHomeScreen.dart | 188 ++++++++ lib/screens/appLockScreen.dart | 35 +- lib/screens/blockedUsersScreen.dart | 8 +- lib/screens/deviceInfoScreen.dart | 15 +- lib/screens/homePage.dart | 5 +- lib/screens/languageScreen.dart | 8 +- lib/screens/notificationsScreen.dart | 6 +- lib/screens/paymentMethodScreen.dart | 10 +- lib/screens/paymentMethodsScreen.dart | 7 +- lib/screens/privacyScreen.dart | 7 +- lib/screens/qrFullScreen.dart | 9 +- lib/screens/qrGenerateScreen.dart | 17 +- lib/screens/qrScanScreen.dart | 13 +- lib/screens/requestScreen.dart | 147 +++++- lib/screens/rewardzScreen.dart | 3 +- lib/screens/securityScreen.dart | 8 +- lib/screens/sendScreen.dart | 147 +++++- lib/screens/settingsScreen.dart | 27 +- lib/screens/transactionDetailScreen.dart | 79 ++-- lib/screens/transactionHistoryScreen.dart | 217 +++++---- lib/screens/ussdServiceScreen.dart | 8 +- lib/screens/voicePayDialog.dart | 260 ++++++++--- lib/security/dependencyProvider.dart | 21 - lib/security/rsaHandling.dart | 245 ---------- lib/security/securityDashboard.dart | 277 +++++------ pubspec.lock | 70 +-- pubspec.yaml | 8 +- test/widget_test.dart | 2 +- 36 files changed, 1877 insertions(+), 999 deletions(-) delete mode 100644 lib/components/constant.dart rename lib/components/{row_item.dart => rowItem.dart} (100%) create mode 100644 lib/global.dart delete mode 100644 lib/models/transactionModel.dart create mode 100644 lib/screens/DrawerScreens/appDrawer.dart create mode 100644 lib/screens/DrawerScreens/drawerUserController.dart create mode 100644 lib/screens/DrawerScreens/navigationHomeScreen.dart delete mode 100644 lib/security/dependencyProvider.dart delete mode 100644 lib/security/rsaHandling.dart diff --git a/lib/components/appBar.dart b/lib/components/appBar.dart index d44de88..4782f00 100644 --- a/lib/components/appBar.dart +++ b/lib/components/appBar.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'constant.dart'; class TopBar extends StatelessWidget implements PreferredSizeWidget { final String title; @@ -31,12 +30,20 @@ class TopBar extends StatelessWidget implements PreferredSizeWidget { tag: 'topBarBtn', child: Card( elevation: 0, - shape: kBackButtonShape, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topRight: Radius.circular(30), + ), + ), child: MaterialButton( height: 50, minWidth: 50, elevation: 10, - shape: kBackButtonShape, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topRight: Radius.circular(30), + ), + ), onPressed: onPressed, child: child, ), diff --git a/lib/components/constant.dart b/lib/components/constant.dart deleted file mode 100644 index 2ad0070..0000000 --- a/lib/components/constant.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter/material.dart'; - -ShapeBorder kBackButtonShape = RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topRight: Radius.circular(30), - ), -); - -Widget kBackBtn = Icon( - Icons.arrow_back_ios, - // color: Colors.black54, -); diff --git a/lib/components/row_item.dart b/lib/components/rowItem.dart similarity index 100% rename from lib/components/row_item.dart rename to lib/components/rowItem.dart diff --git a/lib/global.dart b/lib/global.dart new file mode 100644 index 0000000..bd7edd7 --- /dev/null +++ b/lib/global.dart @@ -0,0 +1,119 @@ +import 'package:http/http.dart' as http; +import 'package:random_string/random_string.dart'; +import 'package:simple_rsa/simple_rsa.dart'; + +String publicKey = + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvt4Iixd3XigxqLLHvMp4PDKklFGFbuqnO96AoUdcLl8IHdv6o3gUJnCz3fpj7VFXQzBD0rZ4aOJhJrctfi9F6OGmcazpj7BVk3B1YbjEVLJf3fsZ27PlnwBd8y4te3EcLdUDlFOKErXXb6kCzd4h6azAKik9VYrIn/nnpfuVJLBTenuJEcnHJRY8MyWlL7F3epikHOvqCQRtDcmEqbrMJqLVCLXVjYlZTnPyrzemQ+tGcpVaKKwsjb1EDR9JgDP/Xkpy8eZ18vCDHncpUp2k7FoBM1pg6n1PBMCYGYMN5J76dX7bjeRVeFkRR2Ajh2Ajw2/UL1C+guDeALlUO92fywIDAQAB"; +String privateKey = + "MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQC+3giLF3deKDGosse8yng8MqSUUYVu6qc73oChR1wuXwgd2/qjeBQmcLPd+mPtUVdDMEPStnho4mEmty1+L0Xo4aZxrOmPsFWTcHVhuMRUsl/d+xnbs+WfAF3zLi17cRwt1QOUU4oStddvqQLN3iHprMAqKT1Visif+eel+5UksFN6e4kRycclFjwzJaUvsXd6mKQc6+oJBG0NyYSpuswmotUItdWNiVlOc/KvN6ZD60ZylVoorCyNvUQNH0mAM/9eSnLx5nXy8IMedylSnaTsWgEzWmDqfU8EwJgZgw3knvp1ftuN5FV4WRFHYCOHYCPDb9QvUL6C4N4AuVQ73Z/LAgMBAAECggEBAJWdHj1Ji7w27ZY7be5DF7S4TeIldN7Y+XYol9PUSCHhRE+DnBh/i+wF9DhQifwBAtIcB04o0oIE0fqzI+oBzF8cYohA7mQ/6RTF1n1fhCaQHC25Iy/g+GGGvB5fWC+nHlue2ktuoJDCEbnpVdViBltRmuBxqy5et50PG9I0P1idtFciZ9MuzcYSvdkErgAtDc4YA4XFcN6o9l3UnuW1I0c6ECzA13QIh6tCeHMFaGbVfgiW224nBvnEZWVR9TiLcvQ0GqhIMyiX1sbOEOjWmaaHquoFo78lnW7URR42ktYSERcuwzleItT09rA3qpHoYAOj/JIwRYIn9LS+VS50dWECgYEA5FnQdQ4wSP4307NRxy7eqDaS4i+2Jq+XITtUMt30WQuwg3X13VFkH1AIxcXOxXRwfQZyjQEKLJBCZOHXSlIjtAgIGp7gn7usVLlnM0aUbElVohEYzr185L54Yt2zcHDTH7f7pWhF8beMWizJ0A03rSDXYcI3XCzmLHQEkjLK1vcCgYEA1fpX4gObPfumwWv7TLUAvtNAkmW4aTYtG0+kjqPURzsXhETTmklC7aGjvzFg7YGxBTDzR+rYQIeE9khoGKRSsZhcn1gDAlLg6vfTOgETRmemYVFqOb+40BICV8j/jHxxV7vwRenQFOwnsP+bJ+poABfhqPO+HLzOd8KhNseBZM0CgYEAtYvSd734FZBHwj/m3H0e+I2q6bkVEFy5wunwXyCni8QHafz2pCZ5e4ud7d7+LW4NoNjnacNR22w13Q7Qo336dL+N8dwuqdADirh8m/+ZMR58voTpPDTafuIPxEqOxu5sa+NSZocoVKyhIXBKYuafRT2+/zHx4Y6w0NbMa4+GRLECgYEAmxV9Wo74lhztCGUF1tuc9bFQrIpS9NZSLOg1QTiWIyY97hygLMOKYYZ0kp7sPFdyAGww9t/L6kEOah2ibLG0SYk/IDH+xFFjOIlzqyeaW73FxeTnE4HUJeHXlt5T8PNEhqztAQ7sRC3AurUXM//dbqvgXr6B/HwPPJdwlq5UJsUCgYEAshqcXJ/5Y9HPIheenyNSH1MKaLD91cmRr+nO/stMy+l57VVoqeT2uhxMEbj+Xh7HeMJoXPQ1zfVOdjM2IMJ/caJ2WeIXcooiNLVjYXyb84cSPPCblNbV5tHeI5lqNXnjiL6AkMzQm+L8cbJumOZMDywIod+Sy06sIN/iEUZu7HU="; + +String myHash = 'Qmei1GvwVk2C3ZMFsDmyWZDoWs4oqW1v9eRJfWkF3Nr9mj'; + +String myName = 'Shivam Goyal'; +String myID = 'shivamgoyal@upi'; +String myMobileNumber = '+919012218994'; +List users = [ + 'Utkarsh Mishra', + 'Mankaran Singh', + 'Ambika Arora', + 'Radhika Singhania', + 'Paytm', + 'Khushboo Verma', + 'Zomato', + 'Uber', + 'Swiggy', + 'Abhishek Jain', + 'Sidhant Singh', + 'Saurabh Garg', + 'BookMyShow' +]; + +List listDecryptedTransaction = []; + +Future sendTransaction() async { + String myTID = 'NPC' + randomNumeric(32).toString(); + print( + '------------------------------ Previous Hash -------------------------------\n' + + myHash); + print( + '----------------------------------------------------------------------------\n\n'); + print( + '----------------------------- Transaction ID -------------------------------\n' + + myTID); + print( + '----------------------------------------------------------------------------\n\n'); + int selectedUserNumber = randomBetween(0, users.length - 1); + String text = + '${users[selectedUserNumber]},${users[selectedUserNumber].toLowerCase().replaceAll(' ', '') + '@upi'},${'+91' + randomBetween(7000000000, 9999999999).toString()},$myName,$myID,$myMobileNumber,${randomBetween(10, 2000)},$myTID,${DateTime.now()},success'; + print( + '--------------------------------- Text -------------------------------------\n' + + text); + print( + '----------------------------------------------------------------------------\n\n'); + String encryptedText = await encryptString(text, publicKey); + encryptedText = encryptedText.replaceAll('\n', ''); + print( + '----------------------------- Encrypted Text -------------------------------\n' + + encryptedText); + print( + '----------------------------------------------------------------------------\n'); + String url = 'https://npci-database.herokuapp.com/contact'; + var body = { + 'status': myHash == '' ? 'Y' : 'N', + 'hash': myHash == '' ? '' : myHash, + 'tid': myTID, + 'main': encryptedText, + }; + var response = await http.post(url, body: body); + myHash = response.body; + print( + '------------------------------ Updated Hash --------------------------------\n' + + myHash); + print( + '----------------------------------------------------------------------------\n'); + print( + ' _ \n'); + print( + ' .__(.)< (AeroCoders) \n'); + print( + ' \\___) \n'); + print( + ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n\n'); +} + +Future getTransaction() async { + listDecryptedTransaction.clear(); + print( + '------------------------------ Recorded Hash -------------------------------\n' + + myHash); + print( + '----------------------------------------------------------------------------\n\n'); + String url = 'https://ipfs.io/ipfs/' + myHash; + var response = await http.get(url); + List listEncryptedTransaction = response.body.split('\n'); + String lastEncryptedTransaction = + listEncryptedTransaction[listEncryptedTransaction.length - 2]; + print( + '----------------------- Last Encrypted Transaction -------------------------\n' + + lastEncryptedTransaction); + print( + '----------------------------------------------------------------------------\n\n'); + print( + '------------------------ All Decrypted Transaction -------------------------\n'); + for (int i = 0; i < listEncryptedTransaction.length - 1; i++) { + String toBeAddedTransaction = + await decryptString(listEncryptedTransaction[i], privateKey); + print(toBeAddedTransaction); + listDecryptedTransaction.add(toBeAddedTransaction); + } + print( + '----------------------------------------------------------------------------\n'); + print( + ' _ \n'); + print( + ' .__(.)< (AeroCoders) \n'); + print( + ' \\___) \n'); + print( + ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n\n'); +} diff --git a/lib/main.dart b/lib/main.dart index cec371b..7fba493 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,13 +1,15 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; + import 'screens/appLockScreen.dart'; -Future main() async { - await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); - runApp(MyApp()); +void main() { + SystemChrome.setPreferredOrientations( + [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]); + runApp(BHIMApp()); } -class MyApp extends StatelessWidget { +class BHIMApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( diff --git a/lib/models/transactionModel.dart b/lib/models/transactionModel.dart deleted file mode 100644 index 5eaf9ad..0000000 --- a/lib/models/transactionModel.dart +++ /dev/null @@ -1,207 +0,0 @@ -class TransactionModel { - final String payeeName; - final String payeeID; - final String payeeMobileNumber; - final String payerName; - final String payerID; - final String payerMobileNumber; - final String transactionID; - final String transactionMode; - final String transactionStatus; - final String date; - final String time; - final String currency; - final String amount; - final String payeeAvatarUrl; - final String payerAvatarUrl; - - TransactionModel( - {this.payeeName, - this.payeeID, - this.payeeMobileNumber, - this.payerName, - this.payerID, - this.payerMobileNumber, - this.transactionID, - this.transactionMode, - this.transactionStatus, - this.date, - this.time, - this.currency, - this.amount, - this.payeeAvatarUrl, - this.payerAvatarUrl}); -} - -List transactionData = [ - TransactionModel( - payeeName: 'Utkarsh Mishra', - payeeID: 'utkarshmishra@upi', - payeeMobileNumber: '+919977642640', - payerName: 'Shivam Goyal', - payerID: 'shivamgoyal@upi', - payerMobileNumber: '+919012218994', - transactionID: '928523139261', - transactionMode: 'NFC Mode', - transactionStatus: 'pending', - date: '12 Oct 2019', - time: '11:16 PM', - currency: 'INR', - amount: '125.23', - payeeAvatarUrl: 'assets/images/utkarsh.jpg', - payerAvatarUrl: 'assets/images/shivam.jpg', - ), - TransactionModel( - payeeName: 'Shivam Goyal', - payeeID: 'shivamgoyal@upi', - payeeMobileNumber: '+919012218994', - payerName: 'Ambika Arora', - payerID: 'ambikaarora@upi', - payerMobileNumber: '+918564712367', - transactionID: '928552369621', - transactionMode: 'QR Mode', - transactionStatus: 'success', - date: '10 Oct 2019', - time: '12:26 AM', - currency: 'INR', - amount: '236.20', - payeeAvatarUrl: 'assets/images/shivam.jpg', - payerAvatarUrl: 'assets/images/ambika.jpg', - ), - TransactionModel( - payeeName: 'Utkarsh Mishra', - payeeID: 'utkarshmishra@upi', - payeeMobileNumber: '+919977642640', - payerName: 'Shivam Goyal', - payerID: 'shivamgoyal@upi', - payerMobileNumber: '+919012218994', - transactionID: '928523139261', - transactionMode: 'NFC Mode', - transactionStatus: 'success', - date: '08 Oct 2019', - time: '11:16 PM', - currency: 'INR', - amount: '895.23', - payeeAvatarUrl: 'assets/images/utkarsh.jpg', - payerAvatarUrl: 'assets/images/shivam.jpg', - ), - TransactionModel( - payeeName: 'Shivam Goyal', - payeeID: 'shivamgoyal@upi', - payeeMobileNumber: '+919012218994', - payerName: 'Mankaran Singh', - payerID: 'mankaransingh@upi', - payerMobileNumber: '+914567981235', - transactionID: '928523139621', - transactionMode: 'QR Mode', - transactionStatus: 'failed', - date: '07 Oct 2019', - time: '12:26 AM', - currency: 'INR', - amount: '95.20', - payeeAvatarUrl: 'assets/images/shivam.jpg', - payerAvatarUrl: 'assets/images/mankaran.jpg', - ), - TransactionModel( - payeeName: 'Utkarsh Mishra', - payeeID: 'utkarshmishra@upi', - payeeMobileNumber: '+919977642640', - payerName: 'Shivam Goyal', - payerID: 'shivamgoyal@upi', - payerMobileNumber: '+919012218994', - transactionID: '928523139261', - transactionMode: 'NFC Mode', - transactionStatus: 'success', - date: '01 Oct 2019', - time: '11:16 PM', - currency: 'INR', - amount: '143.23', - payeeAvatarUrl: 'assets/images/utkarsh.jpg', - payerAvatarUrl: 'assets/images/shivam.jpg', - ), - TransactionModel( - payeeName: 'Shivam Goyal', - payeeID: 'shivamgoyal@upi', - payeeMobileNumber: '+919012218994', - payerName: 'Mankaran Singh', - payerID: 'mankaransingh@upi', - payerMobileNumber: '+914567981235', - transactionID: '928523139621', - transactionMode: 'QR Mode', - transactionStatus: 'success', - date: '30 Sep 2019', - time: '12:26 AM', - currency: 'INR', - amount: '200.00', - payeeAvatarUrl: 'assets/images/shivam.jpg', - payerAvatarUrl: 'assets/images/mankaran.jpg', - ), - TransactionModel( - payeeName: 'Khushboo Verma', - payeeID: 'khushbooverma@upi', - payeeMobileNumber: '+916941236952', - payerName: 'Shivam Goyal', - payerID: 'shivamgoyal@upi', - payerMobileNumber: '+919012218994', - transactionID: '928523139261', - transactionMode: 'NFC Mode', - transactionStatus: 'failed', - date: '15 Sep 2019', - time: '11:16 PM', - currency: 'INR', - amount: '652.56', - payeeAvatarUrl: 'assets/images/khushboo.jpg', - payerAvatarUrl: 'assets/images/shivam.jpg', - ), - TransactionModel( - payeeName: 'Shivam Goyal', - payeeID: 'shivamgoyal@upi', - payeeMobileNumber: '+919012218994', - payerName: 'Mankaran Singh', - payerID: 'mankaransingh@upi', - payerMobileNumber: '+914567981235', - transactionID: '928523139621', - transactionMode: 'QR Mode', - transactionStatus: 'success', - date: '11 Sep 2019', - time: '12:26 AM', - currency: 'INR', - amount: '62.20', - payeeAvatarUrl: 'assets/images/shivam.jpg', - payerAvatarUrl: 'assets/images/mankaran.jpg', - ), - TransactionModel( - payeeName: 'Utkarsh Mishra', - payeeID: 'utkarshmishra@upi', - payeeMobileNumber: '+919977642640', - payerName: 'Shivam Goyal', - payerID: 'shivamgoyal@upi', - payerMobileNumber: '+919012218994', - transactionID: '928523139261', - transactionMode: 'NFC Mode', - transactionStatus: 'failed', - date: '09 Sep 2019', - time: '11:16 PM', - currency: 'INR', - amount: '456.23', - payeeAvatarUrl: 'assets/images/utkarsh.jpg', - payerAvatarUrl: 'assets/images/shivam.jpg', - ), - TransactionModel( - payeeName: 'Shivam Goyal', - payeeID: 'shivamgoyal@upi', - payeeMobileNumber: '+919012218994', - payerName: 'Mankaran Singh', - payerID: 'mankaransingh@upi', - payerMobileNumber: '+914567981235', - transactionID: '928523139621', - transactionMode: 'QR Mode', - transactionStatus: 'success', - date: '09 Sep 2019', - time: '08:56 AM', - currency: 'INR', - amount: '165.00', - payeeAvatarUrl: 'assets/images/shivam.jpg', - payerAvatarUrl: 'assets/images/mankaran.jpg', - ), -]; diff --git a/lib/screens/DrawerScreens/appDrawer.dart b/lib/screens/DrawerScreens/appDrawer.dart new file mode 100644 index 0000000..ead61a3 --- /dev/null +++ b/lib/screens/DrawerScreens/appDrawer.dart @@ -0,0 +1,436 @@ +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../../global.dart'; + +class AppTheme { + AppTheme._(); + + static const Color notWhite = Color(0xFFEDF0F2); + static const Color nearlyWhite = Color(0xFFFEFEFE); + static const Color white = Color(0xFFFFFFFF); + static const Color nearlyBlack = Color(0xFF213333); + static const Color grey = Color(0xFF3A5160); + static const Color dark_grey = Color(0xFF313A44); + + static const Color darkText = Color(0xFF253840); + static const Color darkerText = Color(0xFF17262A); + static const Color lightText = Color(0xFF4A6572); + static const Color deactivatedText = Color(0xFF767676); + static const Color dismissibleBackground = Color(0xFF364A54); + static const Color chipBackground = Color(0xFFEEF1F3); + static const Color spacer = Color(0xFFF2F2F2); + static const String fontName = 'WorkSans'; + + static const TextTheme textTheme = TextTheme( + display1: display1, + headline: headline, + title: title, + subtitle: subtitle, + body2: body2, + body1: body1, + caption: caption, + ); + + static const TextStyle display1 = TextStyle( + // h4 -> display1 + fontFamily: fontName, + fontWeight: FontWeight.bold, + fontSize: 36, + letterSpacing: 0.4, + height: 0.9, + color: darkerText, + ); + + static const TextStyle headline = TextStyle( + // h5 -> headline + fontFamily: fontName, + fontWeight: FontWeight.bold, + fontSize: 24, + letterSpacing: 0.27, + color: darkerText, + ); + + static const TextStyle title = TextStyle( + // h6 -> title + fontFamily: fontName, + fontWeight: FontWeight.bold, + fontSize: 16, + letterSpacing: 0.18, + color: darkerText, + ); + + static const TextStyle subtitle = TextStyle( + // subtitle2 -> subtitle + fontFamily: fontName, + fontWeight: FontWeight.w400, + fontSize: 14, + letterSpacing: -0.04, + color: darkText, + ); + + static const TextStyle body2 = TextStyle( + // body1 -> body2 + fontFamily: fontName, + fontWeight: FontWeight.w400, + fontSize: 14, + letterSpacing: 0.2, + color: darkText, + ); + + static const TextStyle body1 = TextStyle( + // body2 -> body1 + fontFamily: fontName, + fontWeight: FontWeight.w400, + fontSize: 16, + letterSpacing: -0.05, + color: darkText, + ); + + static const TextStyle caption = TextStyle( + // Caption -> caption + fontFamily: fontName, + fontWeight: FontWeight.w400, + fontSize: 12, + letterSpacing: 0.2, + color: lightText, // was lightText + ); +} + +class MyDrawer extends StatefulWidget { + final AnimationController iconAnimationController; + final DrawerIndex screenIndex; + final Function(DrawerIndex) callBackIndex; + + MyDrawer( + {Key key, + this.screenIndex, + this.iconAnimationController, + this.callBackIndex}) + : super(key: key); + + @override + _MyDrawerState createState() => _MyDrawerState(); +} + +class _MyDrawerState extends State { + List drawerList; + + _launchUrlDeveloper() async { + const url = 'https://shivamgoyal.co'; + if (await canLaunch(url)) { + await launch(url); + } else { + throw 'Could not launch $url'; + } + } + + @override + void initState() { + setdDrawerListArray(); + super.initState(); + } + + void setdDrawerListArray() { + drawerList = [ + DrawerList( + index: DrawerIndex.HOME, + labelName: 'Home', + icon: new Icon(Icons.home), + ), + DrawerList( + index: DrawerIndex.TransactionHistory, + labelName: 'Transaction History', + icon: new Icon(Icons.history), + ), + DrawerList( + index: DrawerIndex.Offers, + labelName: 'Offers', + icon: new Icon(Icons.local_offer), + ), + DrawerList( + index: DrawerIndex.Rewardz, + labelName: 'Rewardz', + icon: new Icon(Icons.card_giftcard), + ), + DrawerList( + index: DrawerIndex.Settings, + labelName: 'Settings', + icon: new Icon(Icons.person), + ), + DrawerList( + index: DrawerIndex.About, + labelName: 'About BHIM', + icon: new Icon(Icons.info_outline), + ), + ]; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppTheme.notWhite.withOpacity(0.5), + body: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + width: double.infinity, + padding: EdgeInsets.only(top: 40.0), + child: Container( + padding: EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + AnimatedBuilder( + animation: widget.iconAnimationController, + builder: (BuildContext context, Widget child) { + return new ScaleTransition( + scale: new AlwaysStoppedAnimation( + 1.0 - (widget.iconAnimationController.value) * 0.2), + child: RotationTransition( + turns: new AlwaysStoppedAnimation(Tween( + begin: 0.0, end: 24.0) + .animate(CurvedAnimation( + parent: widget.iconAnimationController, + curve: Curves.fastOutSlowIn)) + .value / + 360), + child: Container( + height: 100, + width: 100, + decoration: BoxDecoration( + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + color: AppTheme.grey.withOpacity(0.6), + offset: Offset(2.0, 4.0), + blurRadius: 8), + ], + ), + child: CircleAvatar( + backgroundImage: + AssetImage('assets/images/shivam.jpg'), + backgroundColor: Colors.blue, + ), + ), + ), + ); + }, + ), + Padding( + padding: const EdgeInsets.only(top: 12, left: 4), + child: Text( + myName, + style: TextStyle( + fontWeight: FontWeight.w600, + color: AppTheme.grey, + fontSize: 18, + ), + ), + ), + Padding( + padding: const EdgeInsets.only(top: 4, left: 4), + child: Text( + myID, + style: TextStyle( + fontWeight: FontWeight.w600, + color: AppTheme.grey, + fontSize: 14, + ), + ), + ) + ], + ), + ), + ), + SizedBox( + height: 1, + ), + Divider( + height: 1, + color: AppTheme.grey.withOpacity(0.6), + ), + Expanded( + child: ListView.builder( + physics: BouncingScrollPhysics(), + padding: EdgeInsets.all(0.0), + itemCount: drawerList.length, + itemBuilder: (context, index) { + return inkwell(drawerList[index]); + }, + ), + ), + Divider( + height: 1, + color: AppTheme.grey.withOpacity(0.6), + ), + Column( + children: [ + ListTile( + trailing: Icon( + Icons.code, + color: Colors.green, + ), + title: new Text( + "Team AeroCoders", + style: new TextStyle( + fontWeight: FontWeight.w700, + fontSize: 16, + color: AppTheme.darkText, + ), + textAlign: TextAlign.left, + ), + subtitle: Text('NPCI Voice Payments Hackathon', + style: new TextStyle( + fontWeight: FontWeight.w500, + fontSize: 12, + color: AppTheme.darkText, + )), + onTap: () { + _launchUrlDeveloper(); + }, + ), + SizedBox( + height: MediaQuery.of(context).padding.bottom, + ), + ], + ), + ], + ), + ); + } + + Widget inkwell(DrawerList listData) { + return Material( + color: Colors.transparent, + child: InkWell( + splashColor: Colors.grey.withOpacity(0.1), + highlightColor: Colors.transparent, + onTap: () { + navigationtoScreen(listData.index); + }, + child: Stack( + children: [ + Container( + padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + child: Row( + children: [ + Container( + width: 6.0, + height: 46.0, + decoration: BoxDecoration( + color: widget.screenIndex == listData.index + ? Colors.blue + : Colors.transparent, + borderRadius: new BorderRadius.only( + topLeft: Radius.circular(0), + topRight: Radius.circular(16), + bottomLeft: Radius.circular(0), + bottomRight: Radius.circular(16), + ), + ), + ), + Padding( + padding: EdgeInsets.all(4.0), + ), + listData.isAssetsImage + ? Container( + width: 24, + height: 24, + child: Image.asset(listData.imageName, + color: widget.screenIndex == listData.index + ? Colors.blue + : AppTheme.nearlyBlack), + ) + : new Icon(listData.icon.icon, + color: widget.screenIndex == listData.index + ? Colors.blue + : AppTheme.nearlyBlack), + Padding( + padding: EdgeInsets.all(4.0), + ), + new Text( + listData.labelName, + style: new TextStyle( + fontWeight: FontWeight.w500, + fontSize: 16, + color: widget.screenIndex == listData.index + ? Colors.blue + : AppTheme.nearlyBlack, + ), + textAlign: TextAlign.left, + ), + ], + ), + ), + widget.screenIndex == listData.index + ? AnimatedBuilder( + animation: widget.iconAnimationController, + builder: (BuildContext context, Widget child) { + return new Transform( + transform: new Matrix4.translationValues( + (MediaQuery.of(context).size.width * 0.75 - 64) * + (1.0 - + widget.iconAnimationController.value - + 1.0), + 0.0, + 0.0), + child: Padding( + padding: EdgeInsets.only(top: 8, bottom: 8), + child: Container( + width: + MediaQuery.of(context).size.width * 0.75 - 64, + height: 46, + decoration: BoxDecoration( + color: Colors.blue.withOpacity(0.2), + borderRadius: new BorderRadius.only( + topLeft: Radius.circular(0), + topRight: Radius.circular(28), + bottomLeft: Radius.circular(0), + bottomRight: Radius.circular(28), + ), + ), + ), + ), + ); + }, + ) + : SizedBox() + ], + ), + ), + ); + } + + void navigationtoScreen(DrawerIndex indexScreen) async { + widget.callBackIndex(indexScreen); + } +} + +enum DrawerIndex { + HOME, + Settings, + Rewardz, + TransactionHistory, + Offers, + Invite, + About, +} + +class DrawerList { + String labelName; + Icon icon; + bool isAssetsImage; + String imageName; + DrawerIndex index; + + DrawerList({ + this.isAssetsImage = false, + this.labelName = '', + this.icon, + this.index, + this.imageName = '', + }); +} diff --git a/lib/screens/DrawerScreens/drawerUserController.dart b/lib/screens/DrawerScreens/drawerUserController.dart new file mode 100644 index 0000000..f37a8d0 --- /dev/null +++ b/lib/screens/DrawerScreens/drawerUserController.dart @@ -0,0 +1,232 @@ +import 'package:flutter/material.dart'; + +import 'appDrawer.dart'; + +class DrawerUserController extends StatefulWidget { + final double drawerWidth; + final Function(DrawerIndex) onDrawerCall; + final Widget screenView; + final Function(AnimationController) animationController; + final Function(bool) drawerIsOpen; + final AnimatedIconData animatedIconData; + final Widget menuView; + final DrawerIndex screenIndex; + + const DrawerUserController({ + Key key, + this.drawerWidth: 250, + this.onDrawerCall, + this.screenView, + this.animationController, + this.animatedIconData: AnimatedIcons.arrow_menu, + this.menuView, + this.drawerIsOpen, + this.screenIndex, + }) : super(key: key); + + @override + _DrawerUserControllerState createState() => _DrawerUserControllerState(); +} + +class _DrawerUserControllerState extends State + with TickerProviderStateMixin { + ScrollController scrollController; + AnimationController iconAnimationController; + AnimationController animationController; + + double scrolloffset = 0.0; + bool isSetDawer = false; + + @override + void initState() { + animationController = AnimationController( + duration: Duration(milliseconds: 2000), vsync: this); + iconAnimationController = + AnimationController(vsync: this, duration: Duration(milliseconds: 0)); + iconAnimationController.animateTo(1.0, + duration: Duration(milliseconds: 0), curve: Curves.fastOutSlowIn); + scrollController = + ScrollController(initialScrollOffset: widget.drawerWidth); + scrollController + ..addListener(() { + if (scrollController.offset <= 0) { + if (scrolloffset != 1.0) { + setState(() { + scrolloffset = 1.0; + try { + widget.drawerIsOpen(true); + } catch (e) {} + }); + } + iconAnimationController.animateTo(0.0, + duration: Duration(milliseconds: 0), curve: Curves.linear); + } else if (scrollController.offset > 0 && + scrollController.offset < widget.drawerWidth) { + iconAnimationController.animateTo( + (scrollController.offset * 100 / (widget.drawerWidth)) / 100, + duration: Duration(milliseconds: 0), + curve: Curves.linear); + } else if (scrollController.offset <= widget.drawerWidth) { + if (scrolloffset != 0.0) { + setState(() { + scrolloffset = 0.0; + try { + widget.drawerIsOpen(false); + } catch (e) {} + }); + } + iconAnimationController.animateTo(1.0, + duration: Duration(milliseconds: 0), curve: Curves.linear); + } + }); + getInitState(); + super.initState(); + } + + Future getInitState() async { + await Future.delayed(const Duration(milliseconds: 300)); + try { + widget.animationController(iconAnimationController); + } catch (e) {} + await Future.delayed(const Duration(milliseconds: 100)); + scrollController.jumpTo( + widget.drawerWidth, + ); + setState(() { + isSetDawer = true; + }); + return true; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppTheme.white, + body: SingleChildScrollView( + controller: scrollController, + scrollDirection: Axis.horizontal, + physics: PageScrollPhysics(parent: ClampingScrollPhysics()), + child: Opacity( + opacity: isSetDawer ? 1 : 0, + child: SizedBox( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width + widget.drawerWidth, + child: Row( + children: [ + SizedBox( + width: widget.drawerWidth, + height: MediaQuery.of(context).size.height, + child: AnimatedBuilder( + animation: iconAnimationController, + builder: (BuildContext context, Widget child) { + return new Transform( + transform: new Matrix4.translationValues( + scrollController.offset, 0.0, 0.0), + child: SizedBox( + height: MediaQuery.of(context).size.height, + width: widget.drawerWidth, + child: MyDrawer( + screenIndex: widget.screenIndex == null + ? DrawerIndex.HOME + : widget.screenIndex, + iconAnimationController: iconAnimationController, + callBackIndex: (DrawerIndex indexType) { + onDrawerClick(); + try { + widget.onDrawerCall(indexType); + } catch (e) {} + }, + ), + ), + ); + }, + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + child: Container( + decoration: BoxDecoration( + color: AppTheme.white, + boxShadow: [ + BoxShadow( + color: AppTheme.grey.withOpacity(0.6), + blurRadius: 24), + ], + ), + child: Stack( + children: [ + IgnorePointer( + ignoring: scrolloffset == 1 ? true : false, + child: widget.screenView == null + ? Container( + color: Colors.white, + ) + : widget.screenView, + ), + scrolloffset == 1.0 + ? InkWell( + onTap: () { + onDrawerClick(); + }, + ) + : SizedBox(), + Padding( + padding: EdgeInsets.only( + top: MediaQuery.of(context).padding.top + 8, + left: 8), + child: SizedBox( + width: AppBar().preferredSize.height - 8, + height: AppBar().preferredSize.height - 8, + child: Material( + color: Colors.transparent, + child: InkWell( + borderRadius: new BorderRadius.circular( + AppBar().preferredSize.height), + child: Center( + child: widget.menuView != null + ? widget.menuView +// : AnimatedIcon( +// icon: widget.animatedIconData != null +// ? widget.animatedIconData +// : AnimatedIcons.arrow_menu, +// progress: iconAnimationController), + : widget.menuView, + ), + onTap: () { + FocusScope.of(context) + .requestFocus(FocusNode()); + onDrawerClick(); + }, + ), + ), + ), + ), + ], + ), + ), + ), + ], + ), + ), + ), + ), + ); + } + + void onDrawerClick() { + if (scrollController.offset != 0.0) { + scrollController.animateTo( + 0.0, + duration: Duration(milliseconds: 400), + curve: Curves.fastOutSlowIn, + ); + } else { + scrollController.animateTo( + widget.drawerWidth, + duration: Duration(milliseconds: 400), + curve: Curves.fastOutSlowIn, + ); + } + } +} diff --git a/lib/screens/DrawerScreens/navigationHomeScreen.dart b/lib/screens/DrawerScreens/navigationHomeScreen.dart new file mode 100644 index 0000000..2e9100f --- /dev/null +++ b/lib/screens/DrawerScreens/navigationHomeScreen.dart @@ -0,0 +1,188 @@ +import 'package:BHIM/screens/homeScreen.dart'; +import 'package:BHIM/screens/rewardzScreen.dart'; +import 'package:BHIM/screens/settingsScreen.dart'; +import 'package:BHIM/screens/transactionHistoryScreen.dart'; +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import 'appDrawer.dart'; +import 'drawerUserController.dart'; + +class NavigationHomeScreen extends StatefulWidget { + @override + _NavigationHomeScreenState createState() => _NavigationHomeScreenState(); +} + +class _NavigationHomeScreenState extends State { + Widget screenView; + DrawerIndex drawerIndex; + AnimationController sliderAnimationController; + + _launchUrlWebsite() async { + const url = 'https://bhimupi.org.in'; + if (await canLaunch(url)) { + await launch(url); + } else { + throw 'Could not launch $url'; + } + } + + @override + void initState() { + drawerIndex = DrawerIndex.HOME; + screenView = HomeScreen(); + super.initState(); + } + + Future _onBackPressed() { + return showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text("Leave App"), + content: Column( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text("Are you sure you want to leave?\n"), + Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + GestureDetector( + child: Text( + "Cancel", + style: TextStyle( + color: Colors.blue, fontWeight: FontWeight.w700), + ), + onTap: () { + Navigator.of(context).pop(false); + }, + ), + SizedBox(width: 25.0), + GestureDetector( + child: Text( + "Leave", + style: TextStyle( + color: Colors.blue, fontWeight: FontWeight.w700), + ), + onTap: () { + Navigator.of(context).pop(true); + }, + ) + ], + ), + ], + ), + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + return Container( + color: AppTheme.nearlyWhite, + child: SafeArea( + top: false, + bottom: false, + child: WillPopScope( + onWillPop: _onBackPressed, + child: Scaffold( + backgroundColor: AppTheme.nearlyWhite, + body: DrawerUserController( + screenIndex: drawerIndex, + drawerWidth: MediaQuery.of(context).size.width * 0.75, + animationController: (AnimationController animationController) { + sliderAnimationController = animationController; + }, + onDrawerCall: (DrawerIndex drawerIndexdata) { + changeIndex(drawerIndexdata); + }, + screenView: screenView, + ), + ), + ), + ), + ); + } + + void changeIndex(DrawerIndex drawerIndexdata) { + if (drawerIndex != drawerIndexdata) { + drawerIndex = drawerIndexdata; + if (drawerIndex == DrawerIndex.HOME) { + setState(() { + screenView = HomeScreen(); + }); + } else if (drawerIndex == DrawerIndex.TransactionHistory) { + setState(() { + screenView = TransactionHistoryScreen(); + }); + } else if (drawerIndex == DrawerIndex.Rewardz) { + setState(() { + screenView = RewardzScreen(); + }); + } else if (drawerIndex == DrawerIndex.Settings) { + setState(() { + screenView = SettingsScreen(); + }); + } else if (drawerIndex == DrawerIndex.About) { + setState(() { + screenView = HomeScreen(); + drawerIndex = DrawerIndex.HOME; + }); + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(25), + ), + ), + title: Text( + 'About BHIM', + textAlign: TextAlign.center, + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 25.0), + ), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "Bharat Interface for Money (BHIM) is a payment app that lets you make simple, easy and quick transactions using Unified Payments Interface (UPI). You can make direct bank payments to anyone on UPI using their UPI ID or scanning their QR with the BHIM app. You can also request money through the app from a UPI ID.\n\nPioneered and developed by National Payments Corporation of India (NPCI), BHIM has been conceived and launched by the Hon\'ble Prime Minister of India, Narendra Modi on 30th December 2016 to bring in Financial Inclusion to the nation and a digitally empowered society."), + SizedBox(height: 20.0), + GestureDetector( + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Launch Website', + textAlign: TextAlign.center, + style: TextStyle( + fontWeight: FontWeight.w600, fontSize: 18.0), + ), + IconButton( + icon: Icon( + Icons.arrow_forward_ios, + color: Colors.black, + size: 16.0, + ), + ), + ], + ), + onTap: () { + _launchUrlWebsite(); + }, + ) + ], + ), + ); + }, + ); + } else { + //do in your way...... + } + } + } +} diff --git a/lib/screens/appLockScreen.dart b/lib/screens/appLockScreen.dart index 6da6073..17c4f3c 100644 --- a/lib/screens/appLockScreen.dart +++ b/lib/screens/appLockScreen.dart @@ -1,10 +1,8 @@ +import 'package:BHIM/screens/DrawerScreens/navigationHomeScreen.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_lock_screen/flutter_lock_screen.dart'; import 'package:local_auth/local_auth.dart'; -import 'package:pointycastle/api.dart' as crypto; -import '../security/dependencyProvider.dart'; -import 'homePage.dart'; import 'package:permission_handler/permission_handler.dart'; class AppLockScreen extends StatefulWidget { @@ -32,7 +30,7 @@ class _AppLockScreenState extends State { ]); } - void initState(){ + void initState() { super.initState(); getPermission(); } @@ -59,34 +57,11 @@ class _AppLockScreenState extends State { } } - /// The Future that will show the Pem String - Future futureText; - - /// Future to hold the reference to the KeyPair generated with PointyCastle - /// in order to extract the [crypto.PrivateKey] and [crypto.PublicKey] - Future> - futureKeyPair; - - /// The current [crypto.AsymmetricKeyPair] - crypto.AsymmetricKeyPair keyPair; - - /// With the helper [RsaKeyHelper] this method generates a - /// new [crypto.AsymmetricKeyPair - Future> - getKeyPair() { - var keyHelper = DependencyProvider.of(context).getRsaKeyHelper(); - return keyHelper.computeRSAKeyPair(keyHelper.getSecureRandom()); - } - - /// GlobalKey to be used when showing the [Snackbar] for the successful - /// copy of the Key - final key = new GlobalKey(); - @override Widget build(BuildContext context) { var myPass = [1, 2, 3, 4]; return LockScreen( - title: "BHIM UPI", + title: "Default PassCode is 1234", passLength: myPass.length, bgImage: "assets/images/logo.png", fingerPrintImage: "assets/images/ic_touch.png", @@ -104,14 +79,12 @@ class _AppLockScreenState extends State { return false; } } - return true; }, onSuccess: () { -// getKeyPair(); Navigator.of(context).pushReplacement( new MaterialPageRoute(builder: (BuildContext context) { - return MyHomePage(); + return NavigationHomeScreen(); })); }); } diff --git a/lib/screens/blockedUsersScreen.dart b/lib/screens/blockedUsersScreen.dart index 8113d89..ee917f6 100644 --- a/lib/screens/blockedUsersScreen.dart +++ b/lib/screens/blockedUsersScreen.dart @@ -1,7 +1,7 @@ -import '../components/appBar.dart'; -import '../components/constant.dart'; import 'package:flutter/material.dart'; +import '../components/appBar.dart'; + class BlockedUsersScreen extends StatefulWidget { @override _BlockedUsersScreenState createState() => _BlockedUsersScreenState(); @@ -13,7 +13,9 @@ class _BlockedUsersScreenState extends State { return Scaffold( appBar: TopBar( title: 'Blocked users', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/screens/deviceInfoScreen.dart b/lib/screens/deviceInfoScreen.dart index 1eab061..4a053d8 100644 --- a/lib/screens/deviceInfoScreen.dart +++ b/lib/screens/deviceInfoScreen.dart @@ -1,8 +1,8 @@ -import 'package:flutter/material.dart'; import 'package:android_device_info/android_device_info.dart'; +import 'package:flutter/material.dart'; + import '../components/appBar.dart'; -import '../components/constant.dart'; -import '../components/row_item.dart'; +import '../components/rowItem.dart'; class DeviceInfoScreen extends StatefulWidget { @override @@ -14,12 +14,11 @@ class _DeviceInfoScreenState extends State { @override void initState() { + getDeviceInfo(); super.initState(); - - getData(); } - getData() async { + getDeviceInfo() async { var data = {}; final memory = await AndroidDeviceInfo().getNetworkInfo(); @@ -51,7 +50,9 @@ class _DeviceInfoScreenState extends State { backgroundColor: Colors.white, appBar: TopBar( title: 'Device Info', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/screens/homePage.dart b/lib/screens/homePage.dart index b5743cf..0a56985 100644 --- a/lib/screens/homePage.dart +++ b/lib/screens/homePage.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; -import 'transactionHistoryScreen.dart'; -import 'rewardzScreen.dart'; + import 'homeScreen.dart'; +import 'rewardzScreen.dart'; import 'settingsScreen.dart'; +import 'transactionHistoryScreen.dart'; import 'voicePayDialog.dart'; class MyHomePage extends StatefulWidget { diff --git a/lib/screens/languageScreen.dart b/lib/screens/languageScreen.dart index 0d65255..7271855 100644 --- a/lib/screens/languageScreen.dart +++ b/lib/screens/languageScreen.dart @@ -1,7 +1,7 @@ -import '../components/appBar.dart'; -import '../components/constant.dart'; import 'package:flutter/material.dart'; +import '../components/appBar.dart'; + class LanguageScreen extends StatefulWidget { @override _LanguageScreenState createState() => _LanguageScreenState(); @@ -13,7 +13,9 @@ class _LanguageScreenState extends State { return Scaffold( appBar: TopBar( title: 'Change Language', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/screens/notificationsScreen.dart b/lib/screens/notificationsScreen.dart index e7fd7c5..c433e15 100644 --- a/lib/screens/notificationsScreen.dart +++ b/lib/screens/notificationsScreen.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; + import '../components/appBar.dart'; -import '../components/constant.dart'; class NotificationsScreen extends StatefulWidget { @override @@ -13,7 +13,9 @@ class _NotificationsScreenState extends State { return Scaffold( appBar: TopBar( title: 'Notifications', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/screens/paymentMethodScreen.dart b/lib/screens/paymentMethodScreen.dart index 653b595..5473af2 100644 --- a/lib/screens/paymentMethodScreen.dart +++ b/lib/screens/paymentMethodScreen.dart @@ -1,9 +1,9 @@ -import '../components/appBar.dart'; -import '../components/constant.dart'; -import 'qrFullScreen.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import '../components/appBar.dart'; +import 'qrFullScreen.dart'; + class PaymentMethodScreen extends StatefulWidget { @override _PaymentMethodScreenState createState() => _PaymentMethodScreenState(); @@ -15,7 +15,9 @@ class _PaymentMethodScreenState extends State { return Scaffold( appBar: TopBar( title: 'Payment Method', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/screens/paymentMethodsScreen.dart b/lib/screens/paymentMethodsScreen.dart index 5c86545..161df73 100644 --- a/lib/screens/paymentMethodsScreen.dart +++ b/lib/screens/paymentMethodsScreen.dart @@ -1,7 +1,6 @@ -import '../components/appBar.dart'; -import '../components/constant.dart'; import 'package:flutter/material.dart'; +import '../components/appBar.dart'; import 'paymentMethodScreen.dart'; class PaymentMethodsScreen extends StatefulWidget { @@ -15,7 +14,9 @@ class _PaymentMethodsScreenState extends State { return Scaffold( appBar: TopBar( title: 'Payment Methods', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/screens/privacyScreen.dart b/lib/screens/privacyScreen.dart index 2973199..bb94aa4 100644 --- a/lib/screens/privacyScreen.dart +++ b/lib/screens/privacyScreen.dart @@ -1,7 +1,6 @@ -import '../components/appBar.dart'; -import '../components/constant.dart'; import 'package:flutter/material.dart'; +import '../components/appBar.dart'; import 'blockedUsersScreen.dart'; class PrivacyScreen extends StatefulWidget { @@ -15,7 +14,9 @@ class _PrivacyScreenState extends State { return Scaffold( appBar: TopBar( title: 'Privacy', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/screens/qrFullScreen.dart b/lib/screens/qrFullScreen.dart index dfcf919..11e97e3 100644 --- a/lib/screens/qrFullScreen.dart +++ b/lib/screens/qrFullScreen.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:screenshot_and_share/screenshot_share.dart'; -import 'settingsScreen.dart'; + +import '../global.dart'; class QRFullScreen extends StatefulWidget { @override @@ -41,7 +42,7 @@ class _QRFullScreenState extends State { mainAxisSize: MainAxisSize.max, children: [ Text( - '$firstName $lastName', + myName, style: TextStyle( fontSize: 36.0, fontWeight: FontWeight.w600, @@ -49,7 +50,7 @@ class _QRFullScreenState extends State { ), SizedBox(height: 10.0), Text( - '$upiID', + '$myID', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.w600), ), @@ -59,7 +60,7 @@ class _QRFullScreenState extends State { width: MediaQuery.of(context).size.width * 0.75, child: QrImage( data: - 'upi://pay?pa=$upiID&pn=$firstName $lastName&cu=INR&mode=02&purpose=00&orgid=189999&sign=MEQCHxuGu2MuYK7KM+73lS5q+4iUq8qxigXBJHCv+NeMyVsCIQClwuqF8p0T0kcHZqQKafyea+AF6rzuk45UFhW8+KCfAg==', + 'upi://pay?pa=$myID&pn=$myName&cu=INR&mode=02&purpose=00&orgid=189999&sign=MEQCHxuGu2MuYK7KM+73lS5q+4iUq8qxigXBJHCv+NeMyVsCIQClwuqF8p0T0kcHZqQKafyea+AF6rzuk45UFhW8+KCfAg==', embeddedImage: AssetImage('assets/images/ic_launcher.png'), embeddedImageStyle: diff --git a/lib/screens/qrGenerateScreen.dart b/lib/screens/qrGenerateScreen.dart index aa9d090..8ffb659 100644 --- a/lib/screens/qrGenerateScreen.dart +++ b/lib/screens/qrGenerateScreen.dart @@ -1,14 +1,15 @@ -import '../components/appBar.dart'; -import '../components/constant.dart'; -import 'package:flutter/material.dart'; -import 'package:qr_flutter/qr_flutter.dart'; -import 'package:flutter/services.dart'; import 'dart:async'; +import 'dart:io'; import 'dart:typed_data'; import 'dart:ui'; -import 'dart:io'; + +import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/services.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:qr_flutter/qr_flutter.dart'; + +import '../components/appBar.dart'; class QRGenerateScreen extends StatefulWidget { @override @@ -31,7 +32,9 @@ class QRGenerateScreenState extends State { backgroundColor: Colors.white, appBar: TopBar( title: 'QR Code Generator', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/screens/qrScanScreen.dart b/lib/screens/qrScanScreen.dart index b657c74..0f16d68 100644 --- a/lib/screens/qrScanScreen.dart +++ b/lib/screens/qrScanScreen.dart @@ -1,9 +1,10 @@ +import 'dart:async'; + +import 'package:barcode_scan/barcode_scan.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:barcode_scan/barcode_scan.dart'; -import 'dart:async'; + import '../components/appBar.dart'; -import '../components/constant.dart'; class QRScanScreen extends StatefulWidget { @override @@ -11,7 +12,7 @@ class QRScanScreen extends StatefulWidget { } class _ScanState extends State { - String barcode = ""; + String barcode = ''; @override initState() { @@ -24,7 +25,9 @@ class _ScanState extends State { backgroundColor: Colors.white, appBar: TopBar( title: 'QR Code Scanner', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/screens/requestScreen.dart b/lib/screens/requestScreen.dart index d7bbeaf..608f870 100644 --- a/lib/screens/requestScreen.dart +++ b/lib/screens/requestScreen.dart @@ -1,6 +1,8 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:native_contact_picker/native_contact_picker.dart'; + import '../components/appBar.dart'; -import '../components/constant.dart'; class RequestScreen extends StatefulWidget { @override @@ -8,17 +10,158 @@ class RequestScreen extends StatefulWidget { } class _RequestScreenState extends State { + final NativeContactPicker _contactPicker = new NativeContactPicker(); + Contact _contact; + final controller = TextEditingController(); + FocusNode myFocusNode; + bool isVerified = false; + @override Widget build(BuildContext context) { return Scaffold( appBar: TopBar( title: 'Request Money', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, ), backgroundColor: Colors.white, + body: Container( + alignment: Alignment.center, + padding: EdgeInsets.symmetric(horizontal: 20.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25.0)), + elevation: 4.0, + onPressed: () async { + Contact contact = await _contactPicker.selectContact(); + setState(() { + _contact = contact; + }); +// if (_contact != null) { +// Navigator.of(context).push( +// new MaterialPageRoute(builder: (BuildContext context) { +// return VerifiedRequestScreen(); +// })); +// } + }, + child: Container( + alignment: Alignment.center, + height: 50.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.contacts, + size: 18.0, + color: Colors.white, + ), + Text( + ' Pick Contact', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18.0), + ), + ], + ), + ), + color: Colors.blue, + ), + SizedBox(height: 20.0), + Text( + 'OR Enter UPI ID', + style: TextStyle(fontSize: 16.0), + ), + SizedBox(height: 20.0), + TextField( + controller: controller, + keyboardType: TextInputType.emailAddress, + textCapitalization: TextCapitalization.none, + focusNode: myFocusNode, + autofocus: false, + obscureText: false, + style: TextStyle(fontSize: 20.0), + decoration: InputDecoration( + contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), + hintText: 'UPI ID', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(25.0))), + ), + SizedBox(height: 20.0), + _contact == null + ? Card( + elevation: 4.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0)), + child: ListTile( + title: Text('No Contact Selected'), + ), + ) + : Card( + elevation: 4.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0)), + child: ListTile( + leading: CircleAvatar( + radius: 25.0, +// backgroundImage: AssetImage('assets/images/shivam.jpg'), + backgroundColor: Colors.blue, + child: Text( + _contact.toString()[0], + style: TextStyle( + fontSize: 22.0, fontWeight: FontWeight.w700), + ), + ), + title: Text(_contact.toString().split(':')[0]), + subtitle: Text(_contact + .toString() + .split(':')[1] + .replaceAll('+91', ' ') + .replaceAll(new RegExp(r'\s+\b|\b\s'), '')), + ), + ), + SizedBox(height: 20.0), + RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25.0)), + elevation: 4.0, + onPressed: () {}, + child: Container( + alignment: Alignment.center, + height: 50.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.verified_user, + size: 18.0, + color: Colors.white, + ), + Text( + ' Proceed to Request', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18.0), + ), + ], + ), + ), + color: Colors.green, + ), + SizedBox(height: 20.0), + ], + ), + ), ); } } diff --git a/lib/screens/rewardzScreen.dart b/lib/screens/rewardzScreen.dart index e67a915..a2fbea3 100644 --- a/lib/screens/rewardzScreen.dart +++ b/lib/screens/rewardzScreen.dart @@ -1,6 +1,7 @@ -import '../components/appBar.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; + +import '../components/appBar.dart'; import 'scratchCardDialog.dart'; class RewardzScreen extends StatefulWidget { diff --git a/lib/screens/securityScreen.dart b/lib/screens/securityScreen.dart index a24e3c0..da79099 100644 --- a/lib/screens/securityScreen.dart +++ b/lib/screens/securityScreen.dart @@ -1,7 +1,7 @@ -import '../components/appBar.dart'; -import '../components/constant.dart'; import 'package:flutter/material.dart'; +import '../components/appBar.dart'; + class SecurityScreen extends StatefulWidget { @override _SecurityScreenState createState() => _SecurityScreenState(); @@ -13,7 +13,9 @@ class _SecurityScreenState extends State { return Scaffold( appBar: TopBar( title: 'Security', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/screens/sendScreen.dart b/lib/screens/sendScreen.dart index 3de9902..315a7a4 100644 --- a/lib/screens/sendScreen.dart +++ b/lib/screens/sendScreen.dart @@ -1,6 +1,8 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:native_contact_picker/native_contact_picker.dart'; + import '../components/appBar.dart'; -import '../components/constant.dart'; class SendScreen extends StatefulWidget { @override @@ -8,17 +10,158 @@ class SendScreen extends StatefulWidget { } class _SendScreenState extends State { + final NativeContactPicker _contactPicker = new NativeContactPicker(); + Contact _contact; + final controller = TextEditingController(); + FocusNode myFocusNode; + bool isVerified = false; + @override Widget build(BuildContext context) { return Scaffold( appBar: TopBar( title: 'Send Money', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, ), backgroundColor: Colors.white, + body: Container( + alignment: Alignment.center, + padding: EdgeInsets.symmetric(horizontal: 20.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25.0)), + elevation: 4.0, + onPressed: () async { + Contact contact = await _contactPicker.selectContact(); + setState(() { + _contact = contact; + }); +// if (_contact != null) { +// Navigator.of(context).push( +// new MaterialPageRoute(builder: (BuildContext context) { +// return VerifiedSendScreen(); +// })); +// } + }, + child: Container( + alignment: Alignment.center, + height: 50.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.contacts, + size: 18.0, + color: Colors.white, + ), + Text( + ' Pick Contact', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18.0), + ), + ], + ), + ), + color: Colors.blue, + ), + SizedBox(height: 20.0), + Text( + 'OR Enter UPI ID', + style: TextStyle(fontSize: 16.0), + ), + SizedBox(height: 20.0), + TextField( + controller: controller, + keyboardType: TextInputType.emailAddress, + textCapitalization: TextCapitalization.none, + focusNode: myFocusNode, + autofocus: false, + obscureText: false, + style: TextStyle(fontSize: 20.0), + decoration: InputDecoration( + contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), + hintText: 'UPI ID', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(25.0))), + ), + SizedBox(height: 20.0), + _contact == null + ? Card( + elevation: 4.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0)), + child: ListTile( + title: Text('No Contact Selected'), + ), + ) + : Card( + elevation: 4.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0)), + child: ListTile( + leading: CircleAvatar( + radius: 25.0, +// backgroundImage: AssetImage('assets/images/shivam.jpg'), + backgroundColor: Colors.blue, + child: Text( + _contact.toString()[0], + style: TextStyle( + fontSize: 22.0, fontWeight: FontWeight.w700), + ), + ), + title: Text(_contact.toString().split(':')[0]), + subtitle: Text(_contact + .toString() + .split(':')[1] + .replaceAll('+91', ' ') + .replaceAll(new RegExp(r'\s+\b|\b\s'), '')), + ), + ), + SizedBox(height: 20.0), + RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25.0)), + elevation: 4.0, + onPressed: () {}, + child: Container( + alignment: Alignment.center, + height: 50.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.verified_user, + size: 18.0, + color: Colors.white, + ), + Text( + ' Proceed to Pay', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18.0), + ), + ], + ), + ), + color: Colors.green, + ), + SizedBox(height: 20.0), + ], + ), + ), ); } } diff --git a/lib/screens/settingsScreen.dart b/lib/screens/settingsScreen.dart index 9fc686a..0ee527e 100644 --- a/lib/screens/settingsScreen.dart +++ b/lib/screens/settingsScreen.dart @@ -1,23 +1,19 @@ -import '../components/appBar.dart'; -import 'deviceInfoScreen.dart'; -import 'languageScreen.dart'; -import 'ussdServiceScreen.dart'; -import '../security/securityDashboard.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:qr_flutter/qr_flutter.dart'; +import '../components/appBar.dart'; +import '../global.dart'; +import '../security/securityDashboard.dart'; +import 'deviceInfoScreen.dart'; +import 'languageScreen.dart'; import 'notificationsScreen.dart'; import 'paymentMethodsScreen.dart'; import 'privacyScreen.dart'; import 'qrFullScreen.dart'; import 'qrGenerateScreen.dart'; import 'securityScreen.dart'; - -var mobileNumber = '9012218994'; -var firstName = 'Shivam'; -var lastName = 'Goyal'; -var upiID = mobileNumber + '@upi'; +import 'ussdServiceScreen.dart'; class SettingsScreen extends StatefulWidget { @override @@ -54,7 +50,7 @@ class _SettingsScreenState extends State { alignment: Alignment.center, child: QrImage( data: - 'upi://pay?pa=$mobileNumber@upi&pn=$firstName $lastName&cu=INR&mode=02&purpose=00&orgid=189999&sign=MEQCHxuGu2MuYK7KM+73lS5q+4iUq8qxigXBJHCv+NeMyVsCIQClwuqF8p0T0kcHZqQKafyea+AF6rzuk45UFhW8+KCfAg==', + 'upi://pay?pa=$myMobileNumber@upi&pn=$myName&cu=INR&mode=02&purpose=00&orgid=189999&sign=MEQCHxuGu2MuYK7KM+73lS5q+4iUq8qxigXBJHCv+NeMyVsCIQClwuqF8p0T0kcHZqQKafyea+AF6rzuk45UFhW8+KCfAg==', embeddedImage: AssetImage('assets/images/ic_launcher.png'), embeddedImageStyle: QrEmbeddedImageStyle(size: Size(14, 14)), ), @@ -64,12 +60,12 @@ class _SettingsScreenState extends State { child: Column( children: [ Text( - '$upiID', + '$myID', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w600), ), SizedBox(height: 2.0), Text( - '$firstName $lastName', + myName, style: TextStyle( fontSize: 36.0, fontWeight: FontWeight.w500, @@ -149,7 +145,6 @@ class _SettingsScreenState extends State { })); }, ), - Divider( height: 0.0, color: Colors.black, @@ -313,8 +308,8 @@ class _SettingsScreenState extends State { ), ListTile( leading: IconButton(icon: Icon(FontAwesomeIcons.userSecret)), - title: Text("RSA Dashboard"), - subtitle: Text('Generate RSA Keys'), + title: Text("Security Dashboard"), + subtitle: Text('Send & Receive encrypted data'), trailing: IconButton( icon: Icon( Icons.arrow_forward_ios, diff --git a/lib/screens/transactionDetailScreen.dart b/lib/screens/transactionDetailScreen.dart index 124a5dd..3630feb 100644 --- a/lib/screens/transactionDetailScreen.dart +++ b/lib/screens/transactionDetailScreen.dart @@ -1,9 +1,8 @@ -import '../components/appBar.dart'; -import '../components/constant.dart'; -import '../models/transactionModel.dart'; import 'package:flutter/material.dart'; import 'package:screenshot_and_share/screenshot_share.dart'; -import 'transactionHistoryScreen.dart'; + +import '../components/appBar.dart'; +import '../global.dart'; class TransactionDetailScreen extends StatelessWidget { final int index; @@ -15,7 +14,9 @@ class TransactionDetailScreen extends StatelessWidget { return Scaffold( appBar: TopBar( title: 'Transaction Details', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, @@ -46,9 +47,12 @@ class TransactionDetailScreen extends StatelessWidget { alignment: Alignment.center, child: CircleAvatar( radius: 30.0, - backgroundColor: Colors.transparent, - backgroundImage: - AssetImage(transactionData[index].payerAvatarUrl), + backgroundColor: Colors.blue, + child: Text( + listDecryptedTransaction[index].split(',')[3][0], + style: + TextStyle(fontSize: 30.0, fontWeight: FontWeight.w700), + ), ), ), SizedBox(width: 2.0), @@ -59,9 +63,12 @@ class TransactionDetailScreen extends StatelessWidget { alignment: Alignment.center, child: CircleAvatar( radius: 30.0, - backgroundColor: Colors.transparent, - backgroundImage: - AssetImage(transactionData[index].payeeAvatarUrl), + backgroundColor: Colors.blue, + child: Text( + listDecryptedTransaction[index].split(',')[0][0], + style: + TextStyle(fontSize: 30.0, fontWeight: FontWeight.w700), + ), ), ) ], @@ -70,20 +77,20 @@ class TransactionDetailScreen extends StatelessWidget { child: Column( children: [ Text( - '₹ ' + transactionData[index].amount, + '₹ ' + listDecryptedTransaction[index].split(',')[6], style: TextStyle(fontSize: 40.0, fontWeight: FontWeight.w500), ), SizedBox(height: 2.0), Text( - myID == transactionData[index].payeeID + myID == listDecryptedTransaction[index].split(',')[1] ? 'Received from' : 'Paid to', style: TextStyle(fontSize: 14.0), ), Text( - myID == transactionData[index].payeeID - ? transactionData[index].payerName - : transactionData[index].payeeName, + myID == listDecryptedTransaction[index].split(',')[1] + ? listDecryptedTransaction[index].split(',')[3] + : listDecryptedTransaction[index].split(',')[0], style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.w500, @@ -98,25 +105,32 @@ class TransactionDetailScreen extends StatelessWidget { color: Colors.black, ), ListTile( - leading: transactionData[index].transactionStatus == 'success' + leading: listDecryptedTransaction[index].split(',')[9] == 'success' ? IconButton( icon: Icon(Icons.check_circle, color: Colors.green)) - : transactionData[index].transactionStatus == 'failed' + : listDecryptedTransaction[index].split(',')[9] == 'failed' ? IconButton( icon: Icon(Icons.remove_circle, color: Colors.red)) : IconButton( icon: Icon(Icons.pause_circle_filled, color: Colors.blue)), - title: Text(transactionData[index].transactionStatus == 'success' - ? myID == transactionData[index].payeeID - ? 'Received' + ' ₹ ' + transactionData[index].amount - : 'Paid' + ' ₹ ' + transactionData[index].amount - : transactionData[index].transactionStatus == 'failed' - ? 'Transaction failed' - : 'Transaction pending'), - subtitle: Text(transactionData[index].date + + title: Text( + listDecryptedTransaction[index].split(',')[9] == 'success' + ? myID == listDecryptedTransaction[index].split(',')[1] + ? 'Received' + + ' ₹ ' + + listDecryptedTransaction[index].split(',')[6] + : 'Paid' + + ' ₹ ' + + listDecryptedTransaction[index].split(',')[6] + : listDecryptedTransaction[index].split(',')[9] == 'failed' + ? 'Transaction failed' + : 'Transaction pending'), + subtitle: Text(listDecryptedTransaction[index] + .split(',')[8] + .split(' ')[0] + ' • ' + - transactionData[index].time), + listDecryptedTransaction[index].split(',')[8].split(' ')[1]), ), Divider( height: 0.0, @@ -124,15 +138,16 @@ class TransactionDetailScreen extends StatelessWidget { ), ListTile( title: Text('UPI Transaction ID'), - subtitle: Text(transactionData[index].transactionID), + subtitle: Text(listDecryptedTransaction[index].split(',')[7]), ), ListTile( - title: Text('To: ' + transactionData[index].payeeName), - subtitle: Text(transactionData[index].payeeID), + title: Text('To: ' + listDecryptedTransaction[index].split(',')[0]), + subtitle: Text(listDecryptedTransaction[index].split(',')[1]), ), ListTile( - title: Text('From: ' + transactionData[index].payerName), - subtitle: Text(transactionData[index].payerID), + title: + Text('From: ' + listDecryptedTransaction[index].split(',')[3]), + subtitle: Text(listDecryptedTransaction[index].split(',')[4]), ), Divider( height: 0.0, diff --git a/lib/screens/transactionHistoryScreen.dart b/lib/screens/transactionHistoryScreen.dart index 1d61474..8344bfc 100644 --- a/lib/screens/transactionHistoryScreen.dart +++ b/lib/screens/transactionHistoryScreen.dart @@ -1,11 +1,9 @@ -import '../components/appBar.dart'; -import '../models/transactionModel.dart'; import 'package:flutter/material.dart'; +import '../components/appBar.dart'; +import '../global.dart'; import 'transactionDetailScreen.dart'; -String myID = 'shivamgoyal@upi'; - class TransactionHistoryScreen extends StatefulWidget { @override _TransactionHistoryScreenState createState() => @@ -13,6 +11,11 @@ class TransactionHistoryScreen extends StatefulWidget { } class _TransactionHistoryScreenState extends State { + @override + void initState() { + super.initState(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -27,96 +30,132 @@ class _TransactionHistoryScreenState extends State { ), ), backgroundColor: Colors.white, - body: ListView.builder( - itemCount: transactionData.length, - itemBuilder: (BuildContext context, index) => Column( - children: [ - myID == transactionData[index].payerID - ? ListTile( - leading: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - CircleAvatar( - backgroundColor: Colors.transparent, - backgroundImage: - AssetImage(transactionData[index].payeeAvatarUrl), - ), - ], - ), - title: Text(transactionData[index].payeeName), - subtitle: Text(transactionData[index].payeeID), - trailing: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - transactionData[index].date + - ' • ' + - transactionData[index].time, - style: TextStyle(fontSize: 12.0), + body: FutureBuilder( + future: getTransaction(), + builder: (context, snapshot) { +// if (snapshot.hasData) { + return ListView.builder( + itemCount: listDecryptedTransaction.length, + itemBuilder: (BuildContext context, index) => Column( + children: [ + myID == listDecryptedTransaction[index].split(',')[4] + ? ListTile( + leading: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + CircleAvatar( + backgroundColor: Colors.blue, + child: Text( + listDecryptedTransaction[index].split(',')[0] + [0], + style: TextStyle( + fontSize: 22.0, + fontWeight: FontWeight.w700), + ), + ), + ], ), - Text( - '-' + ' ₹ ' + transactionData[index].amount, - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 18.0, - color: Colors.red), + title: + Text(listDecryptedTransaction[index].split(',')[0]), + subtitle: + Text(listDecryptedTransaction[index].split(',')[1]), + trailing: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + listDecryptedTransaction[index] + .split(',')[8] + .split(' ')[0] + + ' • ' + + listDecryptedTransaction[index] + .split(',')[8] + .split(' ')[1], + style: TextStyle(fontSize: 12.0), + ), + Text( + '-' + + ' ₹ ' + + listDecryptedTransaction[index].split(',')[6], + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 18.0, + color: Colors.red), + ), + ], ), - ], - ), - onTap: () { - Navigator.of(context).push( - MaterialPageRoute(builder: (BuildContext context) { - return TransactionDetailScreen(index: index); - })); - }, - ) - : ListTile( - leading: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - CircleAvatar( - backgroundColor: Colors.transparent, - backgroundImage: - AssetImage(transactionData[index].payerAvatarUrl), + onTap: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (BuildContext context) { + return TransactionDetailScreen(index: index); + })); + }, + ) + : ListTile( + leading: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + CircleAvatar( + backgroundColor: Colors.blue, + child: Text( + listDecryptedTransaction[index].split(',')[3] + [0], + style: TextStyle( + fontSize: 22.0, + fontWeight: FontWeight.w700), + ), + ), + ], ), - ], - ), - title: Text(transactionData[index].payerName), - subtitle: Text(transactionData[index].payerID), - trailing: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - transactionData[index].date + - ' • ' + - transactionData[index].time, - style: TextStyle(fontSize: 12.0), + title: + Text(listDecryptedTransaction[index].split(',')[3]), + subtitle: + Text(listDecryptedTransaction[index].split(',')[4]), + trailing: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + listDecryptedTransaction[index] + .split(',')[8] + .split(' ')[0] + + ' • ' + + listDecryptedTransaction[index] + .split(',')[8] + .split(' ')[1], + style: TextStyle(fontSize: 12.0), + ), + Text( + '+' + + ' ₹ ' + + listDecryptedTransaction[index].split(',')[6], + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 18.0, + color: Colors.green), + ), + ], ), - Text( - '+' + ' ₹ ' + transactionData[index].amount, - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 18.0, - color: Colors.green), - ), - ], - ), - onTap: () { - Navigator.of(context).push( - MaterialPageRoute(builder: (BuildContext context) { - return TransactionDetailScreen(index: index); - })); - }, - ), - Divider( - height: 0.0, + onTap: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (BuildContext context) { + return TransactionDetailScreen(index: index); + })); + }, + ), + Divider( + height: 0.0, + ), + ], ), - ], - ), + ); +// } +// return Container( +// alignment: Alignment.center, +// child: CircularProgressIndicator(backgroundColor: Colors.black)); + }, ), ); } diff --git a/lib/screens/ussdServiceScreen.dart b/lib/screens/ussdServiceScreen.dart index d3204af..48540f1 100644 --- a/lib/screens/ussdServiceScreen.dart +++ b/lib/screens/ussdServiceScreen.dart @@ -1,7 +1,7 @@ -import '../components/appBar.dart'; -import '../components/constant.dart'; import 'package:flutter/material.dart'; +import '../components/appBar.dart'; + class USSDServiceScreen extends StatefulWidget { @override _USSDServiceScreenState createState() => _USSDServiceScreenState(); @@ -13,7 +13,9 @@ class _USSDServiceScreenState extends State { return Scaffold( appBar: TopBar( title: 'USSD Service', - child: kBackBtn, + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/screens/voicePayDialog.dart b/lib/screens/voicePayDialog.dart index 87d144e..9c05257 100644 --- a/lib/screens/voicePayDialog.dart +++ b/lib/screens/voicePayDialog.dart @@ -1,9 +1,14 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; import 'package:speech_recognition/speech_recognition.dart'; + import '../models/languageModel.dart'; import 'languageScreen.dart'; import 'paymentMethodScreen.dart'; import 'paymentMethodsScreen.dart'; +import 'qrFullScreen.dart'; import 'qrScanScreen.dart'; import 'requestScreen.dart'; import 'rewardzScreen.dart'; @@ -11,7 +16,6 @@ import 'sendScreen.dart'; import 'settingsScreen.dart'; import 'transactionHistoryScreen.dart'; import 'ussdServiceScreen.dart'; -import 'qrFullScreen.dart'; class VoicePay extends StatefulWidget { @override @@ -27,6 +31,9 @@ class _VoicePayState extends State { LanguageModel selectedLang = languageData[0]; + String myIntent; + var myIntentConfidence; + @override initState() { super.initState(); @@ -47,6 +54,181 @@ class _VoicePayState extends State { .then((res) => setState(() => _speechRecognitionAvailable = res)); } + getIntent() async { + print( + '----------------------------- Transcription --------------------------------\n' + + transcription); + print( + '----------------------------------------------------------------------------\n\n'); + String url = 'http://52.66.101.188:5005/model/parse'; + final headers = {'Content-Type': 'application/json'}; + Map body = {"text": transcription}; + String jsonBody = json.encode(body); + final encoding = Encoding.getByName('utf-8'); + http.Response response = await http.post(url, + headers: headers, body: jsonBody, encoding: encoding); +// print(response.headers); +// print(response.statusCode); +// print(response.body); + myIntent = response.body.split('"')[5]; + myIntentConfidence = response.body + .split('"')[8] + .replaceAll(',', '') + .replaceAll('}', '') + .replaceAll(':', ''); + print( + "---------------------------- Intent Detected -------------------------------\n" + + myIntent); + print( + '----------------------------------------------------------------------------\n\n'); + print( + "--------------------------- Intent Conficence ------------------------------\n" + + myIntentConfidence); + print( + '----------------------------------------------------------------------------\n\n\n\n\n'); + navigate(); + } + + navigate() { + if (double.parse(myIntentConfidence) >= 0.75) { + if (myIntent == 'account.balance.check') { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return PaymentMethodScreen(); + })); + } else if (myIntent == 'account.transactions.check') { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return TransactionHistoryScreen(); + })); + } else if (myIntent == 'account.rewards.check') { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return RewardzScreen(); + })); + } else if (transcription.contains('scan')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return QRScanScreen(); + })); + } else if (myIntent == 'transfer.money.send') { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return SendScreen(); + })); + } else if (transcription.contains('receive')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return QRFullScreen(); + })); + } else if (myIntent == 'transfer.money.request') { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return RequestScreen(); + })); + } else if (transcription.contains('accounts')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return PaymentMethodsScreen(); + })); + } else if (transcription.contains('language')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return LanguageScreen(); + })); + } else if (transcription.contains('USSD')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return USSDServiceScreen(); + })); + } else if (transcription.contains('logout')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return TransactionHistoryScreen(); + })); + } else if (transcription.contains('feedback')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return TransactionHistoryScreen(); + })); + } else if (transcription.contains('settings')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return SettingsScreen(); + })); + } + } + } + + navigateHard() { + if (transcription.contains('balance')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return PaymentMethodScreen(); + })); + } else if (transcription.contains('history')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return TransactionHistoryScreen(); + })); + } else if (transcription.contains('rewards')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return RewardzScreen(); + })); + } else if (transcription.contains('scan')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return QRScanScreen(); + })); + } else if (transcription.contains('send')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return SendScreen(); + })); + } else if (transcription.contains('receive')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return QRFullScreen(); + })); + } else if (transcription.contains('request')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return RequestScreen(); + })); + } else if (transcription.contains('accounts')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return PaymentMethodsScreen(); + })); + } else if (transcription.contains('language')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return LanguageScreen(); + })); + } else if (transcription.contains('USSD')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return USSDServiceScreen(); + })); + } else if (transcription.contains('logout')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return TransactionHistoryScreen(); + })); + } else if (transcription.contains('feedback')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return TransactionHistoryScreen(); + })); + } else if (transcription.contains('settings')) { + Navigator.of(context) + .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { + return SettingsScreen(); + })); + } + } + @override Widget build(BuildContext context) { return AlertDialog( @@ -167,9 +349,9 @@ class _VoicePayState extends State { ); } - void start() => _speech - .listen(locale: selectedLang.languageCode) - .then((result) => print('_MyAppState.start => result $result')); + void start() => _speech.listen(locale: selectedLang.languageCode); + +// .then((result) => print('_MyAppState.start => result $result')); void cancel() => _speech.cancel().then((result) => setState(() => _isListening = result)); @@ -182,7 +364,7 @@ class _VoicePayState extends State { setState(() => _speechRecognitionAvailable = result); void onCurrentLocale(String locale) { - print('_MyAppState.onCurrentLocale... $locale'); +// print('_MyAppState.onCurrentLocale... $locale'); } void onRecognitionStarted() => setState(() => _isListening = true); @@ -195,72 +377,8 @@ class _VoicePayState extends State { setState(() { return _isListening = false; }); - if (transcription.contains('balance')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return PaymentMethodScreen(); - })); - } else if (transcription.contains('history')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return TransactionHistoryScreen(); - })); - } else if (transcription.contains('rewards')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return RewardzScreen(); - })); - } else if (transcription.contains('scan')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return QRScanScreen(); - })); - } else if (transcription.contains('send')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return SendScreen(); - })); - } else if (transcription.contains('receive')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return QRFullScreen(); - })); - } else if (transcription.contains('request')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return RequestScreen(); - })); - } else if (transcription.contains('accounts')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return PaymentMethodsScreen(); - })); - } else if (transcription.contains('language')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return LanguageScreen(); - })); - } else if (transcription.contains('USSD')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return USSDServiceScreen(); - })); - } else if (transcription.contains('logout')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return TransactionHistoryScreen(); - })); - } else if (transcription.contains('feedback')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return TransactionHistoryScreen(); - })); - } else if (transcription.contains('settings')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return SettingsScreen(); - })); - } +// getIntent(); + navigateHard(); } void errorHandler() => activateSpeechRecognizer(); diff --git a/lib/security/dependencyProvider.dart b/lib/security/dependencyProvider.dart deleted file mode 100644 index 786dc75..0000000 --- a/lib/security/dependencyProvider.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:flutter/material.dart'; -import 'rsaHandling.dart'; - -class DependencyProvider extends InheritedWidget { - static DependencyProvider of(BuildContext context) { - return (context.inheritFromWidgetOfExactType(DependencyProvider) - as DependencyProvider); - } - - DependencyProvider({ - Key key, - Widget child, - }) : super(key: key, child: child); - - @override - bool updateShouldNotify(InheritedWidget oldWidget) => false; - - RsaKeyHelper getRsaKeyHelper() { - return RsaKeyHelper(); - } -} diff --git a/lib/security/rsaHandling.dart b/lib/security/rsaHandling.dart deleted file mode 100644 index bbac2e7..0000000 --- a/lib/security/rsaHandling.dart +++ /dev/null @@ -1,245 +0,0 @@ -import 'dart:convert'; -import 'dart:math'; -import 'dart:typed_data'; - -import "package:asn1lib/asn1lib.dart"; -import 'package:flutter/foundation.dart'; -import "package:pointycastle/export.dart"; - -/// Helper class to handle RSA key generation and encoding -class RsaKeyHelper { - /// Generate a [PublicKey] and [PrivateKey] pair - /// - /// Returns a [AsymmetricKeyPair] based on the [RSAKeyGenerator] with custom parameters, - /// including a [SecureRandom] - Future> computeRSAKeyPair( - SecureRandom secureRandom) async { - return await compute(getRsaKeyPair, secureRandom); - } - - /// Generates a [SecureRandom] - /// - /// Returns [FortunaRandom] to be used in the [AsymmetricKeyPair] generation - SecureRandom getSecureRandom() { - var secureRandom = FortunaRandom(); - var random = Random.secure(); - List seeds = []; - for (int i = 0; i < 32; i++) { - seeds.add(random.nextInt(255)); - } - secureRandom.seed(new KeyParameter(new Uint8List.fromList(seeds))); - return secureRandom; - } - - /// Decode Public key from PEM Format - /// - /// Given a base64 encoded PEM [String] with correct headers and footers, return a - /// [RSAPublicKey] - /// - /// *PKCS1* - /// RSAPublicKey ::= SEQUENCE { - /// modulus INTEGER, -- n - /// publicExponent INTEGER -- e - /// } - /// - /// *PKCS8* - /// PublicKeyInfo ::= SEQUENCE { - /// algorithm AlgorithmIdentifier, - /// PublicKey BIT STRING - /// } - /// - /// AlgorithmIdentifier ::= SEQUENCE { - /// algorithm OBJECT IDENTIFIER, - /// parameters ANY DEFINED BY algorithm OPTIONAL - /// } - RSAPublicKey parsePublicKeyFromPem(pemString) { - List publicKeyDER = decodePEM(pemString); - var asn1Parser = new ASN1Parser(publicKeyDER); - var topLevelSeq = asn1Parser.nextObject() as ASN1Sequence; - - var modulus, exponent; - // Depending on the first element type, we either have PKCS1 or 2 - if (topLevelSeq.elements[0].runtimeType == ASN1Integer) { - modulus = topLevelSeq.elements[0] as ASN1Integer; - exponent = topLevelSeq.elements[1] as ASN1Integer; - } else { - var publicKeyBitString = topLevelSeq.elements[1]; - - var publicKeyAsn = new ASN1Parser(publicKeyBitString.contentBytes()); - ASN1Sequence publicKeySeq = publicKeyAsn.nextObject(); - modulus = publicKeySeq.elements[0] as ASN1Integer; - exponent = publicKeySeq.elements[1] as ASN1Integer; - } - - RSAPublicKey rsaPublicKey = - RSAPublicKey(modulus.valueAsBigInteger, exponent.valueAsBigInteger); - - return rsaPublicKey; - } - - /// Sign plain text with Private Key - /// - /// Given a plain text [String] and a [RSAPrivateKey], decrypt the text using - /// a [RSAEngine] cipher - String sign(String plainText, RSAPrivateKey privateKey) { - var signer = RSASigner(SHA256Digest(), "0609608648016503040201"); - signer.init(true, PrivateKeyParameter(privateKey)); - return base64Encode( - signer.generateSignature(createUint8ListFromString(plainText)).bytes); - } - - /// Creates a [Uint8List] from a string to be signed - Uint8List createUint8ListFromString(String s) { - var codec = Utf8Codec(allowMalformed: true); - return Uint8List.fromList(codec.encode(s)); - } - - /// Decode Private key from PEM Format - /// - /// Given a base64 encoded PEM [String] with correct headers and footers, return a - /// [RSAPrivateKey] - RSAPrivateKey parsePrivateKeyFromPem(pemString) { - List privateKeyDER = decodePEM(pemString); - var asn1Parser = new ASN1Parser(privateKeyDER); - var topLevelSeq = asn1Parser.nextObject() as ASN1Sequence; - - var modulus, privateExponent, p, q; - // Depending on the number of elements, we will either use PKCS1 or PKCS8 - if (topLevelSeq.elements.length == 3) { - var privateKey = topLevelSeq.elements[2]; - - asn1Parser = new ASN1Parser(privateKey.contentBytes()); - var pkSeq = asn1Parser.nextObject() as ASN1Sequence; - - modulus = pkSeq.elements[1] as ASN1Integer; - privateExponent = pkSeq.elements[3] as ASN1Integer; - p = pkSeq.elements[4] as ASN1Integer; - q = pkSeq.elements[5] as ASN1Integer; - } else { - modulus = topLevelSeq.elements[1] as ASN1Integer; - privateExponent = topLevelSeq.elements[3] as ASN1Integer; - p = topLevelSeq.elements[4] as ASN1Integer; - q = topLevelSeq.elements[5] as ASN1Integer; - } - - RSAPrivateKey rsaPrivateKey = RSAPrivateKey( - modulus.valueAsBigInteger, - privateExponent.valueAsBigInteger, - p.valueAsBigInteger, - q.valueAsBigInteger); - - return rsaPrivateKey; - } - - List decodePEM(String pem) { - return base64.decode(removePemHeaderAndFooter(pem)); - } - - String removePemHeaderAndFooter(String pem) { - var startsWith = [ - "-----BEGIN PUBLIC KEY-----", - "-----BEGIN RSA PRIVATE KEY-----", - "-----BEGIN RSA PUBLIC KEY-----", - "-----BEGIN PRIVATE KEY-----", - "-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nVersion: React-Native-OpenPGP.js 0.1\r\nComment: http://openpgpjs.org\r\n\r\n", - "-----BEGIN PGP PRIVATE KEY BLOCK-----\r\nVersion: React-Native-OpenPGP.js 0.1\r\nComment: http://openpgpjs.org\r\n\r\n", - ]; - var endsWith = [ - "-----END PUBLIC KEY-----", - "-----END PRIVATE KEY-----", - "-----END RSA PRIVATE KEY-----", - "-----END RSA PUBLIC KEY-----", - "-----END PGP PUBLIC KEY BLOCK-----", - "-----END PGP PRIVATE KEY BLOCK-----", - ]; - bool isOpenPgp = pem.indexOf('BEGIN PGP') != -1; - - pem = pem.replaceAll(' ', ''); - pem = pem.replaceAll('\n', ''); - pem = pem.replaceAll('\r', ''); - - for (var s in startsWith) { - s = s.replaceAll(' ', ''); - if (pem.startsWith(s)) { - pem = pem.substring(s.length); - } - } - - for (var s in endsWith) { - s = s.replaceAll(' ', ''); - if (pem.endsWith(s)) { - pem = pem.substring(0, pem.length - s.length); - } - } - - if (isOpenPgp) { - var index = pem.indexOf('\r\n'); - pem = pem.substring(0, index); - } - - return pem; - } - - /// Encode Private key to PEM Format - /// - /// Given [RSAPrivateKey] returns a base64 encoded [String] with standard PEM headers and footers - String encodePrivateKeyToPemPKCS1(RSAPrivateKey privateKey) { - var topLevel = new ASN1Sequence(); - - var version = ASN1Integer(BigInt.from(0)); - var modulus = ASN1Integer(privateKey.n); - var publicExponent = ASN1Integer(privateKey.exponent); - var privateExponent = ASN1Integer(privateKey.d); - var p = ASN1Integer(privateKey.p); - var q = ASN1Integer(privateKey.q); - var dP = privateKey.d % (privateKey.p - BigInt.from(1)); - var exp1 = ASN1Integer(dP); - var dQ = privateKey.d % (privateKey.q - BigInt.from(1)); - var exp2 = ASN1Integer(dQ); - var iQ = privateKey.q.modInverse(privateKey.p); - var co = ASN1Integer(iQ); - - topLevel.add(version); - topLevel.add(modulus); - topLevel.add(publicExponent); - topLevel.add(privateExponent); - topLevel.add(p); - topLevel.add(q); - topLevel.add(exp1); - topLevel.add(exp2); - topLevel.add(co); - - var dataBase64 = base64.encode(topLevel.encodedBytes); - - return """-----BEGIN PRIVATE KEY-----\r\n$dataBase64\r\n-----END PRIVATE KEY-----"""; - } - - /// Encode Public key to PEM Format - /// - /// Given [RSAPublicKey] returns a base64 encoded [String] with standard PEM headers and footers - String encodePublicKeyToPemPKCS1(RSAPublicKey publicKey) { - var topLevel = new ASN1Sequence(); - - topLevel.add(ASN1Integer(publicKey.modulus)); - topLevel.add(ASN1Integer(publicKey.exponent)); - - var dataBase64 = base64.encode(topLevel.encodedBytes); - return """-----BEGIN PUBLIC KEY-----\r\n$dataBase64\r\n-----END PUBLIC KEY-----"""; - } -} - -/// Generate a [PublicKey] and [PrivateKey] pair -/// -/// Returns a [AsymmetricKeyPair] based on the [RSAKeyGenerator] with custom parameters, -/// including a [SecureRandom] -AsymmetricKeyPair getRsaKeyPair( - SecureRandom secureRandom) { - var rsapars = new RSAKeyGeneratorParameters(BigInt.from(65537), 2048, 5); - var params = new ParametersWithRandom(rsapars, secureRandom); - var keyGenerator = new RSAKeyGenerator(); - keyGenerator.init(params); - - print(keyGenerator.generateKeyPair()); - - return keyGenerator.generateKeyPair(); -} diff --git a/lib/security/securityDashboard.dart b/lib/security/securityDashboard.dart index 875febd..acdfa3e 100644 --- a/lib/security/securityDashboard.dart +++ b/lib/security/securityDashboard.dart @@ -1,11 +1,8 @@ -import '../components/appBar.dart'; -import '../components/constant.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:pointycastle/api.dart' as crypto; -import 'dependencyProvider.dart'; -TextStyle get whiteTextStyle => TextStyle(color: Colors.white); +import '../components/appBar.dart'; +import '../global.dart'; class SecurityDashBoard extends StatefulWidget { @override @@ -13,172 +10,132 @@ class SecurityDashBoard extends StatefulWidget { } class _SecurityDashBoardState extends State { - /// The Future that will show the Pem String - Future futureText; - - /// Future to hold the reference to the KeyPair generated with PointyCastle - /// in order to extract the [crypto.PrivateKey] and [crypto.PublicKey] - Future> - futureKeyPair; - - /// The current [crypto.AsymmetricKeyPair] - crypto.AsymmetricKeyPair keyPair; - - /// With the helper [RsaKeyHelper] this method generates a - /// new [crypto.AsymmetricKeyPair - Future> - getKeyPair() { - var keyHelper = DependencyProvider.of(context).getRsaKeyHelper(); - return keyHelper.computeRSAKeyPair(keyHelper.getSecureRandom()); - } - - /// GlobalKey to be used when showing the [Snackbar] for the successful - /// copy of the Key - final key = new GlobalKey(); - - /// Text Editing Controller to retrieve the text to sign - TextEditingController _controller = TextEditingController(); - @override Widget build(BuildContext context) { return Scaffold( - key: key, appBar: TopBar( - title: 'RSA Dashboard', - child: kBackBtn, + title: 'Security Dashboard', + child: Icon( + Icons.arrow_back_ios, + ), onPressed: () { Navigator.of(context).pop(); }, ), - body: Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - MaterialButton( - color: Theme.of(context).accentColor, - child: Text( - "Generate new Key Pair", - style: whiteTextStyle, + backgroundColor: Colors.white, + body: Container( + alignment: Alignment.center, + padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 100.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25.0)), + elevation: 4.0, + onPressed: () { + sendTransaction(); + }, + child: Container( + alignment: Alignment.center, + height: 50.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.arrow_forward_ios, + size: 18.0, + color: Colors.white, + ), + Text( + ' Send Transaction ', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18.0), + ), + Icon( + Icons.arrow_forward_ios, + size: 18.0, + color: Colors.white, + ), + ], ), - onPressed: () { - setState(() { - // If there are any pemString being shown, then show an empty message - futureText = Future.value(""); - // Generate a new keypair - futureKeyPair = getKeyPair(); - }); - }, ), - Expanded( - flex: 1, - child: FutureBuilder< - crypto.AsymmetricKeyPair>( - future: futureKeyPair, - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - // if we are waiting for a future to be completed, show a progress indicator - return Center(child: CircularProgressIndicator()); - } else if (snapshot.hasData) { - // Else, store the new keypair in this state and sbow two buttons - this.keyPair = snapshot.data; - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - MaterialButton( - color: Colors.red, - child: Text("Get Private Key", - style: whiteTextStyle), - onPressed: () { - setState(() { - // With the stored keypair, encode the private key to - // PKCS1 and show it - futureText = Future.value( - DependencyProvider.of(context) - .getRsaKeyHelper() - .encodePrivateKeyToPemPKCS1( - keyPair.privateKey)); - }); - }, - ), - MaterialButton( - color: Colors.green, - child: - Text("Get Public Key", style: whiteTextStyle), - onPressed: () { - setState(() { - // With the stored keypair, encode the public key to - // PKCS1 and show it - futureText = Future.value( - DependencyProvider.of(context) - .getRsaKeyHelper() - .encodePublicKeyToPemPKCS1( - keyPair.publicKey)); - }); - }, - ), - TextField( - decoration: - InputDecoration(hintText: "Text to Sign"), - controller: _controller, - ), - MaterialButton( - color: Colors.black87, - child: Text("Sign Text", style: whiteTextStyle), - onPressed: () { - setState(() { - futureText = Future.value( - DependencyProvider.of(context) - .getRsaKeyHelper() - .sign(_controller.text, - keyPair.privateKey)); - }); - }, - ), - ], - ); - } else { - return Container(); - } - }), + color: Colors.blue, + ), + SizedBox(height: 20.0), + RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25.0)), + elevation: 4.0, + onPressed: () { + getTransaction(); + }, + child: Container( + alignment: Alignment.center, + height: 50.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.arrow_back_ios, + size: 18.0, + color: Colors.white, + ), + Text( + ' Get Transaction ', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18.0), + ), + Icon( + Icons.arrow_back_ios, + size: 18.0, + color: Colors.white, + ), + ], + ), ), - Expanded( - flex: 2, - child: Card( - child: Container( - padding: EdgeInsets.all(8), - margin: EdgeInsets.all(8), - child: FutureBuilder( - future: futureText, - builder: (context, snapshot) { - if (snapshot.hasData) { - return SingleChildScrollView( - // the inkwell is used to register the taps - // in order to be able to copy the text - child: InkWell( - onTap: () { - // Copies the data to the keyboard - Clipboard.setData( - new ClipboardData(text: snapshot.data)); - key.currentState.showSnackBar(new SnackBar( - content: new Text("Copied to Clipboard"), - )); - }, - child: Text(snapshot.data)), - ); - } else { - return Center( - child: Text("Your keys will appear here"), - ); - } - }), - ), + color: Colors.green, + ), + SizedBox(height: 20.0), + RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25.0)), + elevation: 4.0, + onPressed: () { + setState(() { + myHash = ''; + }); + }, + child: Container( + alignment: Alignment.center, + height: 50.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.restore, + size: 18.0, + color: Colors.white, + ), + Text( + ' Reset Hash', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18.0), + ), + ], ), - ) - ], - ), + ), + color: Colors.red, + ) + ], ), ), ); diff --git a/pubspec.lock b/pubspec.lock index 506aa71..40a6936 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -8,20 +8,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.2" - asn1lib: - dependency: "direct main" - description: - name: asn1lib - url: "https://pub.dartlang.org" - source: hosted - version: "0.5.14" async: dependency: transitive description: @@ -50,13 +36,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.2" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" collection: dependency: transitive description: @@ -64,27 +43,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.14.11" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" - encrypt: - dependency: "direct main" - description: - name: encrypt - url: "https://pub.dartlang.org" - source: hosted - version: "3.3.1" flutter: dependency: "direct main" description: flutter @@ -151,6 +109,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.7" + native_contact_picker: + dependency: "direct main" + description: + name: native_contact_picker + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.6" path: dependency: transitive description: @@ -186,13 +151,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.2.1" - pointycastle: - dependency: "direct main" - description: - name: pointycastle - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" qr: dependency: transitive description: @@ -214,6 +172,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.5" + random_string: + dependency: "direct main" + description: + name: random_string + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" scratcher: dependency: "direct main" description: @@ -228,6 +193,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.0.2" + simple_rsa: + dependency: "direct main" + description: + name: simple_rsa + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.5" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 626e8f6..4dbb16c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: BHIM description: Voice Based BHIM UPI Payments App -version: 0.5.0+1 +version: 0.7.0+1 repository: https://github.com/ShivamGoyal1899/BHIM authors: - Shivam Goyal @@ -24,11 +24,11 @@ dependencies: screenshot_and_share: ^0.0.2 speech_recognition: ^0.3.0 scratcher: ^1.2.1 - encrypt: ^3.3.1 - pointycastle: ^1.0.0 - asn1lib: ^0.5.3 http: ^0.12.0 permission_handler: ^4.0.0 + native_contact_picker: ^0.0.6 + simple_rsa: ^0.0.5 + random_string: ^1.1.0 dev_dependencies: flutter_test: diff --git a/test/widget_test.dart b/test/widget_test.dart index 6db856c..4a44a40 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -13,7 +13,7 @@ import '../lib/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(BHIMApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget);