From a2c3141e67b245dc6f104c59f42ac22d150448fb Mon Sep 17 00:00:00 2001 From: suresh Date: Mon, 18 Dec 2023 14:20:47 +0530 Subject: [PATCH] Code updated --- android/app/build.gradle | 8 - lib/ZoomedImageView.dart | 51 + lib/adddeliveryboy.dart | 430 ++++++ lib/approvedoffers.dart | 369 +++++ lib/biddingrequests.dart | 110 +- lib/companyoffrers.dart | 28 +- lib/createoffers.dart | 313 +++-- lib/dashboard.dart | 352 +++-- lib/getalloffers.dart | 271 ++++ lib/getallpharmacies.dart | 28 +- lib/getdeliveryboydata.dart | 501 +++++++ lib/getmedicines.dart | 2 +- lib/inactiveoffersview.dart | 14 +- lib/invitations.dart | 173 +++ lib/medicinecart.dart | 199 ++- lib/medicinedetailspage.dart | 109 +- lib/models/addoffer_model.dart | 69 + lib/models/approvedoffer_model.dart | 69 + lib/models/biddingrequest_model.dart | 36 +- lib/models/getdeliveryboy_model.dart | 30 + lib/models/offersview_model.dart | 89 +- lib/models/pharmacy_accounts_model.dart | 60 + lib/offerstabdata.dart | 1232 +++++++++++------ lib/offersview.dart | 13 +- lib/pharmacyaccounts.dart | 509 +++++++ lib/qrcode_display.dart | 124 ++ lib/settings.dart | 407 ++++-- lib/signup.dart | 42 + lib/updateprofile.dart | 20 +- lib/viewpager.dart | 966 +++++++++++++ lib/zoomable_image.dart | 40 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.lock | 95 +- pubspec.yaml | 13 +- 34 files changed, 5723 insertions(+), 1051 deletions(-) create mode 100644 lib/ZoomedImageView.dart create mode 100644 lib/adddeliveryboy.dart create mode 100644 lib/approvedoffers.dart create mode 100644 lib/getalloffers.dart create mode 100644 lib/getdeliveryboydata.dart create mode 100644 lib/invitations.dart create mode 100644 lib/models/addoffer_model.dart create mode 100644 lib/models/approvedoffer_model.dart create mode 100644 lib/models/getdeliveryboy_model.dart create mode 100644 lib/models/pharmacy_accounts_model.dart create mode 100644 lib/pharmacyaccounts.dart create mode 100644 lib/qrcode_display.dart create mode 100644 lib/viewpager.dart create mode 100644 lib/zoomable_image.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index e1d5ca5..a8d9421 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -34,14 +34,6 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.arminta.healthcare_pharmacy" diff --git a/lib/ZoomedImageView.dart b/lib/ZoomedImageView.dart new file mode 100644 index 0000000..2084090 --- /dev/null +++ b/lib/ZoomedImageView.dart @@ -0,0 +1,51 @@ + + + + +import 'package:flutter/material.dart'; +import 'package:healthcare_pharmacy/settings.dart'; +import 'package:photo_view/photo_view.dart'; + + +class ZoomedImageView extends StatelessWidget { + final String imageUrl; + + ZoomedImageView({required this.imageUrl}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primaryColor, // Set the background color + title: Text('Preview Image'), // Set the title text + actions: [ + IconButton( + icon: Icon(Icons.close), + onPressed: () { + Navigator.pop(context); + }, + ), + ], + ), + + body: GestureDetector( + onTap: () { + Navigator.pop(context); + }, + child: Center( + child: Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + child: PhotoView( + imageProvider: NetworkImage(imageUrl), + maxScale: PhotoViewComputedScale.contained * 4.0, + minScale: PhotoViewComputedScale.contained, + initialScale: PhotoViewComputedScale.contained, + basePosition: Alignment.center, + ), + ), + ), + ), + ); + } +} diff --git a/lib/adddeliveryboy.dart b/lib/adddeliveryboy.dart new file mode 100644 index 0000000..b531a96 --- /dev/null +++ b/lib/adddeliveryboy.dart @@ -0,0 +1,430 @@ + +import 'package:flutter/material.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:healthcare_pharmacy/dashboard.dart'; +import 'package:healthcare_pharmacy/keys.dart'; +import 'package:healthcare_pharmacy/settings.dart'; +import 'package:flutter/services.dart'; +import 'dart:io' show File, Platform; +import 'package:google_maps_flutter_android/google_maps_flutter_android.dart'; +import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; +import 'package:location/location.dart' as locationmap; +import 'google_maps_place_picker_mb/src/models/pick_result.dart'; +import 'google_maps_place_picker_mb/src/place_picker.dart'; + +class Deliverboy extends StatefulWidget { + const Deliverboy({Key? key}) : super(key: key); + + @override + State createState() => _deliverboyState(); +} + +class _deliverboyState extends State { + + TextEditingController pharmacyNameController = TextEditingController(); + TextEditingController deliverNameController = TextEditingController(); + TextEditingController deliveryPhoneNumberController = TextEditingController(); + TextEditingController deliveryAlternativePhoneNumberController = TextEditingController(); + TextEditingController deliveryAddressCapturingController = TextEditingController(); + + + String _currentAddress =''; + String address1 = ''; + String address2 = ''; + String city = ''; + String state = ''; + String zip = ''; + String status = ''; + double lat=0; + double lng=0; + + PickResult? selectedPlace; + + bool _mapsInitialized = false; + final String _mapsRenderer = "latest"; + + var kInitialPosition = const LatLng(15.462477, 78.717401); + + locationmap.Location location = locationmap.Location(); + + final GoogleMapsFlutterPlatform mapsImplementation = + GoogleMapsFlutterPlatform.instance; + + void initRenderer() { + if (_mapsInitialized) return; + if (mapsImplementation is GoogleMapsFlutterAndroid) { + switch (_mapsRenderer) { + case "legacy": + (mapsImplementation as GoogleMapsFlutterAndroid) + .initializeWithRenderer(AndroidMapRenderer.legacy); + break; + case "latest": + (mapsImplementation as GoogleMapsFlutterAndroid) + .initializeWithRenderer(AndroidMapRenderer.latest); + break; + } + } + setState(() { + _mapsInitialized = true; + }); + } + + + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar:AppSettings.appBar('Add Deliveryboy'), + body: SafeArea( + child: SingleChildScrollView( + child: Column( + children: [ + const SizedBox( + height: 15, + ), + Container( + height: MediaQuery.of(context).size.height * .15, + width: double.infinity, + child: Image( + image: const AssetImage('images/logo.png'), + height: MediaQuery.of(context).size.height * .25, + )), + + const SizedBox( + height: 15, + ), + Container( + //padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), + padding: const EdgeInsets.all(10), + child: TextFormField( + cursorColor: greyColor, + controller: pharmacyNameController, + textCapitalization: TextCapitalization.characters, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.propane_tank, + color: greyColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'Enter pharmacy name', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), //tanker name + ), + + + const SizedBox( + height: 15, + ), + Container( + //padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), + padding: const EdgeInsets.all(10), + child: TextFormField( + cursorColor: greyColor, + controller: deliverNameController, + textCapitalization: TextCapitalization.characters, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.propane_tank, + color: greyColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'Enter deliveryboy name', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), //tanker name + ), + const SizedBox( + height: 5, + ), + Container( + padding: const EdgeInsets.all(10), + child: TextFormField( + cursorColor: greyColor, + controller: deliveryPhoneNumberController, + keyboardType: TextInputType.number, + maxLength: 10, + 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 phone number', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + ), //phone number + const SizedBox( + height: 5, + ), + + Container( + padding: const EdgeInsets.all(10), + child: TextFormField( + cursorColor: greyColor, + controller: deliveryAlternativePhoneNumberController, + keyboardType: TextInputType.number, + maxLength: 10, + 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 alternative phone number', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + ), //alternative phone number + const SizedBox( + height: 5, + ), + + + GestureDetector( + child:Container( + padding: const EdgeInsets.all(10), + child: TextFormField( + cursorColor: greyColor, + controller: deliveryAddressCapturingController, + onTap:() + { + + //============================================================================================= + location.serviceEnabled().then((value) { + if (value) { + initRenderer(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return PlacePicker( + resizeToAvoidBottomInset: false, + hintText: "Find a place ...", + searchingText: "Please wait ...", + selectText: "Select place", + outsideOfPickAreaText: "Place not in area", + initialPosition: kInitialPosition, + useCurrentLocation: true, + selectInitialPosition: true, + usePinPointingSearch: true, + usePlaceDetailSearch: true, + zoomGesturesEnabled: true, + zoomControlsEnabled: true, + onMapCreated: (GoogleMapController controller) {}, + onPlacePicked: (PickResult result) { + setState(() { + selectedPlace = result; + lat=selectedPlace!.geometry!.location.lat; + lng=selectedPlace!.geometry!.location.lng; + if(selectedPlace!.types!.length==1){ + deliveryAddressCapturingController.text = + selectedPlace!.formattedAddress!; + } + else{ + deliveryAddressCapturingController.text =selectedPlace!.name!+', '+selectedPlace!.formattedAddress!; + } + Navigator.of(context).pop(); + }); + }, + onMapTypeChanged: (MapType mapType) {}, + apiKey: Platform.isAndroid + ? APIKeys.androidApiKey + : APIKeys.iosApiKey, + forceAndroidLocationManager: true, + ); + }, + ), + ); + } else { + showGeneralDialog( + context: context, + pageBuilder: (context, x, y) { + return Scaffold( + backgroundColor: Colors.grey.withOpacity(.5), + body: Center( + child: Container( + width: double.infinity, + height: 150, + padding: + const EdgeInsets.symmetric(horizontal: 20), + child: Card( + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + "Please enable the location", + style: TextStyle( + fontSize:18, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox( + height: 20, + ), + ElevatedButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text("Cancel"), + ), + ], + ), + ), + ), + ), + ), + ); + }, + ); + } + }); + + //===================================================================================== + + // _getCurrentPosition(); + }, + keyboardType: TextInputType.streetAddress, + readOnly: false, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.location_on_rounded, + color: greyColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'select address from MAP', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + + ), + ), + /* onTap: () + { + },*///address + ), + + + + const SizedBox( + height: 5, + ), + Container( + width: MediaQuery.of(context).size.width * .99, + height: 50, + padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + + if (deliverNameController.text != '' && + deliveryPhoneNumberController.text != '' + ) { + AppSettings.preLoaderDialog(context); + + var payload = new Map(); + payload["pharmacyname"] = pharmacyNameController.text.toString(); + payload["Name"] = deliverNameController.text.toString(); + payload["phone"] = deliveryPhoneNumberController.text.toString(); + payload["alternativeContactNumber"] = deliveryAlternativePhoneNumberController.text.toString(); + payload["address"] = deliveryAddressCapturingController.text; + payload["city"] = city; + payload["state"] = state; + payload["zip"] = zip; + payload["latitude"] = lat; + payload["longitude"] = lng; + payload["status"] = status; + bool deliveryboyStatus = await AppSettings.addDeliverboy(payload); + + try { + if (deliveryboyStatus) { + AppSettings.longSuccessToast( + "Deliverboy Created Successfully"); + deliverNameController.text= ''; + deliveryPhoneNumberController.text= ''; + deliveryAlternativePhoneNumberController.text= ''; + Navigator.of(context,rootNavigator: true).pop(); + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const Dashboard()), + ); + + } else { + Navigator.of(context,rootNavigator: true).pop(); + AppSettings.longFailedToast("Deliverboy not Created Successfully"); + } + } catch (exception) { + print(exception); + } + } + else { + AppSettings.longFailedToast("Please enter valid details"); + } + }, + + child: const Text( + 'Add Deliverboy', + style: TextStyle( + fontSize: 25, + ), + ), + )), + + ], + ), + )), + ); + } +} diff --git a/lib/approvedoffers.dart b/lib/approvedoffers.dart new file mode 100644 index 0000000..5c909a9 --- /dev/null +++ b/lib/approvedoffers.dart @@ -0,0 +1,369 @@ +import 'dart:convert'; +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:geolocator/geolocator.dart'; +import 'package:healthcare_pharmacy/createoffers.dart'; +import 'package:healthcare_pharmacy/getmedicines.dart'; +import 'package:healthcare_pharmacy/models/approvedoffer_model.dart'; +import 'package:healthcare_pharmacy/models/biddingrequest_model.dart'; +import 'package:healthcare_pharmacy/settings.dart'; + +import 'package:image_picker/image_picker.dart'; +import 'package:photo_view/photo_view.dart'; + +class ApprovedOffersData extends StatefulWidget { + const ApprovedOffersData({Key? key}) : super(key: key); + + @override + State createState() => _ApprovedOffersDataState(); +} + +class _ApprovedOffersDataState extends State { + bool isOfferDataLoading=false; + bool isSereverIssue = false; + bool isSereverIssueConnected = false; + bool isSereverIssuePending = false; + List approvedOffersList = []; + final ImagePicker _picker = ImagePicker(); + bool isActiveDataLoading=false; + + + + Future getApprovedOffersViewData() async { + isActiveDataLoading = true; + try { + var data = await AppSettings.getApprovedOffers(); + setState(() { + List responseData = jsonDecode(data)['data']; + approvedOffersList = responseData + .map((jsonObject) => GetApprovedOffersDetailsModel.fromJson(jsonObject)) + .toList(); + isActiveDataLoading = false; + }); + + } catch (error) { + setState(() { + isActiveDataLoading = false; + isSereverIssueConnected = true; + }); + } + } + + + + @override + void initState() { + getApprovedOffersViewData(); + super.initState(); + } + + showPicDialog(var imageUrl){ + return showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return AlertDialog( + title: const Text(''), + content: SingleChildScrollView( + child: ListBody( + children: [ + Container( + width: MediaQuery.of(context).size.width * .10, + height: MediaQuery.of(context).size.height * .50, + child: PhotoView( + imageProvider: NetworkImage(imageUrl) as ImageProvider, + maxScale: PhotoViewComputedScale.contained * 4.0, + minScale: PhotoViewComputedScale.contained, + initialScale: PhotoViewComputedScale.contained, + basePosition: Alignment.center, + + ) + ) + ], + ), + ), + actions: [ + TextButton( + child: Text('Close', style: textButtonStyle()), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }); + }, + ); + } + + + Widget renderzActiveUi(){ + if(approvedOffersList.length!=0){ + + return Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded(child:ListView.builder( + padding: EdgeInsets.all(0), + itemCount: approvedOffersList .length, + itemBuilder: (context,index){ + var data=approvedOffersList[index]; + return GestureDetector( + onTap: () { + + }, + child: Card( + child: ListTile( + leading: GestureDetector( + onTap: () { + showPicDialog(approvedOffersList[index].picture[0].url); + }, + child: Container( + width: 100, + height: 300, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + image: DecorationImage( + fit: BoxFit.cover, + alignment: Alignment.center, + image: data.picture.isEmpty + ? AssetImage('images/logo.png') as ImageProvider + : NetworkImage(approvedOffersList[index].picture[0].url), + ), + ), + ), + ), + + + title: RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Name: ', + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: approvedOffersList[index].offer_name, + style: TextStyle( + color: primaryColor, + ), + ), + ], + ), + ), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // ... (other RichText widgets for Code, Description, Start Date, End Date) + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Code: ', + style: TextStyle( + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), + ), + TextSpan( + text: approvedOffersList[index].offer_code, + style: TextStyle( + color: primaryColor, // Change the color for description content + ), + ), + ], + ), + ), + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Description: ', + style: TextStyle( + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), + ), + TextSpan( + text: approvedOffersList[index].description, + style: TextStyle( + color:primaryColor, // Change the color for description content + ), + ), + ], + ), + ), + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Category: ', + style: TextStyle( + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), + ), + TextSpan( + text: approvedOffersList[index].category, + style: TextStyle( + color:primaryColor, // Change the color for description content + ), + ), + ], + ), + ), + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Start Date: ', + style: TextStyle( + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), + ), + TextSpan( + text: approvedOffersList[index].starting_date, + + style: TextStyle( + color:primaryColor, // Change the color for description content + ), + ), + ], + ), + ), + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'End Date :', + style: TextStyle( + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), + ), + TextSpan( + text: approvedOffersList[index].ending_date, + style: TextStyle( + color:primaryColor, // Change the color for description content + ), + ), + ], + ), + ), + ], + ), + ), + ), + ); + + + + + + + }) ), + Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 8), + child: CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + 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('Approved Ofers'), + body: isActiveDataLoading?Center( + child: CircularProgressIndicator( + color: primaryColor, + strokeWidth: 5.0, + ), + ):renderzActiveUi(), + )); + } +} \ No newline at end of file diff --git a/lib/biddingrequests.dart b/lib/biddingrequests.dart index 8a799ec..d31043b 100644 --- a/lib/biddingrequests.dart +++ b/lib/biddingrequests.dart @@ -20,26 +20,39 @@ class BiddingRequests extends StatefulWidget { class _BiddingRequestsState extends State { String Url = ''; List prescriptionsList = []; - List prescriptionsListOriginal = []; bool isPrescriptionsDataLoading = false; bool isSereverIssue = false; bool isLoading=false; - - - Future getAllPrescriptions() async { isPrescriptionsDataLoading=true; try { var response = await AppSettings.getAllBiddingRecords(); - print(response); - setState(() { - prescriptionsList = - ((jsonDecode(response)['data']) as List).map((dynamic model) { - return BiddingRequestsModel.fromJson(model); - }).toList(); - isPrescriptionsDataLoading = false; - }); + /*for (var item in data) { + BiddingRequestsModel biddingRequestsModel=new BiddingRequestsModel(); + biddingRequestsModel.bidding_bookingid = item['bookingId']!; + biddingRequestsModel.pharmacyid_bidding = item['pharmacyId']!; + biddingRequestsModel.custumerid_bidding = item['customerId']!; + biddingRequestsModel.amount_bidding = item['biddingAmount']!.toString(); + + String? firstName = item['customerDetails']?['firstName']; + String? contactNumber = item['customerDetails']?['profile']?['contactNumber']; + + print('First Name: $firstName'); + + biddingRequestsModel.bidding_firstName = firstName ; // Provide a default value if firstName is null + + // biddingRequestsModel.bidding_contactNumber=contactNumber; + prescriptionsList.add(biddingRequestsModel); + }*/ + + setState(() { + prescriptionsList = + ((jsonDecode(response)['data']) as List).map((dynamic model) { + return BiddingRequestsModel.fromJson(model); + }).toList(); + isPrescriptionsDataLoading = false; + }); } catch (e) { setState(() { @@ -49,6 +62,10 @@ class _BiddingRequestsState extends State { } } + + + + @override void initState() { getAllPrescriptions(); @@ -154,11 +171,12 @@ class _BiddingRequestsState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text(prescriptionsList[index].bidding_firstName.toString().toUpperCase(),style: valuesTextStyle()), + //Text(prescriptionsList[index].bidding_contactNumber.toString().toUpperCase(),style: valuesTextStyle()), + Text(prescriptionsList[index].bidding_bookingid.toString().toUpperCase(),style: valuesTextStyle()), + Text(prescriptionsList[index].amount_bidding.toString().toUpperCase(),style: valuesTextStyle()), Text(prescriptionsList[index].custumerid_bidding.toString().toUpperCase(),style: valuesTextStyle()), Text(prescriptionsList[index].pharmacyid_bidding.toString().toUpperCase(),style: valuesTextStyle()), - Text(prescriptionsList[index].amount_bidding.toString().toUpperCase(),style: valuesTextStyle()), - Text(prescriptionsList[index].bidding_bookingid.toString().toUpperCase(),style: valuesTextStyle()), - ], ), @@ -166,8 +184,9 @@ class _BiddingRequestsState extends State { ), Visibility( - //visible:offersviewList[index].orderStatus.toString().toLowerCase()=='pending', - child: Column( + visible:true , + + child: prescriptionsList[index].status.toString().toLowerCase()=='pending'?Column( children: [ TextButton( child: Text( @@ -179,18 +198,20 @@ class _BiddingRequestsState extends State { ), onPressed: () async { var payload = new Map(); - payload["customerId"] = prescriptionsList[index].custumerid_bidding.toLowerCase(); - payload["pharmacyId"] =AppSettings.healthpharmaIdsign.toLowerCase(); + payload["pharmacyId"] =AppSettings.healthpharmaIdsign.toString(); + payload["action"] = "accept"; bool requestStatus = await AppSettings.getRequestBiddingDetails( - prescriptionsList[index].bidding_bookingid.toLowerCase(), + prescriptionsList[index].bidding_bookingid, payload); - if(requestStatus){ - AppSettings.longSuccessToast("Request Accepted Successfully"); + + if (requestStatus) { + // Navigator.of(context).pop(); + AppSettings.longSuccessToast( + "Booking Accepted"); await getAllPrescriptions(); - } - else{ - } + + } else {} }, ), @@ -203,15 +224,25 @@ class _BiddingRequestsState extends State { primaryColor /*FilteredList[index].text_color*/), ), onPressed: () async { + var payload = new Map(); + payload["pharmacyId"] =AppSettings.healthpharmaIdsign.toString(); + payload["action"] = "reject"; + bool requestStatus = + await AppSettings.getRequestBiddingDetails( + prescriptionsList[index].bidding_bookingid, + payload); + if (requestStatus) { + // Navigator.of(context).pop(); + AppSettings.longSuccessToast( + "Booking Rejected"); + await getAllPrescriptions(); - - - + } else {} }, ), ], - )) + ):Text(prescriptionsList[index].status)), ], @@ -243,18 +274,17 @@ class _BiddingRequestsState extends State { ]); } - 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,), - - ], + else { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'No Bidding Requests Available', + style: TextStyle(fontSize: 18), ), - ) + ], + ), ); } } diff --git a/lib/companyoffrers.dart b/lib/companyoffrers.dart index 8427972..e9ec3af 100644 --- a/lib/companyoffrers.dart +++ b/lib/companyoffrers.dart @@ -12,7 +12,11 @@ import 'package:image_picker/image_picker.dart'; class CompanyOffers extends StatefulWidget { - const CompanyOffers({Key? key}) : super(key: key); + var phid; + + CompanyOffers({ + this.phid + }); @override State createState() => _CompanyOffersState(); @@ -30,8 +34,16 @@ class _CompanyOffersState extends State { var selIOS; final ImagePicker _picker = ImagePicker(); String offerUrl=''; + String medphid=""; - + @override + void initState() { + // TODO: implement initState + super.initState(); + medphid = widget.phid.toString(); + medphid = medphid.replaceAll('[', '').replaceAll(']', ''); + eligiblepharma_Controller.text = medphid; + } Future pickImageFromGallery() async { @@ -244,6 +256,7 @@ class _CompanyOffersState extends State { padding: const EdgeInsets.all(10), child: TextFormField( cursorColor: greyColor, + readOnly: true, controller: eligiblepharma_Controller, textCapitalization: TextCapitalization.characters, decoration: const InputDecoration( @@ -416,17 +429,13 @@ class _CompanyOffersState extends State { ), onPressed: () async { if (offer_nameController.text != '' && - offer_codeController.text != '' && - descriptionController.text != ''&& - starting_dateController.text != '' && - ending_dateController.text != '') { + offer_codeController.text != '' ) { AppSettings.preLoaderDialog(context); - var payload = new Map(); payload["offer_name"] = offer_nameController.text.toString(); payload["offer_code"] = offer_codeController.text.toString(); payload["description"] = descriptionController.text.toString(); - payload["pharmacies_eligible"] = eligiblepharma_Controller.text.toString(); + payload["pharmacies_eligible"] = [eligiblepharma_Controller.text.toString()]; payload["starting_date"] = starting_dateController.text.toString(); payload["ending_date"] = ending_dateController.text.toString(); payload["offer_status"] ="active"; @@ -441,8 +450,7 @@ class _CompanyOffersState extends State { ); AppSettings.longSuccessToast("Company Offer Created Succesfully!!"); } else { - - AppSettings.longFailedToast("Fields should not be empty !!"); + AppSettings.longFailedToast("Fields should not be empty !!"); } } catch(exception){ diff --git a/lib/createoffers.dart b/lib/createoffers.dart index 9c041d6..ab307ea 100644 --- a/lib/createoffers.dart +++ b/lib/createoffers.dart @@ -5,9 +5,11 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:healthcare_pharmacy/dashboard.dart'; import 'package:healthcare_pharmacy/settings.dart'; +import 'package:healthcare_pharmacy/zoomable_image.dart'; import 'package:intl/intl.dart'; import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:image/image.dart' as Img; @@ -25,46 +27,81 @@ class _offersState extends State { TextEditingController descriptionController = TextEditingController(); TextEditingController starting_dateController = TextEditingController(); TextEditingController ending_dateController = TextEditingController(); + String dropdownTypeOfCategory = 'A {1 - 500}'; + var typeOfCategoryItems = [ + 'A {1 - 500}', + 'B {501 - 1000}', + 'C {1001 - 2000}', + 'D {Above 2000}', + 'S {Special offer}', + ]; var selIOS; final ImagePicker _picker = ImagePicker(); String offerUrl=''; + File? _imageFile; - - Future pickImageFromGallery() async { - + Future pickImageFromGallery() async { try { final image = await _picker.pickImage(source: ImageSource.gallery); if (image == null) return; - final imageTemp = File(image.path); + + final File imageFile = File(image.path); + + // Read the image from file + List imageBytes = await imageFile.readAsBytes(); + Img.Image? decodedImage = Img.decodeImage(imageBytes); + + // Compress the image + List compressedImage = Img.encodeJpg(decodedImage!, quality: 45); + + // Save the compressed image back to file + await imageFile.writeAsBytes(compressedImage); AppSettings.preLoaderDialog(context); - var res = await AppSettings.offeruploadImageHTTPNew(image); + var res = await AppSettings.offeruploadImageHTTPNew(imageFile); print(jsonDecode(res)); - Navigator.of(context, rootNavigator: true).pop(); + setState(() { - AppSettings.offerPictureUrl = jsonDecode(res)['picture']; + offerUrl = jsonDecode(res)['picture'][0]['url']; + print(offerUrl); }); - AppSettings.saveData('offer', jsonDecode(res)['picture'], 'STRING'); + + Navigator.of(context, rootNavigator: true).pop(); } 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); + + final File imageFile = File(image.path); + + // Read the image from file + List imageBytes = await imageFile.readAsBytes(); + Img.Image? decodedImage = Img.decodeImage(imageBytes); + + // Compress the image + List compressedImage = Img.encodeJpg(decodedImage!, quality: 45); + + // Save the compressed image back to file + await imageFile.writeAsBytes(compressedImage); + AppSettings.preLoaderDialog(context); - var res = await AppSettings.offeruploadImageHTTPNew(image); + var res = await AppSettings.offeruploadImageHTTPNew(imageFile); print(jsonDecode(res)); - Navigator.of(context, rootNavigator: true).pop(); + setState(() { - //AppSettings.offerPictureUrl = jsonDecode(res)['picture']['url']; - offerUrl=jsonDecode(res)['picture'][0]['url']; + offerUrl = jsonDecode(res)['picture'][0]['url']; + print(offerUrl); }); + + Navigator.of(context, rootNavigator: true).pop(); } on PlatformException catch (e) { print('Failed to pick image: $e'); } @@ -100,7 +137,7 @@ class _offersState extends State { image: (offerUrl!= ''&& offerUrl!= 'null') ? NetworkImage(offerUrl) as ImageProvider : AssetImage("images/mobilebg.png"), // picked file - fit: BoxFit.fitWidth)), + fit: BoxFit.cover)), ), onTap: () { showModalBottomSheet( @@ -145,15 +182,41 @@ class _offersState extends State { }); }, ),), + SizedBox( - height: 05, + height: 15, + ), + GestureDetector( + child: Container( + child: Center( + child: Text( + 'Preview Image', + style: TextStyle( + color: primaryColor, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ZoomableImage(offerUrl), + ), + ); + }, + ), + SizedBox( + height: 20, ), Container( padding: const EdgeInsets.all(10), child: TextFormField( cursorColor: greyColor, controller: offer_nameController, - textCapitalization: TextCapitalization.words, + textCapitalization: TextCapitalization.sentences, decoration: const InputDecoration( prefixIcon: Icon( Icons.person, @@ -182,7 +245,7 @@ class _offersState extends State { child: TextFormField( cursorColor: greyColor, controller: offer_codeController, - textCapitalization: TextCapitalization.words, + textCapitalization: TextCapitalization.sentences, decoration: const InputDecoration( prefixIcon: Icon( Icons.numbers, @@ -214,7 +277,7 @@ class _offersState extends State { child: TextFormField( cursorColor: greyColor, controller: descriptionController, - textCapitalization: TextCapitalization.words, + textCapitalization: TextCapitalization.sentences, keyboardType: TextInputType.multiline, maxLines: null, decoration: const InputDecoration( @@ -238,33 +301,63 @@ class _offersState extends State { ), ), ), - /* Container( - padding: const EdgeInsets.all(10), - child: TextFormField( - cursorColor: greyColor, - controller: descriptionController, - textCapitalization: TextCapitalization.characters, + + const SizedBox( + height: 30, + ), + + + Container( + padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), + child: DropdownButtonFormField( + // Initial Value + value: dropdownTypeOfCategory, + isExpanded: true, decoration: const InputDecoration( prefixIcon: Icon( - Icons.description, - color: primaryColor, + Icons.water, + color: greyColor, ), - contentPadding: const EdgeInsets.symmetric(vertical: 40.0, horizontal: 30.0), border: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor)), + borderSide: BorderSide(color: greyColor)), focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), + borderSide: BorderSide(color: greyColor), ), enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: primaryColor), + borderSide: BorderSide(color: greyColor), ), - labelText: 'Enter Offer Description', + labelText: 'Type of water storage', labelStyle: TextStyle( color: greyColor, //<-- SEE HERE ), ), + + hint: Text('Select Type of Category'), + // Down Arrow Icon + icon: const Icon(Icons.keyboard_arrow_down), + + // Array list of items + items: typeOfCategoryItems.map((String items) { + return DropdownMenuItem( + value: items, + child: Text(items), + ); + }).toList(), + // After selecting the desired option,it will + // change button value to selected value + onChanged: (String? newValue) { + setState(() { + dropdownTypeOfCategory = newValue!; + }); + }, ), - ),*/ //mobile + ), + + + + + + const SizedBox( height: 5, ), @@ -293,39 +386,43 @@ class _offersState extends State { Icons.date_range, ), onPressed: () async { - DatePicker.showDatePicker( - context, - dateFormat: 'dd MMMM yyyy', - 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 index)async { - DateTime selectdate = dateTime; - setState(() { - selIOS = DateFormat('dd-MMM-yyyy').format(selectdate); - }); - - if(selIOS!=''){ - setState(() { - starting_dateController.text=selIOS.toString(); - }); - } - else { - AppSettings.longFailedToast('please select date'); - } + DateTime? pickedDate = await showDatePicker( + context: context, + /* initialDate: DateTime.now(), + firstDate: DateTime(1950), + lastDate: DateTime.now(),*/ + initialDate: DateTime.now(), + firstDate: DateTime(1950), // Set the first selectable date to a past date + lastDate: DateTime(2100), // Set the last selectable date to a future date + builder: (BuildContext context, Widget? child) { + return Theme( + data: ThemeData.dark().copyWith( + colorScheme: ColorScheme.dark( + primary: buttonColors, + onPrimary: Colors.white, + surface: buttonColors, + onSurface: Colors.white, + ), + dialogBackgroundColor: primaryColor, + ), + child: child!, + ); }, ); + + if (pickedDate != null) { + print( + pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000 + String formattedDate = + DateFormat('dd-MM-yyyy').format(pickedDate); + print( + formattedDate); //formatted date output using intl package => 2021-03-16 + setState(() { + starting_dateController.text=formattedDate.toString(); + }); + } else {} }, + ), ), @@ -361,38 +458,38 @@ class _offersState extends State { Icons.date_range, ), onPressed: () async { - DatePicker.showDatePicker( - context, - dateFormat: 'dd MMMM yyyy', - 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 index)async { - DateTime selectdate = dateTime; - setState(() { - selIOS = DateFormat('dd-MMM-yyyy').format(selectdate); - }); - - if(selIOS!=''){ - setState(() { - ending_dateController.text=selIOS.toString(); - }); - } - else { - AppSettings.longFailedToast('please select date'); - } + DateTime? pickedDate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(1950), // Set the first selectable date to a past date + lastDate: DateTime(2100), // Set the last selectable date to a future date + builder: (BuildContext context, Widget? child) { + return Theme( + data: ThemeData.dark().copyWith( + colorScheme: ColorScheme.dark( + primary: buttonColors, + onPrimary: Colors.white, + surface: buttonColors, + onSurface: Colors.white, + ), + dialogBackgroundColor: primaryColor, + ), + child: child!, + ); }, ); + + if (pickedDate != null) { + print( + pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000 + String formattedDate = + DateFormat('dd-MM-yyyy').format(pickedDate); + print( + formattedDate); //formatted date output using intl package => 2021-03-16 + setState(() { + ending_dateController.text=formattedDate.toString(); + }); + } else {} }, ), @@ -401,6 +498,8 @@ class _offersState extends State { ), ),//address description + + const SizedBox( height:15, ), @@ -421,13 +520,30 @@ class _offersState extends State { ending_dateController.text != '') { AppSettings.preLoaderDialog(context); - var payload = new Map(); + /* var payload = new Map(); payload["offer_name"] = offer_nameController.text.toString(); payload["offer_code"] = offer_codeController.text.toString(); payload["description"] = descriptionController.text.toString();; payload["starting_date"] = starting_dateController.text.toString(); payload["ending_date"] = ending_dateController.text.toString(); + payload["picture"] = [offerUrl]; payload["offer_status"] ="active"; + print(payload);*/ + + Map payload = { + "offer_name": offer_nameController.text.toString(), + "offer_code": offer_codeController.text.toString(), + "description":descriptionController.text.toString(), + "starting_date":starting_dateController.text.toString(), + "ending_date": ending_dateController.text.toString(), + "category":dropdownTypeOfCategory.toString(), + "picture": [ + { + "url": offerUrl + } + ], + "offer_status": "active", + }; bool offerStatus = await AppSettings.createOffers(payload); try{ if (offerStatus) { @@ -439,22 +555,25 @@ class _offersState extends State { ); AppSettings.longSuccessToast("Offer Created Succesfully!!"); } else { - - AppSettings.longFailedToast("Fields should not be empty !!"); + Navigator.of(context,rootNavigator: true).pop(); + AppSettings.longFailedToast("Please enter all fields"); } } catch(exception){ print(exception); AppSettings.longFailedToast("Please enter valid details"); + Navigator.of(context,rootNavigator: true).pop(); } } else { AppSettings.longFailedToast("Offer Not Created!!"); - + Navigator.of(context,rootNavigator: true).pop(); } }, child: Text('Create'), )),//login button - + const SizedBox( + height: 10, + ), ], ), )), diff --git a/lib/dashboard.dart b/lib/dashboard.dart index e0e0905..74dd953 100644 --- a/lib/dashboard.dart +++ b/lib/dashboard.dart @@ -3,19 +3,25 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:healthcare_pharmacy/adddeliveryboy.dart'; import 'package:healthcare_pharmacy/companyoffrers.dart'; import 'package:healthcare_pharmacy/getallpharmacies.dart'; +import 'package:healthcare_pharmacy/getdeliveryboydata.dart'; import 'package:healthcare_pharmacy/getmedicines.dart'; import 'package:healthcare_pharmacy/inactiveoffersview.dart'; +import 'package:healthcare_pharmacy/invitations.dart'; import 'package:healthcare_pharmacy/medicinecart.dart'; import 'package:healthcare_pharmacy/createoffers.dart'; import 'package:healthcare_pharmacy/offerstabdata.dart'; import 'package:healthcare_pharmacy/offersview.dart'; import 'package:healthcare_pharmacy/biddingrequests.dart'; +import 'package:healthcare_pharmacy/pharmacyaccounts.dart'; +import 'package:healthcare_pharmacy/qrcode_display.dart'; import 'package:healthcare_pharmacy/updateprofile.dart'; import 'package:image_picker/image_picker.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'dart:ui' as ui; +import 'approvedoffers.dart'; import 'login.dart'; import 'seekopinion.dart'; import 'settings.dart'; @@ -248,12 +254,6 @@ class _DashboardState extends State { } } - - - - - - showLogoutAlertDialog(context) { return showDialog( context: context, @@ -337,105 +337,168 @@ class _DashboardState extends State { padding: EdgeInsets.zero, children: [ DrawerHeader( - decoration: const BoxDecoration( - color: primaryColor, - ), - child: Row( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - child: Container( - width: MediaQuery.of(context).size.width * .60, - height: - MediaQuery.of(context).size.height * .25, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - border: Border.all(width: 2 , color: Colors.blueGrey), - image: DecorationImage( - image: (AppSettings.profilePictureUrl != - '' && - AppSettings.profilePictureUrl != - 'null') - ? NetworkImage(AppSettings - .profilePictureUrl) - as ImageProvider - : AssetImage( - "images/mobilebg.png"), // picked file - fit: BoxFit.fitWidth)), + decoration: const BoxDecoration( + color: primaryColor, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded(child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + GestureDetector( + child: Container( + width: MediaQuery.of(context).size.width * .23, + height: + MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + + shape: BoxShape.rectangle, + image: DecorationImage( + image: (AppSettings.profilePictureUrl != + '' && + AppSettings.profilePictureUrl != + 'null') + ? NetworkImage(AppSettings + .profilePictureUrl) + as ImageProvider + : AssetImage( + "images/profile_pic.png"), + + fit:BoxFit.fitWidth // picked file ), - onTap: () { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return SizedBox( - height: 200, - child: Center( - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - 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); - }, - ), - ], - ), - ), - ); - }); - }, ), ), + onTap: () { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCamera(); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context) + .size + .width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGallery(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + ), + SizedBox( + width: 10, + ), - Text( - AppSettings.pharmacyName, - style: TextStyle(color: Colors.white, fontSize: 15), - ), - Text( - AppSettings.phoneNumber, - style: TextStyle(color: Colors.white, fontSize: 15), - ), - Text( - AppSettings.email, - style: TextStyle(color: Colors.white, fontSize: 15), - ), - SizedBox( - height: 10, + Container( + + child: AppSettings.qrCode==''?TextButton( + child: Text( + 'GetQR', + style: TextStyle( + fontSize: 15, + color: Colors.white, + decoration: TextDecoration.underline, + ), + ), + onPressed: () async{ + AppSettings.preLoaderDialog(context); + + try{ + var value = await AppSettings.generateQRCode(); + var valueResponse = jsonDecode(value); + String dataUri = jsonDecode(value)['qrCodeData']; + + List parts = dataUri.split(","); + String? base64String = parts.length == 2 ? parts[1] : null; + + if (base64String != null) { + + print(base64String); + AppSettings.qrCode=base64String; + } else { + print("Invalid data URI"); + } + Navigator.of(context, rootNavigator: true).pop(); + } + catch(e){ + Navigator.of(context, rootNavigator: true).pop(); + } + + + + }, + ):GestureDetector( + onTap: (){ + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const DisplayQrCode()), + ); + }, + child: Container( + height:MediaQuery.of(context).size.height * .20, + width:MediaQuery.of(context).size.width * .1, + child: Image.memory(Uint8List.fromList(base64.decode(AppSettings.qrCode))), + ), ), - ], - ), - Container() - ], + ) + ], + ),), + SizedBox( + height: 5, + ), + Text( + AppSettings.pharmacyName, + style: TextStyle(color: Colors.white, fontSize: 15), - )), + ), + Text( + AppSettings.phoneNumber, + style: TextStyle(color: Colors.white, fontSize: 15), + + ), + Visibility( + visible: AppSettings.email != '', + child: Text( + AppSettings.email, + style: TextStyle(color: Colors.white, fontSize: 15), + ), + ), + ], + ),), ListTile( title: Row( children: const [ @@ -624,6 +687,7 @@ class _DashboardState extends State { ); }, ), + Divider( color: Colors.grey, ), @@ -638,7 +702,7 @@ class _DashboardState extends State { const SizedBox( width: 10, ), - Text('BiddingRequests', style: TextStyle(color: Colors.black)), + Text('Approved Offers', style: TextStyle(color: Colors.black)), ], ), onTap: () { @@ -646,13 +710,37 @@ class _DashboardState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => BiddingRequests()), + builder: (context) => ApprovedOffersData()), ); + }, + ), + Divider( + color: Colors.grey, + ), + ListTile( + title: Row( + children: const [ + Image( + image: const AssetImage('images/inactive.png'), + height: 25, + width: 25, + fit: BoxFit.fill), + const SizedBox( + width: 10, + ), + Text('Add Delivery Boys', style: TextStyle(color: Colors.black)), + ], + ), + onTap: () { - - + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => Deliverboy()), + ); }, ), + Divider( color: Colors.grey, ), @@ -667,7 +755,7 @@ class _DashboardState extends State { const SizedBox( width: 10, ), - Text('Company Offers', style: TextStyle(color: Colors.black)), + Text('Deliveryboys View', style: TextStyle(color: Colors.black)), ], ), onTap: () { @@ -675,13 +763,64 @@ class _DashboardState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => CompanyOffers()), + builder: (context) => GetDeliveryboyData()), ); + }, + ), + /*Divider( + color: Colors.grey, + ), + ListTile( + title: Row( + children: const [ + Image( + image: const AssetImage('images/inactive.png'), + height: 25, + width: 25, + fit: BoxFit.fill), + const SizedBox( + width: 10, + ), + Text('Accounts', style: TextStyle(color: Colors.black)), + ], + ), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => PharmacyAccounts()), + ); + }, + ),*/ + Divider( + color: Colors.grey, + ), + ListTile( + title: Row( + children: const [ + Image( + image: const AssetImage('images/inactive.png'), + height: 25, + width: 25, + fit: BoxFit.fill), + const SizedBox( + width: 10, + ), + Text('BiddingRequests', style: TextStyle(color: Colors.black)), + ], + ), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => BiddingRequests()), + ); }, ), + Divider( color: Colors.grey, ), @@ -696,15 +835,14 @@ class _DashboardState extends State { const SizedBox( width: 10, ), - Text('GetAllPharmacies', style: TextStyle(color: Colors.black)), + Text('SendInvite', style: TextStyle(color: Colors.black)), ], ), onTap: () { - Navigator.push( context, MaterialPageRoute( - builder: (context) => GetAllPharmacies()), + builder: (context) => Invitations()), ); }, ), diff --git a/lib/getalloffers.dart b/lib/getalloffers.dart new file mode 100644 index 0000000..001e01c --- /dev/null +++ b/lib/getalloffers.dart @@ -0,0 +1,271 @@ +import 'dart:convert'; +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:geolocator/geolocator.dart'; +import 'package:healthcare_pharmacy/companyoffrers.dart'; +import 'package:healthcare_pharmacy/getmedicines.dart'; +import 'package:healthcare_pharmacy/maps/app_colors.dart'; +import 'package:healthcare_pharmacy/models/addoffer_model.dart'; +import 'package:healthcare_pharmacy/models/biddingrequest_model.dart'; +import 'package:healthcare_pharmacy/models/companyoffer_model.dart'; +import 'package:healthcare_pharmacy/settings.dart'; + +import 'package:image_picker/image_picker.dart'; +import 'package:photo_view/photo_view.dart'; + +class GetAllOffers extends StatefulWidget { + const GetAllOffers({Key? key}) : super(key: key); + + @override + State createState() => _GetAllOffersState(); +} + +class _GetAllOffersState extends State { + String Url = ''; + List offersList = []; + List prescriptionsListOriginal = []; + bool isPrescriptionsDataLoading = false; + bool isSereverIssue = false; + bool isLoading=false; + List checked = []; + + + Future getActiveOffersViewData() async { + isLoading = true; + + + try { + var data = await AppSettings.getOffers(); + setState(() { + List responseData = jsonDecode(data)['data']; + offersList = responseData + .map((jsonObject) => GetOffersDetailsModel.fromJson(jsonObject)) + .toList(); + isLoading = false; + }); + + } catch (error) { + setState(() { + isLoading = false; + isSereverIssue = true; + }); + } + } + + @override + void initState() { + getActiveOffersViewData(); + //getAllPharmaciesData(dropdownArea); + super.initState(); + } + + void _onCheckboxChanged(String id, bool value) { + setState(() { + if (value) { + checked.add(id); + } else { + checked.remove(id); + } + }); + } + + showPicDialog(var imageUrl){ + return showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return AlertDialog( + title: const Text(''), + content: SingleChildScrollView( + child: ListBody( + children: [ + Container( + width: MediaQuery.of(context).size.width * .10, + height: MediaQuery.of(context).size.height * .50, + child: PhotoView( + imageProvider: NetworkImage(imageUrl) as ImageProvider, + maxScale: PhotoViewComputedScale.contained * 4.0, + minScale: PhotoViewComputedScale.contained, + initialScale: PhotoViewComputedScale.contained, + basePosition: Alignment.center, + + ) + ) + ], + ), + ), + actions: [ + TextButton( + child: Text('Close', style: textButtonStyle()), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }); + }, + ); + } + + + Widget _allPharmacies() { + if (offersList.length != 0) { + return Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: ListView.builder( + padding: EdgeInsets.all(0), + itemCount: offersList.length, + itemBuilder: (BuildContext context, int index) { + return Card( + child: Padding( + padding: EdgeInsets.all(8), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + child: Container( + width: MediaQuery.of(context).size.width * .18, + height: MediaQuery.of(context).size.height * .10, + decoration: BoxDecoration( + shape: BoxShape.circle, + image: DecorationImage( + image: (AppSettings.updatedImage != null) + ? FileImage(AppSettings.updatedImage!) + as ImageProvider + : AssetImage("images/mobilebg.png"), // picked file + fit: BoxFit.cover, + ), + ), + ), + onTap: () { + // showPicDialog(prescriptionsList[index].prescription_url); + }, + ), + SizedBox(width: MediaQuery.of(context).size.width * .02,), + Container( + width: MediaQuery.of(context).size.width * .55, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + offersList[index].offer_name + .toString() + .toUpperCase(), + style: valuesTextStyle(), + ), + Text( + offersList[index].offer_code + .toString() + .toUpperCase(), + style: valuesTextStyle(), + ), + Text( + offersList[index].category + .toString() + .toUpperCase(), + style: valuesTextStyle(), + ), + Text( + offersList[index].description + .toString() + .toUpperCase(), + style: valuesTextStyle(), + ), + ], + ), + ), + Checkbox( + value: checked.contains( + offersList[index].offer_code.toString()), + onChanged: (value) { + _onCheckboxChanged( + offersList[index].offer_code.toString(), + value ?? false); + }, + ), + ], + ), + ), + ); + }, + ), + ), + + Container( + padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), + child:TextButton( + onPressed: () { + // Add your button click logic here + }, + child: Text( + 'OfferId:$checked', + style: TextStyle( + fontSize: 15, + color:primaryColor, // Text color + decoration: TextDecoration.underline,// Underline the text + fontWeight: FontWeight.bold, // Bold text + ), + ), + ),), + SizedBox( + height: 10, + ), + Container( + width: MediaQuery.of(context).size.width, + height: 60, + padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async{ + Navigator.of(context).pop(); + /* Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new CompanyOffers(phid: checked.toString())));*/ + }, + child: Text('Submit'), + )), + ], + ); + } 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,), + ], + ), + ), + ); + } + } + + + + /**/ + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('All Pharmacies'), + body: isPrescriptionsDataLoading?Center( + child: CircularProgressIndicator( + color: primaryColor, + strokeWidth: 5.0, + ), + ): _allPharmacies(), + ); + } +} diff --git a/lib/getallpharmacies.dart b/lib/getallpharmacies.dart index 310aac1..8b47207 100644 --- a/lib/getallpharmacies.dart +++ b/lib/getallpharmacies.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:geolocator/geolocator.dart'; +import 'package:healthcare_pharmacy/companyoffrers.dart'; import 'package:healthcare_pharmacy/getmedicines.dart'; import 'package:healthcare_pharmacy/maps/app_colors.dart'; import 'package:healthcare_pharmacy/models/biddingrequest_model.dart'; @@ -196,20 +197,18 @@ class _GetAllPharmaciesState extends State { ), ), - /* Container( - width: 400, - height: 50, - padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), + /*Container( + padding: const EdgeInsets.fromLTRB(10, 0, 120, 0), child:TextButton( onPressed: () { // Add your button click logic here }, child: Text( - 'Total Price:$checked.toString()', + 'PharmacyId:$checked', style: TextStyle( - fontSize: 20, - color: AppColors.primaryColor, // Text color - decoration: TextDecoration.underline, // Underline the text + fontSize: 15, + color:primaryColor, // Text color + decoration: TextDecoration.underline,// Underline the text fontWeight: FontWeight.bold, // Bold text ), ), @@ -218,8 +217,8 @@ class _GetAllPharmaciesState extends State { height: 10, ), Container( - width: 400, - height: 50, + width: MediaQuery.of(context).size.width, + height: 60, padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), child: ElevatedButton( style: ElevatedButton.styleFrom( @@ -227,11 +226,10 @@ class _GetAllPharmaciesState extends State { onPrimary: Colors.white, // foreground ), onPressed: () async{ - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(checked.toString()), - ), - ); + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new CompanyOffers(phid: checked.toString()))); }, child: Text('Submit'), )), diff --git a/lib/getdeliveryboydata.dart b/lib/getdeliveryboydata.dart new file mode 100644 index 0000000..369f407 --- /dev/null +++ b/lib/getdeliveryboydata.dart @@ -0,0 +1,501 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:healthcare_pharmacy/adddeliveryboy.dart'; +import 'package:healthcare_pharmacy/dashboard.dart'; +import 'package:healthcare_pharmacy/models/getdeliveryboy_model.dart'; +import 'package:healthcare_pharmacy/settings.dart'; + +class GetDeliveryboyData extends StatefulWidget { + + + + @override + State createState() => _GetDeliveryboyDataState(); +} +class _GetDeliveryboyDataState extends State { + List modeldeliveryboyList = []; + TextEditingController deliveryboyNameController = TextEditingController(); + TextEditingController deliveryboyPhoneController = TextEditingController(); + TextEditingController deliveryboyAlterPhoneController = TextEditingController(); + TextEditingController deliveryboyAddress = TextEditingController(); + TextEditingController deliveryboyStatus = TextEditingController(); + + + bool isLoading=false; + + Future readJson() async { + var response1= await AppSettings.getAllDeliverboy(); + print(response1); + setState(() { + modeldeliveryboyList = + ((jsonDecode(response1)['deliveryBoys']) as List).map((dynamic model) { + return GetDeliveryboyDetailsModel.fromJson(model); + }).toList(); + isLoading=false; + }); + } + + @override + void initState() { + isLoading=true; + readJson(); + super.initState(); + } + + showUpdateDeliveryDialog(var object) async { + deliveryboyNameController.text=object.deliveryboy_name??''; + deliveryboyPhoneController.text=object.deliveryboy_phone??''; + deliveryboyAlterPhoneController.text=object.deliveryboy_alternativeContactNumber??''; + deliveryboyAddress.text=object.deliveryboy_address??''; + return showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return AlertDialog( + title: const Text('Update Deliveryboy'), + content: SingleChildScrollView( + child: ListBody( + children: [ + Container( + padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), + child: TextFormField( + cursorColor: greyColor, + controller: deliveryboyNameController, + textCapitalization: TextCapitalization.characters, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.ac_unit_outlined, + color: greyColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'Enter name', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + ), + Container( + padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), + child: TextFormField( + cursorColor: greyColor, + controller: deliveryboyPhoneController, + keyboardType: TextInputType.number, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.phone, + color: greyColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'Enter phone number', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + ), + Container( + padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), + child: TextFormField( + cursorColor: greyColor, + controller: deliveryboyAlterPhoneController, + keyboardType: TextInputType.number, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.phone, + color: greyColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'Enter Alternative phone number', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + ), + + ], + ), + ), + actions: [ + TextButton( + child: Text('Cancel',style:textButtonStyle()), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: Text('Update',style:textButtonStyle()), + onPressed: () async{ + if (deliveryboyNameController.text != '' ) { + AppSettings.preLoaderDialog(context); + + Map payload = { + "pharmacyname": "string", + "name": deliveryboyNameController.text.toString(), + "alternativeContactNumber": deliveryboyAlterPhoneController.text.toString(), + "phone": deliveryboyPhoneController.text.toString(), + "address": deliveryboyAddress.text.toString(), + "city": "string", + "state": "string", + "zip": "string", + "status": "active", + "longitude": 0, + "latitude": 0, + "fcmId": "string" + }; + + bool offerStatus = await AppSettings.updateDeliveryboy(object.deliveryboy_phone, payload); + try { + if (offerStatus) { + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longSuccessToast( + "Deliveryboy Updated Successfully"); + deliveryboyNameController.text = ''; + deliveryboyAlterPhoneController.text = ''; + deliveryboyPhoneController.text = ''; + Navigator.of(context).pop(); + await readJson(); + + } else { + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longFailedStyledToast( + "Deliveryboy upadtion failed", context); + Navigator.of(context).pop(); + } + } catch (exception) { + Navigator.of(context).pop(); + print(exception); + } + } else { + AppSettings.longFailedStyledToast("enter details", context); + } + }, + ), + ], + ); + }); + }, + ); + } + + + Widget renderzUi(){ + if(modeldeliveryboyList.length!=0){ + + return Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded(child:ListView.builder( + padding: EdgeInsets.all(0), + itemCount: modeldeliveryboyList .length, + itemBuilder: (context,index){ + var data=modeldeliveryboyList[index]; + return GestureDetector( + onTap: () { + + }, + child: Card( + child: ListTile( + title: RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Name: ', + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: modeldeliveryboyList[index].deliveryboy_name, + style: TextStyle( + fontSize: 16, + color: primaryColor, + ), + ), + ], + ), + ), + + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height:5), + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'phone: ', + style: TextStyle( + fontSize: 16, + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), + ), + TextSpan( + text: modeldeliveryboyList[index].deliveryboy_phone, + style: TextStyle( + fontSize: 16, + color: primaryColor, // Change the color for description content + ), + ), + ], + ), + ), + SizedBox(height:5), + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'alternative phone: ', + style: TextStyle( + fontSize: 16, + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), + ), + TextSpan( + text: modeldeliveryboyList[index].deliveryboy_alternativeContactNumber, + style: TextStyle( + fontSize: 16, + color:primaryColor, // Change the color for description content + ), + ), + ], + ), + ), + SizedBox(height:5), + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'address: ', + style: TextStyle( + fontSize: 16, + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), + ), + TextSpan( + text: modeldeliveryboyList[index].deliveryboy_address, + + style: TextStyle( + fontSize: 16, + color:primaryColor, // Change the color for description content + ), + ), + ], + ), + ), + SizedBox(height:10), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + icon: Icon(Icons.edit), + onPressed: () { + showUpdateDeliveryDialog(modeldeliveryboyList[index]); + }, + ), + IconButton( + icon: const Icon(Icons.delete,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 to delete Delivery Boy?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: ()async { + bool deleteDeliveryboyStatus = await AppSettings.deleteDeliveryboy(modeldeliveryboyList[index].deliveryboy_phone); + + + if(deleteDeliveryboyStatus){ + readJson(); + AppSettings.longSuccessToast('Deliveryboy deleted successfully'); + Navigator.of(context).pop(true); + + } + else{ + AppSettings.longFailedToast('Deliveryboy deletion failed'); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); + + + + }, + ), + ], + ), + ], + ), + ), + ), + ); + + + + + + + }) ), + Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 8), + child: CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async{ + Navigator.pop(context); + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => Deliverboy()), + ); + //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 Delivery Boy'), + 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) => Deliverboy()), + ); + }, + ), + ) + ], + ), + ) + ); + } + } + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text('Delivery Boy'), + backgroundColor: primaryColor, + leading: IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () async { + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const Dashboard()), + ); + }, + ), + ), + + body: isLoading?Center( + child: CircularProgressIndicator( + color: primaryColor, + strokeWidth: 5.0, + ), + ):renderzUi(), + )); + } +} diff --git a/lib/getmedicines.dart b/lib/getmedicines.dart index 4c260fb..c493d96 100644 --- a/lib/getmedicines.dart +++ b/lib/getmedicines.dart @@ -267,7 +267,7 @@ class _GetMedicinesState extends State with TickerProviderStateMix cursorColor: greyColor, controller: searchController, onChanged: (string) { - if(string.length>=4){ + if(string.length>=1){ getAllMedecineData(searchController.text); } else{ diff --git a/lib/inactiveoffersview.dart b/lib/inactiveoffersview.dart index 450d8f4..8967393 100644 --- a/lib/inactiveoffersview.dart +++ b/lib/inactiveoffersview.dart @@ -67,7 +67,6 @@ class _InActiveOffersViewState extends State with TickerProv Widget renderzUi(){ if(offersviewList.length!=0){ - return Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ @@ -76,8 +75,6 @@ class _InActiveOffersViewState extends State with TickerProv itemCount: offersviewList.length, itemBuilder: (BuildContext context, int index) { return Card( - - color: offersviewList[index].cardColor, child: Padding( padding:EdgeInsets.all(8) , child: Row( @@ -111,12 +108,11 @@ class _InActiveOffersViewState extends State with TickerProv 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].offer,style: valuesTextStyle()), - Text(offersviewList[index].starting_date,style: valuesTextStyle()), - Text(offersviewList[index].ending_date,style: valuesTextStyle()) + Text(offersviewList[index].offer_name??"",style: valuesTextStyle()), + Text(offersviewList[index].offer_code??"",style: valuesTextStyle()), + Text(offersviewList[index].description??"",style: valuesTextStyle()), + Text(offersviewList[index].starting_date??"",style: valuesTextStyle()), + Text(offersviewList[index].ending_date??"",style: valuesTextStyle()) ], ), diff --git a/lib/invitations.dart b/lib/invitations.dart new file mode 100644 index 0000000..cd4b6ad --- /dev/null +++ b/lib/invitations.dart @@ -0,0 +1,173 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; +import 'package:healthcare_pharmacy/settings.dart'; +import 'package:intl/intl.dart'; + +class Invitations extends StatefulWidget { + const Invitations({Key? key}) : super(key: key); + + @override + State createState() => _InvitationsState(); +} + +class _InvitationsState extends State { + TextEditingController mobileNumberController = TextEditingController(); + TextEditingController nameController = TextEditingController(); + + final FlutterContactPicker _contactPicker = new FlutterContactPicker(); + Contact? _contact; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('Invitations'), + body: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: SafeArea( + + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: TextFormField( + cursorColor: greyColor, + controller: nameController, + decoration: textFormFieldDecoration( + Icons.phone, 'Enter Name'), + ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + Container( + child: TextFormField( + cursorColor: greyColor, + controller: mobileNumberController, + keyboardType: TextInputType.number, + decoration: textFormFieldDecoration( + Icons.phone, 'Enter MobileNumber'), + ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * .04, + ), + Container( + width: double.infinity, + height: + MediaQuery.of(context).size.height * .05, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async { + if (nameController.text != '' && + mobileNumberController.text != '') { + AppSettings.preLoaderDialog(context); + + var now = new DateTime.now(); + String formattedDate = DateFormat('yyyy-MM-dd – kk:mm').format(now); + + var payload = new Map(); + + payload["name"] = nameController.text; + payload["phone"] = mobileNumberController.text; + payload["dateAndTime"] = formattedDate; + bool invitationStatus = await AppSettings.inviteFriend(payload); + try{ + if(invitationStatus){ + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longSuccessToast("Invitation sent successfully"); + nameController.clear(); + mobileNumberController.clear(); + } + else{ + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longFailedToast("Failed invite your friend"); + } + } + catch(e){ + AppSettings.longFailedToast("Failed invite your friend"); + } + } + else { + AppSettings.longFailedToast("details should not be empty"); + } + }, + child: const Text('Invite'), + )), + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + Container( + child: Text( + 'Or', + style: TextStyle( + color: primaryColor, + fontWeight: FontWeight.bold, + fontSize: 20), + ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + TextButton( + child: const Text( + 'Select from contacts', + style: TextStyle( + decoration: TextDecoration.underline, + color: primaryColor, + fontSize: 20), + ), + onPressed: () async { + Contact? contact = + await _contactPicker.selectContact(); + setState(() { + _contact = contact; + }); + AppSettings.preLoaderDialog(context); + + var now = new DateTime.now(); + String formattedDate = DateFormat('yyyy-MM-dd – kk:mm').format(now); + + var payload = new Map(); + + String contactNumber=_contact!.phoneNumbers.toString(); + String newContact= contactNumber.substring( 1, contactNumber.length - 1 ).trim(); + + String stringAfterRemovingWhiteSpace = ''; + for (int i = 0; i < newContact.length; i++) { + if (!newContact[i].contains(' ')) { + stringAfterRemovingWhiteSpace = stringAfterRemovingWhiteSpace + "" + newContact[i]; + } + } + + payload["name"] =_contact!.fullName; + payload["phone"] = stringAfterRemovingWhiteSpace; + payload["dateAndTime"] = formattedDate; + bool invitationStatus = await AppSettings.inviteFriend(payload); + + try{ + if(invitationStatus){ + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longSuccessToast("Invitation sent successfully"); + + } + else{ + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longFailedToast("Failed invite your friend"); + } + } + catch(e){ + AppSettings.longFailedToast("Failed invite your friend"); + } + }, + ) + ], + )))))); + } +} diff --git a/lib/medicinecart.dart b/lib/medicinecart.dart index 4965a5c..315fe51 100644 --- a/lib/medicinecart.dart +++ b/lib/medicinecart.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:healthcare_pharmacy/biddingrequests.dart'; import 'package:healthcare_pharmacy/dashboard.dart'; +import 'package:healthcare_pharmacy/getalloffers.dart'; import 'package:healthcare_pharmacy/getmedicines.dart'; import 'package:healthcare_pharmacy/maps/app_colors.dart'; import 'package:healthcare_pharmacy/medicinedetailspage.dart'; @@ -14,10 +15,10 @@ import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_pic class MedicineCartList extends StatefulWidget { - var bookidcart; + var bookidID; MedicineCartList({ - this.bookidcart + this.bookidID }); @override @@ -44,6 +45,10 @@ class _MedicineCartListState extends State with TickerProvider TextEditingController medicine_nameController = TextEditingController(); TextEditingController medicine_quantityController = TextEditingController(); TextEditingController medicine_priceController = TextEditingController(); + TextEditingController medicine_gstPriceController = TextEditingController(); + TextEditingController medicine_additionalPriceController = TextEditingController(); + TextEditingController medicine_finalPriceController = TextEditingController(); + TextEditingController BookingidController = TextEditingController(); TextEditingController medicine_timingsController = TextEditingController(); @@ -51,7 +56,7 @@ class _MedicineCartListState extends State with TickerProvider isLoading = true; try { - var response = await AppSettings.getCartDetails(widget.bookidcart).then((value){ + var response = await AppSettings.getCartDetails(widget.bookidID).then((value){ setState(() { // offersviewList = BiddingCartviewModel.fromJson(response['items']) as List; offersviewList = @@ -81,6 +86,7 @@ class _MedicineCartListState extends State with TickerProvider @override void initState() { // TODO: implement initState + BookingidController.text=widget.bookidID; getCartViewData(); super.initState(); } @@ -183,9 +189,8 @@ class _MedicineCartListState extends State with TickerProvider })), Container( - width: 400, + width: MediaQuery.of(context).size.width, height: 50, - padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), child:TextButton( onPressed: () { // Add your button click logic here @@ -200,19 +205,129 @@ class _MedicineCartListState extends State with TickerProvider ), ), ),), + Container( + width: MediaQuery.of(context).size.width, + height: 30, + child: Align( + alignment: Alignment.center, + child: TextButton( + onPressed: () async { + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const GetAllOffers()), + ); + }, + child: Text( + 'Add Offers', + style: TextStyle( + fontSize:15, + color: AppColors.primaryColor, // Text color + decoration: TextDecoration.underline, // Underline the text + fontWeight: FontWeight.bold, // Bold text + ), + ), + ), + ), + ), + SizedBox( height: 10, ), Container( - width: 400, - height: 50, - padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), + width: MediaQuery.of(context).size.width, + height: 60, + padding: const EdgeInsets.fromLTRB(20, 0, 20, 10), child: ElevatedButton( style: ElevatedButton.styleFrom( primary: primaryColor, // background onPrimary: Colors.white, // foreground ), onPressed: () async{ + // Calculate final amount + double gst = 0.00; // Replace with your actual GST value + double additionalDiscount = 10.00; // Replace with your actual additional discount value + double finalAmount = double.parse(totalPrice) + gst - additionalDiscount; + + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + // Update controllers with values + medicine_priceController.text = totalPrice.toString(); + medicine_gstPriceController.text = gst.toString(); + medicine_additionalPriceController.text = additionalDiscount.toString(); + + return AlertDialog( + title: Text('Payment Receipt'), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Total Price: $totalPrice'), + Text('GST: $gst'), + Text('Additional Discount: $additionalDiscount'), + Divider(), // Add a divider line + Text('Final Amount: $finalAmount'), // Show final amount + ], + ), + actions: [ + Center( + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + if (medicine_priceController.text != '' && + medicine_gstPriceController.text != ''&& + medicine_additionalPriceController.text != '' + ) { + AppSettings.preLoaderDialog(context); + var response = await AppSettings.cartFinalAmmount(BookingidController.text,medicine_priceController.text, + medicine_gstPriceController.text,medicine_additionalPriceController.text); + print("response$response"); + + //String response= await addToCart("OR1690969760576127","10","300","Dolo650"); + //print("response$response"); + try { + if(response.statusCode==200){ + var msg=jsonDecode(response.body)['message']; + print(msg); + Navigator.of(context,rootNavigator: true).pop(); + AppSettings.longSuccessToast( + "Medicines Final Price Sent Successfully"); + + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => Dashboard()), + ); + + + } + else{ + Navigator.of(context,rootNavigator: true).pop(); + AppSettings.longFailedToast("Failed to Sent Final Medicines Price"); + } + + } catch (exception) { + print(exception); + } + } + else { + AppSettings.longFailedToast("Please enter valid details"); + } + + Navigator.of(context).pop(); + }, + child: Text('Submit'), + ), + ), + ], + ); + }, + ); }, child: Text('CheckOut'), @@ -220,74 +335,6 @@ class _MedicineCartListState extends State with TickerProvider - /*Column( - children: [ - Padding(padding: const EdgeInsets.fromLTRB(10, 10,10,10), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'Add More', - style: TextStyle( - color: Colors.white, - ), - ), - TextButton( - child: const Text( - 'Sign Up', - style: TextStyle(fontSize: 15, - decoration: TextDecoration.underline,color: Colors.white), - ), - onPressed: () { - *//* Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const SignUp()), - );*//* - //signup screen - }, - ) - ], - ),) - Container( - width: 400, - height: 50, - padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), - child:TextButton( - onPressed: () { - // Add your button click logic here - }, - child: Text( - 'Total Price:$totalPrice', - style: TextStyle( - fontSize: 20, - color: AppColors.primaryColor, // Text color - decoration: TextDecoration.underline, // Underline the text - fontWeight: FontWeight.bold, // Bold text - ), - ), - ),), - SizedBox( - height: 10, - ), - Container( - width: 400, - height: 50, - padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, // background - onPrimary: Colors.white, // foreground - ), - onPressed: () async{ - - }, - child: Text('CheckOut'), - )), - ], - )*/ - - ]); } else { diff --git a/lib/medicinedetailspage.dart b/lib/medicinedetailspage.dart index 53c06da..9d9c94a 100644 --- a/lib/medicinedetailspage.dart +++ b/lib/medicinedetailspage.dart @@ -150,33 +150,54 @@ class _deliverboyState extends State { height: 5, ), Container( - //padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), padding: const EdgeInsets.all(10), - child: TextFormField( - cursorColor: greyColor, - controller: MedicineQuantityController, - readOnly: true, - textCapitalization: TextCapitalization.characters, - decoration: const InputDecoration( - prefixIcon: Icon( - Icons.production_quantity_limits, - color: greyColor, - ), - border: OutlineInputBorder( - borderSide: BorderSide(color: greyColor)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: greyColor), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: greyColor), + child: Row( + children: [ + Expanded( + child: TextFormField( + cursorColor: greyColor, + controller: MedicineQuantityController, + readOnly: true, + textCapitalization: TextCapitalization.characters, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.production_quantity_limits, + color: greyColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'Medicine Quantity', + labelStyle: TextStyle( + color: greyColor, + ), + ), + ), ), - labelText: 'Medicine Quantity', - labelStyle: TextStyle( - color: greyColor, //<-- SEE HERE + const SizedBox(width: 10), // Adjust the spacing as needed + QuantityInput( + label: 'Select Medicine Quantity', + value: initialValue, + iconColor: Colors.white, + buttonColor: primaryColor, + onChanged: (value) { + setState(() { + enteredValue = double.tryParse(value) ?? 0.0; + initialValue = int.parse(value.replaceAll(',', '')); + MedicineQuantityController.text = initialValue.toString(); + // MedicinePriceController.text = '${getTotalAmount()}'; + }); + }, ), - ), - ), //tanker name - ), + ], + ), + ), //alternative phone number //phone number const SizedBox( height: 5, @@ -208,34 +229,7 @@ class _deliverboyState extends State { ), ), //tanker name ), //alternative phone number - const SizedBox( - height: 5, - ), - Container( - height: MediaQuery.of(context).size.height * .1, - width: MediaQuery.of(context).size.width * .5, - child: Column( - children: [ - QuantityInput( - label: 'Select Medicine Quntity', - value: initialValue, - iconColor: Colors.white, - buttonColor: primaryColor, - onChanged: (value) { - setState(() { - enteredValue = double.tryParse(value) ?? 0.0; - initialValue = int.parse(value.replaceAll(',', '')); - MedicineQuantityController.text=initialValue.toString(); - // MedicinePriceController.text= '${getTotalAmount()}'; - }); - } - - - ), - ] - ) //tanker name - ), //alternative phone number const SizedBox( height: 5, ), @@ -255,20 +249,9 @@ class _deliverboyState extends State { MedicinePriceController.text != '' ) { AppSettings.preLoaderDialog(context); - /* var payload = new Map(); - payload["mbookingId"] = BookingidController.text.toString(); - payload["items"]=[{ - "medicinename":MedicineNameController.text.toString(), - "quantity":MedicineQuantityController.text.toString(), - "price":MedicinePriceController.text.toString() - }]; - print("responcedata${payload.toString()}");*/ - var response = await AppSettings.addToCart(BookingidController.text,MedicineQuantityController.text, MedicinePriceController.text,MedicineNameController.text,selectedOptionsText); - //String response= await addToCart("OR1690969760576127","10","300","Dolo650"); - //print("response$response"); try { if(response.statusCode==200){ @@ -284,7 +267,7 @@ class _deliverboyState extends State { await Navigator.push( context, MaterialPageRoute( - builder: (context) => MedicineCartList(bookidcart:BookingidController.text.toString())), + builder: (context) => MedicineCartList(bookidID:BookingidController.text.toString())), ); diff --git a/lib/models/addoffer_model.dart b/lib/models/addoffer_model.dart new file mode 100644 index 0000000..814a1bd --- /dev/null +++ b/lib/models/addoffer_model.dart @@ -0,0 +1,69 @@ +import 'dart:convert'; + +List listdadFromJson(String str) => List.from(json.decode(str).map((x) => GetOffersDetailsModel .fromJson(x))); + +String listdadToJson(List data) => json.encode(List.from(data.map((x) => x.toJson()))); + +class GetOffersDetailsModel { + String ? description; + String ? starting_date; + String ? ending_date; + String ? offer_code; + List picture; + String ? offer_name; + String ? category; + + + GetOffersDetailsModel ({ + required this.description, + required this.starting_date, + required this.ending_date, + required this.offer_code, + required this.picture, + required this.offer_name , + required this.category , + + }); + + factory GetOffersDetailsModel .fromJson(Map json) => GetOffersDetailsModel ( + description: json["description"], + starting_date: json["starting_date"], + ending_date: json["ending_date"], + offer_code: json["offer_code"], + category: json["category"], + + picture: List.from(json["picture"].map((x) => Picture.fromJson(x))), + offer_name : json["offer_name"], + ); + + Map toJson() => { + "description": description, + "starting_date": starting_date, + "ending_date": ending_date, + "offer_code": offer_code, + "picture": List.from(picture.map((x) => x.toJson())), + "offer_name": offer_name, + "category": category, + + }; +} + +class Picture { + String id; + String url; + + Picture({ + required this.id, + required this.url, + }); + + factory Picture.fromJson(Map json) => Picture( + id: json["_id"], + url: json["url"], + ); + + Map toJson() => { + "_id": id, + "url": url, + }; +} \ No newline at end of file diff --git a/lib/models/approvedoffer_model.dart b/lib/models/approvedoffer_model.dart new file mode 100644 index 0000000..f07bccc --- /dev/null +++ b/lib/models/approvedoffer_model.dart @@ -0,0 +1,69 @@ +import 'dart:convert'; + +List listdadFromJson(String str) => List.from(json.decode(str).map((x) => GetApprovedOffersDetailsModel .fromJson(x))); + +String listdadToJson(List data) => json.encode(List.from(data.map((x) => x.toJson()))); + +class GetApprovedOffersDetailsModel { + String ? description; + String ? starting_date; + String ? ending_date; + String ? offer_code; + List picture; + String ? offer_name; + String ? category; + + + GetApprovedOffersDetailsModel ({ + required this.description, + required this.starting_date, + required this.ending_date, + required this.offer_code, + required this.picture, + required this.offer_name , + required this.category , + + }); + + factory GetApprovedOffersDetailsModel .fromJson(Map json) => GetApprovedOffersDetailsModel ( + description: json["description"], + starting_date: json["starting_date"], + ending_date: json["ending_date"], + offer_code: json["offer_code"], + category: json["category"], + + picture: List.from(json["picture"].map((x) => Picture.fromJson(x))), + offer_name : json["offer_name"], + ); + + Map toJson() => { + "description": description, + "starting_date": starting_date, + "ending_date": ending_date, + "offer_code": offer_code, + "picture": List.from(picture.map((x) => x.toJson())), + "offer_name": offer_name, + "category": category, + + }; +} + +class Picture { + String id; + String url; + + Picture({ + required this.id, + required this.url, + }); + + factory Picture.fromJson(Map json) => Picture( + id: json["_id"], + url: json["url"], + ); + + Map toJson() => { + "_id": id, + "url": url, + }; +} \ No newline at end of file diff --git a/lib/models/biddingrequest_model.dart b/lib/models/biddingrequest_model.dart index 6af567e..ebab168 100644 --- a/lib/models/biddingrequest_model.dart +++ b/lib/models/biddingrequest_model.dart @@ -1,12 +1,21 @@ import 'package:flutter/material.dart'; +import 'package:healthcare_pharmacy/settings.dart'; class BiddingRequestsModel { - String custumerid_bidding = ''; - String pharmacyid_bidding=''; - String amount_bidding=''; - String bidding_bookingid=''; + String? custumerid_bidding = ''; + String? pharmacyid_bidding=''; + String? amount_bidding=''; + String? bidding_bookingid=''; + String? bidding_firstName=''; + // String? bidding_contactNumber=''; + String? bidding_address1=''; + String orderStatus=''; + String status=''; + Color cardColor=Colors.white; + Color textColor=Colors.black; + BiddingRequestsModel(); @@ -18,9 +27,26 @@ class BiddingRequestsModel { rtvm.pharmacyid_bidding = json['pharmacyId'].toString() ?? ''; rtvm.amount_bidding = json['biddingAmount'].toString() ?? ''; rtvm.bidding_bookingid = json['bookingId'].toString() ?? ''; + rtvm.bidding_firstName = json['customerDetails']["firstName"].toString() ?? ''; + rtvm.status = json['status'] ; - // rtvm.prescription_url = json['pictureUrl'][0] ?? ''; + // rtvm.bidding_contactNumber = json['customerDetails']['profile']["contactNumber"].toString() ?? ''; + + // rtvm.bidding_contactNumber = json['contactNumber'].toString() ?? ''; + // rtvm.bidding_address1 = json['address1'].toString() ?? ''; + + + // rtvm.prescription_url = json['pictureUrl'][0] ?? ''; + if(rtvm.status.toString().toLowerCase()=='accepted'){ + rtvm.textColor=Colors.green; + } + else if(rtvm.status.toString().toLowerCase()=='rejected'){ + rtvm.textColor=Colors.red; + } + else{ + rtvm.textColor=primaryColor; + } return rtvm; } diff --git a/lib/models/getdeliveryboy_model.dart b/lib/models/getdeliveryboy_model.dart new file mode 100644 index 0000000..0c36142 --- /dev/null +++ b/lib/models/getdeliveryboy_model.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + + +class GetDeliveryboyDetailsModel { + String deliveryboy_name = ''; + String deliveryboy_phone = ''; + String deliveryboy_alternativeContactNumber = ''; + String deliveryboy_address=''; + // String deliveryboy_status=''; + + + Color cardColor=Colors.white; + + GetDeliveryboyDetailsModel(); + + factory GetDeliveryboyDetailsModel.fromJson(Map json){ + GetDeliveryboyDetailsModel rtvm = new GetDeliveryboyDetailsModel(); + + rtvm.deliveryboy_name = json['name'] ?? ''; + rtvm.deliveryboy_phone = json['phone'] ?? ''; + rtvm.deliveryboy_alternativeContactNumber = json['alternativeContactNumber'] ?? ''; + rtvm.deliveryboy_address = json['address'] ??''; + // rtvm.deliveryboy_status = json['status'] ??''; + + + + return rtvm; + } + +} \ No newline at end of file diff --git a/lib/models/offersview_model.dart b/lib/models/offersview_model.dart index ef4f81d..747ca5e 100644 --- a/lib/models/offersview_model.dart +++ b/lib/models/offersview_model.dart @@ -1,30 +1,79 @@ -import 'package:flutter/material.dart'; +import 'dart:convert'; +List listdadFromJson(String str) => List.from(json.decode(str).map((x) => GetOffersDetailsModel .fromJson(x))); -class GetOffersDetailsModel { - String offer_name = ''; - String offer_code = ''; - String description = ''; - String offer=''; - String starting_date=''; - Color cardColor=Colors.white; - String ending_date=''; +String listdadToJson(List data) => json.encode(List.from(data.map((x) => x.toJson()))); +class GetOffersDetailsModel { + String ? description; + String ? starting_date; + String ? ending_date; + String ? offer_code; + List picture; + String ? offer_name; + String ? category; + String ? pharmacyId; + String request_status=''; - GetOffersDetailsModel(); + GetOffersDetailsModel ({ + required this.description, + required this.starting_date, + required this.ending_date, + required this.offer_code, + required this.picture, + required this.offer_name , + required this.category , + required this.pharmacyId , + required this.request_status , + }); - factory GetOffersDetailsModel.fromJson(Map json){ - GetOffersDetailsModel rtvm = new GetOffersDetailsModel(); + factory GetOffersDetailsModel .fromJson(Map json) => GetOffersDetailsModel ( + description: json["description"], + starting_date: json["starting_date"], + ending_date: json["ending_date"], + offer_code: json["offer_code"], + category: json["category"], - rtvm.offer_name = json['offer_name'] ?? ''; - rtvm.offer_code = json['offer_code'] ?? ''; - rtvm.description = json['description'] ?? ''; - rtvm.offer = json['offer'] ?? ''; - rtvm.starting_date = json['starting_date'] ??''; - rtvm.ending_date = json['ending_date'] ??''; + picture: List.from(json["picture"].map((x) => Picture.fromJson(x))), + offer_name : json["offer_name"], + pharmacyId : json["pharmacyId"], + request_status : json["request_status"], - return rtvm; - } + ); + Map toJson() => { + "description": description, + "starting_date": starting_date, + "ending_date": ending_date, + "offer_code": offer_code, + "picture": List.from(picture.map((x) => x.toJson())), + "offer_name": offer_name, + "category": category, + "pharmacyId": pharmacyId, + "request_status": request_status, + + + + }; +} + +class Picture { + String id; + String url; + + Picture({ + required this.id, + required this.url, + }); + + factory Picture.fromJson(Map json) => Picture( + id: json["_id"], + url: json["url"], + ); + + Map toJson() => { + "_id": id, + "url": url, + }; } \ No newline at end of file diff --git a/lib/models/pharmacy_accounts_model.dart b/lib/models/pharmacy_accounts_model.dart new file mode 100644 index 0000000..b8bbe4c --- /dev/null +++ b/lib/models/pharmacy_accounts_model.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; +import 'package:healthcare_pharmacy/settings.dart'; +class PharmacyAccountsModel { + + String pharmacyId = ''; + String customerId = ''; + String bookingId = ''; + String biddingAmount = ''; + String date = ''; + String orderStatus = ''; + String acceptedCount = ''; + String pendingRejectedCount = ''; + String deliveredCount = ''; + String deliveredTotalPrice = ''; + String deliveredTotalAmountPaid = ''; + String deliveredTotalAmountDue = ''; + Color payment_color=Colors.grey; + String displayText = ''; + + + + + + + + PharmacyAccountsModel(); + + + factory PharmacyAccountsModel.fromJson(Map json){ + PharmacyAccountsModel rtvm = new PharmacyAccountsModel(); + + rtvm.pharmacyId = json['pharmacyId'] ?? ''; + + rtvm.customerId = json['customerId'] ?? ''; + rtvm.bookingId = json['bookingId'] ?? ''; + rtvm.biddingAmount = json['biddingAmount'] ?? ''; + rtvm.date = json['date'] ?? ''; + rtvm.orderStatus = json['status'] ?? ''; + + rtvm.acceptedCount = json['acceptedCount'] ?? ''; + rtvm.pendingRejectedCount = json['pendingRejectedCount'] ?? ''; + rtvm.deliveredCount = json['deliveredCount'] ?? ''; + rtvm.deliveredTotalPrice = json['deliveredTotalPrice'] ?? ''; + rtvm.deliveredTotalAmountPaid = json['deliveredTotalAmountPaid'] ?? ''; + rtvm.deliveredTotalAmountDue = json['deliveredTotalAmountDue'] ?? ''; + + /* if(rtvm.orderStatus=='delivered' && rtvm.payment_status=='paid'){ + rtvm.payment_color=Colors.green; + rtvm.displayText='Payment Completed'; + } + else if(rtvm.orderStatus=='delivered' && rtvm.payment_status=='due'){ + rtvm.payment_color=primaryColor; + rtvm.displayText='Due'; + }*/ + + + return rtvm; + } + +} \ No newline at end of file diff --git a/lib/offerstabdata.dart b/lib/offerstabdata.dart index 23324ca..025c3fc 100644 --- a/lib/offerstabdata.dart +++ b/lib/offerstabdata.dart @@ -1,12 +1,17 @@ import 'dart:convert'; +import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:healthcare_pharmacy/dashboard.dart'; import 'package:healthcare_pharmacy/maps/app_colors.dart'; import 'package:healthcare_pharmacy/models/offersview_model.dart'; import 'package:healthcare_pharmacy/createoffers.dart'; import 'package:healthcare_pharmacy/settings.dart'; +import 'package:healthcare_pharmacy/viewpager.dart'; import 'package:intl/intl.dart'; +import 'package:image_picker/image_picker.dart'; import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart'; @@ -17,7 +22,7 @@ class OffersData extends StatefulWidget { State createState() => _OffersDataState(); } -class _OffersDataState extends State with TickerProviderStateMixin { +class _OffersDataState extends State with TickerProviderStateMixin, WidgetsBindingObserver { bool isOfferDataLoading=false; bool isSereverIssue = false; bool isSereverIssueConnected = false; @@ -27,12 +32,24 @@ class _OffersDataState extends State with TickerProviderStateMixin { TextEditingController updateOfferNameController = TextEditingController(); TextEditingController updateOfferCodeController = TextEditingController(); TextEditingController updateOfferDescriptionController = TextEditingController(); + TextEditingController updateOfferCategoryController = TextEditingController(); TextEditingController updateDiscountController = TextEditingController(); TextEditingController updateOfferStartDateController = TextEditingController(); TextEditingController updateOfferEndDateController = TextEditingController(); List activeOffersList = []; List inactiveOffersList = []; + final ImagePicker _picker = ImagePicker(); + String updateofferUrl=''; + String dropdownTypeOfCategory = 'A {1 - 500}'; + var typeOfCategoryItems = [ + 'A {1 - 500}', + 'B {501 - 1000}', + 'C {1001 - 2000}', + 'D {Above 2000}', + 'S {Special offer}', + ]; + List updateCategoryTypes = []; late TabController _controller; bool isActiveDataLoading=false; @@ -51,33 +68,28 @@ class _OffersDataState extends State with TickerProviderStateMixin { children: [Text('InActive Offers')], ), ), - ]; - - - Future getActiveOffersViewData() async { isActiveDataLoading = true; + + try { - var response = await AppSettings.getOffers(); + var data = await AppSettings.getOffers(); setState(() { - activeOffersList = - ((jsonDecode(response)['data']) as List).map((dynamic model) { - return GetOffersDetailsModel.fromJson(model); - }).toList(); + List responseData = jsonDecode(data)['data']; + activeOffersList = responseData + .map((jsonObject) => GetOffersDetailsModel.fromJson(jsonObject)) + .toList(); isActiveDataLoading = false; }); - - } catch (e) { + } catch (error) { setState(() { isActiveDataLoading = false; isSereverIssueConnected = true; }); } } - - Future getInactiveOffersViewData() async { isinactiveDataLoading = true; try { @@ -99,315 +111,548 @@ class _OffersDataState extends State with TickerProviderStateMixin { } } - showUpdateOfferDialog(var object) async { - updateOfferNameController.text = object.offer_name; - updateOfferCodeController.text = object.offer_code; - updateOfferDescriptionController.text = object.description; - updateOfferStartDateController.text=object.starting_date; - updateOfferEndDateController.text=object.ending_date; + + Future pickImageFromGallery(var offerCode) async { + + try { + final image = await _picker.pickImage(source: ImageSource.gallery); + if (image == null) return ''; + + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.offerupdateuploadImageHTTPNew(image, offerCode); + print(jsonDecode(res)); + + setState(() { + updateofferUrl = jsonDecode(res)['picture'][0]['url']; + print("update url: $updateofferUrl"); + }); + + Navigator.of(context, rootNavigator: true).pop(); + if(res.contains("error")){ + return 'some thing went wrong please try again'; + } + else{ + return jsonDecode(res)['picture'][0]['url']; + } + + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + return 'some thing went wrong please try again'; + } + } + + Future takeImageFromCamera(String offerCode) async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return ''; + + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.offerupdateuploadImageHTTPNew(image, offerCode); + print(jsonDecode(res)); + + setState(() { + updateofferUrl = jsonDecode(res)['picture'][0]['url']; + print("update url: $updateofferUrl"); + }); + + Navigator.of(context, rootNavigator: true).pop(); + if(res.contains("error")){ + return 'some thing went wrong please try again'; + } + else{ + return jsonDecode(res)['picture'][0]['url']; + } + + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + return 'some thing went wrong please try again'; + } + + } + + + + + showUpdateOfferDialog(GetOffersDetailsModel object, int index) async { + updateOfferNameController.text = object.offer_name!; + updateOfferCodeController.text = object.offer_code!; + updateOfferDescriptionController.text = object.description!; + updateOfferStartDateController.text=object.starting_date!; + updateOfferEndDateController.text=object.ending_date!; + setState(() { + dropdownTypeOfCategory=object.category.toString().toString()??''; + }); + updateofferUrl=object.picture[0].url; 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: [ - Container( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), - child: TextFormField( - cursorColor: greyColor, - controller: updateOfferNameController, - textCapitalization: TextCapitalization.words, - 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: 'Offer name', - labelStyle: TextStyle( - color: greyColor, //<-- SEE HERE - ), - ), - ), //tanker name - ), - const SizedBox( - height: 20, + builder: (BuildContext context, StateSetter setState) { + var data=activeOffersList[index]; + print("result$updateofferUrl"); + return AlertDialog( + title: const Text('Update Offer'), + content: SingleChildScrollView( + child: ListBody( + children: [ + // ImageView + InkWell( + onTap: () { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCamera(object.offer_code!).then((value) { + print("datatatttta$value"); + setState(() { + updateofferUrl = value; + // print(updateofferUrl); + }); + }); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGallery(object.offer_code).then((value) { + print("datatatttta$value"); + setState(() { + updateofferUrl = value; + // print(updateofferUrl); + }); + });; + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + child: Container( + width: MediaQuery.of(context).size.width, + height: 150, + child: updateofferUrl.isEmpty + ? Image.network( + "https://assets.aboutamazon.com/dims4/default/1db03c8/2147483647/strip/false/crop/2000x1125+0+0/resize/1200x675!/quality/90/?url=https%3A%2F%2Famazon-blogs-brightspot.s3.amazonaws.com%2Fa3%2Fc2%2F5c0b93db41d789be1bec015003bd%2Fpharmacy-hero-2000x1125.jpg", + fit: BoxFit.cover, + ) + : Image.network( + updateofferUrl, + fit: BoxFit.cover, + ), ), - Container( - //padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), - child: TextFormField( - cursorColor: greyColor, - controller: updateOfferCodeController, - textCapitalization: TextCapitalization.words, - 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: 'Offer Code', - labelStyle: TextStyle( - color: greyColor, //<-- SEE HERE - ), + + ), + const SizedBox( + height: 20, + ), + + // Offer Name + Container( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), + child: TextFormField( + cursorColor: greyColor, + controller: updateOfferNameController, + textCapitalization: TextCapitalization.words, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.person, + color: primaryColor, ), - ), //tanker name - ), - const SizedBox( - height: 20, - ), - Container( - //padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), - child: TextFormField( - cursorColor: greyColor, - controller: updateOfferDescriptionController, - textCapitalization: TextCapitalization.words, - 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: 'Offer Description', - labelStyle: TextStyle( - color: greyColor, //<-- SEE HERE - ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), ), - ), //tanker name - ), - const SizedBox( - height: 20, + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: '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.words, + 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: '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.words, + 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: 'Offer Description', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), //tanker name + ), + + const SizedBox( + height: 30, + ), + + + Container( + child: DropdownButtonFormField( + // Initial Value + value: dropdownTypeOfCategory, + isExpanded: true, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.type_specimen, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'Type of category', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + + hint: Text('Select Type of category'), + // Down Arrow Icon + icon: const Icon(Icons.keyboard_arrow_down), + + // Array list of items + items: typeOfCategoryItems.map((String items) { + return DropdownMenuItem( + value: items, + child: Text(items), + ); + }).toList(), + // After selecting the desired option,it will + // change button value to selected value + onChanged: (String? newValue) { + setState(() { + dropdownTypeOfCategory = newValue!; + }); + }, ), - 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', - 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 index)async { - DateTime selectdate = dateTime; - setState(() { - startdate = DateFormat('dd-MMM-yyyy').format(selectdate); - }); + ), - if(startdate!=''){ - setState(() { - updateOfferStartDateController.text=startdate.toString(); - }); - } - else { - AppSettings.longFailedToast('Select start 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: 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', + 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 index)async { + DateTime selectdate = dateTime; + setState(() { + startdate = DateFormat('dd-MMM-yyyy').format(selectdate); + }); + if(startdate!=''){ + setState(() { + updateOfferStartDateController.text=startdate.toString(); + }); + } + else { + AppSettings.longFailedToast('Select start 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', - 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 index)async { - DateTime selectdate = dateTime; - setState(() { - enddate = DateFormat('dd-MMM-yyyy').format(selectdate); - }); + ), - if(enddate!=''){ - setState(() { - updateOfferEndDateController.text=enddate.toString(); - }); - } - else { - AppSettings.longFailedToast('Select end date'); - } - }, - ); - }, + 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', + 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 index)async { + DateTime selectdate = dateTime; + setState(() { + enddate = DateFormat('dd-MMM-yyyy').format(selectdate); + }); - 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), - ), + if(enddate!=''){ + setState(() { + updateOfferEndDateController.text=enddate.toString(); + }); + } + else { + AppSettings.longFailedToast('Select end 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, ), + ),//address description - ], - ), + const SizedBox( + height: 30, + ), + + ], ), - actions: [ - 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(); - - payload["offer_name"] = updateOfferNameController.text.toString(); - payload["offer_code"] = updateOfferCodeController.text.toString(); - payload["description"] = updateOfferDescriptionController.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 = ''; - updateOfferStartDateController.text = ''; - updateOfferEndDateController.text = ''; - - Navigator.of(context).pop(); - await getActiveOffersViewData(); - } else { - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longFailedStyledToast( - "Offer upadtion failed", context); - Navigator.of(context).pop(); + ), + actions: [ + 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); + + Map payload = { + "offer_name": updateOfferNameController.text.toString(), + "offer_code": updateOfferCodeController.text.toString(), + "description":updateOfferDescriptionController.text.toString(), + "category":dropdownTypeOfCategory.toString(), + "starting_date":updateOfferStartDateController.text.toString(), + "ending_date": updateOfferEndDateController.text.toString(), + "picture": [ + { + "url":updateofferUrl } - } catch (exception) { + ], + "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 = ''; + updateOfferStartDateController.text = ''; + updateOfferEndDateController.text = ''; + await getActiveOffersViewData(); + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const OffersData()), + ); + } else { + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longFailedStyledToast( + "Offer upadtion failed", context); Navigator.of(context).pop(); - print(exception); } - } else { - AppSettings.longFailedStyledToast("enter details", context); + } catch (exception) { + Navigator.of(context).pop(); + print(exception); } - }, - ), - ], - ); - }); + } else { + AppSettings.longFailedStyledToast("enter details", context); + } + }, + ), + ], + ); + }, + ); }, ); } + @override void initState() { // TODO: implement initState _controller = TabController(vsync: this, length: 2); getActiveOffersViewData(); getInactiveOffersViewData(); + WidgetsBinding.instance!.addObserver(this); super.initState(); } + @override + void dispose() { + WidgetsBinding.instance!.removeObserver(this); + super.dispose(); + } + + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + if (state == AppLifecycleState.resumed) { + // The app has been resumed from the background + // Add your code here to handle the resume event + // AppSettings.longSuccessToast("Successfully"); + } + } + Widget renderzActiveUi(){ if(activeOffersList.length!=0){ @@ -416,199 +661,239 @@ class _OffersDataState extends State with TickerProviderStateMixin { children: [ Expanded(child:ListView.builder( padding: EdgeInsets.all(0), - itemCount: activeOffersList.length, - itemBuilder: (BuildContext context, int index) { - return Card( - margin: EdgeInsets.all(8.0), - child: ListTile( - contentPadding: EdgeInsets.all(8.0), - leading: CircleAvatar( - backgroundImage: AssetImage('images/logo.png'), // Replace with your image path - radius: 30, // Adjust the radius as needed - ), - title: RichText( - text: TextSpan( - style: DefaultTextStyle.of(context).style, - children: [ - TextSpan( - text: 'Name: ', - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - ), + itemCount: activeOffersList .length, + itemBuilder: (context,index){ + var data=activeOffersList[index]; + return GestureDetector( + onTap: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new Viewpager(activeOffersList,index))); + }, + child: Card( + child: ListTile( + leading: Container( + width: 100, + height: 300, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + image: DecorationImage( + fit: BoxFit.cover, + alignment: Alignment.center, // Align the image within the container + image: data.picture.isEmpty + ? AssetImage('images/logo.png') as ImageProvider + : NetworkImage(activeOffersList[index].picture[0].url), ), - TextSpan( - text: activeOffersList[index].offer_name, - style: TextStyle( - color: primaryColor, + ), + ), + + + title: RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Name: ', + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + ), ), - ), - ], + TextSpan( + text: activeOffersList[index].offer_name, + style: TextStyle( + color: primaryColor, + ), + ), + ], + ), ), - ), - subtitle: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // ... (other RichText widgets for Code, Description, Start Date, End Date) - RichText( - text: TextSpan( - style: DefaultTextStyle.of(context).style, - children: [ - TextSpan( - text: 'Code: ', - style: TextStyle( - color: Colors.black, // Change the color for "Description" text - fontWeight: FontWeight.bold, // You can apply other styles too + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // ... (other RichText widgets for Code, Description, Start Date, End Date) + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Code: ', + style: TextStyle( + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), ), - ), - TextSpan( - text: activeOffersList[index].offer_code, - style: TextStyle( - color: primaryColor, // Change the color for description content + TextSpan( + text: activeOffersList[index].offer_code, + style: TextStyle( + color: primaryColor, // Change the color for description content + ), ), - ), - ], + ], + ), ), - ), - RichText( - text: TextSpan( - style: DefaultTextStyle.of(context).style, - children: [ - TextSpan( - text: 'Description: ', - style: TextStyle( - color: Colors.black, // Change the color for "Description" text - fontWeight: FontWeight.bold, // You can apply other styles too + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Description: ', + style: TextStyle( + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), ), - ), - TextSpan( - text: activeOffersList[index].description, - style: TextStyle( - color:primaryColor, // Change the color for description content + TextSpan( + text: activeOffersList[index].description, + style: TextStyle( + color:primaryColor, // Change the color for description content + ), ), - ), - ], + ], + ), ), - ), - RichText( - text: TextSpan( - style: DefaultTextStyle.of(context).style, - children: [ - TextSpan( - text: 'Start Date: ', - style: TextStyle( - color: Colors.black, // Change the color for "Description" text - fontWeight: FontWeight.bold, // You can apply other styles too + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Category: ', + style: TextStyle( + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), ), - ), - TextSpan( - text: activeOffersList[index].starting_date, - - style: TextStyle( - color:primaryColor, // Change the color for description content + TextSpan( + text: activeOffersList[index].category, + style: TextStyle( + color:primaryColor, // Change the color for description content + ), ), - ), - ], + ], + ), ), - ), - RichText( - text: TextSpan( - style: DefaultTextStyle.of(context).style, - children: [ - TextSpan( - text: 'End Date :', - style: TextStyle( - color: Colors.black, // Change the color for "Description" text - fontWeight: FontWeight.bold, // You can apply other styles too + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Start Date: ', + style: TextStyle( + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), ), - ), - TextSpan( - text: activeOffersList[index].ending_date, - style: TextStyle( - color:primaryColor, // Change the color for description content + TextSpan( + text: activeOffersList[index].starting_date, + + style: TextStyle( + color:primaryColor, // Change the color for description content + ), ), - ), - ], + ], + ), ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - IconButton( - icon: Icon(Icons.edit), - onPressed: () { - showUpdateOfferDialog(activeOffersList[index]); - }, + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'End Date :', + style: TextStyle( + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), + ), + TextSpan( + text: activeOffersList[index].ending_date, + style: TextStyle( + color:primaryColor, // Change the color for description content + ), + ), + ], ), - Switch( - value: false, // Replace with your actual property - onChanged: (newValue) { - if (newValue) { - // Show your AlertDialog for confirmation - showDialog( - context: context, - builder: (BuildContext context) => AlertDialog( - title: Text( - 'Do you want to In_Activate the offer?', - style: TextStyle( - color: primaryColor, - fontSize: 16, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + icon: Icon(Icons.edit), + onPressed: () { + + showUpdateOfferDialog(activeOffersList[index], index); + }, + ), + Switch( + value: false, // Replace with your actual property + onChanged: (newValue) { + if (newValue) { + // Show your AlertDialog for confirmation + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: Text( + 'Do you want to In_Activate the offer?', + style: TextStyle( + color: primaryColor, + fontSize: 16, + ), ), - ), - actionsAlignment: MainAxisAlignment.spaceBetween, - actions: [ - TextButton( - onPressed: () async { - bool deleteOfferStatus = - await AppSettings.deleteOffers( - activeOffersList[index].offer_code); - if (deleteOfferStatus) { - getActiveOffersViewData(); - AppSettings.longSuccessToast( - 'Offer In_Active Successfully!!'); - getInactiveOffersViewData(); - // Update the isActive property - - } else { - AppSettings.longFailedToast('Offer In_Active failed'); - } - Navigator.of(context).pop(true); - }, - child: const Text( - 'Yes', - style: TextStyle( - color: primaryColor, - fontSize: 18, + actionsAlignment: MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + bool deleteOfferStatus = + await AppSettings.deleteOffers( + activeOffersList[index].offer_code); + if (deleteOfferStatus) { + getActiveOffersViewData(); + AppSettings.longSuccessToast( + 'Offer In_Active Successfully!!'); + getInactiveOffersViewData(); + // Update the isActive property + + } else { + AppSettings.longFailedToast('Offer In_Active failed'); + } + Navigator.of(context).pop(true); + }, + 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, + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text( + 'No', + style: TextStyle( + color: primaryColor, + fontSize: 18, + ), ), ), - ), - ], - ), - ); - } else { - // Handle the case where the user wants to undo the In_Activation - // Update the isActive property - //m;./ activeOffersList[index].isActive = false; - // You might want to add code to revert the In_Activation in your data model here - } + ], + ), + ); + } else { + // Handle the case where the user wants to undo the In_Activation + // Update the isActive property + //m;./ activeOffersList[index].isActive = false; + // You might want to add code to revert the In_Activation in your data model here + } - }, - ), - ], - ), - ], + }, + ), + ], + ), + ], + ), ), ), ); @@ -704,13 +989,24 @@ class _OffersDataState extends State with TickerProviderStateMixin { padding: EdgeInsets.all(0), itemCount: inactiveOffersList.length, itemBuilder: (BuildContext context, int index) { + var data=inactiveOffersList[index]; return Card( margin: EdgeInsets.all(8.0), child: ListTile( contentPadding: EdgeInsets.all(8.0), - leading: CircleAvatar( - backgroundImage: AssetImage('images/logo.png'), // Replace with your image path - radius: 30, // Adjust the radius as needed + leading: Container( + width: 100, + height: 300, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + image: DecorationImage( + fit: BoxFit.cover, + alignment: Alignment.center, // Align the image within the container + image: data.picture.isEmpty + ? AssetImage('images/logo.png') as ImageProvider + : NetworkImage(inactiveOffersList[index].picture[0].url), + ), + ), ), title: RichText( text: TextSpan( @@ -775,6 +1071,26 @@ class _OffersDataState extends State with TickerProviderStateMixin { ], ), ), + RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Category: ', + style: TextStyle( + color: Colors.black, // Change the color for "Description" text + fontWeight: FontWeight.bold, // You can apply other styles too + ), + ), + TextSpan( + text: inactiveOffersList[index].category, + style: TextStyle( + color:primaryColor, // Change the color for description content + ), + ), + ], + ), + ), RichText( text: TextSpan( style: DefaultTextStyle.of(context).style, @@ -847,9 +1163,9 @@ class _OffersDataState extends State with TickerProviderStateMixin { bool deleteTankStatus = await AppSettings.reactiveOffers(inactiveOffersList[index].offer_code); if (deleteTankStatus) { - getInactiveOffersViewData(); AppSettings.longSuccessToast('offer Re-Active successfully'); getActiveOffersViewData(); + getInactiveOffersViewData(); Navigator.of(context).pop(true); } else { AppSettings.longFailedToast('offer Re-Active failed'); @@ -1030,6 +1346,16 @@ class _OffersDataState extends State with TickerProviderStateMixin { appBar: AppBar( title: Text('Offers'), backgroundColor: primaryColor, + leading: IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () async { + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const Dashboard()), + ); + }, + ), bottom: TabBar( controller: _controller, tabs: topTabs, diff --git a/lib/offersview.dart b/lib/offersview.dart index 7dc1b0f..4dffce8 100644 --- a/lib/offersview.dart +++ b/lib/offersview.dart @@ -416,8 +416,6 @@ class _OffersViewState extends State with TickerProviderStateMixin { itemCount: offersviewList.length, itemBuilder: (BuildContext context, int index) { return Card( - - color: offersviewList[index].cardColor, child: Padding( padding:EdgeInsets.all(8) , child: Row( @@ -451,12 +449,11 @@ class _OffersViewState extends State with TickerProviderStateMixin { 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].offer,style: valuesTextStyle()), - Text(offersviewList[index].starting_date,style: valuesTextStyle()), - Text(offersviewList[index].ending_date,style: valuesTextStyle()) + Text(offersviewList[index].offer_name??"",style: valuesTextStyle()), + Text(offersviewList[index].offer_code??"",style: valuesTextStyle()), + Text(offersviewList[index].description??"",style: valuesTextStyle()), + Text(offersviewList[index].starting_date??"",style: valuesTextStyle()), + Text(offersviewList[index].ending_date??"",style: valuesTextStyle()) ], ), diff --git a/lib/pharmacyaccounts.dart b/lib/pharmacyaccounts.dart new file mode 100644 index 0000000..4310ec5 --- /dev/null +++ b/lib/pharmacyaccounts.dart @@ -0,0 +1,509 @@ +import 'dart:convert'; +import 'dart:ffi'; + +import 'package:flutter/material.dart'; +import 'package:healthcare_pharmacy/models/pharmacy_accounts_model.dart'; +import 'package:healthcare_pharmacy/settings.dart'; + + +class PharmacyAccounts extends StatefulWidget { + const PharmacyAccounts({Key? key}) : super(key: key); + + @override + State createState() => _PharmacyAccountsState(); +} + +class _PharmacyAccountsState extends State { + List accountsList = []; + String acceptedCount = ''; + String pendingRejectedCount = ''; + String deliveredCount = ''; + String deliveredTotalPrice = ''; + String deliveredTotalAmountPaid = ''; + String deliveredTotalAmountDue = ''; + + bool isLoading = false; + bool isSereverIssue = false; + + Future readJson() async { + isLoading = true; + + try { + var pharmaResponse = await AppSettings.getPharmacyAccounts(); + print("pharmaResponse"+pharmaResponse); + setState(() { + accountsList = + ((jsonDecode(pharmaResponse)['data']) as List).map((dynamic model) { + return PharmacyAccountsModel.fromJson(model); + }).toList(); + acceptedCount = jsonDecode(pharmaResponse)['acceptedCount'].toString(); + pendingRejectedCount = + jsonDecode(pharmaResponse)['pendingRejectedCount'].toString(); + deliveredCount = + jsonDecode(pharmaResponse)['deliveredCount'].toString(); + deliveredTotalPrice = + jsonDecode(pharmaResponse)['deliveredTotalPrice'].toString(); + deliveredTotalAmountPaid = + jsonDecode(pharmaResponse)['deliveredTotalAmountPaid'].toString(); + deliveredTotalAmountDue = + jsonDecode(pharmaResponse)['deliveredTotalAmountDue'].toString(); + + isLoading = false; + }); + } catch (e) { + setState(() { + isLoading = false; + isSereverIssue = true; + }); + } + } + @override + void initState() { + // TODO: implement initState + readJson(); + super.initState(); + } + + modelBottomSheet(var obj) { + showModalBottomSheet( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only(topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0)), + ), + isScrollControlled: true, + context: context, + builder: (BuildContext context) { + return SizedBox( + height: MediaQuery.of(context).size.height * .300, + child: Padding( + padding: EdgeInsets.all(10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Supplier Name', style: labelTextStyle()), + Text('Delivery Agent', style: labelTextStyle()), + Text('Tanker Name', style: labelTextStyle()), + Text('Capacity Of Tanker', style: labelTextStyle()), + Text('Booking Id', style: labelTextStyle()), + Text('Date Of Order', style: labelTextStyle()), + Text('Type Of Water', style: labelTextStyle()), + Text('Start Time', style: labelTextStyle()), + Text('Stop Time', style: labelTextStyle()), + Text('Initial Water Level', style: labelTextStyle()), + Text('Final Water Level', style: labelTextStyle()), + Text('Delivered Water', style: labelTextStyle()), + Text('Actual Price', style: labelTextStyle()), + Text('Amount Paid', style: labelTextStyle()), + Text('Amount Due', style: labelTextStyle()), + Text('Payment Mode', style: labelTextStyle()), + ], + ), + SizedBox(width:5), + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + ], + ), + SizedBox(width:5), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(obj.supplierName, style: valuesTextStyle()), + Text(obj.delivery_agent, style: valuesTextStyle()), + Text(obj.tanker_name, style: valuesTextStyle()), + Text(obj.capacity + ' Ltrs', style: valuesTextStyle()), + Text(obj.bookingid, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + Text(obj.dateOfOrder, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + Text(obj.typeofwater, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + Text(obj.start_time, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + Text(obj.stop_time, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + Text(obj.initial_water_level + ' Ltrs', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + Text(obj.final_water_level + ' Ltrs', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + Text(obj.quantityDelivered + ' Ltrs', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + Text(obj.price, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + Text(obj.amount_paid, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + Text(obj.amount_due, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + Text(obj.payment_mode, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + ], + ), + ), + + Expanded(child: Column( + children: [ + Icon(Icons.payment_outlined, color: obj.payment_color, size: 40,), + Text(obj.displayText, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + )), + ], + )) + ], + ), + )); + }, + ); + } + + Widget _accounsList() { + if (accountsList.length != 0) { + return Column(crossAxisAlignment: CrossAxisAlignment.center, children: [ + Container( + width: double.infinity, + child: Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 0), + child: Card( + child: Padding( + padding: EdgeInsets.all(8), + child: Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'acceptedCount', + style: labelTextStyle(), + ), + Text( + 'pendingRejectedCount', + style: labelTextStyle(), + ), + Text( + 'deliveredCount', + style: labelTextStyle(), + ), + Text( + 'deliveredTotalPrice', + style: labelTextStyle(), + ), + Text( + 'deliveredTotalAmountPaid', + style: labelTextStyle(), + ), + Text( + 'deliveredTotalAmountDue', + style: labelTextStyle(), + ), + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + ': ', + style: labelTextStyle(), + ), + Text( + ': ', + style: labelTextStyle(), + ), + Text( + ': ', + style: labelTextStyle(), + ), + Text( + ': ', + style: labelTextStyle(), + ), + Text( + ': ', + style: labelTextStyle(), + ), + Text( + ': ', + style: labelTextStyle(), + ), + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + acceptedCount, + style: valuesTextStyle(), + ), + Text( + deliveredCount, + style: valuesTextStyle(), + ), + Text( + pendingRejectedCount, + style: valuesTextStyle(), + ), + Row( + children: [ + Icon( + Icons.currency_rupee, + color: Colors.black, + size: 10, + ), + SizedBox(width: 5), + Text( + AppSettings.formNum(deliveredTotalPrice), + style: valuesTextStyle(), + ), + ], + ), + Row( + children: [ + Icon( + Icons.currency_rupee, + color: Colors.black, + size: 10, + ), + SizedBox(width: 5), + Text( + AppSettings.formNum( + deliveredTotalAmountPaid), + style: valuesTextStyle(), + ), + ], + ), + Row( + children: [ + Icon( + Icons.currency_rupee, + color: Colors.black, + size: 10, + ), + SizedBox(width: 5), + Text(deliveredTotalAmountDue=='null'? + '':AppSettings.formNum( + deliveredTotalAmountDue), + style: valuesTextStyle(), + ), + ], + ), + ], + ), + ], + ))), + )), + Expanded( + child: ListView.builder( + padding: EdgeInsets.all(8), + itemCount: accountsList.length, + itemBuilder: (BuildContext context, int index) { + return Card( + child: Padding( + padding: EdgeInsets.all(8), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + // width: MediaQuery.of(context).size.width * .75, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('pharmacyId', style: labelTextStyle()), + Text('bookingId', + style: labelTextStyle()), + Text('biddingAmount', + style: labelTextStyle()), + ], + ), + SizedBox(width: 5), + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + Text(':', style: labelTextStyle()), + ], + ), + SizedBox(width: 5), + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + accountsList[index] + .pharmacyId + .toUpperCase(), + style: valuesTextStyle()), + Text( + accountsList[index] + .bookingId + .toUpperCase(), + style: valuesTextStyle()), + Text( + accountsList[index] + .biddingAmount + .toUpperCase()+' Ltrs', + style: valuesTextStyle()), + ], + ), + ], + ), + ), + Visibility( + visible: accountsList[index].orderStatus=='delivered' , + child: Expanded( + child: TextButton( + onPressed: () { + //modelBottomSheet(accountsList[index]); + }, + child: const Text( + 'More Details', + style: TextStyle( + color: primaryColor, + fontSize: 15, + decoration: TextDecoration.underline, + ), + ), + ), + ),) + ], + ), + ), + ); + })), + ]); + } else { + return Center( + child: Padding( + padding: EdgeInsets.fromLTRB(0, 40, 0, 0), + child: isSereverIssue + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image( + image: AssetImage('images/updatepin.png.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(), + ), + ], + ) + : Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image( + image: AssetImage('images/no_data.png'), + // height: MediaQuery.of(context).size.height * .10, + ), + SizedBox( + height: 20, + ), + Text( + 'No Data', + style: serverIssueTextStyle(), + ), + ], + ), + )); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('Accounts'), + body: isLoading + ? Center( + child: CircularProgressIndicator( + color: primaryColor, + strokeWidth: 5.0, + ), + ) + : _accounsList(), + ); + } +} diff --git a/lib/qrcode_display.dart b/lib/qrcode_display.dart new file mode 100644 index 0000000..3a9d9bc --- /dev/null +++ b/lib/qrcode_display.dart @@ -0,0 +1,124 @@ +import 'dart:convert'; +import 'dart:io'; +import 'dart:ui'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_share/flutter_share.dart'; +import 'package:healthcare_pharmacy/settings.dart'; +import 'package:share/share.dart'; +import 'dart:typed_data'; +import 'package:path_provider/path_provider.dart'; +import 'package:http/http.dart' as http; +import 'package:qr_flutter/qr_flutter.dart'; + + + +class DisplayQrCode extends StatefulWidget { + const DisplayQrCode({Key? key}) : super(key: key); + + @override + State createState() => _DisplayQrCodeState(); +} + +class _DisplayQrCodeState extends State { + + + + Future share(var qr) async { + await FlutterShare.share( + title: 'Example share', + text: 'Example share text', + linkUrl: qr, + chooserTitle: 'Example Chooser Title'); + } + + Future shareQRCodeImage1(qrData) async { + + final tempDir = await getTemporaryDirectory(); + final file = File('${tempDir.path}/qr_code.png'); + await file.writeAsBytes(Uint8List.fromList(base64.decode(qrData))); + + // Share the image using the share package + Share.shareFiles([file.path], text: 'Check out this QR code'); + + } + + String imagePath = ''; + + Future downloadQRImage() async { + final response = await http.get(Uri.parse(AppSettings.qrCode)); + + if (response.statusCode == 200) { + final directory = await getApplicationDocumentsDirectory(); + final filePath = '${directory.path}/qr_image.png'; + + final File file = File(filePath); + await file.writeAsBytes(response.bodyBytes); + + setState(() { + imagePath = filePath; + }); + } + } + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('Qr Code'), + body: Container( + child: Padding(padding: EdgeInsets.all(10), + child: Column( + children: [ + Center( + child: Container( + padding: EdgeInsets.fromLTRB(0, 20, 0, 0), + width: MediaQuery.of(context).size.width * .60, // Set the desired width + height: MediaQuery.of(context).size.height * .35, // Set the desired height + child: + Image.memory(Uint8List.fromList(base64.decode(AppSettings.qrCode),), + fit: BoxFit.fill), + ), + ), + SizedBox( + height:MediaQuery.of(context).size.height * .05, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + onPressed: () { + //share(AppSettings.qrCode); + shareQRCodeImage1(AppSettings.qrCode); + }, + icon: Icon( + Icons.share, + color: primaryColor, + size: 40, + ), + ), + /*IconButton( + onPressed: () { + downloadQRImage(); + }, + icon: Icon( + Icons.download, + color: primaryColor, + size: 40, + ), + ),*/ + ], + ) + /*Container( + padding: EdgeInsets.fromLTRB(0, 20, 0, 0), + child: Center(child: Image.memory(Uint8List.fromList(base64.decode(AppSettings.qrCode),),),), + )*/ + + ], + ),), + ), + ); + + } +} diff --git a/lib/settings.dart b/lib/settings.dart index 2495ab9..3719763 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -19,6 +19,7 @@ import 'package:fluttertoast/fluttertoast.dart'; const Color primaryColor = Color(0XFFA78966); const Color secondaryColor = Color(0XFFF0E0CC); const Color buttonColor = Color(0XFF6A3632); +const Color buttonColors = Color(0XFFFFAC1C); const Color greyColor = Color(0XFF8F8E8E); const Color textFieldStartColor = Colors.grey; @@ -156,6 +157,8 @@ class AppSettings { static bool haspermission = false; static late LocationPermission permission; static late Position position; + static String qrCode = ''; + static String long = "", lat = ""; late StreamSubscription positionStream; static String fcmId=''; @@ -163,7 +166,7 @@ class AppSettings { //api urls - static String host = 'http://35.200.129.165:4000/api/'; + static String host = 'http://cloudh.in:4000/api/'; static String loginUrl = host + 'pharmacylogin'; static String signUpUrl = host + 'addPharmacy'; static String updatePharmacyUrl = host + 'update/currentPharmacy'; @@ -171,6 +174,7 @@ class AppSettings { static String profilePicUrl = host + 'users/profile-picture'; static String uploadPicUrl = host + 'uploadsPharmacy'; static String uploadOfferUrl = host + 'uploads-offerPicture'; + static String updateuploadOfferUrl = host + 'update-uploads-offerPicture'; static String resetTokenUrl = host + 'reset_token'; static String forgotPasswordUrl = host + 'forgotpassword'; static String resetPasswordUrl = host + 'resetpassword'; @@ -179,6 +183,7 @@ class AppSettings { static String createOffersUrl = host + 'addoffer'; static String createCompanyOffersUrl = host + 'addcompanyoffer'; static String getOffersActiveDataUrl = host + 'getActivePharmacyOfferdata'; + static String getApprovedOffersDataUrl = host + 'getapprovedPharmacyOfferdata'; static String getOffersinActiveDataUrl = host + 'getInActivePharmacyOfferdata'; static String updateOffersDataUrl = host + 'updateOffer'; static String inactiveOffersDataUrl = host + 'inactiveOffer'; @@ -186,32 +191,24 @@ class AppSettings { static String deleteOfferUrl = host + 'deleteOffer'; static String medecineDataUrl = host + 'medicine'; static String getAllBiddingDataUrl = host + 'getBiddingRequests'; - static String getRequestBiddingDataUrl = host + 'biddingRequest'; + static String getRequestBiddingDataUrl = host + 'statusBiddingRequest'; static String addToCartDataUrl = host + 'cart/add'; static String getCartDataUrl = host + 'cart/total-price'; + static String getCartFinalAmmountUrl = host + 'cart/final-price-with-gst'; static String getPharmacyDataUrl = host + 'getAllPharmacylist'; - - - - - - - - - - - - - - - - - + static String inviteFriendUrl = host + 'pharmacySendInviteLink'; + static String addDeliveryboyUrl = host + 'addDeliveryboys'; + static String getAllDeliverboyUrl = host + 'deliveryBoys'; + static String updateDeliveryboyUrl = host + 'editDeliveryBoy'; + static String deleteDeliveryboyUrl = host + 'deletedeliveryboy'; + static String getPharmacyAccountsUrl = host + 'pharmacyAccounts'; + static String generateQRCodeUrl = host + 'generate-qrcode-pharmacy'; static File? updatedImage; static String image = ''; static String profilePictureUrl = ''; + static String description = ''; static String offerPictureUrl = ''; static var api = { @@ -232,7 +229,9 @@ class AppSettings { double.parse(s), ); } - + TextStyle drawerHeaderTextStyleNew() { + return TextStyle(color: Colors.black, fontSize: 15); + } /* Preloader */ @@ -370,6 +369,64 @@ class AppSettings { } + + static Future generateQRCode() async { + var uri = Uri.parse(generateQRCodeUrl + '/' + healthpharmaIdsign); + + var response = await http.post(uri, headers: await buildPutRequestHeaders()); + if (response.statusCode == 200) { + return response.body; + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = await http.post(uri, headers: await buildPutRequestHeaders()); + if (response.statusCode == 200) { + return response.body; + } else { + return ''; + } + } else { + return ''; + } + } else { + return ''; + } + } + + + static Future inviteFriend(payload) async { + + var uri = Uri.parse(inviteFriendUrl); + uri = uri.replace(query: 'pharmacyId=$healthpharmaIdsign'); + var response = await http.post(uri, + body: json.encode(payload), headers: await buildRequestHeaders()); + + if (response.statusCode == 200) { + try { + var _response = json.decode(response.body); + print(_response); + return true; + } catch (e) { + // display error toast + return false; + } + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = await http.post(uri, + body: json.encode(payload), headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } static Future uploadImageHTTPNew(file) async { var request = http.MultipartRequest('POST', Uri.parse(uploadPicUrl + '/' + healthpharmaIdsign)); @@ -390,10 +447,6 @@ class AppSettings { return response.body; } - - - - static Future updatePharmaData(payload) async { try { var response = await http.put( @@ -409,6 +462,7 @@ class AppSettings { pharmacyDescription = _response['description']; await saveData('pharmacyname', _response['simplydata']['pharmacyname'], 'STRING'); await saveData('phone', _response['simplydata']['phone'], 'STRING'); + await saveData('description', _response['simplydata']['description'], 'STRING'); await saveData('email', _response['simplydata']['email'][0]['email'], 'STRING'); await loadDataFromMemory(); return true; @@ -451,8 +505,6 @@ class AppSettings { return false; } } - - static Future deleteInActiveOffer(offerCode) async { var uri = Uri.parse(deleteOfferUrl + '/' + healthpharmaIdsign); uri = uri.replace(query: 'offer_code=$offerCode'); @@ -484,14 +536,8 @@ class AppSettings { return false; } } - - - - - - static Future createCompanyOffers(payload) async { - var uri = Uri.parse(createCompanyOffersUrl + '/' + "123456"); + var uri = Uri.parse('http://35.200.129.165:4000/api/addcompanyoffer/1234'); var response = await http.post(uri, body: json.encode(payload), headers: await buildRequestHeaders()); if (response.statusCode == 200) { @@ -520,10 +566,6 @@ class AppSettings { return false; } } - - - - static Future getOffers() async { //path parameter var uri = Uri.parse(getOffersActiveDataUrl + '/' + healthpharmaIdsign); @@ -546,7 +588,28 @@ class AppSettings { return ''; } } - + static Future getApprovedOffers() async { + //path parameter + var uri = Uri.parse(getApprovedOffersDataUrl + '/' + healthpharmaIdsign); + var response = await http.get(uri, headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return response.body; + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = await http.get(uri, headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return response.body; + } else { + return ''; + } + } else { + return ''; + } + } else { + return ''; + } + } static Future getCartDetails(bookingId) async { //path parameter @@ -573,7 +636,6 @@ class AppSettings { return ''; } } - static Future addToCart(String orderId, String quantity, String price,String mName,String mtimings) async { var headers = { 'Content-Type': 'application/json' @@ -604,29 +666,27 @@ class AppSettings { return response; } -/* static Future addToCart(payload) async { - var response = await http.post(Uri.parse(addToCartDataUrl), - body: json.encode(payload), - headers: {'Content-type': 'application/json'}); + static Future cartFinalAmmount(String bookingId,String totalPrice, String priceGst, String additionalDiscont,) async { + var headers = { + 'Content-Type': 'application/json' + }; + var body=json.encode({ + "totalPrice": totalPrice, + "gst": priceGst, + "additional_discount": additionalDiscont + }); + print("cartResponce"+body.toString()); + var uri = Uri.parse(getCartFinalAmmountUrl+ '/' + bookingId); + var response = await http.post( + uri, + headers: headers, + body: body, + ); + + return response; + } + - if (response.statusCode == 200) { - try { - var _response = jsonDecode(response.body); - print("responcedata$_response"); - return true; - *//* if (_response['items']['error'] == false) { - return true; - } else { - return false; - }*//* - } catch (e) { - // display error toast - return false; - } - } else { - return false; - } - }*/ @@ -651,8 +711,6 @@ class AppSettings { return ''; } } - - static Future getAllBiddingRecords() async { //path parameter var uri = Uri.parse(getAllBiddingDataUrl + '/' + healthpharmaIdsign); @@ -675,40 +733,6 @@ class AppSettings { return ''; } } - - //getRequestBiddingDataUrl - - - /*static Future getRequestBiddingDetails( bookingId) async { - var uri = Uri.parse(getRequestBiddingDataUrl + '/' +bookingId ); - try { - var response = await http.put(uri, headers: await buildRequestHeaders()); - var responcedatatemp=jsonDecode(response.body); - print("responcedata$responcedatatemp"); - print("responcedata$bookingId"); - if (response.statusCode == 200) { - return true; - } else if (response.statusCode == 401) { - bool status = await AppSettings.resetToken(); - if (status) { - response = await http.put(uri, headers: await buildRequestHeaders()); - if (response.statusCode == 200) { - return true; - } else { - return false; - } - } else { - return false; - } - } else { - return false; - } - } catch (e) { - print(e); - return false; - } - }*/ - static Future getRequestBiddingDetails(var bookingId,payload) async { var response = await http.put(Uri.parse(getRequestBiddingDataUrl + '/' + bookingId), body: json.encode(payload), headers: await buildRequestHeaders()); @@ -738,13 +762,6 @@ class AppSettings { return false; } } - - - - - - - static Future getinactiveOffers() async { //path parameter var uri = Uri.parse(getOffersinActiveDataUrl + '/' + healthpharmaIdsign); @@ -767,15 +784,25 @@ class AppSettings { return ''; } } + static Future offerupdateuploadImageHTTPNew(file, var offerCode) async { + var request = http.MultipartRequest('POST', Uri.parse(updateuploadOfferUrl + '/' + healthpharmaIdsign+"/"+offerCode)); + request.files.add(await http.MultipartFile.fromPath('picture', file.path)); + var res = await request.send(); + var response = await http.Response.fromStream(res); + if(response.statusCode==200){ + return response.body; + } + else{ + return 'error'; + } + + } static Future updateOffers(offer_code, payload) async { var uri = Uri.parse(updateOffersDataUrl + '/' + healthpharmaIdsign); uri = uri.replace(query: 'offer_code=$offer_code'); - - try { var response = await http.put(uri, body: json.encode(payload), headers: await buildRequestHeaders()); - if (response.statusCode == 200) { return true; } else if (response.statusCode == 401) { @@ -830,7 +857,6 @@ class AppSettings { return false; } } - static Future reactiveOffers(offer_code) async { var uri = Uri.parse(reactiveOffersDataUrl + '/' + healthpharmaIdsign); uri = uri.replace(query: 'offer_code=$offer_code'); @@ -862,7 +888,6 @@ class AppSettings { return false; } } - static Future sendSms(payload) async{ var response=await http.post(Uri.parse(sendSmsUrl),body: json.encode(payload), headers: {'Content-type': 'application/json'}); if(response.statusCode==200){ @@ -872,7 +897,6 @@ class AppSettings { return false; } } - static Future getAllMedecines(var medicine) async { var uri = Uri.parse(medecineDataUrl + '/' + medicine); //uri = uri.replace(query: 'customerId=$customerId'); @@ -896,8 +920,6 @@ class AppSettings { return ''; } } - - static Future phoneVerification(payload) async{ var response=await http.post(Uri.parse(phoneVerificationUrl),body: json.encode(payload), headers: {'Content-type': 'application/json'}); if(response.statusCode==200){ @@ -907,7 +929,6 @@ class AppSettings { return false; } } - static Future resetToken() async { var uri = Uri.parse(resetTokenUrl + '/' + pharmacyId); @@ -952,11 +973,6 @@ class AppSettings { return false; } } - - - - - static Future updateProfilePicture(payload) async { var uri = Uri.parse(profilePicUrl + '/' + pharmacyId); var response = await http.post(uri, @@ -992,6 +1008,155 @@ class AppSettings { } } + + static Future addDeliverboy(payload) async { + var response = await http.post(Uri.parse(addDeliveryboyUrl + '/' + healthpharmaIdsign), + body: json.encode(payload), headers: await buildRequestHeaders()); + + if (response.statusCode == 200) { + try { + var _response = json.decode(response.body); + print(_response); + return true; + } catch (e) { + // display error toast + return false; + } + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = await http.post(Uri.parse(addDeliveryboyUrl + '/' + healthpharmaIdsign), + body: json.encode(payload), headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } + + + + static Future getAllDeliverboy() async { + var response = await http.get(Uri.parse(getAllDeliverboyUrl + '/' + healthpharmaIdsign), + headers: await buildRequestHeaders()); + + if (response.statusCode == 200) { + try { + var _response = json.decode(response.body); + print(_response); + return response.body; + } catch (e) { + // display error toast + return ''; + } + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = await http.get(Uri.parse(getAllDeliverboyUrl + '/' + healthpharmaIdsign), + headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return response.body; + } else { + return ""; + } + } else { + return ""; + } + } else { + return ""; + } + } + + static Future updateDeliveryboy(phone, payload) async { + var uri = Uri.parse(updateDeliveryboyUrl + '/' + healthpharmaIdsign); + uri = uri.replace(query: 'phone=$phone'); + try { + var response = await http.put(uri, + body: json.encode(payload), headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return true; + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = await http.put(uri, + body: json.encode(payload), headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } catch (e) { + print(e); + return false; + } + } + static Future deleteDeliveryboy(phone) async { + var uri = Uri.parse(deleteDeliveryboyUrl + '/' + healthpharmaIdsign); + uri = uri.replace(query: 'phone=$phone'); + + try { + var response = + await http.put(uri, headers: await buildPutRequestHeaders()); + + if (response.statusCode == 200) { + return true; + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = + await http.put(uri, headers: await buildPutRequestHeaders()); + if (response.statusCode == 200) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } catch (e) { + print(e); + return false; + } + } + + + static Future getPharmacyAccounts() async { + var uri = Uri.parse(getPharmacyAccountsUrl + '/' + healthpharmaIdsign); + var response = await http.get(uri, headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return response.body; + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = await http.get(uri, headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return response.body; + } else { + return ''; + } + } else { + return ''; + } + } else { + return ''; + } + } + /*Apis ends here*/ //save data local @@ -1001,6 +1166,8 @@ class AppSettings { await saveData('pharmacyname', input['simplydata']['pharmacyname'], 'STRING'); await saveData('phone', input['simplydata']['phone'], 'STRING'); await saveData('email', input['simplydata']['email'][0]['email'], 'STRING'); + await saveData('description', input['simplydata']['description'], 'STRING'); + await saveData( 'access_token', input['simplydata']['access_token'], 'STRING'); await saveData('pharmacyId', input['simplydata']['pharmacyId'], 'STRING'); @@ -1013,10 +1180,11 @@ class AppSettings { //latitude,longitude await loadDataFromMemory(); } - + static Future saveProfile(dynamic image) async { // save login name information await saveData('profile', image.toString(), 'STRING'); + await saveData('description', image.toString(), 'STRING'); await saveData('offer', image.toString(), 'STRING'); //await loadDataFromMemory(); @@ -1030,6 +1198,7 @@ class AppSettings { pharmacyName = await getData('pharmacyname', 'STRING'); accessToken = await getData('access_token', 'STRING'); email = await getData('email', 'STRING'); + pharmacyName = await getData('description', 'STRING'); userAddress = await getData('user_address', 'STRING'); phoneNumber = await getData('phone', 'STRING'); healthpharmaIdsign = await getData('pharmacyId', 'STRING'); diff --git a/lib/signup.dart b/lib/signup.dart index 8b6cb81..448b5c7 100644 --- a/lib/signup.dart +++ b/lib/signup.dart @@ -51,6 +51,12 @@ class _SignUpState extends State { String country = ''; double lat=0; double lng=0; + String dropdownTypeOfPlans = 'Red'; + var typeOfCategoryPlans = [ + 'Red', + 'Blue', + 'Green', + ]; @@ -217,6 +223,41 @@ class _SignUpState extends State { ), ), + SizedBox( + height: 10, + ), + Container( + padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), + child: DropdownButtonFormField( + // Initial Value + value: dropdownTypeOfPlans, + isExpanded: true, + decoration: textFormFieldDecoration(Icons.next_plan_outlined,'Type of plan'), + hint: Text('Select Type of water'), + // Down Arrow Icon + icon: const Icon(Icons.keyboard_arrow_down), + + // Array list of items + items: typeOfCategoryPlans.map((String items) { + return DropdownMenuItem( + value: items, + child: Text(items), + ); + }).toList(), + // After selecting the desired option,it will + // change button value to selected value + onChanged: (String? newValue) { + setState(() { + dropdownTypeOfPlans = newValue!; + }); + }, + ), + ), + + + SizedBox( + height: 10, + ), GestureDetector( child: Container( padding: const EdgeInsets.all(10), @@ -454,6 +495,7 @@ class _SignUpState extends State { payload["zip"] = zip; payload["country"] = country; payload["description"] = ''; + payload["plan"] = dropdownTypeOfPlans.toString(); payload["latitude"] = lat; payload["longitude"] = lng; payload["fcmId"] = AppSettings.fcmId; diff --git a/lib/updateprofile.dart b/lib/updateprofile.dart index 2b06eb0..99777c1 100644 --- a/lib/updateprofile.dart +++ b/lib/updateprofile.dart @@ -111,7 +111,8 @@ class _UpdateprofileState extends State { image: AssetImage('images/logo.png'), height: MediaQuery.of(context).size.height * .10, )),*/ - Container(child: GestureDetector( + Container(child: + GestureDetector( child: Container( width: MediaQuery.of(context).size.width * .60, height: MediaQuery.of(context).size.height * .15, @@ -163,6 +164,7 @@ class _UpdateprofileState extends State { ), ); }); + }, ),), SizedBox( @@ -306,23 +308,7 @@ class _UpdateprofileState extends State { context, MaterialPageRoute(builder: (context) => Dashboard()), ); - /* try{ - if (signUpStatus) { - Navigator.pop(context); - AppSettings.longSuccessToast("Pharmacy Profile Updated !!"); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => Dashboard()), - ); - } else { - //AppSettings.longFailedToast("Pharmacy Profile Not Updated !!"); - } - } - catch(exception){ - print(exception); - AppSettings.longFailedToast("Please enter valid details"); - }*/ }, child: Text('Update'), ) diff --git a/lib/viewpager.dart b/lib/viewpager.dart new file mode 100644 index 0000000..42fb436 --- /dev/null +++ b/lib/viewpager.dart @@ -0,0 +1,966 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:healthcare_pharmacy/ZoomedImageView.dart'; +import 'package:healthcare_pharmacy/models/offersview_model.dart'; +import 'package:healthcare_pharmacy/offerstabdata.dart'; +import 'package:healthcare_pharmacy/settings.dart'; +import 'package:intl/intl.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:photo_view/photo_view.dart'; + +import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart'; + + + +class Viewpager extends StatefulWidget { + List userdata; + int position; + Viewpager(this.userdata, this.position); + + @override + State createState() => _ViewpagerState(); +} + +class _ViewpagerState extends State { + late PageController _pageController; + int _currentPageIndex = 0; + String selectedOption = 'Option 1'; + bool isActiveDataLoading=false; + bool isSereverIssue = false; + bool isSereverIssueConnected = false; + bool isSereverIssuePending = false; + + bool switchValue = false; + TextEditingController updateOfferNameController = TextEditingController(); + TextEditingController updateOfferCodeController = TextEditingController(); + TextEditingController updateOfferDescriptionController = TextEditingController(); + TextEditingController updateDiscountController = TextEditingController(); + TextEditingController updateOfferStartDateController = TextEditingController(); + TextEditingController updateOfferEndDateController = TextEditingController(); + String dropdownTypeOfCategory = 'A {1 - 500}'; + var typeOfCategoryItems = [ + 'A {1 - 500}', + 'B {501 - 1000}', + 'C {1001 - 2000}', + 'D {Above 2000}', + 'S {Special offer}', + ]; + + List updateCategoryTypes = []; + + var startdate; + var enddate; + String updateofferUrl=''; + + final ImagePicker _picker = ImagePicker(); + List activeOffersList = []; + + + Future pickImageFromGallery(var offerCode) async { + + try { + final image = await _picker.pickImage(source: ImageSource.gallery); + if (image == null) return ''; + + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.offerupdateuploadImageHTTPNew(image, offerCode); + print(jsonDecode(res)); + + setState(() { + updateofferUrl = jsonDecode(res)['picture'][0]['url']; + print("update url: $updateofferUrl"); + }); + + Navigator.of(context, rootNavigator: true).pop(); + if(res.contains("error")){ + return 'some thing went wrong please try again'; + } + else{ + return jsonDecode(res)['picture'][0]['url']; + } + + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + return 'some thing went wrong please try again'; + } + } + + Future takeImageFromCamera(String offerCode) async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return ''; + + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.offerupdateuploadImageHTTPNew(image, offerCode); + print(jsonDecode(res)); + + setState(() { + updateofferUrl = jsonDecode(res)['picture'][0]['url']; + print("update url: $updateofferUrl"); + }); + + Navigator.of(context, rootNavigator: true).pop(); + if(res.contains("error")){ + return 'some thing went wrong please try again'; + } + else{ + return jsonDecode(res)['picture'][0]['url']; + } + + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + return 'some thing went wrong please try again'; + } + + } + + + + + showUpdateOfferDialog(GetOffersDetailsModel object, int index) async { + updateOfferNameController.text = object.offer_name!; + updateOfferCodeController.text = object.offer_code!; + updateOfferDescriptionController.text = object.description!; + updateOfferStartDateController.text=object.starting_date!; + updateOfferEndDateController.text=object.ending_date!; + updateofferUrl=object.picture[0].url; + return showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + var data=activeOffersList[index]; + print("result$updateofferUrl"); + return AlertDialog( + title: const Text('Update Offer'), + content: SingleChildScrollView( + child: ListBody( + children: [ + // ImageView + InkWell( + onTap: () { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCamera(object.offer_code!).then((value) { + print("datatatttta$value"); + setState(() { + updateofferUrl = value; + // print(updateofferUrl); + }); + }); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGallery(object.offer_code).then((value) { + print("datatatttta$value"); + setState(() { + updateofferUrl = value; + // print(updateofferUrl); + }); + });; + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + child: Container( + width: MediaQuery.of(context).size.width, + height: 150, + child: updateofferUrl.isEmpty + ? Image.network( + "https://assets.aboutamazon.com/dims4/default/1db03c8/2147483647/strip/false/crop/2000x1125+0+0/resize/1200x675!/quality/90/?url=https%3A%2F%2Famazon-blogs-brightspot.s3.amazonaws.com%2Fa3%2Fc2%2F5c0b93db41d789be1bec015003bd%2Fpharmacy-hero-2000x1125.jpg", + fit: BoxFit.cover, + ) + : Image.network( + updateofferUrl, + fit: BoxFit.cover, + ), + ), + + + ), + const SizedBox( + height: 20, + ), + + // Offer Name + Container( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), + child: TextFormField( + cursorColor: greyColor, + controller: updateOfferNameController, + textCapitalization: TextCapitalization.words, + 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: '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.words, + 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: '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.words, + 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: 'Offer Description', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), //tanker name + ), + + + + const SizedBox( + height: 30, + ), + + + Container( + child: DropdownButtonFormField( + // Initial Value + value: dropdownTypeOfCategory, + isExpanded: true, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.type_specimen, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'Type of category', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + + hint: Text('Select Type of category'), + // Down Arrow Icon + icon: const Icon(Icons.keyboard_arrow_down), + + // Array list of items + items: typeOfCategoryItems.map((String items) { + return DropdownMenuItem( + value: items, + child: Text(items), + ); + }).toList(), + // After selecting the desired option,it will + // change button value to selected value + onChanged: (String? newValue) { + setState(() { + dropdownTypeOfCategory = newValue!; + }); + }, + ), + ), + + + + + 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', + 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 index)async { + DateTime selectdate = dateTime; + setState(() { + startdate = DateFormat('dd-MMM-yyyy').format(selectdate); + }); + + if(startdate!=''){ + setState(() { + updateOfferStartDateController.text=startdate.toString(); + }); + } + else { + AppSettings.longFailedToast('Select start 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', + 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 index)async { + DateTime selectdate = dateTime; + setState(() { + enddate = DateFormat('dd-MMM-yyyy').format(selectdate); + }); + + if(enddate!=''){ + setState(() { + updateOfferEndDateController.text=enddate.toString(); + }); + } + else { + AppSettings.longFailedToast('Select end 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: [ + 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); + + Map payload = { + "offer_name": updateOfferNameController.text.toString(), + "offer_code": updateOfferCodeController.text.toString(), + "description":updateOfferDescriptionController.text.toString(), + "category":dropdownTypeOfCategory.toString(), + "starting_date":updateOfferStartDateController.text.toString(), + "ending_date": updateOfferEndDateController.text.toString(), + "picture": [ + { + "url":updateofferUrl + } + ], + "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 = ''; + updateOfferStartDateController.text = ''; + updateOfferEndDateController.text = ''; + await getActiveOffersViewData(); + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const OffersData()), + ); + } 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); + } + }, + ), + ], + ); + }, + ); + }, + ); + } + + Future getActiveOffersViewData() async { + isActiveDataLoading = true; + + + try { + var data = await AppSettings.getOffers(); + setState(() { + List responseData = jsonDecode(data)['data']; + activeOffersList = responseData + .map((jsonObject) => GetOffersDetailsModel.fromJson(jsonObject)) + .toList(); + isActiveDataLoading = false; + }); + + } catch (error) { + setState(() { + isActiveDataLoading = false; + isSereverIssueConnected = true; + }); + } + } + @override + void initState() { + super.initState(); + getActiveOffersViewData(); + _pageController = PageController(initialPage: widget.position); + } + void removeItem(int index) { + setState(() { + widget.userdata.removeAt(index); + if (_currentPageIndex > 0) { + _currentPageIndex--; + } + }); + _pageController = PageController(initialPage: _currentPageIndex); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Offers Details'), + backgroundColor: primaryColor, + leading: IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () async { + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const OffersData()), + ); + }, + ), + ), + body: PageView.builder( + controller: _pageController, + itemCount: widget.userdata.length, + onPageChanged: (int index) { + setState(() { + _currentPageIndex = index; + }); + }, + itemBuilder: (BuildContext context, int index) { + var object = widget.userdata[index]; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + Container( + width: MediaQuery.of(context).size.width, // Set width to screen width + height: 350, // Set your desired height + child: GestureDetector( + onTap: () { + + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ZoomedImageView( + imageUrl: widget.userdata[index].picture.isEmpty + ? "https://assets.aboutamazon.com/dims4/default/1db03c8/2147483647/strip/false/crop/2000x1125+0+0/resize/1200x675!/quality/90/?url=https%3A%2F%2Famazon-blogs-brightspot.s3.amazonaws.com%2Fa3%2Fc2%2F5c0b93db41d789be1bec015003bd%2Fpharmacy-hero-2000x1125.jpg" + : widget.userdata[index].picture[0].url, + ), + ), + ); + + }, + child: widget.userdata[index].picture.isEmpty + ? Image.network( + "https://assets.aboutamazon.com/dims4/default/1db03c8/2147483647/strip/false/crop/2000x1125+0+0/resize/1200x675!/quality/90/?url=https%3A%2F%2Famazon-blogs-brightspot.s3.amazonaws.com%2Fa3%2Fc2%2F5c0b93db41d789be1bec015003bd%2Fpharmacy-hero-2000x1125.jpg", + fit: BoxFit.cover, + ) + : Image.network( + widget.userdata[index].picture[0].url, + fit: BoxFit.cover, + ), + ), + ), + + + Positioned( + left: 5.0, // Adjust this value as needed + top: MediaQuery.of(context).size.height / 5 - 16.0, // Center vertically + child: IconButton( + icon: Icon(Icons.arrow_back_ios, color: Colors.white), + onPressed: () { + if (_pageController.page! > 0) { + _pageController.previousPage( + duration: Duration(milliseconds: 300), + curve: Curves.easeInOut, + ); + } + }, + ), + ), + Positioned( + right: 5.0, // Adjust this value as needed + top: MediaQuery.of(context).size.height / 5 - 16.0, // Center vertically + child: IconButton( + icon: Icon(Icons.arrow_forward_ios, color: Colors.white), + onPressed: () { + if (_pageController.page! < widget.userdata.length - 1) { + _pageController.nextPage( + duration: Duration(milliseconds: 300), + curve: Curves.easeInOut, + ); + } + }, + ), + ), + ], + + ), + const SizedBox( + height: 10, + ), + Padding( + padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets + child: RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Name: ', + style: TextStyle( + color: Colors.black, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: widget.userdata[index].offer_name, + style: TextStyle( + color: primaryColor, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ), + const SizedBox( + height: 5, + ), + Padding( + padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets + child: RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Code: ', + style: TextStyle( + color: Colors.black, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: widget.userdata[index].offer_code, + style: TextStyle( + color: primaryColor, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ), + const SizedBox( + height: 5, + ), + Padding( + padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets + child: RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Description: ', + style: TextStyle( + color: Colors.black, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: widget.userdata[index].description ?? "", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: primaryColor, + ), + ), + ], + ), + ), + ), + const SizedBox( + height: 5, + ), + Padding( + padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets + child: RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'Category: ', + style: TextStyle( + color: Colors.black, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: widget.userdata[index].category ?? "", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: primaryColor, + ), + ), + ], + ), + ), + ), + const SizedBox( + height: 5, + ), + Padding( + padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets + child: RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'StartDate: ', + style: TextStyle( + fontSize: 20, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: widget.userdata[index].starting_date ?? "", + style: TextStyle( + color: primaryColor, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ), + const SizedBox( + height: 5, + ), + Padding( + padding: EdgeInsets.only(left: 16.0), // Add left padding to all RichText widgets + child: RichText( + text: TextSpan( + style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: 'EndDate: ', + style: TextStyle( + fontSize: 20, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: widget.userdata[index].ending_date ?? "", + style: TextStyle( + color: primaryColor, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ), + + const SizedBox( + height: 15, + ), + Padding( + padding: EdgeInsets.only(left: 16.0), // Add left padding + child: Row( + children: [ + Switch( + value: false, + onChanged: (value) { + setState(() { + switchValue = value; + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Are you sure you want to in_active this Offer?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + // Perform the action + print("offercode${widget.userdata[index].offer_code}"); + bool deleteOfferStatus = + await AppSettings.deleteOffers( + widget.userdata[index].offer_code); + if(deleteOfferStatus){ + widget.userdata.remove(widget.userdata[index]); + switchValue=false; + } + else{ + switchValue=false; + } + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const OffersData()), + ); // Close the dialog + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(false); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ); + + }, + ); + }); + }, + ), + const SizedBox( + width: 100, + ), + IconButton( + icon: Icon(Icons.edit), + onPressed: () { + showUpdateOfferDialog(object, index); + }, + ), + ], + ), + ), + ], + ); + }, + ), + ); + } +} diff --git a/lib/zoomable_image.dart b/lib/zoomable_image.dart new file mode 100644 index 0000000..de098c9 --- /dev/null +++ b/lib/zoomable_image.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'package:healthcare_pharmacy/settings.dart'; +import 'package:photo_view/photo_view.dart'; + +class ZoomableImage extends StatelessWidget { + final String imageUrl; + + ZoomableImage(this.imageUrl); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primaryColor, // Set the background color + title: Text('Preview Image'), // Set the title text + actions: [ + IconButton( + icon: Icon(Icons.close), + onPressed: () { + Navigator.pop(context); + }, + ), + ], + ), + body: Center( + child: imageUrl.isNotEmpty + ? PhotoView( + imageProvider: NetworkImage(imageUrl), + minScale: PhotoViewComputedScale.contained, + maxScale: PhotoViewComputedScale.contained * 3.0, + ) + : Image.asset( + 'images/mobilebg.png', // Path to your default image + fit: BoxFit.cover, + ), + ), + ); + } +} + diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 1952d66..a6de6bf 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -13,6 +13,7 @@ import flutter_local_notifications import geolocator_apple import location import package_info_plus_macos +import path_provider_foundation import shared_preferences_foundation import url_launcher_macos @@ -25,6 +26,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin")) LocationPlugin.register(with: registry.registrar(forPlugin: "LocationPlugin")) FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index be82167..f41f934 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -286,6 +286,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_barcode_scanner: + dependency: "direct dev" + description: + name: flutter_barcode_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" flutter_cupertino_datetime_picker: dependency: "direct dev" description: @@ -347,6 +354,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_native_contact_picker: + dependency: "direct dev" + description: + name: flutter_native_contact_picker + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -361,6 +375,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" + flutter_share: + dependency: "direct dev" + description: + name: flutter_share + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" flutter_styled_toast: dependency: "direct dev" description: @@ -561,7 +582,7 @@ packages: source: hosted version: "4.0.2" image: - dependency: transitive + dependency: "direct main" description: name: image url: "https://pub.dartlang.org" @@ -686,6 +707,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" nested: dependency: transitive description: @@ -743,7 +771,7 @@ packages: source: hosted version: "1.0.5" path: - dependency: transitive + dependency: "direct dev" description: name: path url: "https://pub.dartlang.org" @@ -763,6 +791,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.1" + path_provider: + dependency: "direct dev" + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.15" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.27" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.4" path_provider_linux: dependency: transitive description: @@ -868,6 +917,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.0.5" + pull_to_refresh: + dependency: "direct dev" + description: + name: pull_to_refresh + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + qr: + dependency: transitive + description: + name: qr + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + qr_code_scanner: + dependency: "direct dev" + description: + name: qr_code_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + qr_flutter: + dependency: "direct dev" + description: + name: qr_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" quantity_input: dependency: "direct dev" description: @@ -882,6 +959,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + share: + dependency: "direct dev" + description: + name: share + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" shared_preferences: dependency: "direct dev" description: @@ -1090,6 +1174,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + visibility_detector: + dependency: "direct dev" + description: + name: visibility_detector + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0+2" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index b7da571..efa1442 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,12 +10,13 @@ dependencies: flutter: sdk: flutter - cupertino_icons: ^1.0.2 + cupertino_icons: ^1.0.2 location: ^4.4.0 geolocator: ^9.0.2 google_api_headers: ^1.2.0 google_maps_flutter: ^2.2.3 + image: ^3.0.1 google_maps_webservice: ^0.0.20-nullsafety.5 http: ^0.13.5 provider: ^6.0.5 @@ -63,6 +64,16 @@ dev_dependencies: carousel_slider: ^4.2.1 photo_view: ^0.14.0 quantity_input: ^1.0.2 + flutter_native_contact_picker: ^0.0.4 + path: ^1.8.0 + path_provider: ^2.0.11 + visibility_detector: ^0.4.0+2 + flutter_share: ^2.0.0 + share: ^2.0.4 + qr_flutter: ^4.0.0 + qr_code_scanner: ^1.0.1 + flutter_barcode_scanner: ^2.0.0 + pull_to_refresh: ^2.0.0 flutter_icons: