diff --git a/assets/images/payment.gif b/assets/images/payment.gif new file mode 100644 index 0000000..ed85779 Binary files /dev/null and b/assets/images/payment.gif differ diff --git a/lib/global.dart b/lib/global.dart index bd7edd7..1430993 100644 --- a/lib/global.dart +++ b/lib/global.dart @@ -1,6 +1,8 @@ +import 'package:barcode_scan/barcode_scan.dart'; import 'package:http/http.dart' as http; import 'package:random_string/random_string.dart'; import 'package:simple_rsa/simple_rsa.dart'; +import 'package:url_launcher/url_launcher.dart'; String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvt4Iixd3XigxqLLHvMp4PDKklFGFbuqnO96AoUdcLl8IHdv6o3gUJnCz3fpj7VFXQzBD0rZ4aOJhJrctfi9F6OGmcazpj7BVk3B1YbjEVLJf3fsZ27PlnwBd8y4te3EcLdUDlFOKErXXb6kCzd4h6azAKik9VYrIn/nnpfuVJLBTenuJEcnHJRY8MyWlL7F3epikHOvqCQRtDcmEqbrMJqLVCLXVjYlZTnPyrzemQ+tGcpVaKKwsjb1EDR9JgDP/Xkpy8eZ18vCDHncpUp2k7FoBM1pg6n1PBMCYGYMN5J76dX7bjeRVeFkRR2Ajh2Ajw2/UL1C+guDeALlUO92fywIDAQAB"; @@ -30,7 +32,7 @@ List users = [ List listDecryptedTransaction = []; -Future sendTransaction() async { +Future sendMoneyTransaction() async { String myTID = 'NPC' + randomNumeric(32).toString(); print( '------------------------------ Previous Hash -------------------------------\n' + @@ -81,7 +83,58 @@ Future sendTransaction() async { ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n\n'); } -Future getTransaction() async { +Future requestMoneyTransaction() 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 = + '$myName,$myID,$myMobileNumber,${users[selectedUserNumber]},${users[selectedUserNumber].toLowerCase().replaceAll(' ', '') + '@upi'},${'+91' + randomBetween(7000000000, 9999999999).toString()},${randomBetween(10, 2000)},$myTID,${DateTime.now()},pending'; + 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 getAllTransactions() async { listDecryptedTransaction.clear(); print( '------------------------------ Recorded Hash -------------------------------\n' + @@ -100,12 +153,13 @@ Future getTransaction() async { '----------------------------------------------------------------------------\n\n'); print( '------------------------ All Decrypted Transaction -------------------------\n'); - for (int i = 0; i < listEncryptedTransaction.length - 1; i++) { + for (int i = listEncryptedTransaction.length - 2; i >= 0; i--) { String toBeAddedTransaction = await decryptString(listEncryptedTransaction[i], privateKey); print(toBeAddedTransaction); listDecryptedTransaction.add(toBeAddedTransaction); } +// listDecryptedTransaction = listEncryptedTransaction.reversed.toList(); print( '----------------------------------------------------------------------------\n'); print( @@ -117,3 +171,12 @@ Future getTransaction() async { print( ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n\n'); } + +Future scan() async { + String barcode = await BarcodeScanner.scan(); + if (await canLaunch(barcode)) { + await launch(barcode); + } else { + throw 'Could not launch $barcode'; + } +} diff --git a/lib/screens/DrawerScreens/appDrawer.dart b/lib/screens/DrawerScreens/appDrawer.dart index ead61a3..ce85299 100644 --- a/lib/screens/DrawerScreens/appDrawer.dart +++ b/lib/screens/DrawerScreens/appDrawer.dart @@ -143,11 +143,6 @@ class _MyDrawerState extends State { 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', @@ -156,7 +151,7 @@ class _MyDrawerState extends State { DrawerList( index: DrawerIndex.Settings, labelName: 'Settings', - icon: new Icon(Icons.person), + icon: new Icon(Icons.settings), ), DrawerList( index: DrawerIndex.About, diff --git a/lib/screens/DrawerScreens/navigationHomeScreen.dart b/lib/screens/DrawerScreens/navigationHomeScreen.dart index 2e9100f..bba6c97 100644 --- a/lib/screens/DrawerScreens/navigationHomeScreen.dart +++ b/lib/screens/DrawerScreens/navigationHomeScreen.dart @@ -39,37 +39,74 @@ class _NavigationHomeScreenState extends State { context: context, builder: (BuildContext context) { return AlertDialog( - title: Text("Leave App"), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(25), + ), + ), + title: Text( + 'Leave BHIM', + textAlign: TextAlign.center, + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 25.0), + ), content: Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - Text("Are you sure you want to leave?\n"), + Text("Are you sure you want to exit?\n"), Row( mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ GestureDetector( - child: Text( - "Cancel", - style: TextStyle( - color: Colors.blue, fontWeight: FontWeight.w700), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + icon: Icon( + Icons.arrow_back_ios, + color: Colors.black, + size: 16.0, + ), + ), + Text( + 'Stay', + textAlign: TextAlign.center, + style: TextStyle( + fontWeight: FontWeight.w600, fontSize: 18.0), + ), + ], ), onTap: () { Navigator.of(context).pop(false); }, ), - SizedBox(width: 25.0), + SizedBox(height: 20.0), GestureDetector( - child: Text( - "Leave", - style: TextStyle( - color: Colors.blue, fontWeight: FontWeight.w700), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Leave', + 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: () { Navigator.of(context).pop(true); }, - ) + ), ], ), ], diff --git a/lib/screens/homeScreen.dart b/lib/screens/homeScreen.dart index d40ff3d..6da4047 100644 --- a/lib/screens/homeScreen.dart +++ b/lib/screens/homeScreen.dart @@ -1,9 +1,8 @@ import 'package:BHIM/screens/requestScreen.dart'; import 'package:BHIM/screens/sendScreen.dart'; -import 'package:barcode_scan/barcode_scan.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; +import '../global.dart'; import 'voicePayDialog.dart'; class HomeScreen extends StatefulWidget { @@ -17,12 +16,18 @@ class _HomeScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - floatingActionButton: FloatingActionButton( + floatingActionButton: FloatingActionButton.extended( + foregroundColor: Colors.blue, + backgroundColor: Colors.white, elevation: 4.0, - child: Icon( + icon: Icon( Icons.mic_none, size: 25, ), + label: Text( + 'VoicePay', + style: TextStyle(fontSize: 16.0), + ), onPressed: () { showDialog( context: context, @@ -32,7 +37,7 @@ class _HomeScreenState extends State { ); }, ), - floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, backgroundColor: Colors.white, body: ListView( padding: EdgeInsets.only(top: 40.0), @@ -172,30 +177,187 @@ class _HomeScreenState extends State { ), ], ), - SizedBox(height: 200), + SizedBox(height: 20.0), + Container( + height: 550.0, + padding: EdgeInsets.symmetric(horizontal: 10.0), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + stops: [0.1, 0.3, 0.8, 0.9], + colors: [ + Colors.orange[900], + Colors.orange[500], + Colors.orange[100], + Colors.white10, + ], + ), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(25), + topRight: Radius.circular(25), + bottomLeft: Radius.circular(0), + bottomRight: Radius.circular(0), + ), + ), + child: Column( + children: [ + SizedBox(height: 25.0), + Container( + margin: EdgeInsets.symmetric(horizontal: 50.0), + height: 50.0, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(25), + topRight: Radius.circular(25), + bottomLeft: Radius.circular(25), + bottomRight: Radius.circular(25), + ), + ), + alignment: Alignment.center, + child: Text('UTILITY SERVICES', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 25.0, + color: Colors.black)), + ), + SizedBox(height: 30.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + children: [ + ActionCard( + title: 'Mobile Prepaid', + icon: Icons.phone_iphone, + ), + ActionCard( + title: 'Movie Tickets', + icon: Icons.local_movies, + ), + ActionCard( + title: 'Electricity', + icon: Icons.lightbulb_outline, + ), + ActionCard( + title: 'Flight Tickets', + icon: Icons.flight_takeoff, + ), + ], + ), + SizedBox(height: 30.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + children: [ + ActionCard( + title: 'DTH', + icon: Icons.live_tv, + ), + ActionCard( + title: 'Shopping', + icon: Icons.shopping_cart, + ), + ActionCard( + title: 'Food', + icon: Icons.fastfood, + ), + ActionCard( + title: 'Broadband', + icon: Icons.wifi, + ), + ], + ), + SizedBox(height: 30.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + children: [ + ActionCard( + title: 'Pets', + icon: Icons.pets, + ), + ActionCard( + title: 'Challan', + icon: Icons.traffic, + ), + ActionCard( + title: 'Fees', + icon: Icons.school, + ), + ActionCard( + title: 'Credit Card', + icon: Icons.credit_card, + ), + ], + ), + SizedBox(height: 30.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + children: [ + ActionCard( + title: 'Donation', + icon: Icons.local_florist, + ), + ActionCard( + title: 'Train Tickets', + icon: Icons.train, + ), + ActionCard( + title: 'Nearby Deals', + icon: Icons.location_on, + ), + ActionCard( + title: 'More', + icon: Icons.more_horiz, + ), + ], + ), + ], + ), + ) ], ), ); } +} + +class ActionCard extends StatelessWidget { + final String title; + final IconData icon; - Future scan() async { - try { - String barcode = await BarcodeScanner.scan(); - setState(() => this.barcode = barcode); - } on PlatformException catch (e) { - if (e.code == BarcodeScanner.CameraAccessDenied) { - setState(() { - this.barcode = 'The user did not grant the camera permission!'; - }); - } else { - setState(() => this.barcode = 'Unknown error: $e'); - } - } on FormatException { - setState(() => this.barcode = - 'null (User returned using the "back"-button before scanning anything. Result)'); - } catch (e) { - setState(() => this.barcode = 'Unknown error: $e'); - } - print(barcode); + const ActionCard({Key key, this.title, this.icon}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width * 0.22, + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(5), + topRight: Radius.circular(5), + bottomLeft: Radius.circular(5), + bottomRight: Radius.circular(5), + ), + ), + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Icon(icon, size: 30.0), + ), + ), + SizedBox(height: 8.0), + Container( + alignment: Alignment.center, + child: Text(title, style: TextStyle(fontSize: 13.0)), + ), + ], + ), + ); } } diff --git a/lib/screens/qrScanScreen.dart b/lib/screens/qrScanScreen.dart index 0f16d68..1a27807 100644 --- a/lib/screens/qrScanScreen.dart +++ b/lib/screens/qrScanScreen.dart @@ -1,10 +1,7 @@ -import 'dart:async'; - -import 'package:barcode_scan/barcode_scan.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import '../components/appBar.dart'; +import '../global.dart'; class QRScanScreen extends StatefulWidget { @override @@ -43,7 +40,9 @@ class _ScanState extends State { color: Colors.blue, textColor: Colors.white, splashColor: Colors.blueGrey, - onPressed: scan, + onPressed: () { + scan(); + }, child: const Text('Pay Now')), ), Padding( @@ -58,24 +57,4 @@ class _ScanState extends State { ), ); } - - Future scan() async { - try { - String barcode = await BarcodeScanner.scan(); - setState(() => this.barcode = barcode); - } on PlatformException catch (e) { - if (e.code == BarcodeScanner.CameraAccessDenied) { - setState(() { - this.barcode = 'The user did not grant the camera permission!'; - }); - } else { - setState(() => this.barcode = 'Unknown error: $e'); - } - } on FormatException { - setState(() => this.barcode = - 'null (User returned using the "back"-button before scanning anything. Result)'); - } catch (e) { - setState(() => this.barcode = 'Unknown error: $e'); - } - } } diff --git a/lib/screens/requestScreen.dart b/lib/screens/requestScreen.dart index 608f870..ef73c1e 100644 --- a/lib/screens/requestScreen.dart +++ b/lib/screens/requestScreen.dart @@ -1,3 +1,4 @@ +import 'package:BHIM/global.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:native_contact_picker/native_contact_picker.dart'; @@ -12,8 +13,10 @@ class RequestScreen extends StatefulWidget { class _RequestScreenState extends State { final NativeContactPicker _contactPicker = new NativeContactPicker(); Contact _contact; - final controller = TextEditingController(); - FocusNode myFocusNode; + final upiIDcontroller = TextEditingController(); + final amountController = TextEditingController(); + FocusNode upiIDFocusNode; + FocusNode amountFocusNode; bool isVerified = false; @override @@ -29,137 +32,177 @@ class _RequestScreenState extends State { }, ), 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), - ), - ], + body: SingleChildScrollView( + child: Container( + alignment: Alignment.center, + padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 75.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; + }); + }, + 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, ), - 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, + SizedBox(height: 20.0), + Text( + 'OR Enter UPI ID', + style: TextStyle(fontSize: 16.0), + ), + SizedBox(height: 20.0), + TextField( + controller: upiIDcontroller, + keyboardType: TextInputType.emailAddress, + textCapitalization: TextCapitalization.none, + focusNode: upiIDFocusNode, + 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), + TextField( + controller: amountController, + keyboardType: TextInputType.number, + textCapitalization: TextCapitalization.none, + focusNode: amountFocusNode, + autofocus: false, + obscureText: false, + style: TextStyle(fontSize: 20.0), + decoration: InputDecoration( + contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), + hintText: 'Amount', + 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), + 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'), '')), ), - 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: () async { + requestMoneyTransaction(); + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(25), + ), + ), + title: Text( + 'Request Successful', + textAlign: TextAlign.center, + style: TextStyle( + fontWeight: FontWeight.w700, fontSize: 25.0), + ), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Image.asset('assets/images/payment.gif'), + ], + ), + ); + }, + ); + await new Future.delayed(const Duration(seconds: 3)); + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + 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), + ), + ], ), - 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, ), - color: Colors.green, - ), - SizedBox(height: 20.0), - ], + SizedBox(height: 20.0), + ], + ), ), ), ); diff --git a/lib/screens/sendScreen.dart b/lib/screens/sendScreen.dart index 315a7a4..9f85b6a 100644 --- a/lib/screens/sendScreen.dart +++ b/lib/screens/sendScreen.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:native_contact_picker/native_contact_picker.dart'; import '../components/appBar.dart'; +import '../global.dart'; class SendScreen extends StatefulWidget { @override @@ -12,8 +13,10 @@ class SendScreen extends StatefulWidget { class _SendScreenState extends State { final NativeContactPicker _contactPicker = new NativeContactPicker(); Contact _contact; - final controller = TextEditingController(); - FocusNode myFocusNode; + final upiIDcontroller = TextEditingController(); + final amountController = TextEditingController(); + FocusNode upiIDFocusNode; + FocusNode amountFocusNode; bool isVerified = false; @override @@ -29,137 +32,176 @@ class _SendScreenState extends State { }, ), 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), - ), - ], + body: SingleChildScrollView( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 75.0), + alignment: Alignment.center, + 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; + }); + }, + 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, ), - 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'), + SizedBox(height: 20.0), + Text( + 'OR Enter UPI ID', + style: TextStyle(fontSize: 16.0), + ), + SizedBox(height: 20.0), + TextField( + controller: upiIDcontroller, + keyboardType: TextInputType.emailAddress, + textCapitalization: TextCapitalization.none, + focusNode: upiIDFocusNode, + 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), + TextField( + controller: amountController, + keyboardType: TextInputType.number, + textCapitalization: TextCapitalization.none, + focusNode: amountFocusNode, + autofocus: false, + obscureText: false, + style: TextStyle(fontSize: 20.0), + decoration: InputDecoration( + contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), + hintText: 'Amount', + 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, + 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'), '')), + ), ), - ) - : 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], + SizedBox(height: 20.0), + RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25.0)), + elevation: 4.0, + onPressed: () async { + sendMoneyTransaction(); + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(25), + ), + ), + title: Text( + 'Payment Successful', + textAlign: TextAlign.center, style: TextStyle( - fontSize: 22.0, fontWeight: FontWeight.w700), + fontWeight: FontWeight.w700, fontSize: 25.0), + ), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Image.asset('assets/images/payment.gif'), + ], ), + ); + }, + ); + await new Future.delayed(const Duration(seconds: 3)); + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + child: Container( + alignment: Alignment.center, + height: 50.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.verified_user, + size: 18.0, + color: Colors.white, ), - title: Text(_contact.toString().split(':')[0]), - subtitle: Text(_contact - .toString() - .split(':')[1] - .replaceAll('+91', ' ') - .replaceAll(new RegExp(r'\s+\b|\b\s'), '')), - ), + Text( + ' Proceed to Pay', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18.0), + ), + ], ), - 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, ), - color: Colors.green, - ), - SizedBox(height: 20.0), - ], + SizedBox(height: 20.0), + ], + ), ), ), ); diff --git a/lib/screens/transactionHistoryScreen.dart b/lib/screens/transactionHistoryScreen.dart index 8344bfc..f193f66 100644 --- a/lib/screens/transactionHistoryScreen.dart +++ b/lib/screens/transactionHistoryScreen.dart @@ -31,7 +31,7 @@ class _TransactionHistoryScreenState extends State { ), backgroundColor: Colors.white, body: FutureBuilder( - future: getTransaction(), + future: getAllTransactions(), builder: (context, snapshot) { // if (snapshot.hasData) { return ListView.builder( diff --git a/lib/screens/voicePayDialog.dart b/lib/screens/voicePayDialog.dart index 9c05257..08a54ec 100644 --- a/lib/screens/voicePayDialog.dart +++ b/lib/screens/voicePayDialog.dart @@ -4,12 +4,12 @@ import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:speech_recognition/speech_recognition.dart'; +import '../global.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'; import 'sendScreen.dart'; @@ -107,10 +107,8 @@ class _VoicePayState extends State { return RewardzScreen(); })); } else if (transcription.contains('scan')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return QRScanScreen(); - })); + Navigator.of(context).pop(); + scan(); } else if (myIntent == 'transfer.money.send') { Navigator.of(context) .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { @@ -177,10 +175,8 @@ class _VoicePayState extends State { return RewardzScreen(); })); } else if (transcription.contains('scan')) { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { - return QRScanScreen(); - })); + Navigator.of(context).pop(); + scan(); } else if (transcription.contains('send')) { Navigator.of(context) .pushReplacement(MaterialPageRoute(builder: (BuildContext context) { diff --git a/lib/security/securityDashboard.dart b/lib/security/securityDashboard.dart index acdfa3e..856d95a 100644 --- a/lib/security/securityDashboard.dart +++ b/lib/security/securityDashboard.dart @@ -36,7 +36,7 @@ class _SecurityDashBoardState extends State { borderRadius: BorderRadius.circular(25.0)), elevation: 4.0, onPressed: () { - sendTransaction(); + sendMoneyTransaction(); }, child: Container( alignment: Alignment.center, @@ -72,7 +72,7 @@ class _SecurityDashBoardState extends State { borderRadius: BorderRadius.circular(25.0)), elevation: 4.0, onPressed: () { - getTransaction(); + getAllTransactions(); }, child: Container( alignment: Alignment.center, diff --git a/pubspec.yaml b/pubspec.yaml index 4dbb16c..99535d4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: BHIM description: Voice Based BHIM UPI Payments App -version: 0.7.0+1 +version: 0.9.0+1 repository: https://github.com/ShivamGoyal1899/BHIM authors: - Shivam Goyal