diff --git a/assets/tick.gif b/assets/tick.gif new file mode 100644 index 0000000..46b7247 Binary files /dev/null and b/assets/tick.gif differ diff --git a/firebase.json b/firebase.json index a68a195..61675bd 100644 --- a/firebase.json +++ b/firebase.json @@ -1,7 +1,7 @@ { "functions": { "predeploy": [ - "npm --prefix \"$RESOURCE_DIR\" run lint" - ] + ], + "source": "functions" } } diff --git a/functions/dist/index.dev.js b/functions/dist/index.dev.js new file mode 100644 index 0000000..fa09e48 --- /dev/null +++ b/functions/dist/index.dev.js @@ -0,0 +1,163 @@ +"use strict"; + +var functions = require('firebase-functions'); + +var admin = require('firebase-admin'); + +admin.initializeApp(); +var fcm = admin.messaging(); +var msgData; +exports.adminOrderTrigger = functions.firestore.document('confirmedOrders/{id}').onCreate(function _callee(snapshot, context) { + var tokens, _snap; + + return regeneratorRuntime.async(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + tokens = []; + _context.next = 3; + return regeneratorRuntime.awrap(admin.firestore().collection('userInfo').where('isAdmin', '==', true).get()); + + case 3: + _snap = _context.sent; + + _snap.forEach(function (k) { + tokens.push(k.data().token.toString()); + }); + + return _context.abrupt("return", fcm.sendToDevice(tokens, { + notification: { + title: 'New Order', + body: 'New order has been placed', + clickAction: 'FLUTTER_NOTIFICATION_CLICK' + } + })); + + case 6: + case "end": + return _context.stop(); + } + } + }); +}); +exports.adminBookingTrigger = functions.firestore.document('BookingDetails/{id}').onCreate(function _callee2(snapshot, context) { + var tokens, _snap; + + return regeneratorRuntime.async(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + tokens = []; + _context2.next = 3; + return regeneratorRuntime.awrap(admin.firestore().collection('userInfo').where('isAdmin', '==', true).get()); + + case 3: + _snap = _context2.sent; + + _snap.forEach(function (k) { + tokens.push(k.data().token.toString()); + }); + + return _context2.abrupt("return", fcm.sendToDevice(tokens, { + notification: { + title: 'New Booking', + body: 'New booking request sent', + clickAction: 'FLUTTER_NOTIFICATION_CLICK' + } + })); + + case 6: + case "end": + return _context2.stop(); + } + } + }); +}); +exports.confirmNotification = functions.firestore.document('confirmedOrders/{id}').onUpdate(function _callee3(snapshot, context) { + var token, rejected, confirmed; + return regeneratorRuntime.async(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + token = snapshot.after.data().token; + rejected = snapshot.after.data().isRejected; + confirmed = snapshot.after.data().isConfirmed; + + if (!(confirmed === true)) { + _context3.next = 7; + break; + } + + return _context3.abrupt("return", fcm.sendToDevice(token, { + notification: { + title: 'Order Confirmation', + body: 'Your order has been confirmed', + clickAction: 'FLUTTER_NOTIFICATION_CLICK' + } + })); + + case 7: + if (!(rejected === true)) { + _context3.next = 9; + break; + } + + return _context3.abrupt("return", fcm.sendToDevice(token, { + notification: { + title: 'Order rejected', + body: 'Your order has been rejected', + clickAction: 'FLUTTER_NOTIFICATION_CLICK' + } + })); + + case 9: + case "end": + return _context3.stop(); + } + } + }); +}); +exports.BookingNotification = functions.firestore.document('BookingDetails/{id}').onUpdate(function _callee4(snapshot, context) { + var token, isConfirmed, isRejected; + return regeneratorRuntime.async(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + token = snapshot.after.data().token; + isConfirmed = snapshot.after.data().isConfirmed; + isRejected = snapshot.after.data().isRejected; + + if (!(isConfirmed === true)) { + _context4.next = 7; + break; + } + + return _context4.abrupt("return", fcm.sendToDevice(token, { + notification: { + title: 'Booking Confirmation', + body: 'Your Booking has been confirmed', + clickAction: 'FLUTTER_NOTIFICATION_CLICK' + } + })); + + case 7: + if (!(isRejected === true)) { + _context4.next = 9; + break; + } + + return _context4.abrupt("return", fcm.sendToDevice(token, { + notification: { + title: 'Booking Rejection', + body: 'Your Booking has been rejected', + clickAction: 'FLUTTER_NOTIFICATION_CLICK' + } + })); + + case 9: + case "end": + return _context4.stop(); + } + } + }); +}); \ No newline at end of file diff --git a/functions/index.js b/functions/index.js index d6279bb..fa3c7e8 100644 --- a/functions/index.js +++ b/functions/index.js @@ -8,21 +8,13 @@ const fcm = admin.messaging(); var msgData; -// exports.offerTrigger = functions.firestore.document('confirmedOrders/{id}').onCreate((snapshot, context) => { -// msgData = snapshot.data(); -// return fcm.sendToTopic('confirmedOrders', { -// notification: {title: snapshot.data().name, body: 'order has been placed',clickAction: 'FLUTTER_NOTIFICATION_CLICK'} -// }); - -// }); - -exports.adminOrderTrigger = functions.firestore.document('confirmedOrders/{id}').onCreate((snapshot, context) => { - var tokens = [ - 'd7cf7_GgXCg:APA91bF-HqKMwlAfTsy3dRv_LVuvxkDbiBOWkBMWHweu6X8wvq_9Zw7x8ws2qSepPOk1dypxySmiv-6ct72Pbzwu6nOejFCcTEy17-_k8EmvOEMvcS2BGP-ToNAqsfF9m_EbPG4jdlhu', - 'dtG7Gozeq5M:APA91bHAblBNNNJnPn9EY0DWqVLbTnT8jvZNctTDxLVI9QkYU7T0BJP_U8j_pjdRu0LYeNGYtDUHzPN22cmB1cT0z95Z1Y8NDHsJD8wuWHfPax68nwYa4OmgG4Ky6i5KjaHca7-AnWdc' - - ]; +exports.adminOrderTrigger = functions.firestore.document('confirmedOrders/{id}').onCreate(async (snapshot, context) => { + var tokens = []; + const _snap = await admin.firestore().collection('userInfo').where('isAdmin', '==', true).get(); + _snap.forEach((k) => { + tokens.push(k.data().token.toString()); + }) return fcm.sendToDevice(tokens, { notification: { title: 'New Order', @@ -33,11 +25,12 @@ exports.adminOrderTrigger = functions.firestore.document('confirmedOrders/{id}') }); -exports.adminBookingTrigger = functions.firestore.document('BookingDetails/{id}').onCreate((snapshot, context) => { - var tokens = [ - 'dtG7Gozeq5M:APA91bHAblBNNNJnPn9EY0DWqVLbTnT8jvZNctTDxLVI9QkYU7T0BJP_U8j_pjdRu0LYeNGYtDUHzPN22cmB1cT0z95Z1Y8NDHsJD8wuWHfPax68nwYa4OmgG4Ky6i5KjaHca7-AnWdc', - 'd7cf7_GgXCg:APA91bF-HqKMwlAfTsy3dRv_LVuvxkDbiBOWkBMWHweu6X8wvq_9Zw7x8ws2qSepPOk1dypxySmiv-6ct72Pbzwu6nOejFCcTEy17-_k8EmvOEMvcS2BGP-ToNAqsfF9m_EbPG4jdlhu' - ]; +exports.adminBookingTrigger = functions.firestore.document('BookingDetails/{id}').onCreate(async (snapshot, context) => { + var tokens = []; + const _snap = await admin.firestore().collection('userInfo').where('isAdmin', '==', true).get(); + _snap.forEach((k) => { + tokens.push(k.data().token.toString()); + }) return fcm.sendToDevice(tokens, { notification: { title: 'New Booking', @@ -47,25 +40,52 @@ exports.adminBookingTrigger = functions.firestore.document('BookingDetails/{id}' }) }); -exports.confirmNotification = functions.firestore.document('confirmedOrders/{id}').onUpdate((snapshot, context) => { +exports.confirmNotification = functions.firestore.document('confirmedOrders/{id}').onUpdate(async(snapshot, context) => { var token = snapshot.after.data().token; - return fcm.sendToDevice(token, { - notification: { - title: 'Order Confirmation', - body: 'Your order has been confirmed', - clickAction: 'FLUTTER_NOTIFICATION_CLICK' - } - }) + var rejected = snapshot.after.data().isRejected; + var confirmed = snapshot.after.data().isConfirmed; + + if(confirmed === true) { + return fcm.sendToDevice(token, { + notification: { + title: 'Order Confirmation', + body: 'Your order has been confirmed', + clickAction: 'FLUTTER_NOTIFICATION_CLICK' + } + }); + } else if(rejected === true) { + return fcm.sendToDevice(token, { + notification: { + title: 'Order rejected', + body: 'Your order has been rejected', + clickAction: 'FLUTTER_NOTIFICATION_CLICK' + } + }); + } + }); -exports.BookingNotification = functions.firestore.document('BookingDetails/{id}').onUpdate((snapshot, context) => { +exports.BookingNotification = functions.firestore.document('BookingDetails/{id}').onUpdate(async(snapshot, context) => { var token = snapshot.after.data().token; - return fcm.sendToDevice(token, { - notification: { - title: 'Booking Confirmation', - body: 'Your Booking has been confirmed', - clickAction: 'FLUTTER_NOTIFICATION_CLICK' - } - }) + var isConfirmed = snapshot.after.data().isConfirmed; + var isRejected = snapshot.after.data().isRejected; + if(isConfirmed === true) { + return fcm.sendToDevice(token, { + notification: { + title: 'Booking Confirmation', + body: 'Your Booking has been confirmed', + clickAction: 'FLUTTER_NOTIFICATION_CLICK' + } + }); + } else if(isRejected === true) { + return fcm.sendToDevice(token, { + notification: { + title: 'Booking Rejection', + body: 'Your Booking has been rejected', + clickAction: 'FLUTTER_NOTIFICATION_CLICK' + } + }); + } }); + diff --git a/lib/CustomWidget/food_card.dart b/lib/CustomWidget/food_card.dart index 3c9d8bc..d367d87 100644 --- a/lib/CustomWidget/food_card.dart +++ b/lib/CustomWidget/food_card.dart @@ -13,7 +13,8 @@ class FoodCard extends StatelessWidget { final int itemprice; final bool areYouAdmin; - FoodCard({this.areYouAdmin, this.categoryName, this.imagePath, this.itemprice}); + FoodCard( + {this.areYouAdmin, this.categoryName, this.imagePath, this.itemprice}); StoreData storeData = StoreData(); @@ -51,171 +52,183 @@ class FoodCard extends StatelessWidget { @override Widget build(BuildContext context) { - return areYouAdmin ? FocusedMenuHolder( - onPressed: () {}, - menuItems: [ - FocusedMenuItem( - title: Text('Delete the item'), - onPressed: () { - deleteMenu(); - }) - ], - child: Container( - width: 168, - margin: EdgeInsets.only(right: 10.0), - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage(imagePath), - fit: BoxFit.cover, - ), - borderRadius: BorderRadius.circular(6)), - child: Container( - padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - InkWell( - onTap: () { - deleteMenu(); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.deepOrange, - borderRadius: BorderRadius.circular(5)), - child: Icon( - Icons.delete_outline, - color: Colors.white, - ), - ), - ) - ], - ), - Row( + return areYouAdmin + ? FocusedMenuHolder( + onPressed: () {}, + menuItems: [ + FocusedMenuItem( + title: Text('Delete the item'), + onPressed: () { + deleteMenu(); + }) + ], + child: Container( + width: MediaQuery.of(context).size.width * 0.41, + margin: EdgeInsets.only(right: 10.0), + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage(imagePath), + fit: BoxFit.cover, + ), + borderRadius: BorderRadius.circular(6)), + child: Container( + padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), + child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, children: [ - Column( + Row( mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - width: MediaQuery.of(context).size.width*0.25, - height: MediaQuery.of(context).size.height*0.03, - child: Text( - categoryName, - style: GoogleFonts.inter( - fontWeight: FontWeight.bold, - fontSize: 13.0, - color: Colors.white), - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.left, + InkWell( + onTap: () { + deleteMenu(); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.deepOrange, + borderRadius: BorderRadius.circular(5)), + child: Icon( + Icons.delete_outline, + color: Colors.white, + ), ), - ), - Container( - width: MediaQuery.of(context).size.width*0.2, - height: MediaQuery.of(context).size.height*0.03, - - child:Text( - '₹' + '$itemprice', - style: GoogleFonts.inter(color: Colors.white), - ) ) ], ), - InkWell( - onTap: () { - addToCart(categoryName, itemprice); - showFlushbar(context); - }, - child: Container( - height: 25, - width: MediaQuery.of(context).size.width*0.1, - decoration: BoxDecoration( - color: Colors.deepOrange, - border: - Border.all(color: Colors.black, width: 0.1), - borderRadius: BorderRadius.circular(5)), - child: Center( - child: Text( - 'Add', - style: GoogleFonts.inter( - fontWeight: FontWeight.w400, - color: Colors.white), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: + MediaQuery.of(context).size.width * 0.25, + height: + MediaQuery.of(context).size.height * 0.03, + child: Text( + categoryName, + style: GoogleFonts.inter( + fontWeight: FontWeight.bold, + fontSize: 13.0, + color: Colors.white), + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + ), + ), + Container( + width: + MediaQuery.of(context).size.width * 0.2, + height: MediaQuery.of(context).size.height * + 0.03, + child: Text( + '₹' + '$itemprice', + style: GoogleFonts.inter( + color: Colors.white), + )) + ], ), - ), - ), - ) - ]) - ], - ), - )), - ) : Container( - width: 160, - margin: EdgeInsets.only(right: 10.0), - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage(imagePath), - fit: BoxFit.cover, - ), - borderRadius: BorderRadius.circular(6)), - child: Container( - padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 60, - child: Text( - categoryName, - style: GoogleFonts.inter( - fontWeight: FontWeight.bold, - fontSize: 16.0, - color: Colors.white), + InkWell( + onTap: () { + addToCart(categoryName, itemprice); + showFlushbar(context); + }, + child: Container( + height: 25, + width: MediaQuery.of(context).size.width * 0.1, + decoration: BoxDecoration( + color: Colors.deepOrange, + border: Border.all( + color: Colors.black, width: 0.1), + borderRadius: BorderRadius.circular(5)), + child: Center( + child: Text( + 'Add', + style: GoogleFonts.inter( + fontWeight: FontWeight.w400, + color: Colors.white), + ), + ), + ), + ) + ]) + ], + ), + )), + ) + : Container( + width: MediaQuery.of(context).size.width * 0.41, + margin: EdgeInsets.only(right: 10.0), + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage(imagePath), + fit: BoxFit.cover, + ), + borderRadius: BorderRadius.circular(6)), + child: Container( + padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.25, + height: MediaQuery.of(context).size.height * 0.03, + child: Text( + categoryName, + style: GoogleFonts.inter( + fontWeight: FontWeight.bold, + fontSize: 13.0, + color: Colors.white), + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + ), ), - ), - Text( - '₹' + '$itemprice', - style: GoogleFonts.inter(color: Colors.white), - ) - ], - ), - InkWell( - onTap: () { - addToCart(categoryName, itemprice); - showFlushbar(context); - }, - child: Container( - height: 25, - width: 45, - decoration: BoxDecoration( - color: Colors.deepOrange, - border: - Border.all(color: Colors.black, width: 0.1), - borderRadius: BorderRadius.circular(5)), - child: Center( - child: Text( - 'Add', - style: GoogleFonts.inter( - fontWeight: FontWeight.w400, - color: Colors.white), + Container( + width: MediaQuery.of(context).size.width * 0.2, + height: MediaQuery.of(context).size.height * 0.03, + child: Text( + '₹' + '$itemprice', + style: GoogleFonts.inter(color: Colors.white), + ), + ) + ], + ), + InkWell( + onTap: () { + addToCart(categoryName, itemprice); + showFlushbar(context); + }, + child: Container( + height: 25, + width: 45, + decoration: BoxDecoration( + color: Colors.deepOrange, + border: + Border.all(color: Colors.black, width: 0.1), + borderRadius: BorderRadius.circular(5)), + child: Center( + child: Text( + 'Add', + style: GoogleFonts.inter( + fontWeight: FontWeight.w400, + color: Colors.white), + ), ), ), - ), - ) - ]) - ], - ), - )); + ) + ]) + ], + ), + )); } } diff --git a/lib/CustomWidget/foot_category.dart b/lib/CustomWidget/foot_category.dart index 3d5073d..ebd4538 100644 --- a/lib/CustomWidget/foot_category.dart +++ b/lib/CustomWidget/foot_category.dart @@ -41,7 +41,8 @@ class FoodCategory extends StatelessWidget { size: 45, ), SizedBox(height: 20), - Text('LOADING', style: GoogleFonts.inter(fontWeight: FontWeight.w400)) + Text('LOADING', + style: GoogleFonts.inter(fontWeight: FontWeight.w400)) ]), ); } else { @@ -51,17 +52,11 @@ class FoodCategory extends StatelessWidget { scrollDirection: Axis.horizontal, itemCount: _menuList.length, itemBuilder: (BuildContext context, int index) { - return FocusedMenuHolder( - onPressed: () {}, - menuItems: [ - FocusedMenuItem(title: Text('delete'), onPressed: () {}) - ], - child: FoodCard( - areYouAdmin: areYouAdmin, - categoryName: _menuList[index].category_menu, - imagePath: _menuList[index].imagepath, - itemprice: _menuList[index].price, - ), + return FoodCard( + areYouAdmin: areYouAdmin, + categoryName: _menuList[index].category_menu, + imagePath: _menuList[index].imagepath, + itemprice: _menuList[index].price, ); }, ), diff --git a/lib/main.dart b/lib/main.dart index 20ee121..7c7ac94 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,6 +10,7 @@ import 'package:rcapp/pages/CategoryMenuList/Bread_Menu.dart'; import 'package:rcapp/pages/CategoryMenuList/Breakfast_Menu.dart'; import 'package:rcapp/pages/CategoryMenuList/Burger_Menu.dart'; import 'package:rcapp/pages/CategoryMenuList/Chinese_Menu.dart'; +import 'package:rcapp/pages/CategoryMenuList/ContactDetails.dart'; import 'package:rcapp/pages/CategoryMenuList/FriedRiceAndNoodles_Menu.dart'; import 'package:rcapp/pages/CategoryMenuList/MainCourse_Menu.dart'; import 'package:rcapp/pages/CategoryMenuList/Pasta_Menu.dart'; @@ -38,21 +39,24 @@ import 'package:rcapp/pages/mainhall.dart'; import 'package:rcapp/pages/orderdetails.dart'; import 'package:rcapp/pages/previousBooking.dart'; import 'package:rcapp/pages/previousOrder.dart'; +import 'package:rcapp/pages/storeData.dart'; import 'package:rcapp/pages/uploadAvatar.dart'; import 'package:rcapp/pages/uploadImage.dart'; import 'package:rcapp/pages/uploadPdf.dart'; +import 'package:rcapp/pages/uploadPdfImage.dart'; import 'package:rcapp/pages/welcome.dart'; import 'package:rcapp/services/auth.dart'; import 'pages/wrapper.dart'; import 'package:provider/provider.dart'; import 'package:rcapp/models/user.dart'; + void main() async { WidgetsFlutterBinding.ensureInitialized(); await FlutterDownloader.initialize( debug: true // optional: set false to disable printing logs to console ); - + runApp(MyApp()); } @@ -60,60 +64,65 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return StreamProvider.value( - value: AuthService().user, - child: MaterialApp( - debugShowCheckedModeBanner: false, - home: welcome(), - routes: { - '/navigationbar': (context) => NavigationBar(), - '/bookingcalendar': (context) => Calendar(), - '/cart': (context) => Cart(), - '/adminorder': (context) => AdminOrder(), - // '/orderdetails': (context) => OrderDetails(), - '/wrapper': (context) => Wrapper(), - "/add_event": (context) => AddEventPage(), - "/address": (context) => AddressForm(), - "/previousOrder": (context) => PreviousOrder(), - "/previousBooking": (context) => PreviousBooking(), - "/adminBooking": (context) => AdminBooking(), - // "/previousOrder": (context) => PreviousOrderDetails(), + value: AuthService().user, + child: ChangeNotifierProvider( + create: (context) => StoreData(), + child: MaterialApp( + debugShowCheckedModeBanner: false, + home: welcome(), + routes: { + '/navigationbar': (context) => NavigationBar(), + '/bookingcalendar': (context) => Calendar(), + '/cart': (context) => Cart(), + '/adminorder': (context) => AdminOrder(), + // '/orderdetails': (context) => OrderDetails(), + '/wrapper': (context) => Wrapper(), + "/add_event": (context) => AddEventPage(), + "/address": (context) => AddressForm(), + "/previousOrder": (context) => PreviousOrder(), + "/previousBooking": (context) => PreviousBooking(), + "/adminBooking": (context) => AdminBooking(), + "/contactDetails": (context) => ContactDetails(), + // "/previousOrder": (context) => PreviousOrderDetails(), - //routes for different categories of food - "/allmenu": (context) => AllMenu(), - "/biryanimenu": (context) => Biryani_MenuList(), - "/breadmenu": (context) => Bread_MenuList(), - "/breakfastmenu": (context) => Breakfast_MenuList(), - "/burgermenu": (context) => Burger_MenuList(), - "/chinesemenu": (context) => ChineseMenuList(), - "/friedriceandnoodlesmenu": (context) => - FriedRiceAndNoodles_MenuList(), - "/maincoursemenu": (context) => MainCourse_MenuList(), - "/pastamenu": (context) => Pasta_MenuList(), - "/pizzamenu": (context) => Pizza_MenuList(), - "/rollmenu": (context) => Roll_MenuList(), - "/sandwichmenu": (context) => Sandwich_MenuList(), - "/snacksmenu": (context) => Snacks_MenuList(), - "/soupmenu": (context) => Soup_MenuList(), - "/startermenu": (context) => StarterMenuList(), - "/tandoorimenu": (context) => Tandoori_MenuList(), - "/accompanimentmenu": (context) => Accompaniment_Menu(), + //routes for different categories of food + "/allmenu": (context) => AllMenu(), + "/biryanimenu": (context) => Biryani_MenuList(), + "/breadmenu": (context) => Bread_MenuList(), + "/breakfastmenu": (context) => Breakfast_MenuList(), + "/burgermenu": (context) => Burger_MenuList(), + "/chinesemenu": (context) => ChineseMenuList(), + "/friedriceandnoodlesmenu": (context) => + FriedRiceAndNoodles_MenuList(), + "/maincoursemenu": (context) => MainCourse_MenuList(), + "/pastamenu": (context) => Pasta_MenuList(), + "/pizzamenu": (context) => Pizza_MenuList(), + "/rollmenu": (context) => Roll_MenuList(), + "/sandwichmenu": (context) => Sandwich_MenuList(), + "/snacksmenu": (context) => Snacks_MenuList(), + "/soupmenu": (context) => Soup_MenuList(), + "/startermenu": (context) => StarterMenuList(), + "/tandoorimenu": (context) => Tandoori_MenuList(), + "/accompanimentmenu": (context) => Accompaniment_Menu(), - // lounge routes - "/bluelounge": (context) => BlueLounge(), - "/yellowlounge": (context) => YellowLounge(), - "/milanlounge": (context) => MilanLounge(), - "/milaplounge": (context) => MilapLounge(), - "/coluseum": (context) => Coluseum(), - "/mainhall" : (context) => MainHall(), - "/weddinghall": (context) => WeddingHall(), - "/tenniscourt": (context) => TennisCourt(), + // lounge routes + "/bluelounge": (context) => BlueLounge(), + "/yellowlounge": (context) => YellowLounge(), + "/milanlounge": (context) => MilanLounge(), + "/milaplounge": (context) => MilapLounge(), + "/coluseum": (context) => Coluseum(), + "/mainhall" : (context) => MainHall(), + "/weddinghall": (context) => WeddingHall(), + "/tenniscourt": (context) => TennisCourt(), - //Routes for admin - "/uploadImage": (context) => UploadImage(), - "/uploadPdf": (context) => UploadPdf(), - "/uploadAvatarImage": (context) => UploadAvatar() - }, - ), - ); + //Routes for admin + "/uploadImage": (context) => UploadImage(), + "/uploadPdf": (context) => UploadPdf(), + "/uploadPdfImage": (context) => UploadPdfImage(), + "/uploadAvatarImage": (context) => UploadAvatar() + }, + ), + ), + ); } } diff --git a/lib/pages/BlueL.dart b/lib/pages/BlueL.dart index ae39e26..6235b4e 100644 --- a/lib/pages/BlueL.dart +++ b/lib/pages/BlueL.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:google_fonts/google_fonts.dart'; - class BlueLounge extends StatefulWidget { @override _BlueLoungeState createState() => _BlueLoungeState(); @@ -14,52 +14,59 @@ class _BlueLoungeState extends State { appBar: AppBar( elevation: 10.0, backgroundColor: Colors.deepOrange, - title: Text('Blue Lounge'), + title: Text('Lounges'), ), - body: new Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Container( - height: 200.0, - width: double.infinity, - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/12.jpg"), - fit: BoxFit.fill)), - ), - ), - Text( - "Blue Lounge", - style: GoogleFonts.inter( - color: Colors.blueAccent, - fontSize: 40, - ), + body: Container( + height: MediaQuery.of(context).size.height * 1, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Container( + height: 200.0, + width: double.infinity, + padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/12.jpg"), + fit: BoxFit.fill)), + ), + ), + Text( + "Blue Lounge", + style: GoogleFonts.inter( + color: Colors.blueAccent, + fontSize: MediaQuery.of(context).size.width * 0.075, + ), + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 15, vertical: 0), + child: Text( + "\nThe Blue Lounge is a comfortable lounge present in the ground floor of the club. Perfect for small group gatherings like office parties, get togethers amongst friends etc \n\nCapacity : 15 people \n \n ", + style: GoogleFonts.inter( + fontSize: MediaQuery.of(context).size.width * 0.05), + textAlign: TextAlign.left, + ), + ), + SizedBox( + width: double.infinity, + height: 60, + child: ButtonTheme( + child: RaisedButton( + color: Colors.deepOrange, + onPressed: () { + Navigator.pushNamed(context, "/bookingcalendar"); + }, + child: Text('Book', + style: GoogleFonts.inter( + color: Colors.white, fontSize: 18))), + )), + ], ), - Text( - "\nThe Blue Lounge is a comfortable lounge present in the ground floor of the club. Perfect for small group gatherings like office parties, get togethers amongst friends etc \n\nCapacity : 15 people \n \n ", - style: GoogleFonts.inter( - fontSize: 20 - ), - ), - SizedBox( - width: double.infinity, - height: 60, - child: ButtonTheme( - child: RaisedButton( - color: Colors.deepOrange, - onPressed: () { - Navigator.pushNamed(context, "/bookingcalendar"); - }, - child: Text('Book', - style: GoogleFonts.inter(color: Colors.white, fontSize: 18))), - )), - ], - ), + ), ); } } diff --git a/lib/pages/Booking.dart b/lib/pages/Booking.dart index 4df2a9e..4116fb3 100644 --- a/lib/pages/Booking.dart +++ b/lib/pages/Booking.dart @@ -11,245 +11,279 @@ class Booking extends StatefulWidget { class _BookingState extends State { @override Widget build(BuildContext context) { - return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, elevation: 10.0, backgroundColor: Colors.deepOrange, title: Container( - margin: EdgeInsets.only(left: MediaQuery.of(context).size.width*0.13), - child:Text('Booking', style: GoogleFonts.inter()), - ), //repeat for menu and booking + margin: + EdgeInsets.only(left: MediaQuery.of(context).size.width * 0.13), + child: Text('Booking', style: GoogleFonts.inter()), + ), //repeat for menu and booking ), body: new ListView( children: [ SizedBox(height: 30.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - " Lounges", - style: GoogleFonts.inter( - color: Colors.grey, - fontSize: 18, - fontWeight: FontWeight.w600, + Container( + margin: const EdgeInsets.symmetric(vertical: 0, horizontal: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + " Lounges", + style: GoogleFonts.inter( + color: Colors.grey, + fontSize: 18, + fontWeight: FontWeight.w600, + ), ), - ), - OutlineButton( - onPressed: () { - Navigator.pushNamed(context, '/bookingcalendar'); - }, - shape: new RoundedRectangleBorder( - borderRadius: new BorderRadius.circular(30.0)), - color: Colors.grey, - child: Text('Calendar')), - ], + OutlineButton( + onPressed: () { + Navigator.pushNamed(context, '/bookingcalendar'); + }, + shape: new RoundedRectangleBorder( + borderRadius: new BorderRadius.circular(30.0)), + color: Colors.grey, + child: Text('Book')), + ], + ), ), SizedBox(height: 10.0), Container( - margin: const EdgeInsets.symmetric(vertical: 0, horizontal: 10), - height: 150.0, - width: double.infinity, - child: new Column( - children: [ - Expanded( - child: ListView( - shrinkWrap: true, - physics: ClampingScrollPhysics(), - scrollDirection: Axis.horizontal, - children: [ - InkWell( - onTap: () { - Navigator.pushNamed(context, "/bluelounge"); - }, - child: Container( - height: 100.0, - width: 150.0, - child: Align( - alignment: Alignment.bottomCenter, - child: Text( - 'Blue Lounge', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), - ), - ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/12.jpg"), - fit: BoxFit.fill)), - ), - ), - SizedBox(width: 20), - InkWell( - onTap: () { - Navigator.pushNamed(context, "/yellowlounge"); - }, - child: Container( - height: 100.0, - width: 150.0, - child: Align( - alignment: Alignment.bottomCenter, - child: Text( - 'Yellow Lounge', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), - ), - ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/13.jpg"), - fit: BoxFit.fill)), - ), - ), - SizedBox(width: 20), - InkWell( - onTap: () { - Navigator.pushNamed(context, "/milaplounge"); - }, - child: Container( - height: 100.0, - width: 150.0, - child: Align( - alignment: Alignment.bottomCenter, - child: Text( - 'Milap Hall', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), - ), - ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/17.jpg"), - fit: BoxFit.fill)), - ), - ), - SizedBox(width: 20), - InkWell( - onTap: () { - Navigator.pushNamed(context, "/milanlounge"); - }, - child: Container( - height: 100.0, - width: 150.0, - child: Align( - alignment: Alignment.bottomCenter, + margin: const EdgeInsets.symmetric(vertical: 0, horizontal: 10), + alignment: Alignment.centerLeft, + height: 150.0, + width: double.infinity, + child: new Column( + children: [ + Expanded( + child: Container( + padding: EdgeInsets.fromLTRB(20, 0, 7, 0), + child: ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + scrollDirection: Axis.horizontal, + children: [ + InkWell( + onTap: () { + Navigator.pushNamed(context, "/bluelounge"); + }, + child: Container( + height: 100.0, + width: 150.0, + child: Align( + alignment: Alignment.bottomCenter, + child: Text( + 'Blue Lounge', + style: GoogleFonts.inter( + color: Colors.white, + fontWeight: FontWeight.bold), + ), + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/12.jpg"), + fit: BoxFit.fill)), + ), + ), + SizedBox(width: 20), + InkWell( + onTap: () { + Navigator.pushNamed(context, "/yellowlounge"); + }, + child: Container( + height: 100.0, + width: 150.0, + child: Align( + alignment: Alignment.bottomCenter, + child: Text( + 'Yellow Lounge', + style: GoogleFonts.inter( + color: Colors.white, + fontWeight: FontWeight.bold), + ), + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/13.jpg"), + fit: BoxFit.fill)), + ), + ), + SizedBox(width: 20), + InkWell( + onTap: () { + Navigator.pushNamed(context, "/milaplounge"); + }, + child: Container( + height: 100.0, + width: 150.0, + child: Align( + alignment: Alignment.bottomCenter, + child: Text( + 'Milap Hall', + style: GoogleFonts.inter( + color: Colors.white, + fontWeight: FontWeight.bold), + ), + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/17.jpg"), + fit: BoxFit.fill)), + ), + ), + SizedBox(width: 20), + InkWell( + onTap: () { + Navigator.pushNamed(context, "/milanlounge"); + }, + child: Container( + height: 100.0, + width: 150.0, + child: Align( + alignment: Alignment.bottomCenter, + child: Text( + 'Milan Lounge', + style: GoogleFonts.inter( + color: Colors.white, + fontWeight: FontWeight.bold), + ), + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/18.jpg"), + fit: BoxFit.fill)), + ), + ), + SizedBox(width: 20), + InkWell( + onTap: () { + Navigator.pushNamed(context, "/mainhall"); + }, + child: Container( + height: 100.0, + width: 150.0, + child: Align( + alignment: Alignment.bottomCenter, + child: Text( + 'Main Hall', + style: GoogleFonts.inter( + color: Colors.white, + fontWeight: FontWeight.bold), + ), + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/15.jpg"), + fit: BoxFit.fill)), + ), + ), + SizedBox(width: 20), + ], + ), + ) + ), + SizedBox(height: 20), + ], + )), + SizedBox(height: 30.0), + Container( + margin: const EdgeInsets.symmetric(vertical: 0, horizontal: 20), child: Text( - 'Milan Lounge', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300 + " Banquet Halls", + style: GoogleFonts.inter( + color: Colors.grey, + fontSize: 18, + fontWeight: FontWeight.w600, ), ), ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/18.jpg"), - fit: BoxFit.fill)), - ), - ), - SizedBox(width: 20), - ], - ), - ), - SizedBox(height: 20), - ], - )), - SizedBox(height: 30.0), - Text( - " Banquet Halls", - style: GoogleFonts.inter( - color: Colors.grey, - fontSize: 18, - fontWeight: FontWeight.w600, - ), - ), - SizedBox(height: 10.0), + SizedBox(height: 15.0), Container( margin: const EdgeInsets.symmetric(vertical: 0, horizontal: 10), + alignment: Alignment.centerLeft, height: 150.0, width: double.infinity, child: new Column( children: [ Expanded( - child: ListView( - shrinkWrap: true, - physics: ClampingScrollPhysics(), - scrollDirection: Axis.horizontal, - children: [ - InkWell( - onTap: () { - Navigator.pushNamed(context, "/mainhall"); - }, - child: Container( - height: 100.0, - width: 150.0, - child: Align( - alignment: Alignment.bottomCenter, - child: Text( - 'Main Hall', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w200), + child: Container( + padding: EdgeInsets.fromLTRB(0, 0, 0, 0), + child:ListView( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + scrollDirection: Axis.horizontal, + children: [ + SizedBox(width: 20), + InkWell( + onTap: () { + Navigator.pushNamed(context, "/weddinghall"); + }, + child: Container( + height: 100.0, + width: 150.0, + child: Align( + alignment: Alignment.bottomCenter, + child: Text( + 'Wedding Hall', + style: GoogleFonts.inter( + color: Colors.white, + fontWeight: FontWeight.bold), + ), ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/56.jpg"), + fit: BoxFit.fill)), ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/15.jpg"), - fit: BoxFit.fill)), ), - ), - SizedBox(width: 20), - InkWell( - onTap: () { - Navigator.pushNamed(context, "/weddinghall"); - }, - child: Container( - height: 100.0, - width: 150.0, - child: Align( - alignment: Alignment.bottomCenter, - child: Text( - 'Wedding Hall', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w200), + SizedBox(width: 20), + InkWell( + onTap: () { + Navigator.pushNamed(context, "/tenniscourt"); + }, + child: Container( + height: 100.0, + width: 150.0, + child: Align( + alignment: Alignment.bottomCenter, + child: Text( + 'Tennis Court', + style: GoogleFonts.inter( + color: Colors.white, + fontWeight: FontWeight.bold), + ), ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/55.jpg"), + fit: BoxFit.fill)), ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/16.jpg"), - fit: BoxFit.fill)), ), - ), - SizedBox(width: 20), - InkWell( - onTap: () { - Navigator.pushNamed(context, "/tenniscourt"); - }, - child: Container( - height: 100.0, - width: 150.0, - child: Align( - alignment: Alignment.bottomCenter, - child: Text( - 'Tennis Court', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w200), - ), + InkWell( + child: Container( + height: 100.0, + width: 300.0, ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/51.jpg"), - fit: BoxFit.fill)), ), - ), - ], - ), + ], + ), + ) ), SizedBox(height: 20), ], @@ -258,4 +292,10 @@ class _BookingState extends State { ), ); } + + // @override + // void dispose() { + // // TODO: implement dispose + // super.dispose(); + // } } diff --git a/lib/pages/Cart.dart b/lib/pages/Cart.dart index 681cb26..fb61fc6 100644 --- a/lib/pages/Cart.dart +++ b/lib/pages/Cart.dart @@ -23,6 +23,8 @@ class _CartState extends State { StoreData storeDataforCart = StoreData(); var address = ''; + bool isData = false; + bool loading = true; void init() async { var user = await FirebaseAuth.instance.currentUser(); @@ -33,6 +35,7 @@ class _CartState extends State { setState(() { address = _dat.data["address"]; + loading = false; }); } @@ -59,17 +62,15 @@ class _CartState extends State { qtyList.add(value); }); foodDetail.forEach((k, v) => total = total + v * qtyDetail[k]); + if (totalquantity == 0) { + isData = false; + } else { + isData = true; + } }); } void removeItem(String item) { - // if ((cartList.singleWhere((element) => element.item == item, - // orElse: () => null)) != - // null) { - // return; - // } else { - // cartList.add(Orders(item, price, 1)); - // } storeDataforCart.removeFoodDetails(item); updateTotal(); print(item); @@ -96,6 +97,15 @@ class _CartState extends State { backgroundColor: Colors.deepOrange, title: Text('Cart', style: GoogleFonts.inter()), //repeat for menu and booking + leading: Builder(builder: (BuildContext context) { + return IconButton( + onPressed: () { + refreshVar = !refreshVar; + Navigator.pop(context); + }, + icon: Icon(Icons.arrow_back), + ); + }), ), body: Column(children: [ SizedBox(height: 10), @@ -176,7 +186,8 @@ class _CartState extends State { ), ), SizedBox( - width: 200, + width: + MediaQuery.of(context).size.width * 0.52, child: Text( keyname, style: GoogleFonts.inter( @@ -225,8 +236,7 @@ class _CartState extends State { ); }), ), - // BottomItemView(total: total, qty: totalquantity), - ProceedAccess(address: address) + ProceedAccess(address: address, isData: isData, loading: loading) ])); } } @@ -380,16 +390,73 @@ class _QuantityInCartState extends State { } class ProceedAccess extends StatefulWidget { + var isData; + var loading; var address; - ProceedAccess({this.address}); + ProceedAccess({this.address, this.isData, this.loading}); @override _ProceedAccessState createState() => _ProceedAccessState(); } class _ProceedAccessState extends State { + StoreData storeData = StoreData(); + int total = 0; + int totalquantity = 1; + List itemList = List(); + List priceList = List(); + List quantityList = List(); + + void updateTotal() { + Map foodDetail = storeData.retrieveFoodDetails(); + Map foodqtyDetail = storeData.retrieveQtyDetails(); + + setState(() { + foodDetail.forEach((k, v) => total = total + v * foodqtyDetail[k]); + foodDetail.forEach((k, v) => totalquantity = totalquantity + v); + foodDetail.forEach((key, value) { + itemList.add(key); + priceList.add(value); + }); + foodqtyDetail.forEach((key, value) => quantityList.add(value)); + }); + } + + void confirmOrder() async { + var user = await FirebaseAuth.instance.currentUser(); + var _dat = await Firestore.instance + .collection('userInfo') + .document(user.uid) + .get(); + + var userName = _dat.data["name"]; + var number = _dat.data["number"]; + var address = _dat.data["address"]; + var mobileNumber = _dat.data["mobileNumber"]; + + DatabaseService().confirmOrderofUser(user.uid, userName, number, address, + itemList, priceList, quantityList, total, false, mobileNumber); + + storeData.resetStore(); + updateTotal(); + /*Navigator.pushReplacementNamed(context, '/navigationbar');*/ + } + @override Widget build(BuildContext context) { - if (widget.address == '') { + if (widget.loading == true) { + return Container( + width: double.infinity, + height: 50, + child: FlatButton( + color: Colors.deepOrange, + onPressed: () { + Navigator.pushNamed(context, '/address'); + }, + child: Text( + 'Please Wait ...', + style: GoogleFonts.inter(color: Colors.white), + ))); + } else if (widget.address == '' && widget.loading == false) { return Container( width: double.infinity, height: 50, @@ -402,7 +469,7 @@ class _ProceedAccessState extends State { 'Add address to proceed', style: GoogleFonts.inter(color: Colors.white), ))); - } else if (widget.address != '') { + } else if (widget.address != '' && widget.isData == true) { return Container( width: double.infinity, height: 50, @@ -411,64 +478,31 @@ class _ProceedAccessState extends State { onPressed: () { updateTotal(); confirmOrder(); - Navigator.pushReplacementNamed(context, '/navigationbar'); showDialog( context: context, builder: (context) => CustomAlert( title: 'Order Placed!', description: - 'Your Order has been placed and will be on its way to you shortly', - url: 'assets/nigga.gif', + 'Your Order has been placed and will be on its way to you shortly. For further queries regarding your order, please contact - Mr. Debabrata Mohanty - +919438208969', + // url: 'assets/nigga.gif', )); + // Navigator.pop(context); }, child: Text( - 'Confirm Order(Pay through COD', + 'Confirm Order(Pay through COD)', style: GoogleFonts.inter(color: Colors.white), ))); - } else if (widget.address == null) { + } else if (widget.isData == false) { return Container( - width: double.infinity, height: 50, child: SpinKitChasingDots()); - } - } -} - -// class BottomItemView extends StatefulWidget { -// @override -// _BottomItemViewState createState() => _BottomItemViewState(); -// } - -class BottomItemView extends StatelessWidget { - int total; - int qty; - BottomItemView({this.total, this.qty}); - - @override - Widget build(BuildContext context) { - return Container( - width: double.maxFinite, - height: 54, - decoration: BoxDecoration(color: Colors.deepOrange), - child: Padding( - padding: EdgeInsets.symmetric(vertical: 0, horizontal: 20), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${qty} ' + ' item ' + '|' + ' ' + '₹ ' + '${total}', - style: GoogleFonts.inter( - color: Colors.white, fontWeight: FontWeight.bold), - ), - InkWell( - onTap: (() => Navigator.pushNamed(context, '/cart')), + width: double.infinity, + height: 50, + child: FlatButton( + color: Colors.deepOrange, + onPressed: () {}, child: Text( - 'VIEW CART', - style: GoogleFonts.inter( - color: Colors.white, fontWeight: FontWeight.bold), - ), - ) - ], - ), - ), - ); + 'Add Item To Cart', + style: GoogleFonts.inter(color: Colors.white), + ))); + } } } diff --git a/lib/pages/CategoryMenuList/Accompaniment_Menu.dart b/lib/pages/CategoryMenuList/Accompaniment_Menu.dart index f68c48f..9efebd6 100644 --- a/lib/pages/CategoryMenuList/Accompaniment_Menu.dart +++ b/lib/pages/CategoryMenuList/Accompaniment_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -18,7 +19,26 @@ class _Accompaniment_MenuState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -29,21 +49,30 @@ class _Accompaniment_MenuState extends State { backgroundColor: Colors.deepOrange, title: Text('Accompaniments'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: AccompanimentMenuListPage(), + child: AccompanimentMenuListPage(updateTotal: updateTotal), ) ], ), @@ -53,6 +82,8 @@ class _Accompaniment_MenuState extends State { } class AccompanimentMenuListPage extends StatefulWidget { + final updateTotal; + AccompanimentMenuListPage({this.updateTotal}); @override _AccompanimentMenuListPageState createState() => _AccompanimentMenuListPageState(); @@ -198,6 +229,7 @@ class _AccompanimentMenuListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/All_Menu.dart b/lib/pages/CategoryMenuList/All_Menu.dart index 78e59ad..640e79b 100644 --- a/lib/pages/CategoryMenuList/All_Menu.dart +++ b/lib/pages/CategoryMenuList/All_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:rcapp/models/user.dart'; @@ -14,10 +15,24 @@ class AllMenu extends StatefulWidget { class _AllMenuState extends State { StoreData dataforCart = StoreData(); - int total = 0; - int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + qty = 0; + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,22 +43,30 @@ class _AllMenuState extends State { backgroundColor: Colors.deepOrange, title: Text('All Menu'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushReplacementNamed(context, '/cart'); - // Navigator.popAndPushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: AllMenuListPage(), + child: AllMenuListPage(updateTotal: updateTotal), ) ], ), @@ -53,6 +76,8 @@ class _AllMenuState extends State { } class AllMenuListPage extends StatefulWidget { + final updateTotal; + AllMenuListPage({this.updateTotal}); @override _AllMenuListPageState createState() => _AllMenuListPageState(); } @@ -185,6 +210,7 @@ class _AllMenuListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Biryani_MenuList.dart b/lib/pages/CategoryMenuList/Biryani_MenuList.dart index fa6ced5..101f2d8 100644 --- a/lib/pages/CategoryMenuList/Biryani_MenuList.dart +++ b/lib/pages/CategoryMenuList/Biryani_MenuList.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _Biryani_MenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,22 +48,30 @@ class _Biryani_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Rice and Biryani'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - // Navigator.popAndPushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: BiryaniMenuListListPage(), + child: BiryaniMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -53,6 +81,8 @@ class _Biryani_MenuListState extends State { } class BiryaniMenuListListPage extends StatefulWidget { + final updateTotal; + BiryaniMenuListListPage({this.updateTotal}); @override _BiryaniMenuListListPageState createState() => _BiryaniMenuListListPageState(); @@ -193,6 +223,7 @@ class _BiryaniMenuListListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Bread_Menu.dart b/lib/pages/CategoryMenuList/Bread_Menu.dart index c866d5a..c721509 100644 --- a/lib/pages/CategoryMenuList/Bread_Menu.dart +++ b/lib/pages/CategoryMenuList/Bread_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _Bread_MenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,22 +48,30 @@ class _Bread_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Breads'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - // Navigator.popAndPushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: BiryaniMenuListListPage(), + child: BiryaniMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -53,6 +81,8 @@ class _Bread_MenuListState extends State { } class BiryaniMenuListListPage extends StatefulWidget { + final updateTotal; + BiryaniMenuListListPage({this.updateTotal}); @override _BiryaniMenuListListPageState createState() => _BiryaniMenuListListPageState(); @@ -191,6 +221,7 @@ class _BiryaniMenuListListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Breakfast_Menu.dart b/lib/pages/CategoryMenuList/Breakfast_Menu.dart index 093a35e..e44d95d 100644 --- a/lib/pages/CategoryMenuList/Breakfast_Menu.dart +++ b/lib/pages/CategoryMenuList/Breakfast_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _Breakfast_MenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,22 +48,30 @@ class _Breakfast_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Breakfast'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - // Navigator.popAndPushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: BreadMenuListListPage(), + child: BreadMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -53,6 +81,8 @@ class _Breakfast_MenuListState extends State { } class BreadMenuListListPage extends StatefulWidget { + final updateTotal; + BreadMenuListListPage({this.updateTotal}); @override _BreadMenuListListPageState createState() => _BreadMenuListListPageState(); } @@ -190,6 +220,7 @@ class _BreadMenuListListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Burger_Menu.dart b/lib/pages/CategoryMenuList/Burger_Menu.dart index 4db1b6a..24e8f9c 100644 --- a/lib/pages/CategoryMenuList/Burger_Menu.dart +++ b/lib/pages/CategoryMenuList/Burger_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _Burger_MenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,22 +48,30 @@ class _Burger_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Burgers'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - // Navigator.popAndPushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: BurgerMenuListListPage(), + child: BurgerMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -53,6 +81,8 @@ class _Burger_MenuListState extends State { } class BurgerMenuListListPage extends StatefulWidget { + final updateTotal; + BurgerMenuListListPage({this.updateTotal}); @override _BurgerMenuListListPageState createState() => _BurgerMenuListListPageState(); } @@ -179,8 +209,10 @@ class _BurgerMenuListListPageState extends State { width: 43, margin: EdgeInsets.only(top: 6), alignment: Alignment.center, - decoration: - BoxDecoration(color: Colors.deepOrange, borderRadius: BorderRadius.circular(10)), + decoration: BoxDecoration( + color: Colors.deepOrange, + borderRadius: + BorderRadius.circular(10)), child: IconButton( onPressed: () { showFlushbar(context); @@ -188,6 +220,7 @@ class _BurgerMenuListListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Chinese_Menu.dart b/lib/pages/CategoryMenuList/Chinese_Menu.dart index 27410d9..81d9a36 100644 --- a/lib/pages/CategoryMenuList/Chinese_Menu.dart +++ b/lib/pages/CategoryMenuList/Chinese_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _ChineseMenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,21 +48,30 @@ class _ChineseMenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Chinese'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: ChineseMenuListPage(), + child: ChineseMenuListPage(updateTotal: updateTotal), ) ], ), @@ -52,6 +81,8 @@ class _ChineseMenuListState extends State { } class ChineseMenuListPage extends StatefulWidget { + final updateTotal; + ChineseMenuListPage({this.updateTotal}); @override _ChineseMenuListPageState createState() => _ChineseMenuListPageState(); } @@ -184,6 +215,7 @@ class _ChineseMenuListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/ContactDetails.dart b/lib/pages/CategoryMenuList/ContactDetails.dart new file mode 100644 index 0000000..18c1058 --- /dev/null +++ b/lib/pages/CategoryMenuList/ContactDetails.dart @@ -0,0 +1,75 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class ContactDetails extends StatefulWidget { + @override + _ContactDetailsState createState() => _ContactDetailsState(); +} + +class _ContactDetailsState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Contact'), + backgroundColor: Colors.deepOrange, + ), + body: Container( + height: MediaQuery.of(context).size.height*1, + decoration: BoxDecoration(color: Colors.grey[200]), + child:Column( + children: [ + SizedBox(height: 20), + Container( + height: MediaQuery.of(context).size.height*0.22, + width: MediaQuery.of(context).size.width*0.95, + decoration: BoxDecoration(color: Colors.white), + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), + child: Container( + padding: EdgeInsets.all(10), + margin: EdgeInsets.symmetric(horizontal: 0, vertical: 0), + height: MediaQuery.of(context).size.height*0.1, + width: MediaQuery.of(context).size.width*0.9, + child: Text( + "For order related queries, please contact: \n \nMr. Debabrata Mohanty - +919438208969 \n", + style: TextStyle( + fontSize: 17.5 + ), + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(12.0)), + border: Border.all(color: Colors.grey)), + + ), + ), + SizedBox(height: 20), + Container( + height: MediaQuery.of(context).size.height*0.22, + width: MediaQuery.of(context).size.width*0.95, + decoration: BoxDecoration(color: Colors.white), + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), + child: Container( + padding: EdgeInsets.all(10), + margin: EdgeInsets.symmetric(horizontal: 0, vertical: 0), + height: MediaQuery.of(context).size.height*0.1, + width: MediaQuery.of(context).size.width*0.9, + child: Text( + "For booking related queries, please contact: \n \nMr. Pramod Kumar Pattnaik - +919437116141 \n", + style: TextStyle( + fontSize: 17.5 + ), + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(12.0)), + border: Border.all(color: Colors.grey)), + + ), + ), + ], + ) + ) + ); + } +} diff --git a/lib/pages/CategoryMenuList/FriedRiceAndNoodles_Menu.dart b/lib/pages/CategoryMenuList/FriedRiceAndNoodles_Menu.dart index 92dd9bc..7969dcc 100644 --- a/lib/pages/CategoryMenuList/FriedRiceAndNoodles_Menu.dart +++ b/lib/pages/CategoryMenuList/FriedRiceAndNoodles_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -9,15 +10,36 @@ import 'package:rcapp/services/database.dart'; class FriedRiceAndNoodles_MenuList extends StatefulWidget { @override - _FriedRiceAndNoodles_MenuListState createState() => _FriedRiceAndNoodles_MenuListState(); + _FriedRiceAndNoodles_MenuListState createState() => + _FriedRiceAndNoodles_MenuListState(); } -class _FriedRiceAndNoodles_MenuListState extends State { +class _FriedRiceAndNoodles_MenuListState + extends State { StoreData dataforCart = StoreData(); int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,22 +50,31 @@ class _FriedRiceAndNoodles_MenuListState extends State[ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - // Navigator.popAndPushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: FriedRiceAndNoodlesMenuListListPage(), + child: + FriedRiceAndNoodlesMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -53,11 +84,15 @@ class _FriedRiceAndNoodles_MenuListState extends State _FriedRiceAndNoodlesMenuListListPageState(); + _FriedRiceAndNoodlesMenuListListPageState createState() => + _FriedRiceAndNoodlesMenuListListPageState(); } -class _FriedRiceAndNoodlesMenuListListPageState extends State { +class _FriedRiceAndNoodlesMenuListListPageState + extends State { StoreData storeData = StoreData(); int total = 0; bool checked = false; @@ -179,8 +214,10 @@ class _FriedRiceAndNoodlesMenuListListPageState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,22 +48,30 @@ class _MainCourse_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Main Course'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - // Navigator.popAndPushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: MainCourseMenuListListPage(), + child: MainCourseMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -53,6 +81,8 @@ class _MainCourse_MenuListState extends State { } class MainCourseMenuListListPage extends StatefulWidget { + final updateTotal; + MainCourseMenuListListPage({this.updateTotal}); @override _MainCourseMenuListListPageState createState() => _MainCourseMenuListListPageState(); @@ -192,6 +222,7 @@ class _MainCourseMenuListListPageState setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Pasta_Menu.dart b/lib/pages/CategoryMenuList/Pasta_Menu.dart index 2f3af0d..36815f6 100644 --- a/lib/pages/CategoryMenuList/Pasta_Menu.dart +++ b/lib/pages/CategoryMenuList/Pasta_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _Pasta_MenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,21 +48,30 @@ class _Pasta_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Pasta'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: PastaMenuListListPage(), + child: PastaMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -52,6 +81,8 @@ class _Pasta_MenuListState extends State { } class PastaMenuListListPage extends StatefulWidget { + final updateTotal; + PastaMenuListListPage({this.updateTotal}); @override _PastaMenuListListPageState createState() => _PastaMenuListListPageState(); } @@ -186,6 +217,7 @@ class _PastaMenuListListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Pizza_Menu.dart b/lib/pages/CategoryMenuList/Pizza_Menu.dart index 7e85da8..4056cb3 100644 --- a/lib/pages/CategoryMenuList/Pizza_Menu.dart +++ b/lib/pages/CategoryMenuList/Pizza_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _Pizza_MenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,21 +48,30 @@ class _Pizza_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Pizza'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: PizzaMenuListListPage(), + child: PizzaMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -52,6 +81,8 @@ class _Pizza_MenuListState extends State { } class PizzaMenuListListPage extends StatefulWidget { + final updateTotal; + PizzaMenuListListPage({this.updateTotal}); @override _PizzaMenuListListPageState createState() => _PizzaMenuListListPageState(); } @@ -178,8 +209,10 @@ class _PizzaMenuListListPageState extends State { width: 43, margin: EdgeInsets.only(top: 6), alignment: Alignment.center, - decoration: - BoxDecoration(color: Colors.deepOrange, borderRadius: BorderRadius.circular(10)), + decoration: BoxDecoration( + color: Colors.deepOrange, + borderRadius: + BorderRadius.circular(10)), child: IconButton( onPressed: () { showFlushbar(context); @@ -187,6 +220,7 @@ class _PizzaMenuListListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Roll_Menu.dart b/lib/pages/CategoryMenuList/Roll_Menu.dart index 5cff1fc..9ac875b 100644 --- a/lib/pages/CategoryMenuList/Roll_Menu.dart +++ b/lib/pages/CategoryMenuList/Roll_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _Roll_MenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,21 +48,30 @@ class _Roll_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Roll'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: RollMenuListListPage(), + child: RollMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -52,6 +81,8 @@ class _Roll_MenuListState extends State { } class RollMenuListListPage extends StatefulWidget { + final updateTotal; + RollMenuListListPage({this.updateTotal}); @override _RollMenuListListPageState createState() => _RollMenuListListPageState(); } @@ -178,8 +209,10 @@ class _RollMenuListListPageState extends State { width: 43, margin: EdgeInsets.only(top: 6), alignment: Alignment.center, - decoration: - BoxDecoration(color: Colors.deepOrange, borderRadius: BorderRadius.circular(10)), + decoration: BoxDecoration( + color: Colors.deepOrange, + borderRadius: + BorderRadius.circular(10)), child: IconButton( onPressed: () { showFlushbar(context); @@ -187,6 +220,7 @@ class _RollMenuListListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Sandwich_Menu.dart b/lib/pages/CategoryMenuList/Sandwich_Menu.dart index 9598e50..c1f1252 100644 --- a/lib/pages/CategoryMenuList/Sandwich_Menu.dart +++ b/lib/pages/CategoryMenuList/Sandwich_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _Sandwich_MenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,21 +48,30 @@ class _Sandwich_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Sandwich'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: SandwichMenuListListPage(), + child: SandwichMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -52,6 +81,8 @@ class _Sandwich_MenuListState extends State { } class SandwichMenuListListPage extends StatefulWidget { + final updateTotal; + SandwichMenuListListPage({this.updateTotal}); @override _SandwichMenuListListPageState createState() => _SandwichMenuListListPageState(); @@ -190,6 +221,7 @@ class _SandwichMenuListListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Snacks_Menu.dart b/lib/pages/CategoryMenuList/Snacks_Menu.dart index 898c736..707d793 100644 --- a/lib/pages/CategoryMenuList/Snacks_Menu.dart +++ b/lib/pages/CategoryMenuList/Snacks_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _Snacks_MenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,21 +48,30 @@ class _Snacks_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Snacks'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: SnacksMenuListListPage(), + child: SnacksMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -52,6 +81,8 @@ class _Snacks_MenuListState extends State { } class SnacksMenuListListPage extends StatefulWidget { + final updateTotal; + SnacksMenuListListPage({this.updateTotal}); @override _SnacksMenuListListPageState createState() => _SnacksMenuListListPageState(); } @@ -189,6 +220,7 @@ class _SnacksMenuListListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Soup_Menu.dart b/lib/pages/CategoryMenuList/Soup_Menu.dart index b30a31f..edde5fb 100644 --- a/lib/pages/CategoryMenuList/Soup_Menu.dart +++ b/lib/pages/CategoryMenuList/Soup_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _Soup_MenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,22 +48,30 @@ class _Soup_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Soup'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - // Navigator.popAndPushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: SoupMenuListListPage(), + child: SoupMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -53,6 +81,8 @@ class _Soup_MenuListState extends State { } class SoupMenuListListPage extends StatefulWidget { + final updateTotal; + SoupMenuListListPage({this.updateTotal}); @override _SoupMenuListListPageState createState() => _SoupMenuListListPageState(); } @@ -179,8 +209,10 @@ class _SoupMenuListListPageState extends State { width: 43, margin: EdgeInsets.only(top: 6), alignment: Alignment.center, - decoration: - BoxDecoration(color: Colors.deepOrange, borderRadius: BorderRadius.circular(10)), + decoration: BoxDecoration( + color: Colors.deepOrange, + borderRadius: + BorderRadius.circular(10)), child: IconButton( onPressed: () { showFlushbar(context); @@ -188,6 +220,7 @@ class _SoupMenuListListPageState extends State { setState(() { checked = !checked; }); + widget.updateTotal(); }, icon: Icon( Icons.add, diff --git a/lib/pages/CategoryMenuList/Starter_Menu.dart b/lib/pages/CategoryMenuList/Starter_Menu.dart index bf78dc5..956dfc8 100644 --- a/lib/pages/CategoryMenuList/Starter_Menu.dart +++ b/lib/pages/CategoryMenuList/Starter_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _StarterMenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,21 +48,30 @@ class _StarterMenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Starters'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: StarterMenuListListPage(), + child: StarterMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -52,6 +81,8 @@ class _StarterMenuListState extends State { } class StarterMenuListListPage extends StatefulWidget { + final updateTotal; + StarterMenuListListPage({this.updateTotal}); @override _StarterMenuListListPageState createState() => _StarterMenuListListPageState(); diff --git a/lib/pages/CategoryMenuList/Tandoori_Menu.dart b/lib/pages/CategoryMenuList/Tandoori_Menu.dart index f1f0e7c..df37850 100644 --- a/lib/pages/CategoryMenuList/Tandoori_Menu.dart +++ b/lib/pages/CategoryMenuList/Tandoori_Menu.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -17,7 +18,26 @@ class _Tandoori_MenuListState extends State { int total = 0; int qty = 0; - List qtyList = List(); + + void updateTotal() { + Map qtyDetail = dataforCart.retrieveQtyDetails(); + + total = 0; + qty = 0; + + setState(() { + qtyDetail.forEach((key, value) { + ++qty; + }); + }); + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + updateTotal(); + } @override Widget build(BuildContext context) { @@ -28,21 +48,30 @@ class _Tandoori_MenuListState extends State { backgroundColor: Colors.deepOrange, title: Text('Tandoor'), actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 35, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column( children: [ Expanded( - child: TandooriMenuListListPage(), + child: TandooriMenuListListPage(updateTotal: updateTotal), ) ], ), @@ -52,6 +81,8 @@ class _Tandoori_MenuListState extends State { } class TandooriMenuListListPage extends StatefulWidget { + final updateTotal; + TandooriMenuListListPage({this.updateTotal}); @override _TandooriMenuListListPageState createState() => _TandooriMenuListListPageState(); diff --git a/lib/pages/CategoryMenuList/flushbar.dart b/lib/pages/CategoryMenuList/flushbar.dart index 77825e9..f4649e3 100644 --- a/lib/pages/CategoryMenuList/flushbar.dart +++ b/lib/pages/CategoryMenuList/flushbar.dart @@ -15,7 +15,8 @@ void showFlushbar(context) { dismissDirection: FlushbarDismissDirection.HORIZONTAL, forwardAnimationCurve: Curves.fastLinearToSlowEaseIn, title: "Item added to the cart", - message: "Tap on the top cart icon to view your item in the cart and change quantity. Referesh to see the updated cart.") + message: + "Tap on the top cart icon to view your item in the cart and change quantity. Referesh to see the updated cart.") ..show(context); } @@ -36,3 +37,22 @@ void showFlushbarBooking(context) { message: "Please select another date or different slot") ..show(context); } + +void showFlushbarNotification(context, title, subtitle) { + Flushbar( + flushbarPosition: FlushbarPosition.TOP, + margin: EdgeInsets.all(10), + padding: EdgeInsets.all(10), + borderRadius: 8, + backgroundGradient: LinearGradient( + colors: [Colors.black54, Colors.black54], stops: [0.6, 1]), + boxShadows: [ + BoxShadow(color: Colors.black45, offset: Offset(3, 3), blurRadius: 2), + ], + duration: Duration(seconds: 5), + dismissDirection: FlushbarDismissDirection.HORIZONTAL, + forwardAnimationCurve: Curves.fastLinearToSlowEaseIn, + title: "$title", + message: "$subtitle") + ..show(context); +} diff --git a/lib/pages/Food.dart b/lib/pages/Food.dart index 438f48a..b1b26ca 100644 --- a/lib/pages/Food.dart +++ b/lib/pages/Food.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:rcapp/CustomWidget/foot_category.dart'; @@ -21,6 +22,8 @@ import 'package:rcapp/services/database.dart'; // Orders newOrder; +bool refreshVar = true; + class Food extends StatefulWidget { @override _FoodState createState() => _FoodState(); @@ -32,28 +35,20 @@ class _FoodState extends State { int qty = 0; - // @override - // void initState() { - // // TODO: implement initState - // super.initState(); - // updateTotal(); - // } - - List qtyList = List(); - void updateTotal() { - Map foodDetail = dataforCart.retrieveFoodDetails(); Map qtyDetail = dataforCart.retrieveQtyDetails(); + Map foodDetail = dataforCart.retrieveFoodDetails(); total = 0; qty = 0; setState(() { qtyDetail.forEach((key, value) { - qty += value; - qtyList.add(value); + ++qty; + }); + foodDetail.forEach((key, value) { + total = total + value * qtyDetail[key]; }); - foodDetail.forEach((k, v) => total = total + v * qtyDetail[k]); }); } @@ -69,6 +64,8 @@ class _FoodState extends State { @override Widget build(BuildContext context) { + final store = Provider.of(context); + updateTotal(); return StreamProvider>.value( value: DatabaseService().today_Menu, @@ -78,19 +75,29 @@ class _FoodState extends State { elevation: 10.0, backgroundColor: Colors.deepOrange, title: Container( - margin: EdgeInsets.only(left: MediaQuery.of(context).size.width*0.13), - child:Text('Menu', style: GoogleFonts.inter()), - ), //repeat for menu and booking + margin: + EdgeInsets.only(left: MediaQuery.of(context).size.width * 0.13), + child: Text('Menu', style: GoogleFonts.inter()), + ), //repeat for menu and booking actions: [ - IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.white, + Container( + margin: EdgeInsets.only(right: 10), + child: IconButton( + onPressed: () { + Navigator.pushNamed(context, '/cart'); + }, + icon: Badge( + toAnimate: true, + badgeColor: Colors.yellow, + badgeContent: Text('$qty'), + child: Icon( + Icons.shopping_cart, + color: Colors.white, + size: 28, + ), + ), ), - onPressed: () { - Navigator.pushNamed(context, '/cart'); - }, - ) + ), ], ), body: Column(children: [ @@ -150,12 +157,18 @@ class _FoodState extends State { ], ), ), - SizedBox(height: 10.0), - BottomItemView(total: total, qty: qty) + SizedBox(height: 15.0), + BottomItemView(total: total, qty: qty), ]), ), ); } + + // @override + // void dispose() { + // // TODO: implement dispose + // super.dispose(); + // } } class Quantity extends StatefulWidget { @@ -188,8 +201,9 @@ class _QuantityState extends State { ), height: 25, width: 62, - child: - Center(child: Text('Add', style: GoogleFonts.inter(color: Colors.white))), + child: Center( + child: + Text('Add', style: GoogleFonts.inter(color: Colors.white))), ), ); } else { @@ -207,7 +221,8 @@ class _QuantityState extends State { height: 25, width: 66, child: Center( - child: Text('Remove', style: GoogleFonts.inter(color: Colors.white))), + child: Text('Remove', + style: GoogleFonts.inter(color: Colors.white))), ), ); } @@ -260,7 +275,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Main Course', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -283,7 +299,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Breads', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -306,7 +323,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Biryani', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -329,7 +347,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Tandoori', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -362,7 +381,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Chinese', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -385,7 +405,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Noodles', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -408,7 +429,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Rolls', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -431,7 +453,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Pizza', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -464,7 +487,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Snacks', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -487,7 +511,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Sandwiches', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -510,7 +535,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Burgers', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -533,7 +559,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Pasta', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -566,7 +593,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Soup', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -589,7 +617,10 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Accompaniment', - style: GoogleFonts.inter(fontSize: 12, color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + fontSize: 12, + color: Colors.white, + fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -612,7 +643,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Starters', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -635,7 +667,8 @@ class _ListPageState extends State { alignment: Alignment.bottomCenter, child: Text( 'Breakfast', - style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.w300), + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.w300), ), ), decoration: BoxDecoration( @@ -654,3 +687,50 @@ class _ListPageState extends State { )); } } + +class BottomItemView extends StatefulWidget { + int total; + int qty; + BottomItemView({this.total, this.qty}); + + @override + _BottomItemViewState createState() => _BottomItemViewState(); +} + +class _BottomItemViewState extends State { + @override + Widget build(BuildContext context) { + final store = Provider.of(context); + return Container( + width: double.maxFinite, + height: 54, + decoration: BoxDecoration(color: Colors.deepOrange), + child: Padding( + padding: EdgeInsets.symmetric(vertical: 0, horizontal: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${widget.qty} ' + + ' item ' + + '|' + + ' ' + + '₹ ' + + '${widget.total}', + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.bold), + ), + InkWell( + onTap: (() => Navigator.pushNamed(context, '/cart')), + child: Text( + 'VIEW CART', + style: GoogleFonts.inter( + color: Colors.white, fontWeight: FontWeight.bold), + ), + ) + ], + ), + ), + ); + } +} diff --git a/lib/pages/Home.dart b/lib/pages/Home.dart index e5b1427..4092f31 100644 --- a/lib/pages/Home.dart +++ b/lib/pages/Home.dart @@ -11,6 +11,7 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:rcapp/CustomWidget/foot_category.dart'; import 'package:rcapp/models/user.dart'; import 'package:rcapp/pages/customAlert.dart'; +import 'package:rcapp/pages/storeData.dart'; import 'package:rcapp/services/auth.dart'; import 'package:provider/provider.dart'; import 'package:rcapp/services/database.dart'; @@ -47,27 +48,6 @@ class _HomeState extends State { } } - // void exp() async { - // // var date = 1600288449003; - // // var result = await Firestore.instance - // // .collection('events') - // // .where('slot', isEqualTo: 1) - // // .getDocuments(); - // // result.documents.forEach((element) { - // // print(DateTime.fromMillisecondsSinceEpoch(date)); - // // }); - // DateTime currentPhoneDate = DateTime.now(); - // Timestamp myTimeStamp = Timestamp.fromDate(currentPhoneDate); - // DateTime myDateTime = myTimeStamp.toDate(); - // print("$currentPhoneDate"); - // print("$myDateTime"); - // var result = await Firestore.instance - // .collection('events') - // .where("slot", isEqualTo: 1) - // .getDocuments(); - // print(result.documents[0]["event_date"].toDate()); - // } - @override void initState() { // TODO: implement initState @@ -201,16 +181,7 @@ class _HomeState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ InkWell( - onTap: () { - showDialog( - context: context, - builder: (context) => CustomAlert( - title: 'hello world nigga', - description: - 'teri maa ki choot madarchod order karta hai bhosdiwale', - url: 'assets/nigga.gif', - )); - }, + onTap: () {}, child: Text( " Notice Board", style: GoogleFonts.inter( @@ -231,7 +202,23 @@ class _HomeState extends State { shape: new RoundedRectangleBorder( borderRadius: new BorderRadius.circular(10.0)), child: Text( - 'Add To List', + 'Add Pdf', + style: TextStyle(color: Colors.white), + ), + color: Colors.deepOrange, + ), + ), + SizedBox(width: 10), + Container( + height: 28, + child: FlatButton( + onPressed: () { + Navigator.pushNamed(context, '/uploadPdfImage'); + }, + shape: new RoundedRectangleBorder( + borderRadius: new BorderRadius.circular(10.0)), + child: Text( + 'Add Image', style: TextStyle(color: Colors.white), ), color: Colors.deepOrange, @@ -282,8 +269,19 @@ class _HomeState extends State { Container( padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0), child: FoodCategory(areYouadmin)), - SizedBox(height: 20.0), - Text( + SizedBox(height: 48.0), + Container( + padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0), + child: Text( + " Designed by : Aswin Kumar Raju \n Developed by : Sounmay Mishra & Naiyar Imam", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 8, + fontWeight: FontWeight.w600, + ) + ), + ), + /*Text( " Upcoming Events", style: TextStyle( color: Colors.grey, @@ -299,13 +297,19 @@ class _HomeState extends State { color: Colors.black12, borderRadius: BorderRadius.circular(10)), child: Center(child: Text('No Current Events')), - ), + ),*/ SizedBox(height: 50) ], ), ), ); } + + // @override + // void dispose() { + // // TODO: implement dispose + // super.dispose(); + // } } class HomeListPage extends StatefulWidget { @@ -318,7 +322,10 @@ class _HomeListPageState extends State { Future getPosts() async { var firestore = Firestore.instance; - QuerySnapshot qn = await firestore.collection("noticeBoard").getDocuments(); + QuerySnapshot qn = await firestore + .collection("noticeBoard") + .orderBy('_date', descending: true) + .getDocuments(); print(qn); return qn.documents; } @@ -327,8 +334,9 @@ class _HomeListPageState extends State { void initState() { // TODO: implement initState super.initState(); - - _data = getPosts(); + setState(() { + _data = getPosts(); + }); } @override @@ -485,15 +493,6 @@ class _AdminOptionState extends State { style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25), ), ), - // InkWell( - // onTap: () { - // Navigator.pushNamed(context, '/adminBooking'); - // }, - // child: Text( - // 'Admin Booking', - // style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25), - // ), - // ), ) ]); } else if (isAdminglobal == null || isAdminglobal == false) { @@ -540,6 +539,7 @@ class _LoadingDataState extends State { @override Widget build(BuildContext context) { final AuthService _auth = AuthService(); + StoreData _storedata = StoreData(); return Container( child: FutureBuilder( @@ -573,7 +573,7 @@ class _LoadingDataState extends State { context, '/uploadAvatarImage'); }, child: CircleAvatar( - radius: 60.0, + radius: MediaQuery.of(context).size.width * 0.15, backgroundImage: NetworkImage( 'https://www.pngitem.com/pimgs/m/146-1468479_my-profile-icon-blank-profile-picture-circle-hd.png'), backgroundColor: Colors.transparent, @@ -586,7 +586,7 @@ class _LoadingDataState extends State { context, '/uploadAvatarImage'); }, child: CircleAvatar( - radius: 60.0, + radius: MediaQuery.of(context).size.width * 0.15, backgroundImage: NetworkImage('${snapshot.data["avatar"]}'), backgroundColor: Colors.transparent, @@ -598,12 +598,19 @@ class _LoadingDataState extends State { children: [ Text( '${snapshot.data["name"]}', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 20), + style: GoogleFonts.inter( + fontWeight: FontWeight.bold, + fontSize: + MediaQuery.of(context).size.width * + 0.05), ), Text( - 'Personal No. ${snapshot.data["number"]}', - style: TextStyle(color: Colors.grey[700]), + 'Personal No: ${snapshot.data["number"]}', + style: GoogleFonts.inter( + color: Colors.grey[700], + fontSize: + MediaQuery.of(context).size.width * + 0.026), ), ]) ]), @@ -634,26 +641,27 @@ class _LoadingDataState extends State { )), ), SizedBox(height: 10), - // Container( - // padding: EdgeInsets.fromLTRB(15, 0, 0, 10), - // child: InkWell( - // onTap: () { - // Navigator.pushNamed(context, '/uploadImage'); - // }, - // child: Text( - // "Upload Today's Menu", - // style: TextStyle( - // fontWeight: FontWeight.bold, fontSize: 25), - // ), - // ), - // ), SizedBox(height: 10), AdminOption(areYouadmin: snapshot.data["isAdmin"]), SizedBox(height: 10), + Container( + padding: EdgeInsets.fromLTRB(15, 0, 0, 10), + child: InkWell( + onTap: () { + Navigator.pushNamed(context, '/contactDetails'); + }, + child: Text( + 'Contact', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 25), + )), + ), + SizedBox(height: 10), Container( padding: EdgeInsets.fromLTRB(15, 0, 0, 10), child: InkWell( onTap: () async { + _storedata.resetStore(); await _auth.signOut(); }, child: Text( diff --git a/lib/pages/Login.dart b/lib/pages/Login.dart index 945e153..d957a84 100644 --- a/lib/pages/Login.dart +++ b/lib/pages/Login.dart @@ -75,6 +75,7 @@ class _LoginState extends State { child: logincarousel), SizedBox(height: 18.0), TextFormField( + keyboardType: TextInputType.number, decoration: InputDecoration( hintText: 'Personal Number', fillColor: Colors.white, @@ -95,6 +96,7 @@ class _LoginState extends State { }), SizedBox(height: 20.0), TextFormField( + keyboardType: TextInputType.number, decoration: InputDecoration( hintText: 'Password', fillColor: Colors.white, @@ -154,7 +156,7 @@ class _LoginState extends State { style: GoogleFonts.inter(color: Colors.red, fontSize: 14.0), ), SizedBox(height: 15.0), - Row( + /*Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( @@ -172,7 +174,7 @@ class _LoginState extends State { decoration: TextDecoration.underline, fontSize: 15)), ) - ]) + ])*/ ]), )), ), diff --git a/lib/pages/Milan.dart b/lib/pages/Milan.dart index 461d369..53d2969 100644 --- a/lib/pages/Milan.dart +++ b/lib/pages/Milan.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; - class MilanLounge extends StatefulWidget { @override _MilanLoungeState createState() => _MilanLoungeState(); @@ -14,51 +13,58 @@ class _MilanLoungeState extends State { appBar: AppBar( elevation: 10.0, backgroundColor: Colors.deepOrange, - title: Text('Blue Lounge'), + title: Text('Lounges'), ), - body: new Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Container( - height: 200.0, - width: double.infinity, - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/18.jpg"), - fit: BoxFit.fill)), + body: Container( + height: MediaQuery.of(context).size.height * 1, + child: new Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Container( + height: 200.0, + width: double.infinity, + padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/18.jpg"), + fit: BoxFit.fill)), + ), ), - ), - Text( - "Milan Lounge", - style: GoogleFonts.inter( - color: Colors.blueAccent, - fontSize: 40, + Text( + "Milan Lounge", + style: GoogleFonts.inter( + color: Colors.blueAccent, + fontSize: MediaQuery.of(context).size.width * 0.075, + ), ), - ), - Text( - "The Milan Lounge is a cozy lounge. Perfect for small group gatherings like office parties, get togethers amongst friends etc \n \nCapacity : 15 people\n \n \n \n ", - style: GoogleFonts.inter( - fontSize: 20 + Container( + padding: EdgeInsets.symmetric(horizontal: 15, vertical: 0), + child: Text( + "The Milan Lounge is a cozy lounge. Perfect for small group gatherings like office parties, get togethers amongst friends etc \n \nCapacity : 15 people\n \n \n \n ", + style: GoogleFonts.inter( + fontSize: MediaQuery.of(context).size.width * 0.05), + ), ), - ), - SizedBox( - width: double.infinity, - height: 60, - child: ButtonTheme( - child: RaisedButton( - color: Colors.deepOrange, - onPressed: () { - Navigator.pushNamed(context, "/bookingcalendar"); - }, - child: Text('Book', - style: GoogleFonts.inter(color: Colors.white, fontSize: 18))), - )), - ], + SizedBox( + width: double.infinity, + height: 60, + child: ButtonTheme( + child: RaisedButton( + color: Colors.deepOrange, + onPressed: () { + Navigator.pushNamed(context, "/bookingcalendar"); + }, + child: Text('Book', + style: GoogleFonts.inter( + color: Colors.white, fontSize: 18))), + )), + ], + ), ), - ); } + ); + } } diff --git a/lib/pages/MilapL.dart b/lib/pages/MilapL.dart index 92bef04..4600b2f 100644 --- a/lib/pages/MilapL.dart +++ b/lib/pages/MilapL.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; - - class MilapLounge extends StatefulWidget { @override _MilapLoungeState createState() => _MilapLoungeState(); @@ -15,51 +13,56 @@ class _MilapLoungeState extends State { appBar: AppBar( elevation: 10.0, backgroundColor: Colors.deepOrange, - title: Text('Milap Lounge'), + title: Text('Lounges'), ), - body: new Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Container( - height: 200.0, - width: double.infinity, - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/17.jpg"), - fit: BoxFit.fill)), + body: Container( + height: MediaQuery.of(context).size.height * 1, + child: new Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Container( + height: 200.0, + width: double.infinity, + padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/17.jpg"), + fit: BoxFit.fill)), + ), ), - ), - Text( - "Milap Reception Hall", - style: GoogleFonts.inter( - color: Colors.blueAccent, - fontSize: 40, + Text( + "Milap Reception Hall", + style: GoogleFonts.inter( + color: Colors.blueAccent, + fontSize: MediaQuery.of(context).size.width * 0.075, + ), ), - ), - Text( - " \nThe Milap Reception Hall is a large hall present in the first floor of the club. Perfect for medium group gatherings like office parties, departmental dinners etc \n \nCapacity : 70 people\n \n \n ", - style: GoogleFonts.inter( - fontSize: 20 + Container( + padding: EdgeInsets.symmetric(horizontal: 15, vertical: 0), + child: Text( + " \nThe Milap Reception Hall is a large hall present in the first floor of the club. Perfect for medium group gatherings like office parties, departmental dinners etc \n \nCapacity : 70 people\n \n ", + style: GoogleFonts.inter(fontSize: MediaQuery.of(context).size.width*0.05), + ), ), - ), - SizedBox( - width: double.infinity, - height: 60, - child: ButtonTheme( - child: RaisedButton( - color: Colors.deepOrange, - onPressed: () { - Navigator.pushNamed(context, "/bookingcalendar"); - }, - child: Text('Book', - style: GoogleFonts.inter(color: Colors.white, fontSize: 18))), - )), - ], + SizedBox( + width: double.infinity, + height: 60, + child: ButtonTheme( + child: RaisedButton( + color: Colors.deepOrange, + onPressed: () { + Navigator.pushNamed(context, "/bookingcalendar"); + }, + child: Text('Book', + style: GoogleFonts.inter( + color: Colors.white, fontSize: 18))), + )), + ], + ), ), ); } diff --git a/lib/pages/NavigationBar.dart b/lib/pages/NavigationBar.dart index a283f00..d88df31 100644 --- a/lib/pages/NavigationBar.dart +++ b/lib/pages/NavigationBar.dart @@ -1,7 +1,12 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; import 'package:rcapp/pages/Booking.dart'; +import 'package:rcapp/pages/CategoryMenuList/flushbar.dart'; import 'package:rcapp/pages/Food.dart'; import 'package:rcapp/pages/Home.dart'; +import 'package:provider/provider.dart'; +import 'package:rcapp/pages/storeData.dart'; class NavigationBar extends StatefulWidget { @override @@ -9,6 +14,7 @@ class NavigationBar extends StatefulWidget { } class _NavigationBarState extends State { + StoreData storeData = StoreData(); int _currentIndex = 0; final List _children = [ Home(), @@ -16,12 +22,50 @@ class _NavigationBarState extends State { Booking(), ]; + register() async { + final fbm = FirebaseMessaging(); + var token = await fbm.getToken(); + print('this is token ::: ' + '$token'); + var admin = await Firestore.instance + .collection('userInfo') + .where('isAdmin', isEqualTo: true) + .getDocuments(); + var admintoken = []; + admin.documents.forEach((element) { + admintoken.add(element["token"].toString()); + }); + print(admintoken); + } + + Future configure() async { + final fbm = FirebaseMessaging(); + fbm.configure(onMessage: (msg) { + print(msg); + showFlushbarNotification( + context, msg['notification']['title'], msg['notification']['body']); + return; + }, onLaunch: (msg) { + print(msg); + return; + }, onResume: (msg) { + print(msg); + return; + }); + } + void onTappedBar(int index) { setState(() { _currentIndex = index; }); } + @override + void initState() { + // TODO: implement initState + super.initState(); + configure(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -38,18 +82,24 @@ class _NavigationBarState extends State { backgroundColor: Colors.deepOrange, ), BottomNavigationBarItem( - icon: Icon(Icons.fastfood), - title: Text('Food'), - backgroundColor: Colors.deepOrange, - activeIcon: Icon(Icons.fastfood, color: Colors.deepOrange), - ), + icon: Icon(Icons.fastfood), + title: Text('Food'), + backgroundColor: Colors.deepOrange, + activeIcon: Icon(Icons.fastfood, color: Colors.deepOrange), + ), BottomNavigationBarItem( - icon: Icon(Icons.book), - title: Text('Booking'), - backgroundColor: Colors.deepOrange, + icon: Icon(Icons.book), + title: Text('Booking'), + backgroundColor: Colors.deepOrange, ), ], ), ); } + + // @override + // void dispose() { + // // TODO: implement dispose + // super.dispose(); + // } } diff --git a/lib/pages/Search.dart b/lib/pages/Search.dart index c00c717..81ccad1 100644 --- a/lib/pages/Search.dart +++ b/lib/pages/Search.dart @@ -54,6 +54,7 @@ class _SearchState extends State { onChanged: (val) { initiateSearch(val); }, + textCapitalization: TextCapitalization.words, decoration: InputDecoration( prefixIcon: IconButton( color: Colors.black, @@ -123,8 +124,9 @@ class _SearchQuantityState extends State { ), height: 25, width: 62, - child: - Center(child: Text('Add', style: GoogleFonts.inter(color: Colors.white))), + child: Center( + child: + Text('Add', style: GoogleFonts.inter(color: Colors.white))), ), ); } else { @@ -178,7 +180,8 @@ class _SearchQuantityState extends State { width: 33, child: Text( '$FQty', - style: GoogleFonts.inter(fontSize: 17, fontWeight: FontWeight.bold), + style: + GoogleFonts.inter(fontSize: 17, fontWeight: FontWeight.bold), ), ), Container( @@ -258,13 +261,18 @@ class _SearchListState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - '${widget.tempSearchStore[index]['item']}', - style: GoogleFonts.inter(fontSize: 17, fontWeight: FontWeight.bold), + Container( + width: MediaQuery.of(context).size.width * 0.6, + child: Text( + '${widget.tempSearchStore[index]['item']}', + overflow: TextOverflow.ellipsis, + style: GoogleFonts.inter( + fontSize: 17, fontWeight: FontWeight.bold), + ), ), SearchQuantity( item: widget.tempSearchStore[index]['item'], - price: widget.tempSearchStore[index]['price']), + price: widget.tempSearchStore[index]['club_rate']), ], ), ); diff --git a/lib/pages/TennisCourt.dart b/lib/pages/TennisCourt.dart index 400685b..0b79349 100644 --- a/lib/pages/TennisCourt.dart +++ b/lib/pages/TennisCourt.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; - class TennisCourt extends StatefulWidget { @override _TennisCourtState createState() => _TennisCourtState(); @@ -14,52 +13,57 @@ class _TennisCourtState extends State { appBar: AppBar( elevation: 10.0, backgroundColor: Colors.deepOrange, - title: Text('Tennis Court'), + title: Text('Banquets'), ), - body: new Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Container( - height: 200.0, - width: double.infinity, - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/51.jpg"), - fit: BoxFit.fill)), + body: Container( + height: MediaQuery.of(context).size.height * 1, + child: new Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Container( + height: 200.0, + width: double.infinity, + padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/55.jpg"), + fit: BoxFit.fill)), + ), ), - ), - Text("Tennis Court", - style: GoogleFonts.inter( - color: Colors.green, - fontSize: 30 - ),), - Container( - padding: EdgeInsets.all(10), - child:Text("The Open Tennis court is perfect for sporting events, and for large group gettogethers like Anniversaries, Birthdays, Office picnics etc \n \n" - "Capacity - 250 people", + Text( + "Tennis Court", style: GoogleFonts.inter( - color: Colors.black, - fontSize: 20 - ),), - ), - SizedBox( - width: double.infinity, - height: 60, - child: ButtonTheme( - child: RaisedButton( - color: Colors.deepOrange, - onPressed: () { - Navigator.pushNamed(context, "/bookingcalendar"); - }, - child: Text('Book', - style: GoogleFonts.inter(color: Colors.white, fontSize: 18))), - )), - ], + color: Colors.green, + fontSize: MediaQuery.of(context).size.width * 0.075), + ), + Container( + padding: EdgeInsets.all(10), + child: Text( + "The Open Tennis court is perfect for sporting events, and for large group gettogethers like Anniversaries, Birthdays, Office picnics etc \n \n" + "Capacity - 250 people", + style: GoogleFonts.inter(color: Colors.black, fontSize: MediaQuery.of(context).size.width * 0.05), + ), + ), + SizedBox( + width: double.infinity, + height: 60, + child: ButtonTheme( + child: RaisedButton( + color: Colors.deepOrange, + onPressed: () { + Navigator.pushNamed(context, "/bookingcalendar"); + }, + child: Text('Book', + style: GoogleFonts.inter( + color: Colors.white, fontSize: 18))), + )), + ], + ), ), - ); } + ); + } } diff --git a/lib/pages/WeddingHall.dart b/lib/pages/WeddingHall.dart index 801aa8f..b03c18b 100644 --- a/lib/pages/WeddingHall.dart +++ b/lib/pages/WeddingHall.dart @@ -13,52 +13,58 @@ class _WeddingHallState extends State { appBar: AppBar( elevation: 10.0, backgroundColor: Colors.deepOrange, - title: Text('Wedding Recption Hall'), + title: Text('Banquets'), ), - body: new Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Container( - height: 200.0, - width: double.infinity, - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/16.jpg"), - fit: BoxFit.fill)), + body: Container( + height: MediaQuery.of(context).size.height * 1, + child: new Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Container( + height: 200.0, + width: double.infinity, + padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/56.jpg"), + fit: BoxFit.fill)), + ), ), - ), - Text("Wedding Reception Hall", - style: GoogleFonts.inter( - color: Colors.blueGrey, - fontSize: 30 - ),), - Container( - padding: EdgeInsets.all(10), - child:Text("Located near the swimming pool area, the wedding reception hall is meant for big gatherings in occasions like marriages, receptions, birthday parties etc. \n \n" - "Capacity - 250 people", + Text( + "Wedding Reception Hall", style: GoogleFonts.inter( - color: Colors.black, - fontSize: 20 - ),), - ), - SizedBox( - width: double.infinity, - height: 60, - child: ButtonTheme( - child: RaisedButton( - color: Colors.deepOrange, - onPressed: () { - Navigator.pushNamed(context, "/bookingcalendar"); - }, - child: Text('Book', - style: GoogleFonts.inter(color: Colors.white, fontSize: 18))), - )), - ], + color: Colors.blueGrey, + fontSize: MediaQuery.of(context).size.width * 0.075), + ), + Container( + padding: EdgeInsets.all(10), + child: Text( + "Located near the swimming pool area, the wedding reception hall is meant for big gatherings in occasions like marriages, receptions, birthday parties etc. \n \n" + "Capacity - 250 people", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: MediaQuery.of(context).size.width * 0.05), + ), + ), + SizedBox( + width: double.infinity, + height: 60, + child: ButtonTheme( + child: RaisedButton( + color: Colors.deepOrange, + onPressed: () { + Navigator.pushNamed(context, "/bookingcalendar"); + }, + child: Text('Book', + style: GoogleFonts.inter( + color: Colors.white, fontSize: 18))), + )), + ], + ), ), ); } diff --git a/lib/pages/YellowL.dart b/lib/pages/YellowL.dart index 4d6555c..5771122 100644 --- a/lib/pages/YellowL.dart +++ b/lib/pages/YellowL.dart @@ -14,51 +14,57 @@ class _YellowLoungeState extends State { appBar: AppBar( elevation: 10.0, backgroundColor: Colors.deepOrange, - title: Text('Yellow Lounge'), + title: Text('Lounges'), ), - body: new Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Container( - height: 200.0, - width: double.infinity, - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/13.jpg"), - fit: BoxFit.fill)), + body: Container( + height: MediaQuery.of(context).size.height*1, + child: new Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Container( + height: 200.0, + width: double.infinity, + padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/13.jpg"), + fit: BoxFit.fill)), + ), ), - ), - Text( - "Yellow Lounge", - style: GoogleFonts.inter( - color: Colors.orange, - fontSize: 40, + Text( + "Yellow Lounge", + style: GoogleFonts.inter( + color: Colors.orange, + fontSize: MediaQuery.of(context).size.width * 0.075, + ), ), - ), - Text( - "The Yellow Lounge is a large, comfortable lounge in the ground floor of the club. It is decorated with plush sofas and a warm ambience. Perfect for medium gatherings like office gettogethers, birthday parties etc \n \nCapacity : 25 people", - style: GoogleFonts.inter( - fontSize: 20 + Container( + padding: EdgeInsets.symmetric(horizontal: 15, vertical: 0), + child: Text( + "The Yellow Lounge is a large, comfortable lounge in the ground floor of the club. It is decorated with plush sofas and a warm ambience. Perfect for medium gatherings like office gettogethers, birthday parties etc \n \nCapacity : 25 people", + style: GoogleFonts.inter( + fontSize: MediaQuery.of(context).size.width*0.05 + ), + ), ), - ), - SizedBox( - width: double.infinity, - height: 60, - child: ButtonTheme( - child: RaisedButton( - color: Colors.deepOrange, - onPressed: () { - Navigator.pushNamed(context, "/bookingcalendar"); - }, - child: Text('Book', - style: GoogleFonts.inter(color: Colors.white, fontSize: 18))), - )), - ], + SizedBox( + width: double.infinity, + height: 60, + child: ButtonTheme( + child: RaisedButton( + color: Colors.deepOrange, + onPressed: () { + Navigator.pushNamed(context, "/bookingcalendar"); + }, + child: Text('Book', + style: GoogleFonts.inter(color: Colors.white, fontSize: 18))), + )), + ], + ), ), ); } diff --git a/lib/pages/add_event.dart b/lib/pages/add_event.dart index 80de1fc..0b669c6 100644 --- a/lib/pages/add_event.dart +++ b/lib/pages/add_event.dart @@ -26,6 +26,7 @@ class _AddEventPageState extends State { String _name = ''; String _personalno = ''; + String _mobileno = ''; int slot = 1; DateTime _eventDate; int numberOfPeople = 1; @@ -77,15 +78,15 @@ class _AddEventPageState extends State { } }); if (!exits) { - _booking.bookDetails(id, _name, _personalno, numberOfPeople, + _booking.bookDetails(id, _name, _personalno, _mobileno, numberOfPeople, loungeColor[_value1 - 1], slot, _eventDate); showDialog( context: context, builder: (context) => CustomAlert( title: 'Booking Requested', description: - 'Your booking request has been forwarded to the administrator. You will get a confirmation notification within 24 hours and can view your booking in the calendar', - url: 'assets/nigga.gif', + 'Your booking request has been forwarded to the administrator. You will get a confirmation notification within 24 hours and can view your booking in the calendar. For further queries, please contact - Mr. Pramod Kumar Pattnaik - +919437116141', + /*url: 'assets/tick.gif',*/ )); // Navigator.pop(context); @@ -106,6 +107,8 @@ class _AddEventPageState extends State { @override Widget build(BuildContext context) { + _eventDate = ModalRoute.of(context).settings.arguments; + if (_name == '' && _personalno == '') { return Scaffold( appBar: AppBar( @@ -155,6 +158,7 @@ class _AddEventPageState extends State { }), SizedBox(height: 10), TextFormField( + keyboardType: TextInputType.number, initialValue: _personalno, decoration: InputDecoration( hintText: 'Personal No.', @@ -175,6 +179,27 @@ class _AddEventPageState extends State { }), SizedBox(height: 10), TextFormField( + keyboardType: TextInputType.number, + decoration: InputDecoration( + hintText: 'Mobile No.', + fillColor: Colors.white, + filled: true, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 1.0), + borderRadius: BorderRadius.circular(10)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 3.0), + borderRadius: BorderRadius.circular(10))), + validator: (val) => + val.isEmpty ? 'Enter your Personal No.' : null, + onChanged: (val) { + setState(() => _mobileno = val); + }), + SizedBox(height: 10), + TextFormField( + keyboardType: TextInputType.number, decoration: InputDecoration( hintText: 'Number of People', fillColor: Colors.white, @@ -227,11 +252,11 @@ class _AddEventPageState extends State { value: _value2, items: [ DropdownMenuItem( - child: Text("Slot 1"), + child: Text("Lunch Slot(12PM - 3PM)"), value: 1, ), DropdownMenuItem( - child: Text("Slot 2"), + child: Text("Dinner Slot(7:30PM - 10.30PM)"), value: 2, ), ], diff --git a/lib/pages/address.dart b/lib/pages/address.dart index 4dd5b19..f87d456 100644 --- a/lib/pages/address.dart +++ b/lib/pages/address.dart @@ -19,6 +19,7 @@ class _AddressFormState extends State { String _city = ''; String _pincode = ''; String error = ''; + String number = ''; String _finaladdress = ''; @@ -88,7 +89,7 @@ class _AddressFormState extends State { SizedBox(height: 20.0), TextFormField( decoration: InputDecoration( - hintText: 'City', //hardcode to rourkela + hintText: 'City', //hardcode to rourkela fillColor: Colors.white, filled: true, enabledBorder: OutlineInputBorder( @@ -122,57 +123,76 @@ class _AddressFormState extends State { validator: (val) => val.isEmpty ? 'Please Enter Your Pincode' : null, obscureText: false, + keyboardType: TextInputType.number, onChanged: (val) { setState(() => _pincode = val); }), SizedBox(height: 20.0), - Container( - width: 64.0, - height: 40, - child:RaisedButton( - color: Colors.deepOrange, - padding: const EdgeInsets.symmetric( - horizontal: 40, vertical: 15), - child: Text( - 'Save', - style: GoogleFonts.inter( - color: Colors.white, - fontWeight: FontWeight.w400, - fontSize: 20), - ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - onPressed: () async { - if (_formKey.currentState.validate()) { - var user = - (await FirebaseAuth.instance.currentUser()).uid; - setState(() { - _finaladdress = _houseno + - ", " + - _streetname + - ", " + - _city + - "-" + - _pincode; - }); - print(_finaladdress); - dynamic result = await _formUploader - .updateAddressData(user, _finaladdress); - if (result != null) { - setState(() => error = - 'could not upload address, please try again'); - } else { - Navigator.popAndPushNamed(context, '/cart'); - } - } - }, + TextFormField( + decoration: InputDecoration( + hintText: 'Mobile No.', + fillColor: Colors.white, + filled: true, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 1.0), + borderRadius: BorderRadius.circular(10)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 3.0), + borderRadius: BorderRadius.circular(10))), + validator: (val) => + val.isEmpty ? 'Please Enter Mobile No.' : null, + obscureText: false, + keyboardType: TextInputType.number, + onChanged: (val) { + setState(() => number = val); + }), + SizedBox(height: 20.0), + RaisedButton( + color: Colors.deepOrange, + padding: const EdgeInsets.symmetric( + horizontal: 40, vertical: 15), + child: Text( + 'Save', + style: GoogleFonts.inter( + color: Colors.white, + fontWeight: FontWeight.w400, + fontSize: 25), ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + onPressed: () async { + if (_formKey.currentState.validate()) { + var user = + (await FirebaseAuth.instance.currentUser()).uid; + setState(() { + _finaladdress = _houseno + + ", " + + _streetname + + ", " + + _city + + "-" + + _pincode; + }); + print(_finaladdress); + dynamic result = await _formUploader + .updateAddressData(user, _finaladdress, number); + if (result != null) { + setState(() => error = + 'could not upload address, please try again'); + } else { + Navigator.popAndPushNamed(context, '/cart'); + } + } + }, ), SizedBox(height: 20.0), Text( error, - style: GoogleFonts.inter(color: Colors.red, fontSize: 14.0), + style: + GoogleFonts.inter(color: Colors.red, fontSize: 14.0), ) ]), )), diff --git a/lib/pages/adminBooking.dart b/lib/pages/adminBooking.dart index f7b8df5..afa6d69 100644 --- a/lib/pages/adminBooking.dart +++ b/lib/pages/adminBooking.dart @@ -43,7 +43,7 @@ class _AdminBookingState extends State { }); } - void rejectBookinHistory(int _eventDate, int index) async { + void deleteBookinHistory(int _eventDate, int index) async { await Firestore.instance .collection('BookingDetails') .document('$_eventDate') @@ -53,6 +53,16 @@ class _AdminBookingState extends State { }); } + void rejectBooking(int _eventDate, int index) async { + await Firestore.instance + .collection('BookingDetails') + .document('$_eventDate') + .updateData({'isRejected': true}); + setState(() { + bookings[index]["isRejected"] = true; + }); + } + void confirmBooking( String _name, String _personalno, @@ -112,17 +122,23 @@ class _AdminBookingState extends State { } else if (documentlength == 0) { return Scaffold( body: Center( + child: Scaffold( + appBar: AppBar( + title: Text('Admin Booking'), backgroundColor: Colors.deepOrange), + body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Icon(Icons.all_inclusive), - Text('No data') - ])), + Icon(Icons.all_inclusive), + Text('No Bookings Pending') + ]), + ), + )), ); } else { return Scaffold( appBar: AppBar( - title: Text('Your Booking'), + title: Text('Admin Booking'), backgroundColor: Colors.deepOrange, ), body: Container( @@ -141,7 +157,7 @@ class _AdminBookingState extends State { SizedBox(height: 10.0), Container( padding: EdgeInsets.all(10), - height: 240.0, + height: MediaQuery.of(context).size.height * 0.43, width: 380.0, decoration: BoxDecoration( color: Colors.white, @@ -194,6 +210,21 @@ class _AdminBookingState extends State { ], ), SizedBox(height: 10), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + "Mobile No. : " + + "${bookings[index]["mobileNumber"]}", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400), + ), + ], + ), + SizedBox(height: 10), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -214,26 +245,37 @@ class _AdminBookingState extends State { MainAxisAlignment.spaceBetween, children: [ Text( - 'Slot: ${bookings[index]["slot"]}', + bookings[index]["slot"] == 1 + ? 'Slot: Lunch ' + : 'Slot: Dinner ', style: GoogleFonts.inter( color: Colors.black, fontSize: 18, fontWeight: FontWeight.w400), ), - Text( - bookings[index]["isConfirmed"] - ? 'Status: Confirmed' - : 'Status: Not Confirmed', - style: GoogleFonts.inter( - color: Colors.black, - fontSize: 18, - fontWeight: FontWeight.w400)), - SizedBox(width: 30) ], ), SizedBox(height: 10), + if (!bookings[index]["isRejected"]) ...[ + Text( + bookings[index]["isConfirmed"] + ? 'Status: Confirmed' + : 'Status: Not Confirmed', + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400)), + ] else ...[ + Text('Status: Rejected', + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400)), + ], + SizedBox(height: 10), ]), - if (!bookings[index]["isConfirmed"]) ...[ + if (!bookings[index]["isConfirmed"] && + !bookings[index]["isRejected"]) ...[ Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -243,8 +285,11 @@ class _AdminBookingState extends State { width: 110, child: FlatButton( onPressed: () { - rejectBookinHistory( - bookings[index]["_date"], index); + if (!bookings[index]["isConfirmed"]) { + rejectBooking( + bookings[index]["_date"], + index); + } }, color: Colors.red[700], child: Row( @@ -273,15 +318,22 @@ class _AdminBookingState extends State { width: 110, child: FlatButton( onPressed: () { - confirmBooking( - bookings[index]["name"], - bookings[index]["number"], - bookings[index]["lounge"], - bookings[index]["slot"], - bookings[index]["numberOfPeople"], - bookings[index]["_date"], - bookings[index]["bookingDate"], - index); + if (!bookings[index]["isConfirmed"]) { + confirmBooking( + bookings[index]["name"], + bookings[index]["number"], + bookings[index]["lounge"], + bookings[index]["slot"], + bookings[index] + ["numberOfPeople"], + bookings[index]["_date"], + bookings[index]["bookingDate"], + index); + } else { + deleteBookinHistory( + bookings[index]["_date"], + index); + } }, color: Colors.deepOrange, child: Row( @@ -293,11 +345,20 @@ class _AdminBookingState extends State { size: 17, color: Colors.white, ), - Text( - 'Confirm', - style: GoogleFonts.inter( - color: Colors.white), - ), + if (!bookings[index] + ["isConfirmed"]) ...[ + Text( + 'Confirm', + style: GoogleFonts.inter( + color: Colors.white), + ), + ] else ...[ + Text( + 'Delete', + style: GoogleFonts.inter( + color: Colors.white), + ) + ] ]), shape: new RoundedRectangleBorder( borderRadius: @@ -315,7 +376,7 @@ class _AdminBookingState extends State { width: 100, child: FlatButton( onPressed: () { - rejectBookinHistory( + deleteBookinHistory( bookings[index]["_date"], index); }, color: Colors.red[700], diff --git a/lib/pages/admin_order_confirm.dart b/lib/pages/admin_order_confirm.dart index af36aaa..da835fb 100644 --- a/lib/pages/admin_order_confirm.dart +++ b/lib/pages/admin_order_confirm.dart @@ -16,6 +16,7 @@ class _AdminOrderState extends State { List item = []; List quantity = []; List total = []; + bool loading = true; void confirmOrder(int index, int date) async { // var docId = '${orders[index]["id"]}' + '${orders[index]["total"]}'; @@ -28,6 +29,16 @@ class _AdminOrderState extends State { }); } + void rejectOrder(int index, int date) async { + await Firestore.instance + .collection('confirmedOrders') + .document('$date') + .updateData({"isRejected": true}); + setState(() { + orders[index]["isRejected"] = true; + }); + } + void deleteOrder(int index, int date) async { await Firestore.instance .collection('confirmedOrders') @@ -51,6 +62,12 @@ class _AdminOrderState extends State { total.add(res.data["total"]); }); }); + print(result.documents.length); + if (result.documents.length == 0) { + setState(() { + loading = false; + }); + } } @override @@ -63,7 +80,10 @@ class _AdminOrderState extends State { @override Widget build(BuildContext context) { int orderNo = 110; - if (orders.length == 0 && item.length == 0 && quantity.length == 0) { + if (orders.length == 0 && + item.length == 0 && + quantity.length == 0 && + loading == true) { return Scaffold( body: Center( child: Column( @@ -73,7 +93,7 @@ class _AdminOrderState extends State { Text('Loading data') ])), ); - } else { + } else if (orders.length != 0) { return Scaffold( appBar: AppBar( title: Text('Your Orders'), @@ -95,8 +115,8 @@ class _AdminOrderState extends State { SizedBox(height: 10.0), Container( padding: EdgeInsets.all(10), - height: 190.0, - width: 370.0, + height: MediaQuery.of(context).size.height * 0.32, + width: MediaQuery.of(context).size.width * 9, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(12.0)), @@ -111,7 +131,42 @@ class _AdminOrderState extends State { style: GoogleFonts.inter( color: Colors.deepOrange, fontSize: 22), ), - Flexible(child: Text('${orders[index]["date"]}')), + // Flexible(child: Text('${orders[index]["date"]}')), + InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + AdminOrderDetails( + total: orders[index]["total"], + orderNo: orderNo, + name: orders[index]["name"], + date: orders[index]["date"], + number: orders[index] + ["number"], + address: orders[index] + ["address"], + item: item[index], + quantity: quantity[index], + mobileNumber: orders[index] + ["mobileNumber"], + price: orders[index] + ["price"]))); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5, vertical: 4), + decoration: BoxDecoration( + color: Colors.orange, + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(5)), + child: Text('View', + style: GoogleFonts.inter( + color: Colors.white, + )), + ), + ), ], ), SizedBox(height: 8), @@ -137,8 +192,22 @@ class _AdminOrderState extends State { MainAxisAlignment.spaceBetween, children: [ Text( - "Personal No : " + - "${orders[index]["number"]}", + "Date : " + "${orders[index]["date"]}", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400), + ), + ], + ), + SizedBox(height: 8), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + "Mobile No : " + + "${orders[index]["mobileNumber"]}", style: GoogleFonts.inter( color: Colors.black, fontSize: 18, @@ -147,32 +216,62 @@ class _AdminOrderState extends State { ], ), SizedBox(height: 8), - if (orders[index]["isConfirmed"]) ...[ + if (orders[index]["isConfirmed"] && + !orders[index]["isRejected"]) ...[ Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, children: [ Text( - "Status: Confirmed", + "Status: ", style: GoogleFonts.inter( color: Colors.black, fontSize: 18, fontWeight: FontWeight.w400), ), + Text( + "Confirmed", + style: GoogleFonts.inter( + color: Colors.green, + fontSize: 18, + fontWeight: FontWeight.w400), + ), + ], + ), + ] else if (orders[index]["isRejected"]) ...[ + Row( + children: [ + Text( + "Status: ", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400), + ), + Text( + "Rejected", + style: GoogleFonts.inter( + color: Colors.red[800], + fontSize: 18, + fontWeight: FontWeight.w400), + ), ], ), ] else ...[ Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, children: [ Text( - "Status: Not Confirmed", + "Status: ", style: GoogleFonts.inter( color: Colors.black, fontSize: 18, fontWeight: FontWeight.w400), ), + Text( + "Not Confirmed", + style: GoogleFonts.inter( + color: Colors.orange, + fontSize: 18, + fontWeight: FontWeight.w400), + ), ], ), ] @@ -189,25 +288,10 @@ class _AdminOrderState extends State { Row(children: [ InkWell( onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - AdminOrderDetails( - total: orders[index] - ["total"], - orderNo: orderNo, - name: orders[index] - ["name"], - date: orders[index] - ["date"], - number: orders[index] - ["number"], - address: orders[index] - ["address"], - item: item[index], - quantity: - quantity[index]))); + if (!orders[index]["isConfirmed"]) { + rejectOrder( + index, orders[index]["_date"]); + } }, child: Container( padding: EdgeInsets.symmetric( @@ -218,14 +302,15 @@ class _AdminOrderState extends State { Border.all(color: Colors.black), borderRadius: BorderRadius.circular(5)), - child: Text('View', + child: Text('Reject', style: GoogleFonts.inter( color: Colors.white, )), ), ), SizedBox(width: 10), - if (!orders[index]["isConfirmed"]) ...[ + if (!orders[index]["isConfirmed"] && + !orders[index]["isRejected"]) ...[ InkWell( onTap: () { confirmOrder( @@ -280,6 +365,20 @@ class _AdminOrderState extends State { ), ), ); + } else { + return Scaffold( + appBar: AppBar( + title: Text('Admin Orders'), backgroundColor: Colors.deepOrange), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.add_shopping_cart, size: 40, color: Colors.deepOrange), + Text('No Orders Pending', + style: GoogleFonts.inter( + color: Colors.black, fontWeight: FontWeight.bold)) + ])), + ); } } } @@ -287,7 +386,8 @@ class _AdminOrderState extends State { class AdminOrderData extends StatefulWidget { List item; List quantity; - AdminOrderData({this.item, this.quantity}); + List price; + AdminOrderData({this.item, this.quantity, this.price}); @override _AdminOrderDataState createState() => _AdminOrderDataState(); } @@ -297,7 +397,7 @@ class _AdminOrderDataState extends State { Widget build(BuildContext context) { return Container( padding: EdgeInsets.fromLTRB(10, 10, 20, 0), - height: 390, + height: MediaQuery.of(context).size.height * 0.4, child: ListView.builder( itemCount: widget.item.length, itemBuilder: (_, index) { @@ -305,11 +405,27 @@ class _AdminOrderDataState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - child: Row(children: [ - Text('${index + 1}) '), - Text('${widget.item[index]} '), - ])), - Text('${widget.quantity[index]}'), + // decoration: BoxDecoration(color: Colors.deepOrange), + width: MediaQuery.of(context).size.width * 0.34, + child: Text( + '${widget.item[index]}', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + )), + Container( + // decoration: BoxDecoration(color: Colors.deepOrange), + width: MediaQuery.of(context).size.width * 0.2, + child: Text( + '${widget.quantity[index]}', + textAlign: TextAlign.center, + )), + Container( + // decoration: BoxDecoration(color: Colors.deepOrange), + width: MediaQuery.of(context).size.width * 0.2, + child: Text( + '${widget.price[index]}', + textAlign: TextAlign.center, + )), ], ); }), @@ -324,18 +440,21 @@ class AdminOrderDetails extends StatefulWidget { final String name; final String number; final String date; + final String mobileNumber; final List item; final List quantity; - AdminOrderDetails({ - this.orderNo, - this.total, - this.address, - this.name, - this.number, - this.date, - this.item, - this.quantity, - }); + final List price; + AdminOrderDetails( + {this.orderNo, + this.total, + this.address, + this.name, + this.number, + this.date, + this.item, + this.quantity, + this.mobileNumber, + this.price}); @override _AdminOrderDetailsState createState() => _AdminOrderDetailsState(); } @@ -363,8 +482,8 @@ class _AdminOrderDetailsState extends State { SizedBox(height: 20.0), Container( padding: EdgeInsets.all(10), - height: 500.0, - width: 370.0, + height: MediaQuery.of(context).size.height * 0.7, + width: MediaQuery.of(context).size.width * 0.9, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(15.0)), @@ -454,10 +573,34 @@ class _AdminOrderDetailsState extends State { ]), ], ), + SizedBox(height: 10), + Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Mobile No. : ${widget.mobileNumber}", + style: GoogleFonts.inter( + color: Colors.grey, + fontSize: 18, + fontWeight: FontWeight.w500), + ), + SizedBox(height: 5), + /*Padding( + padding: EdgeInsets.fromLTRB(10, 0, 0, 0), + child: Text( + "", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400), + ), + ),*/ + ], + ), ], ), SizedBox(height: 20), - Container( + /* Container( alignment: Alignment.centerLeft, child: Text( 'Menu :', @@ -465,28 +608,44 @@ class _AdminOrderDetailsState extends State { color: Colors.grey, fontSize: 18, fontWeight: FontWeight.w500), - )), + )),*/ Container( padding: EdgeInsets.fromLTRB(10, 10, 0, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('Item Name', - style: GoogleFonts.inter( - fontSize: 20, - fontWeight: FontWeight.w400, - decoration: TextDecoration.underline)), - Text('Quantity', - style: GoogleFonts.inter( - fontSize: 20, - fontWeight: FontWeight.w400, - decoration: TextDecoration.underline)) + Container( + width: MediaQuery.of(context).size.width * 0.4, + child: Text('Item', + style: GoogleFonts.inter( + fontSize: 20, + fontWeight: FontWeight.w400, + decoration: TextDecoration.underline)), + ), + Container( + width: MediaQuery.of(context).size.width * 0.2, + child: Text('Qty', + style: GoogleFonts.inter( + fontSize: 20, + fontWeight: FontWeight.w400, + decoration: TextDecoration.underline)), + ), + Container( + width: MediaQuery.of(context).size.width * 0.2, + child: Text('Rate', + style: GoogleFonts.inter( + fontSize: 20, + fontWeight: FontWeight.w400, + decoration: TextDecoration.underline)), + ), ], ), ), Flexible( child: AdminOrderData( - item: widget.item, quantity: widget.quantity), + item: widget.item, + quantity: widget.quantity, + price: widget.price), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, diff --git a/lib/pages/booking_calendar.dart b/lib/pages/booking_calendar.dart index da0c8fa..0f44b45 100644 --- a/lib/pages/booking_calendar.dart +++ b/lib/pages/booking_calendar.dart @@ -16,6 +16,7 @@ class _CalendarState extends State { CalendarController _controller; Map> _events; List _selectedEvents; + var _selectedDate = DateTime.now(); @override void initState() { @@ -55,95 +56,105 @@ class _CalendarState extends State { _selectedEvents = []; } } - return SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - TableCalendar( - events: _events, - initialCalendarFormat: CalendarFormat.month, - calendarStyle: CalendarStyle( - canEventMarkersOverflow: true, - todayColor: Colors.orange, - selectedColor: Theme.of(context).primaryColor, - - todayStyle: GoogleFonts.inter( - fontWeight: FontWeight.bold, - fontSize: 18.0, - color: Colors.white)), - headerStyle: HeaderStyle( - centerHeaderTitle: true, - formatButtonDecoration: BoxDecoration( - color: Colors.orange, - borderRadius: BorderRadius.circular(20.0), + return SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TableCalendar( + events: _events, + initialCalendarFormat: CalendarFormat.month, + calendarStyle: CalendarStyle( + canEventMarkersOverflow: true, + todayColor: Colors.orange, + selectedColor: Theme.of(context).primaryColor, + todayStyle: GoogleFonts.inter( + fontWeight: FontWeight.bold, + fontSize: 18.0, + color: Colors.white)), + headerStyle: HeaderStyle( + centerHeaderTitle: true, + formatButtonDecoration: BoxDecoration( + color: Colors.orange, + borderRadius: BorderRadius.circular(20.0), + ), + formatButtonTextStyle: + GoogleFonts.inter(color: Colors.white), + formatButtonShowsNext: false, ), - formatButtonTextStyle: GoogleFonts.inter(color: Colors.white), - formatButtonShowsNext: false, - ), - startingDayOfWeek: StartingDayOfWeek.monday, - onDaySelected: (date, events) { - setState(() { - _selectedEvents = events; - }); - }, - builders: CalendarBuilders( - selectedDayBuilder: (context, date, events) => Container( - margin: const EdgeInsets.all(4.0), - alignment: Alignment.center, - decoration: BoxDecoration( - color: Theme.of(context).primaryColor, - borderRadius: BorderRadius.circular(10.0)), - child: Text( - date.day.toString(), - style: GoogleFonts.inter(color: Colors.white), - )), - todayDayBuilder: (context, date, events) => Container( - margin: const EdgeInsets.all(4.0), - alignment: Alignment.center, - decoration: BoxDecoration( - color: Colors.orange, - borderRadius: BorderRadius.circular(10.0)), - child: Text( - date.day.toString(), - style: GoogleFonts.inter(color: Colors.white), - )), - ), - calendarController: _controller, - ), - ..._selectedEvents.map((event) => Container( - height: 35, - width: 250, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(10)), - color: Colors.white, + startingDayOfWeek: StartingDayOfWeek.monday, + onDaySelected: (date, events) { + setState(() { + _selectedEvents = events; + _selectedDate = date; + }); + }, + builders: CalendarBuilders( + selectedDayBuilder: (context, date, events) => Container( + margin: const EdgeInsets.all(4.0), + alignment: Alignment.center, + decoration: BoxDecoration( + color: Theme.of(context).primaryColor, + borderRadius: BorderRadius.circular(10.0)), + child: Text( + date.day.toString(), + style: GoogleFonts.inter(color: Colors.white), + )), + todayDayBuilder: (context, date, events) => Container( + margin: const EdgeInsets.all(4.0), + alignment: Alignment.center, + decoration: BoxDecoration( + color: Colors.orange, + borderRadius: BorderRadius.circular(10.0)), + child: Text( + date.day.toString(), + style: GoogleFonts.inter(color: Colors.white), + )), + ), + calendarController: _controller, ), - margin: EdgeInsets.symmetric(horizontal: 20, vertical: 0), - child:ListTile( - title: Text("${event.Lounge}"+" Room booked for slot " + "${event.slot}", style: TextStyle(color: Colors.deepOrange),), - onTap: () { + ..._selectedEvents.map( + (event) => Container( + height: MediaQuery.of(context).size.height * 0.08, + width: MediaQuery.of(context).size.width * 0.8, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(10)), + color: Colors.white, + ), + margin: EdgeInsets.symmetric(horizontal: 20, vertical: 0), + child: ListTile( + title: Text( + /*"${event.Lounge}"+" Room booked for slot " + "${event.slot}"*/ + event.slot == 1 + ? "${event.Lounge} Room booked for Lunch Slot" + : "${event.Lounge} Room booked for Dinner Slot", + style: TextStyle(color: Colors.deepOrange), + ), + /*onTap: () { Navigator.push( context, MaterialPageRoute( builder: (_) => EventDetailsPage( event: event, ))); - }, + },*/ + ), ), - ), - ), - ], - ), - ); - } - ), + ), + ], + ), + ); + }), floatingActionButton: FloatingActionButton( backgroundColor: Colors.deepOrange, - child: Text('Book', - style: GoogleFonts.inter( - color: Colors.white - ),), - onPressed: () => Navigator.pushNamed(context, '/add_event'), + child: Text( + 'Book', + style: GoogleFonts.inter(color: Colors.white), + ), + onPressed: () => { + // print(_selectedDate) + Navigator.pushNamed(context, '/add_event', arguments: _selectedDate) + }, ), ); } -} \ No newline at end of file +} diff --git a/lib/pages/confirmOrder.dart b/lib/pages/confirmOrder.dart index 4a60aad..d4b86ae 100644 --- a/lib/pages/confirmOrder.dart +++ b/lib/pages/confirmOrder.dart @@ -6,41 +6,42 @@ import 'package:rcapp/services/database.dart'; import 'package:flutter/material.dart'; StoreData storeData = StoreData(); - int total = 0; - int totalquantity = 1; - List itemList = List(); - List quantityList = List(); - - void updateTotal() { - Map foodDetail = storeData.retrieveFoodDetails(); - Map foodqtyDetail = storeData.retrieveQtyDetails(); - - - foodDetail.forEach((k, v) => total = total + v * foodqtyDetail[k]); - foodDetail.forEach((k, v) => totalquantity = totalquantity + v); - foodDetail.forEach((key, value) => itemList.add(key)); - foodqtyDetail.forEach((key, value) => quantityList.add(value)); - } - - void confirmOrder() async { - var user = await FirebaseAuth.instance.currentUser(); - var _dat = await Firestore.instance - .collection('userInfo') - .document(user.uid) - .get(); - - var userName = _dat.data["name"]; - var number = _dat.data["number"]; - var address = _dat.data["address"]; - - DatabaseService().confirmOrderofUser(user.uid, userName, number, address, - itemList, quantityList, total, false); - - storeData.resetStore(); - updateTotal(); - // Navigator.pushReplacementNamed(context, '/navigationbar'); - } - +int total = 0; +int totalquantity = 1; +List itemList = List(); +List priceList = List(); +List quantityList = List(); + +void updateTotal() { + Map foodDetail = storeData.retrieveFoodDetails(); + Map foodqtyDetail = storeData.retrieveQtyDetails(); + + foodDetail.forEach((k, v) => total = total + v * foodqtyDetail[k]); + foodDetail.forEach((k, v) => totalquantity = totalquantity + v); + foodDetail.forEach((key, value) { + itemList.add(key); + priceList.add(value); + }); + foodqtyDetail.forEach((key, value) => quantityList.add(value)); +} + +void confirmOrder() async { + var user = await FirebaseAuth.instance.currentUser(); + var _dat = + await Firestore.instance.collection('userInfo').document(user.uid).get(); + + var userName = _dat.data["name"]; + var number = _dat.data["number"]; + var address = _dat.data["address"]; + var mobileNumber = _dat.data["mobileNumber"]; + + DatabaseService().confirmOrderofUser(user.uid, userName, number, address, + itemList, priceList, quantityList, total, false, mobileNumber); + + storeData.resetStore(); + updateTotal(); + // Navigator.pushReplacementNamed(context, '/navigationbar'); +} // import 'package:cloud_firestore/cloud_firestore.dart'; // import 'package:firebase_auth/firebase_auth.dart'; diff --git a/lib/pages/customAlert.dart b/lib/pages/customAlert.dart index 3b2cc08..e710b3b 100644 --- a/lib/pages/customAlert.dart +++ b/lib/pages/customAlert.dart @@ -4,8 +4,8 @@ import 'package:google_fonts/google_fonts.dart'; class CustomAlert extends StatefulWidget { final title; final description; - final url; - CustomAlert({this.title, this.description, this.url}); + // final url; + CustomAlert({this.title, this.description}); @override _CustomAlertState createState() => _CustomAlertState(); } @@ -56,9 +56,13 @@ class _CustomAlertState extends State { alignment: Alignment.bottomRight, child: InkWell( onTap: () { - Navigator.pop(context); + Navigator.popUntil( + context, ModalRoute.withName('/wrapper')); + // Navigator.pop(context); }, - child: Text('OK')), + child: Container( + padding: EdgeInsets.all(10), + child: Text('OK'))), ) ], ), @@ -70,7 +74,7 @@ class _CustomAlertState extends State { child: CircleAvatar( backgroundColor: Colors.orangeAccent, radius: 50, - backgroundImage: AssetImage(widget.url), + backgroundImage: AssetImage('assets/tick.gif'), ), ) ], diff --git a/lib/pages/customConfirmAlerts.dart b/lib/pages/customConfirmAlerts.dart new file mode 100644 index 0000000..e710b3b --- /dev/null +++ b/lib/pages/customConfirmAlerts.dart @@ -0,0 +1,83 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class CustomAlert extends StatefulWidget { + final title; + final description; + // final url; + CustomAlert({this.title, this.description}); + @override + _CustomAlertState createState() => _CustomAlertState(); +} + +class _CustomAlertState extends State { + @override + Widget build(BuildContext context) { + return Dialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + elevation: 0, + backgroundColor: Colors.transparent, + child: dialogContext(context), + ); + } + + dialogContext(BuildContext context) { + return Stack( + children: [ + Container( + padding: EdgeInsets.fromLTRB(16, 100, 16, 16), + margin: EdgeInsets.only(top: 16), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black26, + blurRadius: 10, + offset: Offset(0, 10)) + ]), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + widget.title, + style: GoogleFonts.inter(), + ), + SizedBox(height: 24), + Text( + widget.description, + style: GoogleFonts.inter(), + ), + SizedBox( + height: 24, + ), + Align( + alignment: Alignment.bottomRight, + child: InkWell( + onTap: () { + Navigator.popUntil( + context, ModalRoute.withName('/wrapper')); + // Navigator.pop(context); + }, + child: Container( + padding: EdgeInsets.all(10), + child: Text('OK'))), + ) + ], + ), + ), + Positioned( + top: 0, + left: 16, + right: 16, + child: CircleAvatar( + backgroundColor: Colors.orangeAccent, + radius: 50, + backgroundImage: AssetImage('assets/tick.gif'), + ), + ) + ], + ); + } +} diff --git a/lib/pages/mainhall.dart b/lib/pages/mainhall.dart index 201a5ca..b1995f9 100644 --- a/lib/pages/mainhall.dart +++ b/lib/pages/mainhall.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; - class MainHall extends StatefulWidget { @override _MainHallState createState() => _MainHallState(); @@ -14,52 +13,58 @@ class _MainHallState extends State { appBar: AppBar( elevation: 10.0, backgroundColor: Colors.deepOrange, - title: Text('Main Recption Hall'), + title: Text('Lounges'), ), - body: new Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Container( - height: 200.0, - width: double.infinity, - padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.blue, - image: DecorationImage( - image: new AssetImage("assets/15.jpg"), - fit: BoxFit.fill)), + body: Container( + height: MediaQuery.of(context).size.height * 1, + child: new Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Container( + height: 200.0, + width: double.infinity, + padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30), + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.blue, + image: DecorationImage( + image: new AssetImage("assets/15.jpg"), + fit: BoxFit.fill)), + ), ), - ), - Text("The Main Banquet Hall", - style: GoogleFonts.inter( - color: Colors.redAccent, - fontSize: 30 - ),), - Container( - padding: EdgeInsets.all(10), - child:Text("Present in front of the entrance, the main Banquet Hall is for major occasion s and for big group gatherings, such as musical events, social gatherings, large office parties, marriage receptions, etc \n \n" - "Capacity - 250 people", + Text( + "The Main Banquet Hall", style: GoogleFonts.inter( - color: Colors.black, - fontSize: 20 - ),), - ), - SizedBox( - width: double.infinity, - height: 60, - child: ButtonTheme( - child: RaisedButton( - color: Colors.deepOrange, - onPressed: () { - Navigator.pushNamed(context, "/bookingcalendar"); - }, - child: Text('Book', - style: GoogleFonts.inter(color: Colors.white, fontSize: 18))), - )), - ], + color: Colors.redAccent, + fontSize: MediaQuery.of(context).size.width * 0.075), + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 15, vertical: 0), + child: Text( + "Present in front of the entrance, the main Banquet Hall is for major occasion s and for big group gatherings, such as musical events, social gatherings, large office parties, marriage receptions, etc \n \n" + "Capacity - 250 people", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: MediaQuery.of(context).size.width * 0.05), + ), + ), + SizedBox( + width: double.infinity, + height: 60, + child: ButtonTheme( + child: RaisedButton( + color: Colors.deepOrange, + onPressed: () { + Navigator.pushNamed(context, "/bookingcalendar"); + }, + child: Text('Book', + style: GoogleFonts.inter( + color: Colors.white, fontSize: 18))), + )), + ], + ), ), ); } diff --git a/lib/pages/previousBooking.dart b/lib/pages/previousBooking.dart index 16dd044..2924afe 100644 --- a/lib/pages/previousBooking.dart +++ b/lib/pages/previousBooking.dart @@ -15,6 +15,7 @@ class _PreviousBookingState extends State { List bookings = []; String name = ''; + String mobileNumber = ''; String number = ''; String lounge = ''; int slot; @@ -34,6 +35,7 @@ class _PreviousBookingState extends State { bookings.add(res.data); name = res.data["name"]; number = res.data["number"]; + mobileNumber = res.data["mobileNumber"]; lounge = res.data["lounge"]; slot = res.data["slot"]; }); @@ -96,7 +98,7 @@ class _PreviousBookingState extends State { SizedBox(height: 10.0), Container( padding: EdgeInsets.all(10), - height: 220.0, + height: MediaQuery.of(context).size.height * 0.38, width: 370.0, decoration: BoxDecoration( color: Colors.white, @@ -149,6 +151,21 @@ class _PreviousBookingState extends State { ], ), SizedBox(height: 10), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + "Mobile No. : " + + "${bookings[index]["mobileNumber"]}", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400), + ), + ], + ), + SizedBox(height: 10), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -164,6 +181,21 @@ class _PreviousBookingState extends State { ], ), SizedBox(height: 10), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + "Number of people : " + + "${bookings[index]["numberOfPeople"]}", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400), + ), + ], + ), + SizedBox(height: 10), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -175,6 +207,41 @@ class _PreviousBookingState extends State { fontSize: 18, fontWeight: FontWeight.w400), ), + if (!bookings[index]["isConfirmed"]) ...[ + Row(children: [ + Text('Status: ', + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400)), + if (bookings[index]["isRejected"]) ...[ + Text('Rejected', + style: GoogleFonts.inter( + color: Colors.red[800], + fontSize: 18, + fontWeight: FontWeight.w400)) + ] else ...[ + Text('Not Confirmed', + style: GoogleFonts.inter( + color: Colors.orange, + fontSize: 18, + fontWeight: FontWeight.w400)) + ] + ]) + ] else ...[ + Row(children: [ + Text('Status: ', + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400)), + Text('Confirmed', + style: GoogleFonts.inter( + color: Colors.green, + fontSize: 18, + fontWeight: FontWeight.w400)) + ]) + ] ], ), ]), diff --git a/lib/pages/previousOrder.dart b/lib/pages/previousOrder.dart index b3eed43..502c2df 100644 --- a/lib/pages/previousOrder.dart +++ b/lib/pages/previousOrder.dart @@ -97,7 +97,7 @@ class _PreviousOrderState extends State { SizedBox(height: 10.0), Container( padding: EdgeInsets.all(10), - height: 140.0, + height: MediaQuery.of(context).size.height * 0.3, width: 370.0, decoration: BoxDecoration( color: Colors.white, @@ -133,9 +133,59 @@ class _PreviousOrderState extends State { ), ], ), - SizedBox(height: 8), ]), - SizedBox(height: 15), + SizedBox(height: 10), + Row( + children: [ + Text( + "Mobile No: ${orders[index]["mobileNumber"]}", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400), + ) + ], + ), + SizedBox( + height: 10, + ), + Row(children: [ + Text( + "Status : ", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400), + ), + if (!orders[index]["isConfirmed"] && !orders[index]["isRejected"]) ...[ + Text( + "Not Confirmed", + style: GoogleFonts.inter( + color: Colors.orange, + fontSize: 18, + fontWeight: FontWeight.w400), + ), + ] else if(orders[index]["isRejected"])...[ + Text( + "Rejected", + style: GoogleFonts.inter( + color: Colors.red[800], + fontSize: 18, + fontWeight: FontWeight.w400), + ), + ] else ...[ + Text( + "Confirmed", + style: GoogleFonts.inter( + color: Colors.green, + fontSize: 18, + fontWeight: FontWeight.w400), + ), + ] + ]), + SizedBox( + height: 15, + ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -161,8 +211,11 @@ class _PreviousOrderState extends State { address: orders[index] ["address"], item: item[index], - quantity: - quantity[index]))); + quantity: quantity[index], + mobileNumber: orders[index] + ["mobileNumber"], + price: orders[index] + ["price"]))); }, child: Container( child: Text('Know More', @@ -190,7 +243,8 @@ class _PreviousOrderState extends State { class OrderData extends StatefulWidget { List item; List quantity; - OrderData({this.item, this.quantity}); + List price; + OrderData({this.item, this.quantity, this.price}); @override _OrderDataState createState() => _OrderDataState(); } @@ -208,11 +262,27 @@ class _OrderDataState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - child: Row(children: [ - Text('${index + 1}) '), - Text('${widget.item[index]} '), - ])), - Text('${widget.quantity[index]}'), + // decoration: BoxDecoration(color: Colors.deepOrange), + width: MediaQuery.of(context).size.width * 0.34, + child: Text( + '${widget.item[index]}', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + )), + Container( + // decoration: BoxDecoration(color: Colors.deepOrange), + width: MediaQuery.of(context).size.width * 0.2, + child: Text( + '${widget.quantity[index]}', + textAlign: TextAlign.center, + )), + Container( + // decoration: BoxDecoration(color: Colors.deepOrange), + width: MediaQuery.of(context).size.width * 0.2, + child: Text( + '${widget.price[index]}', + textAlign: TextAlign.center, + )), ], ); }), @@ -229,6 +299,8 @@ class PreviousOrderDetails extends StatefulWidget { final String date; final List item; final List quantity; + final String mobileNumber; + final List price; PreviousOrderDetails( {this.orderNo, this.total, @@ -237,7 +309,9 @@ class PreviousOrderDetails extends StatefulWidget { this.number, this.date, this.item, - this.quantity}); + this.quantity, + this.mobileNumber, + this.price}); @override _PreviousOrderDetailsState createState() => _PreviousOrderDetailsState(); } @@ -265,8 +339,8 @@ class _PreviousOrderDetailsState extends State { SizedBox(height: 20.0), Container( padding: EdgeInsets.all(10), - height: 500.0, - width: 370.0, + height: MediaQuery.of(context).size.height * 0.7, + width: MediaQuery.of(context).size.width * 0.9, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(15.0)), @@ -305,14 +379,14 @@ class _PreviousOrderDetailsState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - "Personal No. :", + "Personal No. : ${widget.number}", style: GoogleFonts.inter( color: Colors.grey, fontSize: 18, fontWeight: FontWeight.w500), ), SizedBox(height: 5), - Padding( + /*Padding( padding: EdgeInsets.fromLTRB(10, 0, 0, 0), child: Text( "${widget.number}", @@ -321,7 +395,7 @@ class _PreviousOrderDetailsState extends State { fontSize: 18, fontWeight: FontWeight.w400), ), - ), + ),*/ ], ), SizedBox(height: 8), @@ -340,7 +414,9 @@ class _PreviousOrderDetailsState extends State { fontWeight: FontWeight.w500), ), Container( - width: 300, + width: + MediaQuery.of(context).size.width * + 0.4, child: Padding( padding: EdgeInsets.fromLTRB(10, 0, 0, 0), @@ -356,10 +432,36 @@ class _PreviousOrderDetailsState extends State { ]), ], ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + SizedBox( + height: 10.0, + ), + Text( + "Mobile No. : ${widget.mobileNumber}", + style: GoogleFonts.inter( + color: Colors.grey, + fontSize: 18, + fontWeight: FontWeight.w500), + ), + SizedBox(height: 5), + /*Padding( + padding: EdgeInsets.fromLTRB(10, 0, 0, 0), + child: Text( + "${widget.mobileNumber}", + style: GoogleFonts.inter( + color: Colors.black, + fontSize: 18, + fontWeight: FontWeight.w400), + ), + ),*/ + ], + ), ], ), SizedBox(height: 20), - Container( + /*Container( alignment: Alignment.centerLeft, child: Text( 'Menu :', @@ -367,28 +469,44 @@ class _PreviousOrderDetailsState extends State { color: Colors.grey, fontSize: 18, fontWeight: FontWeight.w500), - )), + )),*/ Container( padding: EdgeInsets.fromLTRB(10, 10, 0, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('Item Name', - style: GoogleFonts.inter( - fontSize: 20, - fontWeight: FontWeight.w400, - decoration: TextDecoration.underline)), - Text('Quantity', - style: GoogleFonts.inter( - fontSize: 20, - fontWeight: FontWeight.w400, - decoration: TextDecoration.underline)) + Container( + width: MediaQuery.of(context).size.width * 0.4, + child: Text('Item', + style: GoogleFonts.inter( + fontSize: 20, + fontWeight: FontWeight.w400, + decoration: TextDecoration.underline)), + ), + Container( + width: MediaQuery.of(context).size.width * 0.2, + child: Text('Qty', + style: GoogleFonts.inter( + fontSize: 20, + fontWeight: FontWeight.w400, + decoration: TextDecoration.underline)), + ), + Container( + width: MediaQuery.of(context).size.width * 0.2, + child: Text('Rate', + style: GoogleFonts.inter( + fontSize: 20, + fontWeight: FontWeight.w400, + decoration: TextDecoration.underline)), + ), ], ), ), Flexible( child: OrderData( - item: widget.item, quantity: widget.quantity), + item: widget.item, + quantity: widget.quantity, + price: widget.price), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -407,12 +525,12 @@ class _PreviousOrderDetailsState extends State { PreviousOrderDetails())); }, child: Container( - child: Text('Know More', + /*child: Text('Know More', style: GoogleFonts.inter( color: Colors.deepOrange, decoration: - TextDecoration.underline)), - ), + TextDecoration.underline)),*/ + ), ) ]), ], diff --git a/lib/pages/storeData.dart b/lib/pages/storeData.dart index 42fcb76..beeb76b 100644 --- a/lib/pages/storeData.dart +++ b/lib/pages/storeData.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -class StoreData { +class StoreData with ChangeNotifier { StoreData._privateConstructor(); static final StoreData _instance = StoreData._privateConstructor(); @@ -11,31 +11,34 @@ class StoreData { Map _foodNamePrice = Map(); Map _foodNameQuantity = Map(); - getInstance() {} - void StoreFoodDetails(String foodName, int foodPrice, int value) { _foodNamePrice[foodName] = foodPrice; _foodNameQuantity[foodName] = value; + notifyListeners(); } void removeFoodDetails(String foodName) { _foodNamePrice.remove(foodName); _foodNameQuantity.remove(foodName); + notifyListeners(); } void increaseQty(String foodName) { ++_foodNameQuantity[foodName]; + notifyListeners(); } void decreaseQty(String foodName) { if (_foodNameQuantity[foodName] != 0) { --_foodNameQuantity[foodName]; } + notifyListeners(); } void resetStore() { _foodNamePrice.clear(); _foodNameQuantity.clear(); + notifyListeners(); } Map retrieveFoodDetails() { @@ -45,4 +48,4 @@ class StoreData { Map retrieveQtyDetails() { return _foodNameQuantity; } -} \ No newline at end of file +} diff --git a/lib/pages/uploadPdfImage.dart b/lib/pages/uploadPdfImage.dart new file mode 100644 index 0000000..aaa4e82 --- /dev/null +++ b/lib/pages/uploadPdfImage.dart @@ -0,0 +1,298 @@ +import 'dart:io'; +import 'package:firebase_storage/firebase_storage.dart'; +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:path/path.dart'; +import 'package:rcapp/services/database.dart'; + +class UploadPdfImage extends StatefulWidget { + @override + _UploadPdfImageState createState() => _UploadPdfImageState(); +} + +class _UploadPdfImageState extends State { + @override + Widget build(BuildContext context) { + return ImageCapture(); + } +} + +class ImageCapture extends StatefulWidget { + @override + _ImageCaptureState createState() => _ImageCaptureState(); +} + +class _ImageCaptureState extends State { + File _pickedImage; + + bool showOptions = false; + + String title = ''; + String subtitle = ''; + + void _pickImage(ImageSource source) async { + final pickedImageFile = await ImagePicker.pickImage( + source: source, imageQuality: 100, maxWidth: 350, maxHeight: 280); + setState(() { + _pickedImage = pickedImageFile; + }); + } + + void _clear() { + setState(() => _pickedImage = null); + } + + void toggle() { + setState(() { + showOptions = !showOptions; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.deepOrange, + title: Text('Upload Image'), + ), + bottomNavigationBar: BottomAppBar( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + if (showOptions == true) ...[ + Container( + height: 90, + child: Column(children: [ + IconButton( + iconSize: 40, + color: Colors.deepOrange, + icon: Icon(Icons.photo_library), + onPressed: () => _pickImage(ImageSource.gallery), + ), + Text( + 'File Explorer', + style: GoogleFonts.inter( + color: Colors.black, fontWeight: FontWeight.bold), + ) + ]), + ), + Container( + height: 90, + child: Column(children: [ + IconButton( + iconSize: 40, + color: Colors.deepOrange, + icon: Icon(Icons.camera), + onPressed: () => _pickImage(ImageSource.camera), + ), + Text('Camera', + style: GoogleFonts.inter( + color: Colors.black, fontWeight: FontWeight.bold)) + ]), + ) + ] + ], + ), + ), + body: SingleChildScrollView( + child: Container( + padding: EdgeInsets.fromLTRB(40, 10, 40, 0), + child: Column(children: [ + if (_pickedImage == null) ...[ + Center( + child: Container( + width: 320, + height: 250, + decoration: BoxDecoration( + border: + Border.all(color: Colors.deepOrange, width: 2.0), + borderRadius: BorderRadius.circular(10)), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + onPressed: () { + toggle(); + }, + iconSize: 40, + icon: Icon(Icons.image), + ), + SizedBox(height: 5), + Text('ADD AN IMAGE', + style: GoogleFonts.inter( + fontWeight: FontWeight.w500, fontSize: 20)) + ], + ), + ), + ), + SizedBox(height: 10), + TextFormField( + decoration: InputDecoration( + hintText: 'Title', + fillColor: Colors.white, + filled: true, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 1.0), + borderRadius: BorderRadius.circular(10)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 3.0), + borderRadius: BorderRadius.circular(10))), + validator: (val) => val.isEmpty ? 'Enter Title' : null, + onChanged: (val) { + setState(() => title = val); + }), + SizedBox(height: 10), + TextFormField( + decoration: InputDecoration( + hintText: 'Sub-Title', + fillColor: Colors.white, + filled: true, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 1.0), + borderRadius: BorderRadius.circular(10)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 3.0), + borderRadius: BorderRadius.circular(10))), + validator: (val) => val.isEmpty ? 'Enter Subtitle' : null, + onChanged: (val) { + setState(() => subtitle = val); + }) + ], + if (_pickedImage != null) ...[ + Image.file(_pickedImage), + SizedBox(height: 10), + TextFormField( + decoration: InputDecoration( + hintText: 'Title', + fillColor: Colors.white, + filled: true, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 1.0), + borderRadius: BorderRadius.circular(10)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 3.0), + borderRadius: BorderRadius.circular(10))), + validator: (val) => val.isEmpty ? 'Enter Title' : null, + onChanged: (val) { + setState(() => title = val); + }), + SizedBox(height: 10), + TextFormField( + decoration: InputDecoration( + hintText: 'Sub-Title', + fillColor: Colors.white, + filled: true, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 1.0), + borderRadius: BorderRadius.circular(10)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.deepOrange, width: 3.0), + borderRadius: BorderRadius.circular(10))), + validator: (val) => val.isEmpty ? 'Enter Subtitle' : null, + onChanged: (val) { + setState(() => subtitle = val); + }), + SizedBox(height: 10), + Uploader(file: _pickedImage, title: title, subtitle: subtitle), + SizedBox(height: 20), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + FlatButton( + color: Colors.deepOrange, + child: Icon(Icons.refresh), + onPressed: _clear, + shape: new RoundedRectangleBorder( + borderRadius: new BorderRadius.circular(10.0)), + ), + ]), + ] + ]), + ), + )); + } +} + +class Uploader extends StatefulWidget { + final title; + final subtitle; + final file; + Uploader({this.file, this.title, this.subtitle}); + @override + _UploaderState createState() => _UploaderState(); +} + +class _UploaderState extends State { + final FirebaseStorage _storage = + FirebaseStorage(storageBucket: 'gs://rcapp-de25c.appspot.com'); + // StorageUploadTask _uploadTask; + + var _uploadTask; + + final DatabaseService _pdfUploader = DatabaseService(); + + Future _startUpload(String title, String subtitle) async { + try { + final ref = FirebaseStorage.instance + .ref() + .child('pdf_store') + .child('${DateTime.now()}.jpg'); + + setState(() { + _uploadTask = ref.putFile(widget.file); + }); + + await ref.putFile(widget.file).onComplete; + + final url = await ref.getDownloadURL(); + + _pdfUploader.updatePdf(title, subtitle, url); + print(url); + } catch (e) { + print(e.toString()); + } + } + + @override + Widget build(BuildContext context) { + if (_uploadTask != null) { + return StreamBuilder( + stream: _uploadTask.events, + builder: (context, snapshot) { + var event = snapshot?.data?.snapshot; + double progressPercent = + event != null ? event.bytesTransferred / event.totalByteCount : 0; + + return Column(children: [ + if (_uploadTask.isComplete) Text("Uploaded To Database"), + LinearProgressIndicator(value: progressPercent), + Text('${(progressPercent * 100).toStringAsFixed(2)} %') + ]); + }, + ); + } else { + return FlatButton.icon( + onPressed: () { + _startUpload(widget.title, widget.subtitle); + }, + icon: Icon(Icons.cloud_upload), + label: Text( + 'Save Data To List', + style: GoogleFonts.inter(fontSize: 17), + ), + shape: new RoundedRectangleBorder( + borderRadius: new BorderRadius.circular(10.0)), + color: Colors.deepOrange, + ); + } + } +} diff --git a/lib/pages/welcome.dart b/lib/pages/welcome.dart index c5cb5e6..e0304d4 100644 --- a/lib/pages/welcome.dart +++ b/lib/pages/welcome.dart @@ -10,26 +10,11 @@ class welcome extends StatefulWidget { } class _welcomeState extends State { - Future configure() async { - final fbm = FirebaseMessaging(); - fbm.configure(onMessage: (msg) { - print(msg); - return; - }, onLaunch: (msg) { - print(msg); - return; - }, onResume: (msg) { - print(msg); - return; - }); - - } @override void initState() { // TODO: implement initState super.initState(); - configure(); } @override diff --git a/lib/services/auth.dart b/lib/services/auth.dart index e4dd977..4cffb0d 100644 --- a/lib/services/auth.dart +++ b/lib/services/auth.dart @@ -46,6 +46,25 @@ class AuthService { .get() .then((value) => value.data["isAdmin"]); + final FirebaseMessaging _messaging = FirebaseMessaging(); + var token = await _messaging.getToken(); + + await Firestore.instance + .collection('userInfo') + .document(userkaabba) + .updateData({'token': token}); + var _tokendata = await Firestore.instance + .collection('confirmedOrders') + .where('id', isEqualTo: userkaabba) + .getDocuments(); + + _tokendata.documents.forEach((element) { + Firestore.instance + .collection('confirmedOrders') + .document('${element.data["_date"]}') + .updateData({'token': token}); + }); + isAdminglobal = dat; return _userFromFirebaseUser(user); diff --git a/lib/services/database.dart b/lib/services/database.dart index 9b64c22..ca2cd0c 100644 --- a/lib/services/database.dart +++ b/lib/services/database.dart @@ -80,8 +80,10 @@ class DatabaseService { }); } - Future updateAddressData(String id, String address) async { - return await userInfo.document(id).updateData({'address': address}); + Future updateAddressData(String id, String address, String number) async { + return await userInfo + .document(id) + .updateData({'address': address, 'mobileNumber': number}); } Future updateTodayMenu(String food, int price, String url) async { @@ -95,15 +97,17 @@ class DatabaseService { } Future updatePdf(String title, String subtitle, String url) async { + var _date = DateTime.now().toUtc().millisecondsSinceEpoch; return await notice_pdfData - .document() - .setData({'title': title, 'subtitle': subtitle, 'downloadLink': url}); + .document('$_date') + .setData({'_date': _date,'title': title, 'subtitle': subtitle, 'downloadLink': url}); } - Future bookDetails(String id, String name, String number, int numberOfPeople, - String lounge, int slot, DateTime date) async { + Future bookDetails(String id, String name, String number, String mobileNumber, + int numberOfPeople, String lounge, int slot, DateTime date) async { var _date = DateTime.now().toUtc().millisecondsSinceEpoch; - var forToken = await Firestore.instance.collection('userInfo').document(id).get(); + var forToken = + await Firestore.instance.collection('userInfo').document(id).get(); var _token = forToken.data["token"]; return await bookingDetails.document('$_date').setData({ '_date': _date, @@ -111,20 +115,32 @@ class DatabaseService { 'name': name, 'isConfirmed': false, 'number': number, + 'mobileNumber': mobileNumber, 'numberOfPeople': numberOfPeople, 'lounge': lounge, 'slot': slot, 'date': '${date.day}' + '/' + '${date.month}' + '/' + '${date.year}', 'bookingDate': date, - 'token': _token + 'token': _token, + 'isRejected': false }); } - Future confirmOrderofUser(String id, String name, String number, - String address, List item, List qty, int total, bool isConfirmed) async { + Future confirmOrderofUser( + String id, + String name, + String number, + String address, + List item, + List price, + List qty, + int total, + bool isConfirmed, + String mobileNumber) async { // var docId = '$id' + '$total'; var _date = DateTime.now().toUtc().millisecondsSinceEpoch; - var forToken = await Firestore.instance.collection('userInfo').document(id).get(); + var forToken = + await Firestore.instance.collection('userInfo').document(id).get(); var _token = forToken.data["token"]; return await confirmedOrders.document('$_date').setData({ 'id': id, @@ -132,6 +148,7 @@ class DatabaseService { 'number': number, 'address': address, 'item': item, + 'price': price, 'quantity': qty, 'total': total, 'isConfirmed': isConfirmed, @@ -141,7 +158,9 @@ class DatabaseService { '${DateTime.now().month}' + '/' + '${DateTime.now().year}', - 'token': _token + 'token': _token, + 'mobileNumber': mobileNumber, + 'isRejected': false }); } @@ -157,7 +176,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return Menu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -166,7 +185,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return MainCourseMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -175,7 +194,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return ChineseMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -184,7 +203,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return StarterMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -193,7 +212,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return BiryaniMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -211,7 +230,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return BreadMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -220,7 +239,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return TandooriMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -230,7 +249,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return FriedRiceAndNoodlesMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -239,7 +258,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return RollMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -248,7 +267,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return SandwichMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -257,7 +276,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return PizzaMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -266,7 +285,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return SnacksMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -275,7 +294,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return BurgerMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -284,7 +303,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return PastaMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -293,7 +312,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return SoupMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -303,7 +322,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return AccompanimentMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } @@ -312,7 +331,7 @@ class DatabaseService { return snapshot.documents.map((doc) { return BreakfastMenu( item: doc.data["item"] ?? '', - price: doc.data["price"] ?? 0, + price: doc.data["club_rate"] ?? 0, searchIndex: doc.data["search_index"] ?? ''); }).toList(); } diff --git a/pubspec.lock b/pubspec.lock index 0a55f72..389fab0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -29,6 +29,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.4.2" + badges: + dependency: "direct main" + description: + name: badges + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.3" boolean_selector: dependency: transitive description: @@ -479,7 +486,7 @@ packages: source: hosted version: "3.0.13" provider: - dependency: "direct dev" + dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" diff --git a/pubspec.yaml b/pubspec.yaml index 3ce1235..1b0c69d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -48,6 +48,10 @@ dependencies: google_fonts: ^1.1.0 flutter_launcher_icons: ^0.8.0 fluttertoast: ^7.1.1 + provider: ^3.1.0 + badges: ^1.1.3 + marquee: ^1.6.1 + flutter_icons: