diff --git a/images/activeoffer.png b/images/activeoffer.png index f4181c2..358605c 100644 Binary files a/images/activeoffer.png and b/images/activeoffer.png differ diff --git a/lib/companyoffrers.dart b/lib/companyoffrers.dart new file mode 100644 index 0000000..8427972 --- /dev/null +++ b/lib/companyoffrers.dart @@ -0,0 +1,466 @@ +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/settings.dart'; +import 'package:intl/intl.dart'; +import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart'; +import 'package:image_picker/image_picker.dart'; + + + +class CompanyOffers extends StatefulWidget { + const CompanyOffers({Key? key}) : super(key: key); + + @override + State createState() => _CompanyOffersState(); +} + +class _CompanyOffersState extends State { + + TextEditingController offer_nameController = TextEditingController(); + TextEditingController offer_codeController = TextEditingController(); + TextEditingController descriptionController = TextEditingController(); + TextEditingController eligiblepharma_Controller = TextEditingController(); + TextEditingController starting_dateController = TextEditingController(); + TextEditingController ending_dateController = TextEditingController(); + + var selIOS; + final ImagePicker _picker = ImagePicker(); + String offerUrl=''; + + + + + Future pickImageFromGallery() 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.offeruploadImageHTTPNew(image); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + AppSettings.offerPictureUrl = jsonDecode(res)['picture']; + }); + AppSettings.saveData('offer', jsonDecode(res)['picture'], 'STRING'); + } 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); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.offeruploadImageHTTPNew(image); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + //AppSettings.offerPictureUrl = jsonDecode(res)['picture']['url']; + offerUrl=jsonDecode(res)['picture'][0]['url']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + appBar: AppSettings.appBar('Cteate Offers'), + body: Stack(children: [ + + GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: SafeArea( + child: SingleChildScrollView( + child: Column( + children: [ + + SizedBox( + height: 20, + ), + Container(child: GestureDetector( + child: Container( + width: MediaQuery.of(context).size.width * .60, + height: MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + border: Border.all(width: 2, color: Colors.blueGrey), + image: DecorationImage( + image: (offerUrl!= ''&& + offerUrl!= 'null') ? + NetworkImage(offerUrl) as ImageProvider : AssetImage("images/mobilebg.png"), // picked file + fit: BoxFit.fitWidth)), + ), + 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( + height: 05, + ), + Container( + padding: const EdgeInsets.all(10), + child: TextFormField( + cursorColor: greyColor, + controller: offer_nameController, + textCapitalization: TextCapitalization.words, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.person, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + labelText: 'Enter Offer Name', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + ), //name + SizedBox( + height: 05, + ), + Container( + padding: const EdgeInsets.all(10), + child: TextFormField( + cursorColor: greyColor, + controller: offer_codeController, + textCapitalization: TextCapitalization.words, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.numbers, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + labelText: 'Enter Offer Code', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + ), + const SizedBox( + height: 5, + ), + + + + Container( + padding: const EdgeInsets.all(10), + child: TextFormField( + cursorColor: greyColor, + controller: descriptionController, + textCapitalization: TextCapitalization.words, + keyboardType: TextInputType.multiline, + maxLines: null, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.description, + color:primaryColor, + ), + contentPadding: const EdgeInsets.symmetric(vertical:40.0, horizontal:30.0), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'Enter Offer Description', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + ), + Container( + padding: const EdgeInsets.all(10), + child: TextFormField( + cursorColor: greyColor, + controller: eligiblepharma_Controller, + textCapitalization: TextCapitalization.characters, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.local_pharmacy, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + labelText: 'Enter Eligible Pharmacies', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + ), //mobile + const SizedBox( + height: 5, + ), + Container( + padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), + child: TextFormField( + readOnly: true, + cursorColor: greyColor, + controller: starting_dateController, + decoration: InputDecoration( + labelText: 'Select Start Date', + prefixIcon: const Icon(Icons.date_range, color: primaryColor,), + labelStyle: const TextStyle( + color: greyColor, //<-- SEE HERE + ), + border: const OutlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + focusedBorder: const OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + enabledBorder: const OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + suffixIcon: IconButton( + icon: Icon( + Icons.date_range, + ), + onPressed: () async { + DatePicker.showDatePicker( + context, + dateFormat: 'dd MMMM yyyy', + 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'); + } + }, + ); + }, + ), + + ), + + ), + ), + + const SizedBox( + height: 5, + ), + Container( + padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), + child: TextFormField( + readOnly: true, + cursorColor: greyColor, + controller: ending_dateController, + decoration: InputDecoration( + labelText: 'Select End Date', + prefixIcon: const Icon(Icons.date_range, color: primaryColor,), + labelStyle: const TextStyle( + color: greyColor, //<-- SEE HERE + ), + border: const OutlineInputBorder( + borderSide: BorderSide(color: primaryColor)), + focusedBorder: const OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + enabledBorder: const OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + ), + suffixIcon: IconButton( + icon: Icon( + Icons.date_range, + ), + onPressed: () async { + DatePicker.showDatePicker( + context, + dateFormat: 'dd MMMM yyyy', + 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'); + } + }, + ); + }, + ), + + ), + + ), + ),//address description + + const SizedBox( + height:15, + ), + Container( + width:MediaQuery.of(context).size.width * .99, + height: 55, + padding: const EdgeInsets.fromLTRB(3, 0, 3, 0), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + if (offer_nameController.text != '' && + offer_codeController.text != '' && + descriptionController.text != ''&& + starting_dateController.text != '' && + ending_dateController.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["starting_date"] = starting_dateController.text.toString(); + payload["ending_date"] = ending_dateController.text.toString(); + payload["offer_status"] ="active"; + bool offerStatus = await AppSettings.createCompanyOffers(payload); + try{ + if (offerStatus) { + Navigator.pop(context); + Navigator.of(context,rootNavigator: true).pop(); + Navigator.push( + context, + MaterialPageRoute(builder: (context) => Dashboard()), + ); + AppSettings.longSuccessToast("Company Offer Created Succesfully!!"); + } else { + + AppSettings.longFailedToast("Fields should not be empty !!"); + } + } + catch(exception){ + print(exception); + AppSettings.longFailedToast("Please enter valid details"); + } + } else { + AppSettings.longFailedToast("Company Offer Not Created!!"); + + } + }, + child: Text('Create'), + )),//login button + + ], + ), + )), + ), + ])), ); + } +} diff --git a/lib/offers.dart b/lib/createoffers.dart similarity index 75% rename from lib/offers.dart rename to lib/createoffers.dart index f779edf..9c041d6 100644 --- a/lib/offers.dart +++ b/lib/createoffers.dart @@ -1,9 +1,14 @@ +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/settings.dart'; import 'package:intl/intl.dart'; import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart'; +import 'package:image_picker/image_picker.dart'; + class offers extends StatefulWidget { @@ -18,11 +23,52 @@ class _offersState extends State { TextEditingController offer_nameController = TextEditingController(); TextEditingController offer_codeController = TextEditingController(); TextEditingController descriptionController = TextEditingController(); - TextEditingController offerController = TextEditingController(); TextEditingController starting_dateController = TextEditingController(); TextEditingController ending_dateController = TextEditingController(); var selIOS; + final ImagePicker _picker = ImagePicker(); + String offerUrl=''; + + + + Future pickImageFromGallery() 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.offeruploadImageHTTPNew(image); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + AppSettings.offerPictureUrl = jsonDecode(res)['picture']; + }); + AppSettings.saveData('offer', jsonDecode(res)['picture'], 'STRING'); + } 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); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.offeruploadImageHTTPNew(image); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + //AppSettings.offerPictureUrl = jsonDecode(res)['picture']['url']; + offerUrl=jsonDecode(res)['picture'][0]['url']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } @override Widget build(BuildContext context) { @@ -43,13 +89,62 @@ class _offersState extends State { SizedBox( height: 20, ), - Container( - //width: double.infinity, - child: Image( - image: const AssetImage('images/logo.png'), - height: MediaQuery.of(context).size.height * .18, - )), - + Container(child: GestureDetector( + child: Container( + width: MediaQuery.of(context).size.width * .60, + height: MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + border: Border.all(width: 2, color: Colors.blueGrey), + image: DecorationImage( + image: (offerUrl!= ''&& + offerUrl!= 'null') ? + NetworkImage(offerUrl) as ImageProvider : AssetImage("images/mobilebg.png"), // picked file + fit: BoxFit.fitWidth)), + ), + 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( height: 05, ), @@ -58,7 +153,7 @@ class _offersState extends State { child: TextFormField( cursorColor: greyColor, controller: offer_nameController, - textCapitalization: TextCapitalization.characters, + textCapitalization: TextCapitalization.words, decoration: const InputDecoration( prefixIcon: Icon( Icons.person, @@ -87,7 +182,7 @@ class _offersState extends State { child: TextFormField( cursorColor: greyColor, controller: offer_codeController, - textCapitalization: TextCapitalization.characters, + textCapitalization: TextCapitalization.words, decoration: const InputDecoration( prefixIcon: Icon( Icons.numbers, @@ -111,24 +206,30 @@ class _offersState extends State { const SizedBox( height: 5, ), + + + Container( padding: const EdgeInsets.all(10), child: TextFormField( cursorColor: greyColor, controller: descriptionController, - textCapitalization: TextCapitalization.characters, + textCapitalization: TextCapitalization.words, + keyboardType: TextInputType.multiline, + maxLines: null, decoration: const InputDecoration( prefixIcon: Icon( Icons.description, - color: primaryColor, + color:primaryColor, ), + 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', labelStyle: TextStyle( @@ -136,23 +237,19 @@ class _offersState extends State { ), ), ), - ), //mobile - - const SizedBox( - height: 5, ), - Container( + /* Container( padding: const EdgeInsets.all(10), child: TextFormField( cursorColor: greyColor, - controller: offerController, - keyboardType: TextInputType.text, + controller: descriptionController, textCapitalization: TextCapitalization.characters, decoration: const InputDecoration( prefixIcon: Icon( - Icons.local_offer, + Icons.description, color: primaryColor, ), + contentPadding: const EdgeInsets.symmetric(vertical: 40.0, horizontal: 30.0), border: OutlineInputBorder( borderSide: BorderSide(color: primaryColor)), focusedBorder: OutlineInputBorder( @@ -161,17 +258,16 @@ class _offersState extends State { enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: primaryColor), ), - labelText: 'Enter Offer', + labelText: 'Enter Offer Description', labelStyle: TextStyle( color: greyColor, //<-- SEE HERE ), ), ), - ), + ),*/ //mobile const SizedBox( height: 5, ), - Container( padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), child: TextFormField( @@ -199,7 +295,7 @@ class _offersState extends State { onPressed: () async { DatePicker.showDatePicker( context, - dateFormat: 'dd MMMM yyyy HH:mm', + dateFormat: 'dd MMMM yyyy', initialDateTime: DateTime.now(), minDateTime:DateTime.now(), maxDateTime: DateTime.now().add(Duration(days: 365)), @@ -216,7 +312,7 @@ class _offersState extends State { onConfirm: (dateTime, List index)async { DateTime selectdate = dateTime; setState(() { - selIOS = DateFormat('dd-MMM-yyyy - HH:mm').format(selectdate); + selIOS = DateFormat('dd-MMM-yyyy').format(selectdate); }); if(selIOS!=''){ @@ -267,7 +363,7 @@ class _offersState extends State { onPressed: () async { DatePicker.showDatePicker( context, - dateFormat: 'dd MMMM yyyy HH:mm', + dateFormat: 'dd MMMM yyyy', initialDateTime: DateTime.now(), minDateTime:DateTime.now(), maxDateTime: DateTime.now().add(Duration(days: 365)), @@ -284,7 +380,7 @@ class _offersState extends State { onConfirm: (dateTime, List index)async { DateTime selectdate = dateTime; setState(() { - selIOS = DateFormat('dd-MMM-yyyy - HH:mm').format(selectdate); + selIOS = DateFormat('dd-MMM-yyyy').format(selectdate); }); if(selIOS!=''){ @@ -321,7 +417,6 @@ class _offersState extends State { if (offer_nameController.text != '' && offer_codeController.text != '' && descriptionController.text != ''&& - offerController.text != ''&& starting_dateController.text != '' && ending_dateController.text != '') { AppSettings.preLoaderDialog(context); @@ -330,7 +425,6 @@ class _offersState extends State { payload["offer_name"] = offer_nameController.text.toString(); payload["offer_code"] = offer_codeController.text.toString(); payload["description"] = descriptionController.text.toString();; - payload["offer"] = offerController.text.toString(); payload["starting_date"] = starting_dateController.text.toString(); payload["ending_date"] = ending_dateController.text.toString(); payload["offer_status"] ="active"; diff --git a/lib/dashboard.dart b/lib/dashboard.dart index d245e33..e0e0905 100644 --- a/lib/dashboard.dart +++ b/lib/dashboard.dart @@ -3,10 +3,12 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:healthcare_pharmacy/companyoffrers.dart'; +import 'package:healthcare_pharmacy/getallpharmacies.dart'; import 'package:healthcare_pharmacy/getmedicines.dart'; import 'package:healthcare_pharmacy/inactiveoffersview.dart'; import 'package:healthcare_pharmacy/medicinecart.dart'; -import 'package:healthcare_pharmacy/offers.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'; @@ -644,7 +646,7 @@ class _DashboardState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => MedicineCartList()), + builder: (context) => BiddingRequests()), ); @@ -654,7 +656,7 @@ class _DashboardState extends State { Divider( color: Colors.grey, ), - /* ListTile( + ListTile( title: Row( children: const [ Image( @@ -665,7 +667,7 @@ class _DashboardState extends State { const SizedBox( width: 10, ), - Text('Get Medicines', style: TextStyle(color: Colors.black)), + Text('Company Offers', style: TextStyle(color: Colors.black)), ], ), onTap: () { @@ -673,7 +675,7 @@ class _DashboardState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => GetMedicines()), + builder: (context) => CompanyOffers()), ); @@ -682,7 +684,33 @@ class _DashboardState extends State { ), 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('GetAllPharmacies', style: TextStyle(color: Colors.black)), + ], + ), + onTap: () { + + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => GetAllPharmacies()), + ); + }, + ), + Divider( + color: Colors.grey, + ), ListTile( title: Row( children: const [ diff --git a/lib/getallpharmacies.dart b/lib/getallpharmacies.dart new file mode 100644 index 0000000..310aac1 --- /dev/null +++ b/lib/getallpharmacies.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/getmedicines.dart'; +import 'package:healthcare_pharmacy/maps/app_colors.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 GetAllPharmacies extends StatefulWidget { + const GetAllPharmacies({Key? key}) : super(key: key); + + @override + State createState() => _GetAllPharmaciesState(); +} + +class _GetAllPharmaciesState extends State { + String Url = ''; + List pharmacyList = []; + List prescriptionsListOriginal = []; + bool isPrescriptionsDataLoading = false; + bool isSereverIssue = false; + bool isLoading=false; + List checked = []; + + + Future getAllPharmacies() async { + isPrescriptionsDataLoading=true; + try { + var response = await AppSettings.getPharmacyData(); + print(response); + setState(() { + pharmacyList = + ((jsonDecode(response)['data']) as List).map((dynamic model) { + return GetAllPharmacyModel.fromJson(model); + }).toList(); + isPrescriptionsDataLoading = false; + }); + + + } catch (e) { + setState(() { + isLoading = false; + isPrescriptionsDataLoading = false; + }); + } + } + + @override + void initState() { + getAllPharmacies(); + //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 (pharmacyList.length != 0) { + return Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: ListView.builder( + padding: EdgeInsets.all(0), + itemCount: pharmacyList.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( + pharmacyList[index].pharmacyname_offer + .toString() + .toUpperCase(), + style: valuesTextStyle(), + ), + Text( + pharmacyList[index].pharmacyId_offer + .toString() + .toUpperCase(), + style: valuesTextStyle(), + ), + Text( + pharmacyList[index].phone_offer + .toString() + .toUpperCase(), + style: valuesTextStyle(), + ), + Text( + pharmacyList[index].description_offer + .toString() + .toUpperCase(), + style: valuesTextStyle(), + ), + ], + ), + ), + Checkbox( + value: checked.contains( + pharmacyList[index].pharmacyId_offer.toString()), + onChanged: (value) { + _onCheckboxChanged( + pharmacyList[index].pharmacyId_offer.toString(), + value ?? false); + }, + ), + ], + ), + ), + ); + }, + ), + ), + + /* 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:$checked.toString()', + 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{ + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(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/getmedicines.dart b/lib/getmedicines.dart index f355303..4c260fb 100644 --- a/lib/getmedicines.dart +++ b/lib/getmedicines.dart @@ -36,15 +36,11 @@ class _GetMedicinesState extends State with TickerProviderStateMix String medicine_mrp=''; String medicine_primary_use=''; String medbookingid = ''; - - List medImages=[]; Future getAllMedecineData(var medicineName) async { FilteredList=[]; isMedecineDataLoading = true; - - try { var medecineResponse = await AppSettings.getAllMedecines(medicineName); diff --git a/lib/inactiveoffersview.dart b/lib/inactiveoffersview.dart index babf68f..450d8f4 100644 --- a/lib/inactiveoffersview.dart +++ b/lib/inactiveoffersview.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:healthcare_pharmacy/models/offersview_model.dart'; -import 'package:healthcare_pharmacy/offers.dart'; +import 'package:healthcare_pharmacy/createoffers.dart'; import 'package:healthcare_pharmacy/settings.dart'; import 'package:intl/intl.dart'; import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart'; diff --git a/lib/login.dart b/lib/login.dart index 2d9f8b4..22a841d 100644 --- a/lib/login.dart +++ b/lib/login.dart @@ -122,7 +122,7 @@ class _LoginState extends State { labelText: 'Password', prefixIcon: const Icon(Icons.password, color: greyColor,), labelStyle: const TextStyle( - color: primaryColor, fontWeight: FontWeight.bold//<-- SEE HERE + color: Color(0xFF7A7575), fontWeight: FontWeight.bold//<-- SEE HERE ), border: const OutlineInputBorder( borderSide: BorderSide(color: primaryColor)), diff --git a/lib/medicinecart.dart b/lib/medicinecart.dart index e7f65b5..4965a5c 100644 --- a/lib/medicinecart.dart +++ b/lib/medicinecart.dart @@ -320,11 +320,12 @@ class _MedicineCartListState extends State with TickerProvider leading: IconButton( icon: Icon(Icons.arrow_back), // You can use a different back icon if needed onPressed: () { + Navigator.of(context).pop(); // Implement the navigation logic to go back - Navigator.push( + /* Navigator.push( context, - MaterialPageRoute(builder: (context) => BiddingRequests()), - ); // This will pop the current route and go back + MaterialPageRoute(builder: (context) => GetMedicines()), + );*/ // This will pop the current route and go back }, ), title: Text('Cart Details'), diff --git a/lib/models/companyoffer_model.dart b/lib/models/companyoffer_model.dart new file mode 100644 index 0000000..078a37f --- /dev/null +++ b/lib/models/companyoffer_model.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; + +class GetAllPharmacyModel { + String pharmacyname_offer = ''; + String phone_offer=''; + String description_offer=''; + String pharmacyId_offer=''; + + Color cardColor=Colors.white; + + + GetAllPharmacyModel(); + + factory GetAllPharmacyModel.fromJson(Map json){ + GetAllPharmacyModel rtvm = new GetAllPharmacyModel(); + + rtvm.pharmacyname_offer = json['pharmacyname'].toString() ??''; + rtvm.phone_offer = json['phone'].toString() ?? ''; + rtvm.description_offer = json['description'].toString() ?? ''; + rtvm.pharmacyId_offer = json['pharmacyId'].toString() ?? ''; + + // rtvm.prescription_url = json['pictureUrl'][0] ?? ''; + + return rtvm; + } + +} \ No newline at end of file diff --git a/lib/offerstabdata.dart b/lib/offerstabdata.dart index 504b087..23324ca 100644 --- a/lib/offerstabdata.dart +++ b/lib/offerstabdata.dart @@ -2,8 +2,9 @@ import 'dart:convert'; import 'package:flutter/material.dart'; +import 'package:healthcare_pharmacy/maps/app_colors.dart'; import 'package:healthcare_pharmacy/models/offersview_model.dart'; -import 'package:healthcare_pharmacy/offers.dart'; +import 'package:healthcare_pharmacy/createoffers.dart'; import 'package:healthcare_pharmacy/settings.dart'; import 'package:intl/intl.dart'; import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart'; @@ -102,7 +103,6 @@ class _OffersDataState extends State with TickerProviderStateMixin { updateOfferNameController.text = object.offer_name; updateOfferCodeController.text = object.offer_code; updateOfferDescriptionController.text = object.description; - updateDiscountController.text = object.discount_percentage; updateOfferStartDateController.text=object.starting_date; updateOfferEndDateController.text=object.ending_date; return showDialog( @@ -121,7 +121,7 @@ class _OffersDataState extends State with TickerProviderStateMixin { child: TextFormField( cursorColor: greyColor, controller: updateOfferNameController, - textCapitalization: TextCapitalization.characters, + textCapitalization: TextCapitalization.words, decoration: const InputDecoration( prefixIcon: Icon( Icons.person, @@ -135,7 +135,7 @@ class _OffersDataState extends State with TickerProviderStateMixin { enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: greyColor), ), - labelText: 'Enter offer name', + labelText: 'Offer name', labelStyle: TextStyle( color: greyColor, //<-- SEE HERE ), @@ -151,7 +151,7 @@ class _OffersDataState extends State with TickerProviderStateMixin { child: TextFormField( cursorColor: greyColor, controller: updateOfferCodeController, - textCapitalization: TextCapitalization.characters, + textCapitalization: TextCapitalization.words, decoration: const InputDecoration( prefixIcon: Icon( Icons.numbers, @@ -165,7 +165,7 @@ class _OffersDataState extends State with TickerProviderStateMixin { enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: greyColor), ), - labelText: 'Enter Offer Code', + labelText: 'Offer Code', labelStyle: TextStyle( color: greyColor, //<-- SEE HERE ), @@ -180,7 +180,7 @@ class _OffersDataState extends State with TickerProviderStateMixin { child: TextFormField( cursorColor: greyColor, controller: updateOfferDescriptionController, - textCapitalization: TextCapitalization.characters, + textCapitalization: TextCapitalization.words, decoration: const InputDecoration( prefixIcon: Icon( Icons.description, @@ -194,37 +194,7 @@ class _OffersDataState extends State with TickerProviderStateMixin { enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: greyColor), ), - labelText: 'Enter Offer Description', - labelStyle: TextStyle( - color: greyColor, //<-- SEE HERE - ), - ), - ), //tanker name - ), - const SizedBox( - height: 20, - ), - Container( - //padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), - child: TextFormField( - cursorColor: greyColor, - maxLength: 2, - controller: updateDiscountController, - textCapitalization: TextCapitalization.characters, - decoration: const InputDecoration( - prefixIcon: Icon( - Icons.percent_outlined, - color: primaryColor, - ), - border: OutlineInputBorder( - borderSide: BorderSide(color: greyColor)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: greyColor), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: greyColor), - ), - labelText: 'Enter Offer Discount', + labelText: 'Offer Description', labelStyle: TextStyle( color: greyColor, //<-- SEE HERE ), @@ -249,10 +219,10 @@ class _OffersDataState extends State with TickerProviderStateMixin { onPressed: () async { DatePicker.showDatePicker( context, - dateFormat: 'dd MMMM yyyy HH:mm', + dateFormat: 'dd MMMM yyyy', initialDateTime: DateTime.now(), minDateTime:DateTime.now(), - maxDateTime: DateTime.now().add(Duration(days: 15)), + maxDateTime: DateTime.now().add(Duration(days: 365)), onMonthChangeStartWithFirstDate: true, pickerMode: DateTimePickerMode.datetime, pickerTheme: DateTimePickerTheme( @@ -266,7 +236,7 @@ class _OffersDataState extends State with TickerProviderStateMixin { onConfirm: (dateTime, List index)async { DateTime selectdate = dateTime; setState(() { - startdate = DateFormat('dd-MMM-yyyy - HH:mm').format(selectdate); + startdate = DateFormat('dd-MMM-yyyy').format(selectdate); }); if(startdate!=''){ @@ -275,7 +245,7 @@ class _OffersDataState extends State with TickerProviderStateMixin { }); } else { - AppSettings.longFailedToast('please select date'); + AppSettings.longFailedToast('Select start date'); } }, ); @@ -308,7 +278,7 @@ class _OffersDataState extends State with TickerProviderStateMixin { cursorColor: greyColor, controller: updateOfferEndDateController, decoration: InputDecoration( - labelText: 'Select End Date', + labelText: 'Select end Date', prefixIcon: IconButton( icon: Icon( Icons.date_range, @@ -317,10 +287,10 @@ class _OffersDataState extends State with TickerProviderStateMixin { onPressed: () async { DatePicker.showDatePicker( context, - dateFormat: 'dd MMMM yyyy HH:mm', + dateFormat: 'dd MMMM yyyy', initialDateTime: DateTime.now(), minDateTime:DateTime.now(), - maxDateTime: DateTime.now().add(Duration(days: 15)), + maxDateTime: DateTime.now().add(Duration(days: 365)), onMonthChangeStartWithFirstDate: true, pickerMode: DateTimePickerMode.datetime, pickerTheme: DateTimePickerTheme( @@ -334,7 +304,7 @@ class _OffersDataState extends State with TickerProviderStateMixin { onConfirm: (dateTime, List index)async { DateTime selectdate = dateTime; setState(() { - enddate = DateFormat('dd-MMM-yyyy - HH:mm').format(selectdate); + enddate = DateFormat('dd-MMM-yyyy').format(selectdate); }); if(enddate!=''){ @@ -343,7 +313,7 @@ class _OffersDataState extends State with TickerProviderStateMixin { }); } else { - AppSettings.longFailedToast('please select date'); + AppSettings.longFailedToast('Select end date'); } }, ); @@ -390,7 +360,6 @@ class _OffersDataState extends State with TickerProviderStateMixin { payload["offer_name"] = updateOfferNameController.text.toString(); payload["offer_code"] = updateOfferCodeController.text.toString(); payload["description"] = updateOfferDescriptionController.text.toString(); - payload["discount_percentage"] = updateDiscountController.text.toString(); payload["starting_date"] = updateOfferStartDateController.text.toString(); payload["ending_date"] = updateOfferEndDateController.text.toString(); payload["offer_status"] ="active"; @@ -404,7 +373,6 @@ class _OffersDataState extends State with TickerProviderStateMixin { updateOfferNameController.text = ''; updateOfferCodeController.text = ''; updateOfferDescriptionController.text = ''; - updateDiscountController.text = ''; updateOfferStartDateController.text = ''; updateOfferEndDateController.text = ''; @@ -451,140 +419,205 @@ class _OffersDataState extends State with TickerProviderStateMixin { itemCount: activeOffersList.length, itemBuilder: (BuildContext context, int index) { return Card( - - color: activeOffersList[index].cardColor, - child: Padding( - padding:EdgeInsets.all(8) , - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, + 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, + ), + ), + TextSpan( + text: activeOffersList[index].offer_name, + style: TextStyle( + color: primaryColor, + ), + ), + ], + ), + ), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - - Container( - //width: MediaQuery.of(context).size.width * .55, - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('OfferName :',style: labelTextStyle()), - Text('OfferCode :',style: labelTextStyle()), - Text('OfferDes :' ,style: labelTextStyle()), - Text('offer :' ,style: labelTextStyle()), - Text('StartDate :',style: labelTextStyle()), - Text('EndDate :' ,style: labelTextStyle()), - - ], - ), - SizedBox(width: 5,), - Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(activeOffersList[index].offer_name,style: valuesTextStyle()), - Text(activeOffersList[index].offer_code,style: valuesTextStyle()), - Text(activeOffersList[index].description,style: valuesTextStyle()), - Text(activeOffersList[index].offer,style: valuesTextStyle()), - Text(activeOffersList[index].starting_date,style: valuesTextStyle()), - Text(activeOffersList[index].ending_date,style: valuesTextStyle()) - - ], - ), - ], + // ... (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 + ), ), ], ), ), + 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 + ), + ), + ], + ), + ), + 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].starting_date, - Expanded(child:IconButton( - icon: const Icon(Icons.edit,color: primaryColor,), - onPressed: () { - showUpdateOfferDialog(activeOffersList[index]); - }, - ),), - Expanded( - child: Row( - children: [ - Text(''), - Switch( - value: false, // Replace this with your actual property - onChanged: (newValue) async { - 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, - ), + 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: activeOffersList[index].ending_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]); + }, + ), + 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 + } + + }, + ), + ], ), - ], - ), ), ); + + + + + + }) ), Padding( padding: EdgeInsets.fromLTRB(8, 8, 8, 8), @@ -672,121 +705,245 @@ class _OffersDataState extends State with TickerProviderStateMixin { itemCount: inactiveOffersList.length, itemBuilder: (BuildContext context, int index) { return Card( - - color: inactiveOffersList[index].cardColor, - child: Padding( - padding:EdgeInsets.all(8) , - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, + 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, + ), + ), + TextSpan( + text: inactiveOffersList[index].offer_name, + style: TextStyle( + color: primaryColor, + ), + ), + ], + ), + ), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ + 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: inactiveOffersList[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: inactiveOffersList[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 + ), + ), + TextSpan( + text: inactiveOffersList[index].starting_date, - Container( - //width: MediaQuery.of(context).size.width * .55, - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('OfferName :',style: labelTextStyle()), - Text('OfferCode :',style: labelTextStyle()), - Text('OfferDes :' ,style: labelTextStyle()), - Text('OfferDis(%) :' ,style: labelTextStyle()), - Text('StartDate :',style: labelTextStyle()), - Text('EndDate :' ,style: labelTextStyle()), - - ], - ), - SizedBox(width: 5,), - Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(inactiveOffersList[index].offer_name,style: valuesTextStyle()), - Text(inactiveOffersList[index].offer_code,style: valuesTextStyle()), - Text(inactiveOffersList[index].description,style: valuesTextStyle()), - Text(inactiveOffersList[index].offer,style: valuesTextStyle()), - Text(inactiveOffersList[index].starting_date,style: valuesTextStyle()), - Text(inactiveOffersList[index].ending_date,style: valuesTextStyle()) + 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: inactiveOffersList[index].ending_date, + style: TextStyle( + color:primaryColor, // Change the color for description content + ), ), ], ), ), - Expanded(child:TextButton( - onPressed: () { - showDialog( - //if set to true allow to close popup by tapping out of the popup - //barrierDismissible: false, - context: context, - builder: (BuildContext context) => AlertDialog( - title: const Text('Do you want to Re_Active offer ??', - style: TextStyle( - color: primaryColor, - fontSize: 16, - )), - actionsAlignment: MainAxisAlignment.spaceBetween, - actions: [ - TextButton( - onPressed: ()async { - bool deleteTankStatus = await AppSettings.reactiveOffers(inactiveOffersList[index].offer_code); - - if(deleteTankStatus){ - getInactiveOffersViewData(); - AppSettings.longSuccessToast('offer Re_Active successfully'); - getActiveOffersViewData(); - Navigator.of(context).pop(true); - - } - else{ - AppSettings.longFailedToast('offer Re_Active failed'); - } - }, - child: const Text('Yes', - style: TextStyle( - color: primaryColor, - fontSize: 18, - )), + SizedBox(height: 8), + + + + + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + TextButton( + onPressed: () { + showDialog( + //if set to true allow to close popup by tapping out of the popup + //barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text( + 'Do you want to Re-Active offer ??', + style: TextStyle( + color: primaryColor, + fontSize: 16, + ), + ), + actionsAlignment: MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + bool deleteTankStatus = await AppSettings.reactiveOffers(inactiveOffersList[index].offer_code); + + if (deleteTankStatus) { + getInactiveOffersViewData(); + AppSettings.longSuccessToast('offer Re-Active successfully'); + getActiveOffersViewData(); + Navigator.of(context).pop(true); + } else { + AppSettings.longFailedToast('offer Re-Active failed'); + } + }, + child: const Text( + 'Yes', + style: TextStyle( + color: primaryColor, + fontSize: 18, + ), + ), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text( + 'No', + style: TextStyle( + color: primaryColor, + fontSize: 18, + ), + ), + ), + ], ), - TextButton( - onPressed: () { - Navigator.of(context).pop(true); - }, - child: const Text('No', + ); + }, + child: Text( + 'Re-activate', + style: TextStyle( + color: primaryColor, // You can set the text color to your preference. + fontSize: 16, // You can adjust the font size as needed. + ), + ), + ), + IconButton( + icon: Icon( + Icons.delete, + color: primaryColor, // Customize the delete icon color + ), + 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 Offer?', style: TextStyle( color: primaryColor, - fontSize: 18, + fontSize: 20, )), + actionsAlignment: MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: ()async { + bool deleteOfferStatus = await AppSettings.deleteInActiveOffer(inactiveOffersList[index].offer_code); + if(deleteOfferStatus){ + getInactiveOffersViewData(); + AppSettings.longSuccessToast('Offer deleted successfully'); + Navigator.of(context).pop(true); + + } + else{ + AppSettings.longFailedToast('Offer 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, + )), + ), + ], ), - ], - ), - ); - }, - child: const Text( - 'RE_ACTIVE', - style: TextStyle( - color: primaryColor, - fontSize: 15, - fontWeight: FontWeight.bold - /* decoration: TextDecoration.underline,*/ + ); + }, ), - ), - ), - + ], ), ], - ), ), ); diff --git a/lib/offersview.dart b/lib/offersview.dart index 9e0eef4..7dc1b0f 100644 --- a/lib/offersview.dart +++ b/lib/offersview.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:healthcare_pharmacy/models/offersview_model.dart'; -import 'package:healthcare_pharmacy/offers.dart'; +import 'package:healthcare_pharmacy/createoffers.dart'; import 'package:healthcare_pharmacy/settings.dart'; import 'package:intl/intl.dart'; import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart'; diff --git a/lib/otpscreen.dart b/lib/otpscreen.dart index ec2958b..d7e65ef 100644 --- a/lib/otpscreen.dart +++ b/lib/otpscreen.dart @@ -20,6 +20,8 @@ class _OtpScreenState extends State { final TextEditingController _fieldSix = TextEditingController(); TextEditingController mobileNumberController = TextEditingController(); TextEditingController passwordController = TextEditingController(); + TextEditingController otpController = TextEditingController(); + bool isTextfieldVisible=true; bool isOtpVisible=false; @@ -35,36 +37,6 @@ class _OtpScreenState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ const Text('Phone Number Verification'), - - - Visibility( - visible: false, - child: Container( - padding: const EdgeInsets.all(10), - child: TextFormField( - cursorColor: greyColor, - controller: mobileNumberController, - 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 MobileNumber', - labelStyle: TextStyle( - color: greyColor, //<-- SEE HERE - ), - ), - ), - ),), const SizedBox( height: 30, ), @@ -100,49 +72,6 @@ class _OtpScreenState extends State { const SizedBox( height: 30, ), - Visibility( - visible: false, - child: Container( - padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), - child: TextFormField( - cursorColor: greyColor, - obscureText: isObscureText, - controller: passwordController, - decoration: InputDecoration( - labelText: 'Password', - prefixIcon: const Icon(Icons.password, color: greyColor,), - labelStyle: const TextStyle( - color: greyColor, //<-- SEE HERE - ), - border: const OutlineInputBorder( - borderSide: BorderSide(color: greyColor)), - focusedBorder: const OutlineInputBorder( - borderSide: BorderSide(color: greyColor), - ), - enabledBorder: const OutlineInputBorder( - borderSide: BorderSide(color: textFieldStartColor), - ), - suffixIcon: IconButton( - icon: Icon( - Icons.visibility_off_outlined, - color: isObscureText==true?greyColor:primaryColor, - ), - onPressed: () { - - print("show password"); - setState(() { - isObscureText = !isObscureText; - }); - }, - ), - - ), - - ), - ),), - const SizedBox( - height: 30, - ), Visibility( visible: true, child: Container( @@ -164,6 +93,9 @@ class _OtpScreenState extends State { }); if (_otp!.length == 6) { + + // Set the OTP to the otpController + otpController.text = _otp!; AppSettings.preLoaderDialog(context); bool isOnline = await AppSettings.internetConnectivity(); diff --git a/lib/settings.dart b/lib/settings.dart index c83f7e8..2495ab9 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -125,7 +125,7 @@ InputDecoration textFormFieldDecoration(IconData icon,var text){ ), labelText: text, labelStyle: - TextStyle(color: primaryColor, fontWeight: FontWeight.bold //<-- SEE HERE + TextStyle(color: Color(0xFF7A7575), fontWeight: FontWeight.bold //<-- SEE HERE ), ); } @@ -170,22 +170,28 @@ class AppSettings { static String verifyPhnUrl = host + 'phone'; static String profilePicUrl = host + 'users/profile-picture'; static String uploadPicUrl = host + 'uploadsPharmacy'; + static String uploadOfferUrl = host + 'uploads-offerPicture'; static String resetTokenUrl = host + 'reset_token'; static String forgotPasswordUrl = host + 'forgotpassword'; static String resetPasswordUrl = host + 'resetpassword'; static String sendSmsUrl = host + 'sendSms'; static String phoneVerificationUrl = host + 'pharmacyphone'; static String createOffersUrl = host + 'addoffer'; + static String createCompanyOffersUrl = host + 'addcompanyoffer'; static String getOffersActiveDataUrl = host + 'getActivePharmacyOfferdata'; static String getOffersinActiveDataUrl = host + 'getInActivePharmacyOfferdata'; static String updateOffersDataUrl = host + 'updateOffer'; - static String deleteOffersDataUrl = host + 'deleteOffer'; + static String inactiveOffersDataUrl = host + 'inactiveOffer'; static String reactiveOffersDataUrl = host + 'reactiveOffer'; + static String deleteOfferUrl = host + 'deleteOffer'; static String medecineDataUrl = host + 'medicine'; static String getAllBiddingDataUrl = host + 'getBiddingRequests'; static String getRequestBiddingDataUrl = host + 'biddingRequest'; static String addToCartDataUrl = host + 'cart/add'; static String getCartDataUrl = host + 'cart/total-price'; + static String getPharmacyDataUrl = host + 'getAllPharmacylist'; + + @@ -206,6 +212,8 @@ class AppSettings { static File? updatedImage; static String image = ''; static String profilePictureUrl = ''; + static String offerPictureUrl = ''; + static var api = { 'signIn': host + '/login', }; @@ -373,6 +381,19 @@ class AppSettings { } + static Future offeruploadImageHTTPNew(file) async { + + var request = http.MultipartRequest('POST', Uri.parse(uploadOfferUrl + '/' + healthpharmaIdsign)); + request.files.add(await http.MultipartFile.fromPath('picture', file.path)); + var res = await request.send(); + var response = await http.Response.fromStream(res); + return response.body; + } + + + + + static Future updatePharmaData(payload) async { try { var response = await http.put( @@ -430,6 +451,79 @@ class AppSettings { return false; } } + + + static Future deleteInActiveOffer(offerCode) async { + var uri = Uri.parse(deleteOfferUrl + '/' + healthpharmaIdsign); + uri = uri.replace(query: 'offer_code=$offerCode'); + + 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 createCompanyOffers(payload) async { + var uri = Uri.parse(createCompanyOffersUrl + '/' + "123456"); + 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 getOffers() async { //path parameter var uri = Uri.parse(getOffersActiveDataUrl + '/' + healthpharmaIdsign); @@ -535,6 +629,30 @@ class AppSettings { }*/ + + static Future getPharmacyData() async { + var uri = Uri.parse(getPharmacyDataUrl); + 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 getAllBiddingRecords() async { //path parameter var uri = Uri.parse(getAllBiddingDataUrl + '/' + healthpharmaIdsign); @@ -682,7 +800,7 @@ class AppSettings { } } static Future deleteOffers(offer_code) async { - var uri = Uri.parse(deleteOffersDataUrl + '/' + healthpharmaIdsign); + var uri = Uri.parse(inactiveOffersDataUrl + '/' + healthpharmaIdsign); uri = uri.replace(query: 'offer_code=$offer_code'); try { @@ -899,6 +1017,8 @@ class AppSettings { static Future saveProfile(dynamic image) async { // save login name information await saveData('profile', image.toString(), 'STRING'); + await saveData('offer', image.toString(), 'STRING'); + //await loadDataFromMemory(); } @@ -915,6 +1035,8 @@ class AppSettings { healthpharmaIdsign = await getData('pharmacyId', 'STRING'); userLatitude = await getData('latitude', 'DOUBLE'); profilePictureUrl=await getData('profile', 'STRING'); + profilePictureUrl=await getData('profile', 'STRING'); + offerPictureUrl=await getData('offer', 'STRING'); userLongitude =await getData('longitude', 'DOUBLE'); fcmId =await getData('fcmId', 'STRING'); } diff --git a/lib/signup.dart b/lib/signup.dart index f92913b..8b6cb81 100644 --- a/lib/signup.dart +++ b/lib/signup.dart @@ -178,7 +178,7 @@ class _SignUpState extends State { cursorColor: greyColor, controller: nameController, textCapitalization: TextCapitalization.characters, - decoration: textFormFieldDecoration(Icons.person,'Name'), + decoration: textFormFieldDecoration(Icons.person,'Enter Your Name'), ), ), //name @@ -212,7 +212,7 @@ class _SignUpState extends State { cursorColor: greyColor, controller: emailController, keyboardType: TextInputType.emailAddress, - decoration: textFormFieldDecoration(Icons.email,'Enter Your Mail'), + decoration: textFormFieldDecoration(Icons.email,'Enter Your Email'), ), ), @@ -344,7 +344,7 @@ class _SignUpState extends State { cursorColor: greyColor, controller: userAddressDescriptionController, textCapitalization: TextCapitalization.characters, - decoration: textFormFieldDecoration(Icons.plagiarism_outlined,'Address Description (Ex: Flat No)'), + decoration: textFormFieldDecoration(Icons.plagiarism_outlined,'Address Description ex:FlatNo [Optional]'), ), ),//address description const SizedBox(