| After Width: | Height: | Size: 913 B | 
| After Width: | Height: | Size: 6.4 KiB | 
| After Width: | Height: | Size: 6.3 KiB | 
| Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 6.5 KiB | 
| After Width: | Height: | Size: 4.8 KiB | 
| After Width: | Height: | Size: 698 B | 
| After Width: | Height: | Size: 958 B | 
| Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 7.6 KiB | 
| After Width: | Height: | Size: 1.0 KiB | 
| After Width: | Height: | Size: 7.5 KiB | 
| Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 5.1 KiB | 
| Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 7.1 KiB | 
| After Width: | Height: | Size: 609 B | 
| Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 8.1 KiB | 
| Before Width: | Height: | Size: 344 KiB After Width: | Height: | Size: 417 KiB | 
| After Width: | Height: | Size: 775 KiB | 
| After Width: | Height: | Size: 1.4 MiB | 
| After Width: | Height: | Size: 1.6 KiB | 
| After Width: | Height: | Size: 1.2 KiB | 
| After Width: | Height: | Size: 1.5 KiB | 
| After Width: | Height: | Size: 237 KiB | 
| Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 6.8 KiB | 
| After Width: | Height: | Size: 14 KiB | 
| After Width: | Height: | Size: 1.3 KiB | 
| Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 4.1 KiB | 
| Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 10 KiB | 
| Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 14 KiB | 
| After Width: | Height: | Size: 738 B | 
| After Width: | Height: | Size: 1.1 KiB | 
| After Width: | Height: | Size: 1.5 KiB | 
| @ -0,0 +1,374 @@ | ||||
| import 'dart:convert'; | ||||
| import 'dart:io'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:geolocator/geolocator.dart'; | ||||
| import 'package:healthcare_pharmacy/models/medicineview_model.dart'; | ||||
| import 'package:healthcare_pharmacy/settings.dart'; | ||||
| import 'package:flutter/services.dart'; | ||||
| import 'package:url_launcher/url_launcher.dart'; | ||||
| import 'package:cloudinary_public/cloudinary_public.dart'; | ||||
| 
 | ||||
| class WaterSuppliers extends StatefulWidget { | ||||
|   const WaterSuppliers({Key? key}) : super(key: key); | ||||
| 
 | ||||
|   @override | ||||
|   State<WaterSuppliers> createState() => _WaterSuppliersState(); | ||||
| } | ||||
| 
 | ||||
| class _WaterSuppliersState extends State<WaterSuppliers> with TickerProviderStateMixin { | ||||
|   bool isMedecineDataLoading=false; | ||||
|   bool isSereverIssue = false; | ||||
|   List<GetMedecineDetailsModel> medecineList = []; | ||||
|   List<GetMedecineDetailsModel> FilteredList = []; | ||||
| 
 | ||||
|   TextEditingController searchController = TextEditingController(); | ||||
|   String dropdownArea = '2'; | ||||
|   //String dropdownType = 'Tank'; | ||||
| 
 | ||||
|   Future<void> getSuppliersDataByMedecineName(var MedecineName) async { | ||||
|     FilteredList=[]; | ||||
|     isMedecineDataLoading = true; | ||||
| 
 | ||||
| 
 | ||||
|     try { | ||||
|       var medecineResponse = await AppSettings.getAllMedecines(MedecineName); | ||||
| 
 | ||||
|       setState(() { | ||||
|         medecineList = | ||||
|             ((jsonDecode(medecineResponse)['medicine']) as List).map((dynamic model) { | ||||
|               return GetMedecineDetailsModel(distance).fromJson(model); | ||||
|             }).toList(); | ||||
| 
 | ||||
|         FilteredList= medecineList.where( | ||||
|                 (x) => x.name.toLowerCase().contains(MedecineName) | ||||
|         ).toList(); | ||||
| 
 | ||||
|         //FilteredList=suppliersList.where((product) => product.supplier_phone_number.toString()==phnNum).toList(); | ||||
| 
 | ||||
|       }); | ||||
| 
 | ||||
|       //FilteredList=suppliersList.where((product) => product.address.toString().toUpperCase()=='SUMP').toList(); | ||||
| 
 | ||||
| 
 | ||||
|       isMedecineDataLoading = false; | ||||
| 
 | ||||
| 
 | ||||
|     } catch (e) { | ||||
|       setState(() { | ||||
|         isMedecineDataLoading = false; | ||||
|         isSereverIssue = true; | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   Future<void> getAllMedecineData(var distance) async { | ||||
|     FilteredList=[]; | ||||
|     isMedecineDataLoading = true; | ||||
| 
 | ||||
| 
 | ||||
|     try { | ||||
|       var medecineResponse = await AppSettings.getAllMedecines(); | ||||
|       setState(() { | ||||
|         medecineList = | ||||
|             ((jsonDecode(medecineResponse)['medicine']) as List).map((dynamic model) { | ||||
|               return GetMedecineDetailsModel.fromJson(model); | ||||
|             }).toList(); | ||||
|         FilteredList=[]; | ||||
|         medecineList.forEach((element) async{ | ||||
|           var distanceInM; | ||||
|           if(distance=='2'){ | ||||
|             distanceInM=2000; | ||||
|           } | ||||
|           else if(distance=='5'){ | ||||
|             distanceInM=5000; | ||||
|           } | ||||
|           else if(distance=='10'){ | ||||
|             distanceInM=10000; | ||||
|           } | ||||
|           else if(distance=='25'){ | ||||
|             distanceInM=25000; | ||||
|           } | ||||
|           else if(distance=='50'){ | ||||
|             distanceInM=50000; | ||||
|           } | ||||
|           else if(distance=='100'){ | ||||
|             distanceInM=100000; | ||||
|           } | ||||
|          /* double distanceInMeters =  await Geolocator.distanceBetween(element.lat,element.lng,lat,lng); | ||||
|           if(distanceInMeters<=distanceInM){ | ||||
|             FilteredList.add(element); | ||||
|           }*/ | ||||
|         }); | ||||
| 
 | ||||
|         //FilteredList=suppliersList.where((product) => product.address.toString().toUpperCase()=='SUMP').toList(); | ||||
| 
 | ||||
| 
 | ||||
|         isMedecineDataLoading = false; | ||||
|       }); | ||||
| 
 | ||||
| 
 | ||||
|     } catch (e) { | ||||
|       setState(() { | ||||
|         isMedecineDataLoading = false; | ||||
|         isSereverIssue = true; | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   void initState() { | ||||
|     // TODO: implement initState | ||||
|     //getAllSuppliers(); | ||||
|     getAllMedecineData(dropdownArea); | ||||
|     super.initState(); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   Widget _tanker() { | ||||
|     if (FilteredList.length != 0) { | ||||
|       return ListView.builder( | ||||
|           padding: EdgeInsets.all(0), | ||||
|           itemCount: FilteredList.length, | ||||
|           itemBuilder: (BuildContext context, int index) { | ||||
|             return GestureDetector( | ||||
|               onTap: () { | ||||
|                // modelBottomSheet(FilteredList[index]); | ||||
|               }, | ||||
|               child: Card( | ||||
|                 child: Padding( | ||||
|                   padding: EdgeInsets.fromLTRB(0,8,0,0), | ||||
|                   child: Row( | ||||
|                     mainAxisAlignment: MainAxisAlignment.start, | ||||
|                     crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                     children: [ | ||||
|                       Container( | ||||
|                         width: MediaQuery.of(context).size.width * .18, | ||||
|                         height: | ||||
|                         MediaQuery.of(context).size.height * .10, | ||||
|                         decoration: BoxDecoration( | ||||
|                             shape: BoxShape.circle, | ||||
|                             image: DecorationImage( | ||||
|                                 image: FilteredList[index].picture=='' | ||||
|                                     ?AssetImage("images/logo.png") | ||||
|                                     : NetworkImage(FilteredList[index].picture) as ImageProvider, // picked file | ||||
|                                 fit: BoxFit.contain)), | ||||
|                       ), | ||||
|                       /*Container( | ||||
|                         width: MediaQuery.of(context).size.width * .15, | ||||
|                         height: MediaQuery.of(context).size.height * .10, | ||||
|                         child: CircleAvatar( | ||||
|                           child:(FilteredList[index].picture)=='' | ||||
|                               ? Image(image: AssetImage("images/logo.png")) | ||||
|                               :  Image.network('https://storage.googleapis.com/arminta_profile_pictures/photo.jpeg'), | ||||
|                         ) | ||||
|                       ),*/ | ||||
|                       SizedBox(width: 5,), | ||||
|                       Expanded( | ||||
|                         child: Container( | ||||
|                             width: MediaQuery.of(context).size.width * .70, | ||||
|                             child: Column( | ||||
|                               mainAxisAlignment: | ||||
|                               MainAxisAlignment.spaceBetween, | ||||
|                               crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                               children: [ | ||||
|                                 Text( | ||||
|                                     FilteredList[index] | ||||
|                                         .name | ||||
|                                         .toUpperCase(), | ||||
|                                     style: wrapTextStyleBlack()), | ||||
|                                 SizedBox(height: 10,), | ||||
|                                 Text( | ||||
|                                     FilteredList[index] | ||||
|                                         .manufacturers | ||||
|                                         .toUpperCase(), | ||||
|                                     style: wrapTextStyleBlack()), | ||||
|                                 Visibility( | ||||
|                                   visible: FilteredList[index].name!='', | ||||
|                                   child: Text( | ||||
|                                       FilteredList[index] | ||||
|                                           .salt_composition | ||||
|                                           .toUpperCase(), | ||||
|                                       style: wrapTextStyleBlack()),), | ||||
|                                 SizedBox(height: 10,), | ||||
|                                 Text( | ||||
|                                     FilteredList[index] | ||||
|                                         .mrp | ||||
|                                         .toUpperCase(), | ||||
|                                     style: wrapTextStyleBlack()), | ||||
|                                 Visibility( | ||||
|                                   visible: FilteredList[index].primary_use!='', | ||||
|                                   child: SizedBox(height: 10,),), | ||||
|                                 Visibility( | ||||
|                                   visible: FilteredList[index].primary_use!='', | ||||
|                                   child: Text( | ||||
|                                       FilteredList[index] | ||||
|                                           .primary_use | ||||
|                                           .toUpperCase(), | ||||
|                                       style: wrapTextStyleBlack()),), | ||||
|                                 SizedBox(height: 10,), | ||||
| 
 | ||||
|                               ], | ||||
|                             ) | ||||
|                         ), | ||||
|                       ), | ||||
| 
 | ||||
| 
 | ||||
|                     ], | ||||
|                   ), | ||||
|                 ), | ||||
|               ), | ||||
|             ); | ||||
|           }); | ||||
|     } | ||||
|     else { | ||||
|       return Center( | ||||
|           child: Padding( | ||||
|             padding: EdgeInsets.fromLTRB(0, 40, 0, 0), | ||||
|             child: isSereverIssue | ||||
|                 ? Column( | ||||
|               mainAxisAlignment: MainAxisAlignment.center, | ||||
|               children: [ | ||||
|                 Image( | ||||
|                   image: AssetImage('images/serverissue.png'), | ||||
|                   //  height: MediaQuery.of(context).size.height * .10, | ||||
|                 ), | ||||
|                 SizedBox( | ||||
|                   height: 20, | ||||
|                 ), | ||||
|                 Text( | ||||
|                   'There is an issue at server please try after some time',style:serverIssueTextStyle() ,), | ||||
|               ], | ||||
|             ) | ||||
|                 :  userAddress==''?Column( | ||||
|               mainAxisAlignment: MainAxisAlignment.center, | ||||
|               children: [ | ||||
|                 /*Image( | ||||
|                   image: AssetImage('images/resourceblue.pngs'), | ||||
|                   //  height: MediaQuery.of(context).size.height * .10, | ||||
|                 ),*/ | ||||
|                 Icon(Icons.location_on_outlined,color: primaryColor,size: 40,), | ||||
|                 SizedBox( | ||||
|                   height: 20, | ||||
|                 ), | ||||
|                 Text( | ||||
|                   'Please select location to see near by tankers',style:TextStyle( | ||||
|                   color: primaryColor, | ||||
|                   fontWeight: FontWeight.bold, | ||||
|                 ),), | ||||
|               ], | ||||
|             ): | ||||
|             Column( | ||||
|               mainAxisAlignment: MainAxisAlignment.center, | ||||
|               children: [ | ||||
|                 Image( | ||||
|                   image: AssetImage('images/no_data.png'), | ||||
|                   //  height: MediaQuery.of(context).size.height * .10, | ||||
|                 ), | ||||
|                 SizedBox( | ||||
|                   height: 20, | ||||
|                 ), | ||||
|                 Text( | ||||
|                   'No Tankers',style:serverIssueTextStyle() ,), | ||||
|               ], | ||||
|             ), | ||||
|           )); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Scaffold( | ||||
|       appBar: AppBar( | ||||
|         title: Text('Medecine Details'), | ||||
|         backgroundColor: primaryColor,), | ||||
|       /* body: */ | ||||
|       body: TabBarView(controller: _controller, children: [ | ||||
|         Container( | ||||
|           //color: Colors.purpleAccent, | ||||
|           child:Column( | ||||
|             children: [ | ||||
|               Padding(padding:EdgeInsets.all(10) , | ||||
|                 child: Container( | ||||
|                     height: MediaQuery.of(context).size.height * .07, | ||||
|                     padding:  EdgeInsets.all(5), | ||||
|                     child: Center(child: TextField( | ||||
| 
 | ||||
|                       cursorColor: greyColor, | ||||
|                       controller: searchController, | ||||
|                       keyboardType: TextInputType.number, | ||||
|                       onChanged: (string) { | ||||
|                         if(string.length>=1){ | ||||
|                           getSuppliersDataByPhnNumber(string); | ||||
|                         } | ||||
|                         else{ | ||||
|                           getAllMedecineData(dropdownArea); | ||||
|                         } | ||||
|                       }, | ||||
|                       decoration:  InputDecoration( | ||||
|                         prefixIcon: Icon( | ||||
|                           Icons.search, | ||||
|                           color: greyColor, | ||||
|                         ), | ||||
|                         /*suffixIcon: Icon( | ||||
|                               Icons.clear, | ||||
|                               color: greyColor, | ||||
|                             ),*/ | ||||
|                         suffixIcon: IconButton( | ||||
|                           icon:  Icon( | ||||
|                             Icons.clear, | ||||
|                             color: greyColor, | ||||
|                           ), | ||||
|                           onPressed: () { | ||||
|                             setState(() { | ||||
|                               searchController.text=''; | ||||
|                             }); | ||||
|                             getAllMedecineData(dropdownArea); | ||||
|                           }, | ||||
|                         ), | ||||
|                         border: OutlineInputBorder( | ||||
|                           borderSide: BorderSide(color: greyColor), | ||||
|                           borderRadius: BorderRadius.circular(30), | ||||
|                         ), | ||||
|                         focusedBorder: OutlineInputBorder( | ||||
|                           borderSide: BorderSide(color: greyColor), | ||||
|                           borderRadius: BorderRadius.circular(30), | ||||
|                         ), | ||||
|                         enabledBorder: OutlineInputBorder( | ||||
|                           borderSide: BorderSide(color: greyColor), | ||||
|                           borderRadius: BorderRadius.circular(30), | ||||
|                         ), | ||||
|                         //labelText: 'Search by phone number', | ||||
|                         hintText: 'Search phone number', | ||||
|                         labelStyle: TextStyle( | ||||
|                           color: greyColor, //<-- SEE HERE | ||||
|                         ), | ||||
|                       ), | ||||
|                     ),) | ||||
|                 ),), | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|               Expanded(child: Container( | ||||
|                 child:isMedecineDataLoading | ||||
|                     ? Center( | ||||
|                   child: CircularProgressIndicator( | ||||
|                     color: primaryColor, | ||||
|                     strokeWidth: 5.0, | ||||
|                   ), | ||||
|                 ) | ||||
|                     : _tanker() , | ||||
|               )) | ||||
|             ], | ||||
|           ), | ||||
|         ), | ||||
| 
 | ||||
|       ]), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,285 @@ | ||||
| import 'dart:convert'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:healthcare_pharmacy/models/offersview_model.dart'; | ||||
| import 'package:healthcare_pharmacy/offers.dart'; | ||||
| import 'package:healthcare_pharmacy/settings.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart'; | ||||
| 
 | ||||
| 
 | ||||
| class InActiveOffersView extends StatefulWidget { | ||||
|   const InActiveOffersView({Key? key}) : super(key: key); | ||||
| 
 | ||||
|   @override | ||||
|   State<InActiveOffersView> createState() => _InActiveOffersViewState(); | ||||
| } | ||||
| 
 | ||||
| class _InActiveOffersViewState extends State<InActiveOffersView> with TickerProviderStateMixin { | ||||
|   bool isSupplierDataLoading=false; | ||||
|   bool isSereverIssue = false; | ||||
|   bool isSereverIssueConnected = false; | ||||
|   bool isSereverIssuePending = false; | ||||
|   var startdate; | ||||
|   var enddate; | ||||
| 
 | ||||
| 
 | ||||
|   List<GetOffersDetailsModel> offersviewList = []; | ||||
|   TextEditingController offerNameController = TextEditingController(); | ||||
|   TextEditingController offerCodeController = TextEditingController(); | ||||
|   TextEditingController offerDescriptionController = TextEditingController(); | ||||
|   TextEditingController offerDiscountController = TextEditingController(); | ||||
|   TextEditingController offerStartDateController = TextEditingController(); | ||||
|   TextEditingController offerEndDateController = TextEditingController(); | ||||
| 
 | ||||
| 
 | ||||
|   bool isLoading=false; | ||||
| 
 | ||||
|   Future<void> getOffersViewData() async { | ||||
|     isLoading = true; | ||||
|     try { | ||||
|       var response = await AppSettings.getinactiveOffers(); | ||||
|       setState(() { | ||||
|         offersviewList = | ||||
|             ((jsonDecode(response)['data']) as List).map((dynamic model) { | ||||
|               return GetOffersDetailsModel.fromJson(model); | ||||
|             }).toList(); | ||||
|         isLoading = false; | ||||
|       }); | ||||
| 
 | ||||
| 
 | ||||
|     } catch (e) { | ||||
|       setState(() { | ||||
|         isLoading = false; | ||||
|         isSereverIssueConnected = true; | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   @override | ||||
|   void initState() { | ||||
|     // TODO: implement initState | ||||
|     isLoading=true; | ||||
|     getOffersViewData(); | ||||
|     super.initState(); | ||||
|   } | ||||
| 
 | ||||
|   Widget renderzUi(){ | ||||
|     if(offersviewList.length!=0){ | ||||
| 
 | ||||
|       return  Column( | ||||
|           crossAxisAlignment: CrossAxisAlignment.end, | ||||
|           children: [ | ||||
|             Expanded(child:ListView.builder( | ||||
|                 padding:  EdgeInsets.all(0), | ||||
|                 itemCount: offersviewList.length, | ||||
|                 itemBuilder: (BuildContext context, int index) { | ||||
|                   return Card( | ||||
| 
 | ||||
|                     color: offersviewList[index].cardColor, | ||||
|                     child: Padding( | ||||
|                       padding:EdgeInsets.all(8) , | ||||
|                       child: Row( | ||||
|                         mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                         crossAxisAlignment: CrossAxisAlignment.center, | ||||
|                         children: [ | ||||
| 
 | ||||
|                           Container( | ||||
|                             //width: MediaQuery.of(context).size.width * .55, | ||||
|                             child: Column( | ||||
|                               children: [ | ||||
|                                 Row( | ||||
|                                   mainAxisAlignment: MainAxisAlignment.start, | ||||
|                                   crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                                   children: [ | ||||
|                                     Column( | ||||
|                                       mainAxisAlignment: MainAxisAlignment.start, | ||||
|                                       crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                                       children: [ | ||||
|                                         Text('OfferName :',style: labelTextStyle()), | ||||
|                                         Text('OfferCode :',style: labelTextStyle()), | ||||
|                                         Text('OfferDes :' ,style: labelTextStyle()), | ||||
|                                         Text('OfferDis(%) :' ,style: labelTextStyle()), | ||||
|                                         Text('StartDate :',style: labelTextStyle()), | ||||
|                                         Text('EndDate   :' ,style: labelTextStyle()), | ||||
| 
 | ||||
|                                       ], | ||||
|                                     ), | ||||
|                                     SizedBox(width: 5,), | ||||
|                                     Column( | ||||
|                                       mainAxisAlignment: MainAxisAlignment.start, | ||||
|                                       crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                                       children: [ | ||||
|                                         Text(offersviewList[index].offer_name,style: valuesTextStyle()), | ||||
|                                         Text(offersviewList[index].offer_code,style: valuesTextStyle()), | ||||
|                                         Text(offersviewList[index].description,style: valuesTextStyle()), | ||||
|                                         Text(offersviewList[index].discount_percentage,style: valuesTextStyle()), | ||||
|                                         Text(offersviewList[index].starting_date,style: valuesTextStyle()), | ||||
|                                         Text(offersviewList[index].ending_date,style: valuesTextStyle()) | ||||
| 
 | ||||
|                                       ], | ||||
|                                     ), | ||||
|                                   ], | ||||
|                                 ), | ||||
|                               ], | ||||
|                             ), | ||||
|                           ), | ||||
| 
 | ||||
|                           Expanded(child:TextButton( | ||||
|                              onPressed: () { | ||||
|                                showDialog( | ||||
|                                  //if set to true allow to close popup by tapping out of the popup | ||||
|                                  //barrierDismissible: false, | ||||
|                                  context: context, | ||||
|                                  builder: (BuildContext context) => AlertDialog( | ||||
|                                    title: const Text('Do you want to Re_Active offer ??', | ||||
|                                        style: TextStyle( | ||||
|                                          color: primaryColor, | ||||
|                                          fontSize: 16, | ||||
|                                        )), | ||||
|                                    actionsAlignment: MainAxisAlignment.spaceBetween, | ||||
|                                    actions: [ | ||||
|                                      TextButton( | ||||
|                                        onPressed: ()async { | ||||
|                                          bool deleteTankStatus = await AppSettings.reactiveOffers(offersviewList[index].offer_code); | ||||
| 
 | ||||
|                                          if(deleteTankStatus){ | ||||
|                                            getOffersViewData(); | ||||
|                                            AppSettings.longSuccessToast('offer Re_Active successfully'); | ||||
|                                            Navigator.of(context).pop(true); | ||||
| 
 | ||||
|                                          } | ||||
|                                          else{ | ||||
|                                            AppSettings.longFailedToast('offer Re_Active failed'); | ||||
|                                          } | ||||
|                                        }, | ||||
|                                        child: const Text('Yes', | ||||
|                                            style: TextStyle( | ||||
|                                              color: primaryColor, | ||||
|                                              fontSize: 18, | ||||
|                                            )), | ||||
|                                      ), | ||||
|                                      TextButton( | ||||
|                                        onPressed: () { | ||||
|                                          Navigator.of(context).pop(true); | ||||
|                                        }, | ||||
|                                        child: const Text('No', | ||||
|                                            style: TextStyle( | ||||
|                                              color: primaryColor, | ||||
|                                              fontSize: 18, | ||||
|                                            )), | ||||
|                                      ), | ||||
|                                    ], | ||||
|                                  ), | ||||
|                                ); | ||||
|                            }, | ||||
|                            child: const Text( | ||||
|                            'RE_ACTIVE', | ||||
|                             style: TextStyle( | ||||
|                            color: primaryColor, | ||||
|                             fontSize: 15, | ||||
|                           fontWeight: FontWeight.bold | ||||
|                           /* decoration: TextDecoration.underline,*/ | ||||
| 
 | ||||
|                                ), | ||||
|                            ), | ||||
|                            ), | ||||
| 
 | ||||
|                           ), | ||||
| 
 | ||||
|                         ], | ||||
| 
 | ||||
|                       ), | ||||
|                     ), | ||||
|                   ); | ||||
|                 }) ), | ||||
|             Padding( | ||||
|               padding: EdgeInsets.fromLTRB(8, 8, 8, 8), | ||||
|               child: CircleAvatar( | ||||
|                 backgroundColor: primaryColor, | ||||
|                 radius: 40, | ||||
|                 child: Column( | ||||
|                   mainAxisSize: MainAxisSize.min, | ||||
|                   children: <Widget>[ | ||||
|                     IconButton( | ||||
|                       iconSize: 40, | ||||
|                       icon: const Icon( | ||||
|                         Icons.add, | ||||
|                         color: Colors.white, | ||||
|                       ), | ||||
|                       onPressed: () async{ | ||||
|                         Navigator.pop(context); | ||||
|                         await Navigator.push( | ||||
|                           context, | ||||
|                           MaterialPageRoute( | ||||
|                               builder: (context) => offers()), | ||||
|                         ); | ||||
|                         //showBoreAddingDialog(); | ||||
|                       }, | ||||
|                     ), | ||||
|                     /* Padding( | ||||
|                       padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | ||||
|                       child: Text( | ||||
|                         'Add Tanks ', | ||||
|                         style: TextStyle(color: Colors.white), | ||||
|                       ), | ||||
|                     )*/ | ||||
|                   ], | ||||
|                 ), | ||||
|               ), | ||||
|             ), | ||||
|           ]); | ||||
|     } | ||||
|     else{ | ||||
|       return  Center( | ||||
|           child: Padding( | ||||
|             padding: EdgeInsets.fromLTRB(0, 40, 0, 0), | ||||
|             child: Column( | ||||
|               crossAxisAlignment: CrossAxisAlignment.center, | ||||
|               children: [ | ||||
|                 SizedBox(height: MediaQuery.of(context).size.height * .25,), | ||||
|                 Text('Click below icon to add new Offer'), | ||||
|                 SizedBox( | ||||
|                   height: 20, | ||||
|                 ), | ||||
|                 CircleAvatar( | ||||
|                   backgroundColor: primaryColor, | ||||
|                   radius: 40, | ||||
|                   child: IconButton( | ||||
|                     iconSize: 40, | ||||
|                     icon: const Icon( | ||||
|                       Icons.add, | ||||
|                       color: Colors.white, | ||||
|                     ), | ||||
|                     onPressed: () async { | ||||
|                       Navigator.pop(context); | ||||
|                       await Navigator.push( | ||||
|                         context, | ||||
|                         MaterialPageRoute( | ||||
|                             builder: (context) => offers()), | ||||
|                       ); | ||||
|                     }, | ||||
|                   ), | ||||
|                 ) | ||||
|               ], | ||||
|             ), | ||||
|           ) | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return SafeArea( | ||||
|         child: Scaffold( | ||||
|           appBar: AppSettings.appBar('InActive OfersView'), | ||||
|           body: isLoading?Center( | ||||
|             child: CircularProgressIndicator( | ||||
|               color: primaryColor, | ||||
|               strokeWidth: 5.0, | ||||
|             ), | ||||
|           ):renderzUi(), | ||||
|         )); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,34 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| 
 | ||||
| 
 | ||||
| class GetMedecineDetailsModel { | ||||
|   String name = ''; | ||||
|   String manufacturers = ''; | ||||
|   String salt_composition = ''; | ||||
|   String mrp=''; | ||||
|   String primary_use=''; | ||||
| 
 | ||||
| 
 | ||||
|   String bs64str=''; | ||||
|   String picture=''; | ||||
|   Map<String,dynamic> picture1={}; | ||||
|   Color text_color=Colors.black; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   GetMedecineDetailsModel(); | ||||
| 
 | ||||
|   factory GetMedecineDetailsModel.fromJson(Map<String, dynamic> json){ | ||||
|     GetMedecineDetailsModel rtvm = new GetMedecineDetailsModel(); | ||||
| 
 | ||||
|     rtvm.name = json['name'] ?? ''; | ||||
|     rtvm.manufacturers = json['manufacturers'] ?? ''; | ||||
|     rtvm.salt_composition = json['salt_composition'] ?? ''; | ||||
|     rtvm.mrp = json['mrp'] ?? ''; | ||||
|     rtvm.primary_use = json['primary_use'] ??''; | ||||
|     rtvm.picture = json['picture'] ?? ''; | ||||
| 
 | ||||
|     return rtvm; | ||||
|   } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,30 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| 
 | ||||
| 
 | ||||
| class GetOffersDetailsModel { | ||||
|   String offer_name = ''; | ||||
|   String offer_code = ''; | ||||
|   String description = ''; | ||||
|   String discount_percentage=''; | ||||
|   String starting_date=''; | ||||
|   Color cardColor=Colors.white; | ||||
|   String ending_date=''; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   GetOffersDetailsModel(); | ||||
| 
 | ||||
|   factory GetOffersDetailsModel.fromJson(Map<String, dynamic> json){ | ||||
|     GetOffersDetailsModel rtvm = new GetOffersDetailsModel(); | ||||
| 
 | ||||
|     rtvm.offer_name = json['offer_name'] ?? ''; | ||||
|     rtvm.offer_code = json['offer_code'] ?? ''; | ||||
|     rtvm.description = json['description'] ?? ''; | ||||
|     rtvm.discount_percentage = json['discount_percentage'] ?? ''; | ||||
|     rtvm.starting_date = json['starting_date'] ??''; | ||||
|     rtvm.ending_date = json['ending_date'] ??''; | ||||
| 
 | ||||
|     return rtvm; | ||||
|   } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,370 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:flutter/services.dart'; | ||||
| import 'package:healthcare_pharmacy/dashboard.dart'; | ||||
| import 'package:healthcare_pharmacy/settings.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart'; | ||||
| 
 | ||||
| 
 | ||||
| class offers extends StatefulWidget { | ||||
|   const offers({Key? key}) : super(key: key); | ||||
| 
 | ||||
|   @override | ||||
|   State<offers> createState() => _offersState(); | ||||
| } | ||||
| 
 | ||||
| class _offersState extends State<offers> { | ||||
| 
 | ||||
|   TextEditingController offer_nameController = TextEditingController(); | ||||
|   TextEditingController offer_codeController = TextEditingController(); | ||||
|   TextEditingController descriptionController = TextEditingController(); | ||||
|   TextEditingController discount_percentageController = TextEditingController(); | ||||
|   TextEditingController starting_dateController = TextEditingController(); | ||||
|   TextEditingController ending_dateController = TextEditingController(); | ||||
|   var selIOS; | ||||
| 
 | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return SafeArea( | ||||
|       child: Scaffold( | ||||
|           appBar: AppSettings.appBar('Cteate Offers'), | ||||
|           body: Stack(children: <Widget>[ | ||||
| 
 | ||||
|             GestureDetector( | ||||
|               onTap: () { | ||||
|                 FocusManager.instance.primaryFocus?.unfocus(); | ||||
|               }, | ||||
|               child: SafeArea( | ||||
|                   child: SingleChildScrollView( | ||||
|                     child: Column( | ||||
|                       children: <Widget>[ | ||||
| 
 | ||||
|                         SizedBox( | ||||
|                           height: 20, | ||||
|                         ), | ||||
|                         Container( | ||||
|                           //width: double.infinity, | ||||
|                             child: Image( | ||||
|                               image: const AssetImage('images/logo.png'), | ||||
|                               height: MediaQuery.of(context).size.height * .18, | ||||
|                             )), | ||||
| 
 | ||||
|                         SizedBox( | ||||
|                           height: 05, | ||||
|                         ), | ||||
|                         Container( | ||||
|                           padding: const EdgeInsets.all(10), | ||||
|                           child: TextFormField( | ||||
|                             cursorColor: greyColor, | ||||
|                             controller: offer_nameController, | ||||
|                             textCapitalization: TextCapitalization.characters, | ||||
|                             decoration: const InputDecoration( | ||||
|                               prefixIcon: Icon( | ||||
|                                 Icons.person, | ||||
|                                 color: primaryColor, | ||||
|                               ), | ||||
|                               border: OutlineInputBorder( | ||||
|                                   borderSide: BorderSide(color: primaryColor)), | ||||
|                               focusedBorder: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               enabledBorder: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               labelText: 'Enter Offer Name', | ||||
|                               labelStyle: TextStyle( | ||||
|                                 color: greyColor, //<-- SEE HERE | ||||
|                               ), | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), //name | ||||
|                         SizedBox( | ||||
|                           height: 05, | ||||
|                         ), | ||||
|                         Container( | ||||
|                           padding: const EdgeInsets.all(10), | ||||
|                           child: TextFormField( | ||||
|                             cursorColor: greyColor, | ||||
|                             controller: offer_codeController, | ||||
|                             textCapitalization: TextCapitalization.characters, | ||||
|                             decoration: const InputDecoration( | ||||
|                               prefixIcon: Icon( | ||||
|                                 Icons.numbers, | ||||
|                                 color: primaryColor, | ||||
|                               ), | ||||
|                               border: OutlineInputBorder( | ||||
|                                   borderSide: BorderSide(color: primaryColor)), | ||||
|                               focusedBorder: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               enabledBorder: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               labelText: 'Enter Offer Code', | ||||
|                               labelStyle: TextStyle( | ||||
|                                 color: greyColor, //<-- SEE HERE | ||||
|                               ), | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), | ||||
|                         const SizedBox( | ||||
|                           height: 5, | ||||
|                         ), | ||||
|                         Container( | ||||
|                           padding: const EdgeInsets.all(10), | ||||
|                           child: TextFormField( | ||||
|                             cursorColor: greyColor, | ||||
|                             controller: descriptionController, | ||||
|                             textCapitalization: TextCapitalization.characters, | ||||
|                             decoration: const InputDecoration( | ||||
|                               prefixIcon: Icon( | ||||
|                                 Icons.description, | ||||
|                                 color: primaryColor, | ||||
|                               ), | ||||
|                               border: OutlineInputBorder( | ||||
|                                   borderSide: BorderSide(color: primaryColor)), | ||||
|                               focusedBorder: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               enabledBorder: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               labelText: 'Enter Offer Description', | ||||
|                               labelStyle: TextStyle( | ||||
|                                 color: greyColor, //<-- SEE HERE | ||||
|                               ), | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), //mobile | ||||
| 
 | ||||
|                         const SizedBox( | ||||
|                           height: 5, | ||||
|                         ), | ||||
|                         Container( | ||||
|                           padding: const EdgeInsets.all(10), | ||||
|                           child: TextFormField( | ||||
|                             cursorColor: greyColor, | ||||
|                             controller: discount_percentageController, | ||||
|                             keyboardType: TextInputType.number, | ||||
|                             maxLength: 2, | ||||
|                             decoration: const InputDecoration( | ||||
|                               prefixIcon: Icon( | ||||
|                                 Icons.percent_outlined, | ||||
|                                 color: primaryColor, | ||||
|                               ), | ||||
|                               border: OutlineInputBorder( | ||||
|                                   borderSide: BorderSide(color: primaryColor)), | ||||
|                               focusedBorder: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               enabledBorder: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               labelText: 'Enter Percentage', | ||||
|                               labelStyle: TextStyle( | ||||
|                                 color: greyColor, //<-- SEE HERE | ||||
|                               ), | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), | ||||
|                         const SizedBox( | ||||
|                           height: 5, | ||||
|                         ), | ||||
| 
 | ||||
|                         Container( | ||||
|                           padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), | ||||
|                           child: TextFormField( | ||||
|                             readOnly: true, | ||||
|                             cursorColor: greyColor, | ||||
|                             controller: starting_dateController, | ||||
|                             decoration: InputDecoration( | ||||
|                               labelText: 'Select Start Date', | ||||
|                               prefixIcon: const Icon(Icons.date_range, color: primaryColor,), | ||||
|                               labelStyle: const TextStyle( | ||||
|                                 color: greyColor, //<-- SEE HERE | ||||
|                               ), | ||||
|                               border: const OutlineInputBorder( | ||||
|                                   borderSide: BorderSide(color: primaryColor)), | ||||
|                               focusedBorder: const OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               enabledBorder: const OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               suffixIcon: IconButton( | ||||
|                                 icon:  Icon( | ||||
|                                   Icons.date_range, | ||||
|                                 ), | ||||
|                                 onPressed: () async { | ||||
|                                   DatePicker.showDatePicker( | ||||
|                                     context, | ||||
|                                     dateFormat: 'dd MMMM yyyy HH:mm', | ||||
|                                     initialDateTime: DateTime.now(), | ||||
|                                     minDateTime:DateTime.now(), | ||||
|                                     maxDateTime: DateTime.now().add(Duration(days: 365)), | ||||
|                                     onMonthChangeStartWithFirstDate: true, | ||||
|                                     pickerMode: DateTimePickerMode.datetime, | ||||
|                                     pickerTheme: DateTimePickerTheme( | ||||
|                                       // backgroundColor: Colors.white, | ||||
|                                       cancelTextStyle: labelTextStyle(), | ||||
|                                       confirmTextStyle: labelTextStyle(), | ||||
|                                       // showTitle: true, | ||||
|                                       //title: Text('Pick date and time'), | ||||
|                                       itemTextStyle: valuesTextStyle(), | ||||
|                                     ), | ||||
|                                     onConfirm: (dateTime, List<int> index)async { | ||||
|                                       DateTime selectdate = dateTime; | ||||
|                                       setState(() { | ||||
|                                         selIOS = DateFormat('dd-MMM-yyyy - HH:mm').format(selectdate); | ||||
|                                       }); | ||||
| 
 | ||||
|                                       if(selIOS!=''){ | ||||
|                                         setState(() { | ||||
|                                           starting_dateController.text=selIOS.toString(); | ||||
|                                         }); | ||||
|                                       } | ||||
|                                       else { | ||||
|                                         AppSettings.longFailedToast('please select date'); | ||||
|                                       } | ||||
|                                     }, | ||||
|                                   ); | ||||
|                                 }, | ||||
|                               ), | ||||
| 
 | ||||
|                             ), | ||||
| 
 | ||||
|                           ), | ||||
|                         ), | ||||
| 
 | ||||
|                         const SizedBox( | ||||
|                           height: 5, | ||||
|                         ), | ||||
|                         Container( | ||||
|                           padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), | ||||
|                           child: TextFormField( | ||||
|                             readOnly: true, | ||||
|                             cursorColor: greyColor, | ||||
|                             controller: ending_dateController, | ||||
|                             decoration: InputDecoration( | ||||
|                               labelText: 'Select End Date', | ||||
|                               prefixIcon: const Icon(Icons.date_range, color: primaryColor,), | ||||
|                               labelStyle: const TextStyle( | ||||
|                                 color: greyColor, //<-- SEE HERE | ||||
|                               ), | ||||
|                               border: const OutlineInputBorder( | ||||
|                                   borderSide: BorderSide(color: primaryColor)), | ||||
|                               focusedBorder: const OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               enabledBorder: const OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor), | ||||
|                               ), | ||||
|                               suffixIcon: IconButton( | ||||
|                                 icon:  Icon( | ||||
|                                   Icons.date_range, | ||||
|                                 ), | ||||
|                                 onPressed: () async { | ||||
|                                   DatePicker.showDatePicker( | ||||
|                                     context, | ||||
|                                     dateFormat: 'dd MMMM yyyy HH:mm', | ||||
|                                     initialDateTime: DateTime.now(), | ||||
|                                     minDateTime:DateTime.now(), | ||||
|                                     maxDateTime: DateTime.now().add(Duration(days: 365)), | ||||
|                                     onMonthChangeStartWithFirstDate: true, | ||||
|                                     pickerMode: DateTimePickerMode.datetime, | ||||
|                                     pickerTheme: DateTimePickerTheme( | ||||
|                                       // backgroundColor: Colors.white, | ||||
|                                       cancelTextStyle: labelTextStyle(), | ||||
|                                       confirmTextStyle: labelTextStyle(), | ||||
|                                       // showTitle: true, | ||||
|                                       //title: Text('Pick date and time'), | ||||
|                                       itemTextStyle: valuesTextStyle(), | ||||
|                                     ), | ||||
|                                     onConfirm: (dateTime, List<int> index)async { | ||||
|                                       DateTime selectdate = dateTime; | ||||
|                                       setState(() { | ||||
|                                         selIOS = DateFormat('dd-MMM-yyyy - HH:mm').format(selectdate); | ||||
|                                       }); | ||||
| 
 | ||||
|                                       if(selIOS!=''){ | ||||
|                                         setState(() { | ||||
|                                           ending_dateController.text=selIOS.toString(); | ||||
|                                         }); | ||||
|                                       } | ||||
|                                       else { | ||||
|                                         AppSettings.longFailedToast('please select date'); | ||||
|                                       } | ||||
|                                     }, | ||||
|                                   ); | ||||
|                                 }, | ||||
|                               ), | ||||
| 
 | ||||
|                             ), | ||||
| 
 | ||||
|                           ), | ||||
|                         ),//address description | ||||
| 
 | ||||
|                         const SizedBox( | ||||
|                           height:15, | ||||
|                         ), | ||||
|                         Container( | ||||
|                             width:MediaQuery.of(context).size.width * .99, | ||||
|                             height: 55, | ||||
|                             padding: const EdgeInsets.fromLTRB(3, 0, 3, 0), | ||||
|                             child: ElevatedButton( | ||||
|                               style: ElevatedButton.styleFrom( | ||||
|                                 primary: buttonColor, // background | ||||
|                                 onPrimary: Colors.white, // foreground | ||||
|                               ), | ||||
|                               onPressed: () async { | ||||
|                                 if (offer_nameController.text != '' && | ||||
|                                     offer_codeController.text != '' && | ||||
|                                     descriptionController.text != ''&& | ||||
|                                     discount_percentageController.text != ''&& | ||||
|                                     starting_dateController.text != '' && | ||||
|                                     ending_dateController.text != '') { | ||||
|                                   AppSettings.preLoaderDialog(context); | ||||
| 
 | ||||
|                                   var payload = new Map<String, dynamic>(); | ||||
|                                   payload["offer_name"] = offer_nameController.text.toString(); | ||||
|                                   payload["offer_code"] = offer_codeController.text.toString(); | ||||
|                                   payload["description"] =  descriptionController.text.toString();; | ||||
|                                   payload["discount_percentage"] = discount_percentageController.text.toString(); | ||||
|                                   payload["starting_date"] = starting_dateController.text.toString(); | ||||
|                                   payload["ending_date"] = ending_dateController.text.toString(); | ||||
|                                   payload["offer_status"] ="active"; | ||||
|                                   bool offerStatus = await AppSettings.createOffers(payload); | ||||
|                                   try{ | ||||
|                                     if (offerStatus) { | ||||
|                                       Navigator.pop(context); | ||||
|                                       Navigator.of(context,rootNavigator: true).pop(); | ||||
|                                      Navigator.push( | ||||
|                                         context, | ||||
|                                         MaterialPageRoute(builder: (context) => Dashboard()), | ||||
|                                       ); | ||||
|                                       AppSettings.longSuccessToast("Offer Created Succesfully!!"); | ||||
|                                     } else { | ||||
| 
 | ||||
|                                       AppSettings.longFailedToast("Fields should not be empty !!"); | ||||
|                                     } | ||||
|                                   } | ||||
|                                   catch(exception){ | ||||
|                                     print(exception); | ||||
|                                     AppSettings.longFailedToast("Please enter valid details"); | ||||
|                                   } | ||||
|                                 } else { | ||||
|                                   AppSettings.longFailedToast("Offer Not Created!!"); | ||||
| 
 | ||||
|                                 } | ||||
|                               }, | ||||
|                               child: Text('Create'), | ||||
|                             )),//login button | ||||
| 
 | ||||
|                       ], | ||||
|                     ), | ||||
|                   )), | ||||
|             ), | ||||
|           ])), ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,623 @@ | ||||
| import 'dart:convert'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:healthcare_pharmacy/models/offersview_model.dart'; | ||||
| import 'package:healthcare_pharmacy/offers.dart'; | ||||
| import 'package:healthcare_pharmacy/settings.dart'; | ||||
| import 'package:intl/intl.dart'; | ||||
| import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart'; | ||||
| 
 | ||||
| 
 | ||||
| class OffersView extends StatefulWidget { | ||||
|   const OffersView({Key? key}) : super(key: key); | ||||
| 
 | ||||
|   @override | ||||
|   State<OffersView> createState() => _OffersViewState(); | ||||
| } | ||||
| 
 | ||||
| class _OffersViewState extends State<OffersView> with TickerProviderStateMixin { | ||||
|   bool isSupplierDataLoading=false; | ||||
|   bool isSereverIssue = false; | ||||
|   bool isSereverIssueConnected = false; | ||||
|   bool isSereverIssuePending = false; | ||||
|   var startdate; | ||||
|   var enddate; | ||||
| 
 | ||||
| 
 | ||||
|   List<GetOffersDetailsModel> offersviewList = []; | ||||
|   TextEditingController offerNameController = TextEditingController(); | ||||
|   TextEditingController offerCodeController = TextEditingController(); | ||||
|   TextEditingController offerDescriptionController = TextEditingController(); | ||||
|   TextEditingController offerDiscountController = TextEditingController(); | ||||
|   TextEditingController offerStartDateController = TextEditingController(); | ||||
|   TextEditingController offerEndDateController = TextEditingController(); | ||||
|   TextEditingController updateOfferNameController = TextEditingController(); | ||||
|   TextEditingController updateOfferCodeController = TextEditingController(); | ||||
|   TextEditingController updateOfferDescriptionController = TextEditingController(); | ||||
|   TextEditingController updateDiscountController = TextEditingController(); | ||||
|   TextEditingController updateOfferStartDateController = TextEditingController(); | ||||
|   TextEditingController updateOfferEndDateController = TextEditingController(); | ||||
| 
 | ||||
|   bool isLoading=false; | ||||
| 
 | ||||
|   Future<void> getOffersViewData() async { | ||||
|     isLoading = true; | ||||
|     try { | ||||
|       var response = await AppSettings.getOffers(); | ||||
|       setState(() { | ||||
|         offersviewList = | ||||
|             ((jsonDecode(response)['data']) as List).map((dynamic model) { | ||||
|               return GetOffersDetailsModel.fromJson(model); | ||||
|             }).toList(); | ||||
|         isLoading = false; | ||||
|       }); | ||||
| 
 | ||||
| 
 | ||||
|     } catch (e) { | ||||
|       setState(() { | ||||
|         isLoading = false; | ||||
|         isSereverIssueConnected = true; | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|   @override | ||||
|   void initState() { | ||||
|     // TODO: implement initState | ||||
|     isLoading=true; | ||||
|     getOffersViewData(); | ||||
|     super.initState(); | ||||
|   } | ||||
| 
 | ||||
|   showUpdateOfferDialog(var object) async { | ||||
|     updateOfferNameController.text = object.offer_name; | ||||
|     updateOfferCodeController.text = object.offer_code; | ||||
|     updateOfferDescriptionController.text = object.description; | ||||
|     updateDiscountController.text = object.discount_percentage; | ||||
|     updateOfferStartDateController.text=object.starting_date; | ||||
|     updateOfferEndDateController.text=object.ending_date; | ||||
|     return showDialog( | ||||
|       context: context, | ||||
|       barrierDismissible: false, | ||||
|       builder: (BuildContext context) { | ||||
|         return StatefulBuilder( | ||||
|             builder: (BuildContext context, StateSetter setState) { | ||||
|               return AlertDialog( | ||||
|                 title: const Text('Update Offer'), | ||||
|                 content: SingleChildScrollView( | ||||
|                   child: ListBody( | ||||
|                     children: <Widget>[ | ||||
|                       Container( | ||||
|                         padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), | ||||
|                         child: TextFormField( | ||||
|                           cursorColor: greyColor, | ||||
|                           controller: updateOfferNameController, | ||||
|                           textCapitalization: TextCapitalization.characters, | ||||
|                           decoration: const InputDecoration( | ||||
|                             prefixIcon: Icon( | ||||
|                               Icons.person, | ||||
|                               color: primaryColor, | ||||
|                             ), | ||||
|                             border: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: greyColor)), | ||||
|                             focusedBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             enabledBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             labelText: 'Enter offer name', | ||||
|                             labelStyle: TextStyle( | ||||
|                               color: greyColor, //<-- SEE HERE | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), //tanker name | ||||
|                       ), | ||||
|                       const SizedBox( | ||||
|                         height: 20, | ||||
|                       ), | ||||
| 
 | ||||
|                       Container( | ||||
|                         //padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), | ||||
|                         child: TextFormField( | ||||
|                           cursorColor: greyColor, | ||||
|                           controller: updateOfferCodeController, | ||||
|                           textCapitalization: TextCapitalization.characters, | ||||
|                           decoration: const InputDecoration( | ||||
|                             prefixIcon: Icon( | ||||
|                               Icons.numbers, | ||||
|                               color: primaryColor, | ||||
|                             ), | ||||
|                             border: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: greyColor)), | ||||
|                             focusedBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             enabledBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             labelText: 'Enter Offer Code', | ||||
|                             labelStyle: TextStyle( | ||||
|                               color: greyColor, //<-- SEE HERE | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), //tanker name | ||||
|                       ), | ||||
|                       const SizedBox( | ||||
|                         height: 20, | ||||
|                       ), | ||||
|                       Container( | ||||
|                         //padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), | ||||
|                         child: TextFormField( | ||||
|                           cursorColor: greyColor, | ||||
|                           controller: updateOfferDescriptionController, | ||||
|                           textCapitalization: TextCapitalization.characters, | ||||
|                           decoration: const InputDecoration( | ||||
|                             prefixIcon: Icon( | ||||
|                               Icons.description, | ||||
|                               color: primaryColor, | ||||
|                             ), | ||||
|                             border: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: greyColor)), | ||||
|                             focusedBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             enabledBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             labelText: 'Enter Offer Description', | ||||
|                             labelStyle: TextStyle( | ||||
|                               color: greyColor, //<-- SEE HERE | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), //tanker name | ||||
|                       ), | ||||
|                       const SizedBox( | ||||
|                         height: 20, | ||||
|                       ), | ||||
|                       Container( | ||||
|                         //padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), | ||||
|                         child: TextFormField( | ||||
|                           cursorColor: greyColor, | ||||
|                           maxLength: 2, | ||||
|                           controller: updateDiscountController, | ||||
|                           textCapitalization: TextCapitalization.characters, | ||||
|                           decoration: const InputDecoration( | ||||
|                             prefixIcon: Icon( | ||||
|                               Icons.percent_outlined, | ||||
|                               color: primaryColor, | ||||
|                             ), | ||||
|                             border: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: greyColor)), | ||||
|                             focusedBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             enabledBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             labelText: 'Enter Offer Discount', | ||||
|                             labelStyle: TextStyle( | ||||
|                               color: greyColor, //<-- SEE HERE | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), //tanker name | ||||
|                       ), | ||||
|                       const SizedBox( | ||||
|                         height: 20, | ||||
|                       ), | ||||
|                       Container( | ||||
|                         child: TextFormField( | ||||
|                           readOnly: true, | ||||
|                           cursorColor: greyColor, | ||||
|                           controller: updateOfferStartDateController, | ||||
|                           decoration: InputDecoration( | ||||
|                             labelText: 'Select Start Date', | ||||
|                             prefixIcon: IconButton( | ||||
|                               icon:  Icon( | ||||
|                                 Icons.date_range, | ||||
|                                 color: primaryColor, | ||||
|                               ), | ||||
|                               onPressed: () async { | ||||
|                                 DatePicker.showDatePicker( | ||||
|                                   context, | ||||
|                                   dateFormat: 'dd MMMM yyyy HH:mm', | ||||
|                                   initialDateTime: DateTime.now(), | ||||
|                                   minDateTime:DateTime.now(), | ||||
|                                   maxDateTime: DateTime.now().add(Duration(days: 15)), | ||||
|                                   onMonthChangeStartWithFirstDate: true, | ||||
|                                   pickerMode: DateTimePickerMode.datetime, | ||||
|                                   pickerTheme: DateTimePickerTheme( | ||||
|                                     // backgroundColor: Colors.white, | ||||
|                                     cancelTextStyle: labelTextStyle(), | ||||
|                                     confirmTextStyle: labelTextStyle(), | ||||
|                                     // showTitle: true, | ||||
|                                     //title: Text('Pick date and time'), | ||||
|                                     itemTextStyle: valuesTextStyle(), | ||||
|                                   ), | ||||
|                                   onConfirm: (dateTime, List<int> index)async { | ||||
|                                     DateTime selectdate = dateTime; | ||||
|                                     setState(() { | ||||
|                                       startdate = DateFormat('dd-MMM-yyyy - HH:mm').format(selectdate); | ||||
|                                     }); | ||||
| 
 | ||||
|                                     if(startdate!=''){ | ||||
|                                       setState(() { | ||||
|                                         updateOfferStartDateController.text=startdate.toString(); | ||||
|                                       }); | ||||
|                                     } | ||||
|                                     else { | ||||
|                                       AppSettings.longFailedToast('please select date'); | ||||
|                                     } | ||||
|                                   }, | ||||
|                                 ); | ||||
|                               }, | ||||
|                             ), | ||||
| 
 | ||||
|                               labelStyle: const TextStyle( | ||||
|                               color: greyColor, //<-- SEE HERE | ||||
|                             ), | ||||
|                             border: const OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor)), | ||||
|                             focusedBorder: const OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: primaryColor), | ||||
|                             ), | ||||
|                             enabledBorder: const OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: primaryColor), | ||||
|                             ), | ||||
| 
 | ||||
|                           ), | ||||
| 
 | ||||
|                         ), | ||||
|                       ), | ||||
| 
 | ||||
|                       const SizedBox( | ||||
|                         height: 20, | ||||
|                       ), | ||||
|                       Container( | ||||
|                         child: TextFormField( | ||||
|                           readOnly: true, | ||||
|                           cursorColor: greyColor, | ||||
|                           controller: updateOfferEndDateController, | ||||
|                           decoration: InputDecoration( | ||||
|                             labelText: 'Select End Date', | ||||
|                             prefixIcon: IconButton( | ||||
|                               icon:  Icon( | ||||
|                                 Icons.date_range, | ||||
|                                 color: primaryColor, | ||||
|                               ), | ||||
|                               onPressed: () async { | ||||
|                                 DatePicker.showDatePicker( | ||||
|                                   context, | ||||
|                                   dateFormat: 'dd MMMM yyyy HH:mm', | ||||
|                                   initialDateTime: DateTime.now(), | ||||
|                                   minDateTime:DateTime.now(), | ||||
|                                   maxDateTime: DateTime.now().add(Duration(days: 15)), | ||||
|                                   onMonthChangeStartWithFirstDate: true, | ||||
|                                   pickerMode: DateTimePickerMode.datetime, | ||||
|                                   pickerTheme: DateTimePickerTheme( | ||||
|                                     // backgroundColor: Colors.white, | ||||
|                                     cancelTextStyle: labelTextStyle(), | ||||
|                                     confirmTextStyle: labelTextStyle(), | ||||
|                                     // showTitle: true, | ||||
|                                     //title: Text('Pick date and time'), | ||||
|                                     itemTextStyle: valuesTextStyle(), | ||||
|                                   ), | ||||
|                                   onConfirm: (dateTime, List<int> index)async { | ||||
|                                     DateTime selectdate = dateTime; | ||||
|                                     setState(() { | ||||
|                                       enddate = DateFormat('dd-MMM-yyyy - HH:mm').format(selectdate); | ||||
|                                     }); | ||||
| 
 | ||||
|                                     if(enddate!=''){ | ||||
|                                       setState(() { | ||||
|                                         updateOfferEndDateController.text=enddate.toString(); | ||||
|                                       }); | ||||
|                                     } | ||||
|                                     else { | ||||
|                                       AppSettings.longFailedToast('please select date'); | ||||
|                                     } | ||||
|                                   }, | ||||
|                                 ); | ||||
|                               }, | ||||
|                             ), | ||||
| 
 | ||||
|                             labelStyle: const TextStyle( | ||||
|                               color: greyColor, //<-- SEE HERE | ||||
|                             ), | ||||
|                             border: const OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: primaryColor)), | ||||
|                             focusedBorder: const OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: primaryColor), | ||||
|                             ), | ||||
|                             enabledBorder: const OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: primaryColor), | ||||
|                             ), | ||||
|                           ), | ||||
| 
 | ||||
|                         ), | ||||
|                       ),//address description | ||||
| 
 | ||||
|                       const SizedBox( | ||||
|                         height: 30, | ||||
|                       ), | ||||
| 
 | ||||
|                     ], | ||||
|                   ), | ||||
|                 ), | ||||
|                 actions: <Widget>[ | ||||
|                   TextButton( | ||||
|                     child: Text('cancel', style: textButtonStyle()), | ||||
|                     onPressed: () { | ||||
|                       Navigator.of(context).pop(); | ||||
|                     }, | ||||
|                   ), | ||||
|                   TextButton( | ||||
|                     child: Text('Update', style: textButtonStyle()), | ||||
|                     onPressed: () async { | ||||
|                       if (updateOfferNameController.text != '' ) { | ||||
|                         AppSettings.preLoaderDialog(context); | ||||
|                         var payload = new Map<String, dynamic>(); | ||||
| 
 | ||||
|                         payload["offer_name"] = updateOfferNameController.text.toString(); | ||||
|                         payload["offer_code"] = updateOfferCodeController.text.toString(); | ||||
|                         payload["description"] = updateOfferDescriptionController.text.toString(); | ||||
|                         payload["discount_percentage"] = updateDiscountController.text.toString(); | ||||
|                         payload["starting_date"] = updateOfferStartDateController.text.toString(); | ||||
|                         payload["ending_date"] = updateOfferEndDateController.text.toString(); | ||||
|                         payload["offer_status"] ="active"; | ||||
| 
 | ||||
|                         bool offerStatus = await AppSettings.updateOffers(object.offer_code, payload); | ||||
|                         try { | ||||
|                           if (offerStatus) { | ||||
|                             Navigator.of(context, rootNavigator: true).pop(); | ||||
|                             AppSettings.longSuccessToast( | ||||
|                                 "Offer Updated Successfully"); | ||||
|                             updateOfferNameController.text = ''; | ||||
|                             updateOfferCodeController.text = ''; | ||||
|                             updateOfferDescriptionController.text = ''; | ||||
|                             updateDiscountController.text = ''; | ||||
|                             updateOfferStartDateController.text = ''; | ||||
|                             updateOfferEndDateController.text = ''; | ||||
| 
 | ||||
|                             Navigator.of(context).pop(); | ||||
|                             await getOffersViewData(); | ||||
|                           } else { | ||||
|                             Navigator.of(context, rootNavigator: true).pop(); | ||||
|                             AppSettings.longFailedStyledToast( | ||||
|                                 "Offer upadtion failed", context); | ||||
|                             Navigator.of(context).pop(); | ||||
|                           } | ||||
|                         } catch (exception) { | ||||
|                           Navigator.of(context).pop(); | ||||
|                           print(exception); | ||||
|                         } | ||||
|                       } else { | ||||
|                         AppSettings.longFailedStyledToast("enter details", context); | ||||
|                       } | ||||
|                     }, | ||||
|                   ), | ||||
|                 ], | ||||
|               ); | ||||
|             }); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   Widget renderzUi(){ | ||||
|     if(offersviewList.length!=0){ | ||||
| 
 | ||||
|       return  Column( | ||||
|           crossAxisAlignment: CrossAxisAlignment.end, | ||||
|           children: [ | ||||
|             Expanded(child:ListView.builder( | ||||
|                 padding:  EdgeInsets.all(0), | ||||
|                 itemCount: offersviewList.length, | ||||
|                 itemBuilder: (BuildContext context, int index) { | ||||
|                   return Card( | ||||
| 
 | ||||
|                     color: offersviewList[index].cardColor, | ||||
|                     child: Padding( | ||||
|                       padding:EdgeInsets.all(8) , | ||||
|                       child: Row( | ||||
|                         mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                         crossAxisAlignment: CrossAxisAlignment.center, | ||||
|                         children: [ | ||||
| 
 | ||||
|                           Container( | ||||
|                             //width: MediaQuery.of(context).size.width * .55, | ||||
|                             child: Column( | ||||
|                               children: [ | ||||
|                                 Row( | ||||
|                                   mainAxisAlignment: MainAxisAlignment.start, | ||||
|                                   crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                                   children: [ | ||||
|                                     Column( | ||||
|                                       mainAxisAlignment: MainAxisAlignment.start, | ||||
|                                       crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                                       children: [ | ||||
|                                         Text('OfferName :',style: labelTextStyle()), | ||||
|                                         Text('OfferCode :',style: labelTextStyle()), | ||||
|                                         Text('OfferDes :' ,style: labelTextStyle()), | ||||
|                                         Text('OfferDis(%) :' ,style: labelTextStyle()), | ||||
|                                         Text('StartDate :',style: labelTextStyle()), | ||||
|                                         Text('EndDate   :' ,style: labelTextStyle()), | ||||
| 
 | ||||
|                                       ], | ||||
|                                     ), | ||||
|                                     SizedBox(width: 5,), | ||||
|                                     Column( | ||||
|                                       mainAxisAlignment: MainAxisAlignment.start, | ||||
|                                       crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                                       children: [ | ||||
|                                         Text(offersviewList[index].offer_name,style: valuesTextStyle()), | ||||
|                                         Text(offersviewList[index].offer_code,style: valuesTextStyle()), | ||||
|                                         Text(offersviewList[index].description,style: valuesTextStyle()), | ||||
|                                         Text(offersviewList[index].discount_percentage,style: valuesTextStyle()), | ||||
|                                         Text(offersviewList[index].starting_date,style: valuesTextStyle()), | ||||
|                                         Text(offersviewList[index].ending_date,style: valuesTextStyle()) | ||||
| 
 | ||||
|                                       ], | ||||
|                                     ), | ||||
|                                   ], | ||||
|                                 ), | ||||
|                               ], | ||||
|                             ), | ||||
|                           ), | ||||
| 
 | ||||
|                           Expanded(child:IconButton( | ||||
|                             icon: const Icon(Icons.edit,color: primaryColor,), | ||||
|                             onPressed: () { | ||||
|                               showUpdateOfferDialog(offersviewList[index]); | ||||
|                             }, | ||||
|                           ),), | ||||
|                           Expanded(child:IconButton( | ||||
|                             icon: const Icon(Icons.hide_source_rounded,color: primaryColor,), | ||||
| 
 | ||||
|                             onPressed: () async{ | ||||
|                               showDialog( | ||||
|                                 //if set to true allow to close popup by tapping out of the popup | ||||
|                                 //barrierDismissible: false, | ||||
|                                 context: context, | ||||
|                                 builder: (BuildContext context) => AlertDialog( | ||||
|                                   title: const Text('Do you want In_Active Offer??', | ||||
|                                       style: TextStyle( | ||||
|                                         color: primaryColor, | ||||
|                                         fontSize: 16, | ||||
|                                       )), | ||||
|                                   actionsAlignment: MainAxisAlignment.spaceBetween, | ||||
|                                   actions: [ | ||||
|                                     TextButton( | ||||
|                                       onPressed: ()async { | ||||
|                                         bool deleteOfferStatus = await AppSettings.deleteOffers(offersviewList[index].offer_code); | ||||
|                                         if(deleteOfferStatus){ | ||||
|                                           getOffersViewData(); | ||||
|                                           AppSettings.longSuccessToast('Offer In_Active Successfully!!'); | ||||
|                                           Navigator.of(context).pop(true); | ||||
| 
 | ||||
|                                         } | ||||
|                                         else{ | ||||
|                                           AppSettings.longFailedToast('Offer In_Active failed'); | ||||
|                                         } | ||||
|                                       }, | ||||
|                                       child: const Text('Yes', | ||||
|                                           style: TextStyle( | ||||
|                                             color: primaryColor, | ||||
|                                             fontSize: 18, | ||||
|                                           )), | ||||
|                                     ), | ||||
|                                     TextButton( | ||||
|                                       onPressed: () { | ||||
|                                         Navigator.of(context).pop(true); | ||||
|                                       }, | ||||
|                                       child: const Text('No', | ||||
|                                           style: TextStyle( | ||||
|                                             color: primaryColor, | ||||
|                                             fontSize: 18, | ||||
|                                           )), | ||||
|                                     ), | ||||
|                                   ], | ||||
|                                 ), | ||||
|                               ); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|                             }, | ||||
|                           ),) | ||||
| 
 | ||||
|                         ], | ||||
| 
 | ||||
|                       ), | ||||
|                     ), | ||||
|                   ); | ||||
|                 }) ), | ||||
|             Padding( | ||||
|               padding: EdgeInsets.fromLTRB(8, 8, 8, 8), | ||||
|               child: CircleAvatar( | ||||
|                 backgroundColor: primaryColor, | ||||
|                 radius: 40, | ||||
|                 child: Column( | ||||
|                   mainAxisSize: MainAxisSize.min, | ||||
|                   children: <Widget>[ | ||||
|                     IconButton( | ||||
|                       iconSize: 40, | ||||
|                       icon: const Icon( | ||||
|                         Icons.add, | ||||
|                         color: Colors.white, | ||||
|                       ), | ||||
|                       onPressed: () async{ | ||||
|                         Navigator.pop(context); | ||||
|                         await Navigator.push( | ||||
|                           context, | ||||
|                           MaterialPageRoute( | ||||
|                               builder: (context) => offers()), | ||||
|                         ); | ||||
|                         //showBoreAddingDialog(); | ||||
|                       }, | ||||
|                     ), | ||||
|                     /* Padding( | ||||
|                       padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | ||||
|                       child: Text( | ||||
|                         'Add Tanks ', | ||||
|                         style: TextStyle(color: Colors.white), | ||||
|                       ), | ||||
|                     )*/ | ||||
|                   ], | ||||
|                 ), | ||||
|               ), | ||||
|             ), | ||||
|           ]); | ||||
|     } | ||||
|     else{ | ||||
|       return  Center( | ||||
|           child: Padding( | ||||
|             padding: EdgeInsets.fromLTRB(0, 40, 0, 0), | ||||
|             child: Column( | ||||
|               crossAxisAlignment: CrossAxisAlignment.center, | ||||
|               children: [ | ||||
|                 SizedBox(height: MediaQuery.of(context).size.height * .25,), | ||||
|                 Text('Click below icon to add new Offer'), | ||||
|                 SizedBox( | ||||
|                   height: 20, | ||||
|                 ), | ||||
|                 CircleAvatar( | ||||
|                   backgroundColor: primaryColor, | ||||
|                   radius: 40, | ||||
|                   child: IconButton( | ||||
|                     iconSize: 40, | ||||
|                     icon: const Icon( | ||||
|                       Icons.add, | ||||
|                       color: Colors.white, | ||||
|                     ), | ||||
|                     onPressed: () async { | ||||
|                       Navigator.pop(context); | ||||
|                       await Navigator.push( | ||||
|                         context, | ||||
|                         MaterialPageRoute( | ||||
|                             builder: (context) => offers()), | ||||
|                       ); | ||||
|                     }, | ||||
|                   ), | ||||
|                 ) | ||||
|               ], | ||||
|             ), | ||||
|           ) | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return SafeArea( | ||||
|         child: Scaffold( | ||||
|           appBar: AppSettings.appBar('Active OfersView'), | ||||
|           body: isLoading?Center( | ||||
|             child: CircularProgressIndicator( | ||||
|               color: primaryColor, | ||||
|               strokeWidth: 5.0, | ||||
|             ), | ||||
|           ):renderzUi(), | ||||
|         )); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,329 @@ | ||||
| 
 | ||||
| import 'package:flutter/cupertino.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:flutter/services.dart'; | ||||
| import 'package:healthcare_pharmacy/dashboard.dart'; | ||||
| import 'package:healthcare_pharmacy/settings.dart'; | ||||
| import 'package:image_picker/image_picker.dart'; | ||||
| import 'dart:io'; | ||||
| 
 | ||||
| 
 | ||||
| class UpdateProfile extends StatefulWidget { | ||||
|   const UpdateProfile({Key? key}) : super(key: key); | ||||
|   @override | ||||
|   State<UpdateProfile> createState() => _UpdateprofileState(); | ||||
| } | ||||
| 
 | ||||
| class _UpdateprofileState extends State<UpdateProfile> { | ||||
| 
 | ||||
|   bool isPwdObscureText=true; | ||||
|   bool isConfirmPwdObscureText=true; | ||||
|   TextEditingController nameController = TextEditingController(); | ||||
|   TextEditingController emailController = TextEditingController(); | ||||
|   TextEditingController mobileNumberController = TextEditingController(); | ||||
|   TextEditingController descriptionController = TextEditingController(); | ||||
| 
 | ||||
| 
 | ||||
|   @override | ||||
|   void initState() { | ||||
|     isPwdObscureText=true; | ||||
|     isConfirmPwdObscureText=true; | ||||
|     nameController.text=AppSettings.pharmacyName; | ||||
|     mobileNumberController.text=AppSettings.phoneNumber; | ||||
|     emailController.text=AppSettings.email; | ||||
|     descriptionController.text=AppSettings.pharmacyDescription; | ||||
| 
 | ||||
|     super.initState(); | ||||
|   } | ||||
|   final ImagePicker _picker = ImagePicker(); | ||||
|   Future pickImageFromGallery() async { | ||||
|     try { | ||||
|       final image = await _picker.pickImage(source: ImageSource.gallery); | ||||
|       if (image == null) return; | ||||
|       final imageTemp = File(image.path); | ||||
|       setState(() { | ||||
|         AppSettings.updatedImage = imageTemp; | ||||
|       }); | ||||
|       //uploadProfileApi(AppSettings.updatedImage); | ||||
|       AppSettings.saveProfile(image.path); | ||||
| 
 | ||||
| 
 | ||||
|     } on PlatformException catch (e) { | ||||
|       print('Failed to pick image: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future takeImageFromCamera() async { | ||||
|     try { | ||||
|       final image = await _picker.pickImage(source: ImageSource.camera); | ||||
|       if (image == null) return; | ||||
|       final imageTemp = File(image.path); | ||||
|       setState(() { | ||||
|         AppSettings.updatedImage = imageTemp; | ||||
|       }); | ||||
| 
 | ||||
|      // uploadProfileApi(AppSettings.updatedImage); | ||||
|       AppSettings.saveProfile(image.path); | ||||
| 
 | ||||
|     } on PlatformException catch (e) { | ||||
|       print('Failed to pick image: $e'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
| 
 | ||||
|     return Scaffold( | ||||
|         appBar:AppSettings.appBar('Edit Profile'), | ||||
|         body: Stack(children: <Widget>[ | ||||
|           Container( | ||||
|             decoration: const BoxDecoration( | ||||
|              /* image: DecorationImage( | ||||
|                 image: AssetImage("images/backgroundimage.png"), | ||||
|                 fit: BoxFit.cover, | ||||
|               ),*/ | ||||
|             ), | ||||
|           ), | ||||
|           GestureDetector( | ||||
|             onTap: () { | ||||
|               FocusScope.of(context).requestFocus(new FocusNode()); | ||||
|             }, | ||||
|             child: SafeArea( | ||||
|                 child: SingleChildScrollView( | ||||
|                   child: Column( | ||||
|                     children: <Widget>[ | ||||
|                       SizedBox( | ||||
|                         height: 40, | ||||
|                       ), | ||||
|                       /*Container( | ||||
|                           child: Image( | ||||
|                             image: AssetImage('images/logo.png'), | ||||
|                             height: MediaQuery.of(context).size.height * .10, | ||||
|                           )),*/ | ||||
|                       Container(child:  GestureDetector( | ||||
|                         child: Container( | ||||
|                           width: MediaQuery.of(context).size.width * .60, | ||||
|                           height: | ||||
|                           MediaQuery.of(context).size.height * .15, | ||||
|                           decoration: BoxDecoration( | ||||
|                               shape: BoxShape.rectangle, | ||||
|                               border: Border.all(width: 5, color: Colors.blueGrey), | ||||
|                               image: DecorationImage( | ||||
|                                   image: (AppSettings.updatedImage != | ||||
|                                       null) | ||||
|                                       ? FileImage( | ||||
|                                       AppSettings.updatedImage!) | ||||
|                                   as ImageProvider | ||||
|                                       : AssetImage( | ||||
|                                       "images/mobilebg.png"), // picked file | ||||
|                                   fit: BoxFit.cover)), | ||||
|                         ), | ||||
|                         onTap: () { | ||||
|                           showModalBottomSheet<void>( | ||||
|                               context: context, | ||||
|                               builder: (BuildContext context) { | ||||
|                                 return SizedBox( | ||||
|                                   height: 200, | ||||
|                                   child: Center( | ||||
|                                     child: Row( | ||||
|                                       mainAxisAlignment: | ||||
|                                       MainAxisAlignment.center, | ||||
|                                       children: <Widget>[ | ||||
|                                         GestureDetector( | ||||
|                                           child: Icon( | ||||
|                                             Icons.camera_alt_outlined, | ||||
|                                             size: 100, | ||||
|                                             color: greyColor, | ||||
|                                           ), | ||||
|                                           onTap: () async { | ||||
|                                             await takeImageFromCamera(); | ||||
|                                             Navigator.pop(context); | ||||
|                                           }, | ||||
|                                         ), | ||||
|                                         SizedBox( | ||||
|                                           width: MediaQuery.of(context) | ||||
|                                               .size | ||||
|                                               .width * | ||||
|                                               .20, | ||||
|                                         ), | ||||
|                                         GestureDetector( | ||||
|                                           child: Icon( | ||||
|                                             Icons.photo, | ||||
|                                             size: 100, | ||||
|                                             color: greyColor, | ||||
|                                           ), | ||||
|                                           onTap: () async { | ||||
|                                             await pickImageFromGallery(); | ||||
|                                             Navigator.pop(context); | ||||
|                                           }, | ||||
|                                         ), | ||||
|                                       ], | ||||
|                                     ), | ||||
|                                   ), | ||||
|                                 ); | ||||
|                               }); | ||||
|                         }, | ||||
|                       ),), | ||||
|                       SizedBox( | ||||
|                         height: 10, | ||||
|                       ), | ||||
|                       Container( | ||||
|                         padding: const EdgeInsets.all(10), | ||||
|                         child: TextFormField( | ||||
|                           cursorColor: greyColor, | ||||
|                           controller: nameController, | ||||
|                           decoration: const InputDecoration( | ||||
|                             prefixIcon: Icon( | ||||
|                               Icons.person, | ||||
|                               color: greyColor, | ||||
|                             ), | ||||
|                             border: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: greyColor)), | ||||
|                             focusedBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             enabledBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             labelText: 'Username', | ||||
|                             labelStyle: TextStyle( | ||||
|                               color: greyColor, //<-- SEE HERE | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), | ||||
|                       ),//name | ||||
|                       const SizedBox( | ||||
|                         height: 15, | ||||
|                       ), | ||||
|                       Container( | ||||
|                         padding: const EdgeInsets.all(10), | ||||
|                         child: TextFormField( | ||||
|                           cursorColor: greyColor, | ||||
|                           controller: emailController, | ||||
|                           decoration: const InputDecoration( | ||||
|                             prefixIcon: Icon( | ||||
|                               Icons.email, | ||||
|                               color: greyColor, | ||||
|                             ), | ||||
|                             border: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: greyColor)), | ||||
|                             focusedBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             enabledBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             labelText: 'Enter email ID', | ||||
|                             labelStyle: TextStyle( | ||||
|                               color: greyColor, //<-- SEE HERE | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), | ||||
|                       ), //email | ||||
|                       SizedBox( | ||||
|                         height: 10, | ||||
|                       ), | ||||
|                       Container( | ||||
|                         padding: const EdgeInsets.all(10), | ||||
|                         child: TextFormField( | ||||
|                           cursorColor: greyColor, | ||||
|                           readOnly: true, | ||||
|                           controller: mobileNumberController, | ||||
|                           decoration: const InputDecoration( | ||||
|                             prefixIcon: Icon( | ||||
|                               Icons.phone_android, | ||||
|                               color: greyColor, | ||||
|                             ), | ||||
|                             border: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: greyColor)), | ||||
|                             focusedBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             enabledBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             labelText: 'Enter Mobile Number', | ||||
|                             labelStyle: TextStyle( | ||||
|                               color: greyColor, //<-- SEE HERE | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), | ||||
|                       ), //mobile | ||||
|                       SizedBox( | ||||
|                         height: 10, | ||||
|                       ), | ||||
|                       Container( | ||||
|                         padding: const EdgeInsets.all(10), | ||||
|                         child: TextFormField( | ||||
|                           cursorColor: greyColor, | ||||
|                           controller: descriptionController, | ||||
|                           keyboardType: TextInputType.multiline, | ||||
|                           maxLines: null, | ||||
|                           decoration: const InputDecoration( | ||||
|                             prefixIcon: Icon( | ||||
|                               Icons.description, | ||||
|                               color:greyColor, | ||||
|                             ), | ||||
|                             contentPadding: const EdgeInsets.symmetric(vertical: 60.0, horizontal: 30.0), | ||||
|                             border: OutlineInputBorder( | ||||
|                                 borderSide: BorderSide(color: greyColor)), | ||||
|                             focusedBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             enabledBorder: OutlineInputBorder( | ||||
|                               borderSide: BorderSide(color: greyColor), | ||||
|                             ), | ||||
|                             labelText: 'Enter Description', | ||||
|                             labelStyle: TextStyle( | ||||
|                               color: greyColor, //<-- SEE HERE | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), | ||||
|                       ), | ||||
|                       SizedBox( | ||||
|                         height: 10, | ||||
|                       ), | ||||
| 
 | ||||
|                       Container( | ||||
|                           width: 400, | ||||
|                           height: 55, | ||||
|                           padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), | ||||
|                           child: ElevatedButton( | ||||
|                             style: ElevatedButton.styleFrom( | ||||
|                               primary: buttonColor,// background | ||||
|                               onPrimary: Colors.white,// foreground | ||||
|                             ), | ||||
|                             onPressed: () async{ | ||||
|                               var payload = new Map<String, dynamic>(); | ||||
|                               payload["pharmacyname"] = nameController.text.toString(); | ||||
|                               payload["phone"] = mobileNumberController.text.toString(); | ||||
|                               payload["emails"] = [{"email":emailController.text.toString()}]; | ||||
|                               payload["description"] = descriptionController.text.toString(); | ||||
|                               bool signUpStatus = await AppSettings.updatePharmaData(payload); | ||||
|                               try{ | ||||
|                                 if (signUpStatus) { | ||||
|                                   Navigator.pop(context); | ||||
|                                   Navigator.push( | ||||
|                                     context, | ||||
|                                     MaterialPageRoute(builder: (context) => Dashboard()), | ||||
|                                   ); | ||||
|                                   AppSettings.longSuccessToast("Pharmacy Profile  Updated !!"); | ||||
|                                 } else { | ||||
|                                   AppSettings.longFailedToast("Pharmacy Profile Not Updated !!"); | ||||
|                                 } | ||||
|                               } | ||||
|                               catch(exception){ | ||||
|                                 print(exception); | ||||
|                                 AppSettings.longFailedToast("Please enter valid details"); | ||||
|                               } | ||||
|                             }, | ||||
|                             child: Text('Update'), | ||||
|                           ) | ||||
|                       ), | ||||
|                     ], | ||||
|                   ), | ||||
|                 )), | ||||
|           ), | ||||
|         ])); | ||||
|   } | ||||
| } | ||||