New Code Commited

dev
suresh 1 year ago
parent ba22d47bae
commit 4eb06ee8e5

@ -12,7 +12,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<application <application
android:label="healthcare_pharmacy" android:label="pharmacy"
android:name="${applicationName}" android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher">
<activity <activity

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 836 B

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -5,6 +6,7 @@ import 'package:flutter/services.dart';
import 'package:healthcare_pharmacy/getmedicines.dart'; import 'package:healthcare_pharmacy/getmedicines.dart';
import 'package:healthcare_pharmacy/inactiveoffersview.dart'; import 'package:healthcare_pharmacy/inactiveoffersview.dart';
import 'package:healthcare_pharmacy/offers.dart'; import 'package:healthcare_pharmacy/offers.dart';
import 'package:healthcare_pharmacy/offersdata.dart';
import 'package:healthcare_pharmacy/offersview.dart'; import 'package:healthcare_pharmacy/offersview.dart';
import 'package:healthcare_pharmacy/updateprofile.dart'; import 'package:healthcare_pharmacy/updateprofile.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
@ -54,7 +56,7 @@ class _DashboardState extends State<Dashboard> {
List<String> images = [ List<String> images = [
"images/createoffer.png", "images/createoffer.png",
"images/activeoffer.png", "images/activeoffer.png",
"images/inactiveoffer.png", // "images/inactiveoffer.png",
/* "images/reports.png", /* "images/reports.png",
"images/prescriptions.png", "images/prescriptions.png",
@ -76,16 +78,16 @@ class _DashboardState extends State<Dashboard> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const OffersView()), builder: (context) => const OffersData()),
); );
} }
else if(ind==2){ /* else if(ind==2){
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const InActiveOffersView()), builder: (context) => const InActiveOffersView()),
); );
} }*/
/* /*
else if(ind==3){ else if(ind==3){
Navigator.push( Navigator.push(
@ -195,11 +197,15 @@ class _DashboardState extends State<Dashboard> {
final image = await _picker.pickImage(source: ImageSource.gallery); final image = await _picker.pickImage(source: ImageSource.gallery);
if (image == null) return; if (image == null) return;
final imageTemp = File(image.path); final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageHTTPNew(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
AppSettings.updatedImage = imageTemp; AppSettings.profilePictureUrl = jsonDecode(res)['picture'];
}); });
uploadProfileApi(image.path); AppSettings.saveData('profile', jsonDecode(res)['picture'], 'STRING');
AppSettings.saveProfile(image.path);
} on PlatformException catch (e) { } on PlatformException catch (e) {
print('Failed to pick image: $e'); print('Failed to pick image: $e');
} }
@ -210,12 +216,14 @@ class _DashboardState extends State<Dashboard> {
final image = await _picker.pickImage(source: ImageSource.camera); final image = await _picker.pickImage(source: ImageSource.camera);
if (image == null) return; if (image == null) return;
final imageTemp = File(image.path); final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageHTTPNew(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
AppSettings.updatedImage = imageTemp; AppSettings.profilePictureUrl = jsonDecode(res)['picture'];
}); });
AppSettings.saveData('profile', jsonDecode(res)['picture'], 'STRING');
uploadProfileApi(image.path);
AppSettings.saveProfile(image.path);
} on PlatformException catch (e) { } on PlatformException catch (e) {
print('Failed to pick image: $e'); print('Failed to pick image: $e');
} }
@ -321,21 +329,22 @@ class _DashboardState extends State<Dashboard> {
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
child: Container( child: Container(
width: MediaQuery.of(context).size.width * .30, width: MediaQuery.of(context).size.width * .60,
height: height:
MediaQuery.of(context).size.height * .30, MediaQuery.of(context).size.height * .25,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
border: Border.all(width: 5, color: Colors.blueGrey),
image: DecorationImage( image: DecorationImage(
image: (AppSettings.updatedImage != image: (AppSettings.profilePictureUrl !=
null) '' &&
? FileImage( AppSettings.profilePictureUrl !=
AppSettings.updatedImage!) 'null')
? NetworkImage(AppSettings
.profilePictureUrl)
as ImageProvider as ImageProvider
: AssetImage( : AssetImage(
"images/mobilebg.png"), // picked file "images/mobilebg.png"), // picked file
fit: BoxFit.cover)), fit: BoxFit.fitWidth)),
), ),
onTap: () { onTap: () {
showModalBottomSheet<void>( showModalBottomSheet<void>(
@ -584,21 +593,21 @@ class _DashboardState extends State<Dashboard> {
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
Text('ActiveOffersView', style: TextStyle(color: Colors.black)), Text('OffersData', style: TextStyle(color: Colors.black)),
], ],
), ),
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const OffersView()), builder: (context) => const OffersData()),
); );
}, },
), ),
Divider( Divider(
color: Colors.grey, color: Colors.grey,
), ),
ListTile( /*ListTile(
title: Row( title: Row(
children: const [ children: const [
Image( Image(
@ -626,7 +635,7 @@ class _DashboardState extends State<Dashboard> {
), ),
Divider( Divider(
color: Colors.grey, color: Colors.grey,
), ),*/
ListTile( ListTile(
title: Row( title: Row(
children: const [ children: const [

@ -2,11 +2,13 @@ import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:healthcare_pharmacy/models/medicineview_model.dart'; import 'package:healthcare_pharmacy/models/GetMedecineDetailsModel.dart';
import 'package:healthcare_pharmacy/settings.dart'; import 'package:healthcare_pharmacy/settings.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:cloudinary_public/cloudinary_public.dart'; import 'package:cloudinary_public/cloudinary_public.dart';
import 'package:photo_view/photo_view.dart';
class GetMedicines extends StatefulWidget { class GetMedicines extends StatefulWidget {
const GetMedicines({Key? key}) : super(key: key); const GetMedicines({Key? key}) : super(key: key);
@ -23,13 +25,13 @@ class _GetMedicinesState extends State<GetMedicines> with TickerProviderStateMix
String userAddress=''; String userAddress='';
TextEditingController searchController = TextEditingController(); TextEditingController searchController = TextEditingController();
String dropdownArea = '2';
String medicine_name=''; String medicine_name='';
List medImages=[]; String medicine_manufacturers='';
String medicine_salt_composition='';
//String dropdownType = 'Tank'; String medicine_mrp='';
String medicine_primary_use='';
List medImages=[];
Future<void> getAllMedecineData(var medicineName) async { Future<void> getAllMedecineData(var medicineName) async {
FilteredList=[]; FilteredList=[];
@ -43,6 +45,10 @@ class _GetMedicinesState extends State<GetMedicines> with TickerProviderStateMix
if(jsonDecode(medecineResponse)!=''){ if(jsonDecode(medecineResponse)!=''){
setState(() { setState(() {
medicine_name=jsonDecode(medecineResponse)['medicine'][0]['name']; medicine_name=jsonDecode(medecineResponse)['medicine'][0]['name'];
medicine_manufacturers=jsonDecode(medecineResponse)['medicine'][0]['manufacturers'];
medicine_salt_composition=jsonDecode(medecineResponse)['medicine'][0]['salt_composition'];
medicine_mrp=jsonDecode(medecineResponse)['medicine'][0]['mrp'];
medicine_primary_use=jsonDecode(medecineResponse)['medicine'][0]['primary_use'];
medImages=jsonDecode(medecineResponse)['imageUrls']; medImages=jsonDecode(medecineResponse)['imageUrls'];
/* medecineList = /* medecineList =
((jsonDecode(medecineResponse)['medicine']) as List).map((dynamic model) { ((jsonDecode(medecineResponse)['medicine']) as List).map((dynamic model) {
@ -76,16 +82,175 @@ class _GetMedicinesState extends State<GetMedicines> with TickerProviderStateMix
} }
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: <Widget>[
Container(
width: MediaQuery.of(context).size.width * .10,
height: MediaQuery.of(context).size.height * .30,
child: PhotoView(
imageProvider: NetworkImage(imageUrl) as ImageProvider,
maxScale: PhotoViewComputedScale.contained * 4.0,
minScale: PhotoViewComputedScale.contained,
initialScale: PhotoViewComputedScale.contained,
basePosition: Alignment.center,
)
)
],
),
),
actions: <Widget>[
TextButton(
child: Text('Close', style: textButtonStyle()),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
});
},
);
}
/*Widget _bindMedicines(){
if (medecineList.length != 0) {
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child:ListView.builder(
padding: EdgeInsets.all(0),
itemCount: medecineList.length,
itemBuilder: (BuildContext context, int index) {
return Card(
//color: prescriptionsList[index].cardColor,
child: Padding(
padding:EdgeInsets.all(8) ,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
GestureDetector(
child: Container(
width: MediaQuery.of(context).size.width * .18,
height:
MediaQuery.of(context).size.height * .10,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
image: DecorationImage(
image: NetworkImage(medImages[0]) as ImageProvider, // picked file
fit: BoxFit.contain)),
),
onTap: (){
showPicDialog(medImages[0]);
},
),
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(("Name :"+ medicine_name).toString().toUpperCase(),style: valuesTextStyle()),
Text(("Manufacturers :"+ medicine_manufacturers).toString().toUpperCase(),style: valuesTextStyle()),
Text(("Estimate Price :"+ medicine_mrp).toString().toUpperCase(),style: valuesTextStyle()),
Text(("Medicine_Use :"+ medicine_primary_use).toString().toUpperCase(),style: valuesTextStyle()),
],
),
),
],
),
],
),
),
);
}) ),
]);
}
else{
return Center(
child: Padding(
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
child: isSereverIssue
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 20,
),
Text(
'No medicine found with your search',style:serverIssueTextStyle() ,),
],
)
: userAddress==''?Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.search,color: primaryColor,size: 40,),
SizedBox(
height: 20,
),
Text(
'Please enter atleast 4 letters to continue search',style:TextStyle(
color: primaryColor,
fontWeight: FontWeight.bold,
),),
],
):
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.dataset_rounded,color: primaryColor,size: 40,),
SizedBox(
height: 20,
),
SizedBox(
height: 20,
),
Text(
'No medicine found with your search',style:serverIssueTextStyle() ,),
],
),
));
}
}*/
Widget _bindMedicines() { Widget _bindMedicines() {
if (medicine_name!='') { if (medicine_name!='') {
return Padding(padding: EdgeInsets.all(10), return Padding(padding: EdgeInsets.all(10),
child: Container( child: Container(
width: double.infinity, width: double.infinity,
child: Row( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Container(
GestureDetector(
child: Container(
width: MediaQuery.of(context).size.width * .18, width: MediaQuery.of(context).size.width * .18,
height: height:
MediaQuery.of(context).size.height * .10, MediaQuery.of(context).size.height * .10,
@ -95,9 +260,33 @@ class _GetMedicinesState extends State<GetMedicines> with TickerProviderStateMix
image: NetworkImage(medImages[0]) as ImageProvider, // picked file image: NetworkImage(medImages[0]) as ImageProvider, // picked file
fit: BoxFit.contain)), fit: BoxFit.contain)),
), ),
Text(medicine_name), onTap: (){
showPicDialog(medImages[0]);
},
),
Text(("Name :"+ medicine_name),
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(("Manufacturers :"+ medicine_manufacturers),
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(
medicine_salt_composition,
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(("Estimate Price :"+ medicine_mrp),
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(("Medicine_Use :"+ medicine_primary_use),
style: TextStyle(fontWeight: FontWeight.bold),
),
], ],
), ),
), ),
); );
} }

@ -94,7 +94,7 @@ class _LoginState extends State<Login> {
//width: double.infinity, //width: double.infinity,
child: Image( child: Image(
image: const AssetImage('images/logo.png'), image: const AssetImage('images/logo.png'),
height: MediaQuery.of(context).size.height * .25, height: MediaQuery.of(context).size.height * .18,
)), )),
const SizedBox( const SizedBox(
height: 15, height: 15,

@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
class GetMedecineDetailsModel {
String name = '';
String manufacturers = '';
String salt_composition = '';
String mrp='';
String primary_use='';
String bs64str='';
String picture='';
Map<String,dynamic> picture1={};
Color text_color=Colors.black;
GetMedecineDetailsModel();
factory GetMedecineDetailsModel.fromJson(Map<String, dynamic> json){
GetMedecineDetailsModel rtvm = new GetMedecineDetailsModel();
rtvm.name = json['name'] ?? '';
rtvm.manufacturers = json['manufacturers'] ?? '';
rtvm.salt_composition = json['salt_composition'] ?? '';
rtvm.mrp = json['mrp'] ?? '';
rtvm.primary_use = json['primary_use'] ??'';
rtvm.picture = json['picture'] ?? '';
return rtvm;
}
}

@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
class ConnectedCustomersModel {
String customer_name = '';
String customer_phone_number='';
String customer_building_name='';
String customer_address='';
String customer_id='';
Color text_color=Colors.black;
ConnectedCustomersModel();
factory ConnectedCustomersModel.fromJson(Map<String, dynamic> json){
ConnectedCustomersModel rtvm = new ConnectedCustomersModel();
rtvm.customer_name = json['username'] ?? '';
rtvm.customer_phone_number = json['phone'] ?? '';
rtvm.customer_building_name = json['buildingName'] ?? '';
rtvm.customer_address = json['profile']['address1'] ?? '';
rtvm.customer_id = json['customerId'] ?? '';
return rtvm;
}
}

@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
class PendingSuppliersModel {
String customer_name = '';
String customer_phone_number='';
String customer_address='';
String customer_id='';
Color text_color=Colors.black;
PendingSuppliersModel();
factory PendingSuppliersModel.fromJson(Map<String, dynamic> json){
PendingSuppliersModel rtvm = new PendingSuppliersModel();
rtvm.customer_name = json['username'] ?? '';
rtvm.customer_phone_number = json['phone'] ?? '';
rtvm.customer_address = json['profile']['address1'] ?? '';
rtvm.customer_id = json['customerId'] ?? '';
return rtvm;
}
}

@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
class PendingSuppliersModel {
String customer_name = '';
String customer_phone_number='';
String customer_address='';
String customer_id='';
Color text_color=Colors.black;
PendingSuppliersModel();
factory PendingSuppliersModel.fromJson(Map<String, dynamic> json){
PendingSuppliersModel rtvm = new PendingSuppliersModel();
rtvm.customer_name = json['username'] ?? '';
rtvm.customer_phone_number = json['phone'] ?? '';
rtvm.customer_address = json['profile']['address1'] ?? '';
rtvm.customer_id = json['customerId'] ?? '';
return rtvm;
}
}

@ -0,0 +1,899 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:healthcare_pharmacy/models/offersview_model.dart';
import 'package:healthcare_pharmacy/offers.dart';
import 'package:healthcare_pharmacy/settings.dart';
import 'package:intl/intl.dart';
import 'package:flutter_cupertino_datetime_picker/flutter_cupertino_datetime_picker.dart';
class OffersData extends StatefulWidget {
const OffersData({Key? key}) : super(key: key);
@override
State<OffersData> createState() => _OffersDataState();
}
class _OffersDataState extends State<OffersData> with TickerProviderStateMixin {
bool isOfferDataLoading=false;
bool isSereverIssue = false;
bool isSereverIssueConnected = false;
bool isSereverIssuePending = false;
var startdate;
var enddate;
TextEditingController updateOfferNameController = TextEditingController();
TextEditingController updateOfferCodeController = TextEditingController();
TextEditingController updateOfferDescriptionController = TextEditingController();
TextEditingController updateDiscountController = TextEditingController();
TextEditingController updateOfferStartDateController = TextEditingController();
TextEditingController updateOfferEndDateController = TextEditingController();
List<GetOffersDetailsModel> activeOffersList = [];
List<GetOffersDetailsModel> inactiveOffersList = [];
late TabController _controller;
bool isActiveDataLoading=false;
bool isinactiveDataLoading=false;
final List<Tab> topTabs = <Tab>[
Tab(
child: Column(
children: [Text('Active Offers')],
),
),
Tab(
child: Column(
children: [Text('InActive Offers')],
),
),
];
Future<void> getActiveOffersViewData() async {
isActiveDataLoading = true;
try {
var response = await AppSettings.getOffers();
setState(() {
activeOffersList =
((jsonDecode(response)['data']) as List).map((dynamic model) {
return GetOffersDetailsModel.fromJson(model);
}).toList();
isActiveDataLoading = false;
});
} catch (e) {
setState(() {
isActiveDataLoading = false;
isSereverIssueConnected = true;
});
}
}
Future<void> getInactiveOffersViewData() async {
isinactiveDataLoading = true;
try {
var response = await AppSettings.getinactiveOffers();
setState(() {
inactiveOffersList =
((jsonDecode(response)['data']) as List).map((dynamic model) {
return GetOffersDetailsModel.fromJson(model);
}).toList();
isinactiveDataLoading = false;
});
} catch (e) {
setState(() {
isinactiveDataLoading = false;
isSereverIssueConnected = true;
});
}
}
showUpdateOfferDialog(var object) async {
updateOfferNameController.text = object.offer_name;
updateOfferCodeController.text = object.offer_code;
updateOfferDescriptionController.text = object.description;
updateDiscountController.text = object.discount_percentage;
updateOfferStartDateController.text=object.starting_date;
updateOfferEndDateController.text=object.ending_date;
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return AlertDialog(
title: const Text('Update Offer'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
child: TextFormField(
cursorColor: greyColor,
controller: updateOfferNameController,
textCapitalization: TextCapitalization.characters,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.person,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter offer name',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
), //tanker name
),
const SizedBox(
height: 20,
),
Container(
//padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: TextFormField(
cursorColor: greyColor,
controller: updateOfferCodeController,
textCapitalization: TextCapitalization.characters,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.numbers,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter Offer Code',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
), //tanker name
),
const SizedBox(
height: 20,
),
Container(
//padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: TextFormField(
cursorColor: greyColor,
controller: updateOfferDescriptionController,
textCapitalization: TextCapitalization.characters,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.description,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter Offer Description',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
), //tanker name
),
const SizedBox(
height: 20,
),
Container(
//padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: TextFormField(
cursorColor: greyColor,
maxLength: 2,
controller: updateDiscountController,
textCapitalization: TextCapitalization.characters,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.percent_outlined,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter Offer Discount',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
), //tanker name
),
const SizedBox(
height: 20,
),
Container(
child: TextFormField(
readOnly: true,
cursorColor: greyColor,
controller: updateOfferStartDateController,
decoration: InputDecoration(
labelText: 'Select Start Date',
prefixIcon: IconButton(
icon: Icon(
Icons.date_range,
color: primaryColor,
),
onPressed: () async {
DatePicker.showDatePicker(
context,
dateFormat: 'dd MMMM yyyy HH:mm',
initialDateTime: DateTime.now(),
minDateTime:DateTime.now(),
maxDateTime: DateTime.now().add(Duration(days: 15)),
onMonthChangeStartWithFirstDate: true,
pickerMode: DateTimePickerMode.datetime,
pickerTheme: DateTimePickerTheme(
// backgroundColor: Colors.white,
cancelTextStyle: labelTextStyle(),
confirmTextStyle: labelTextStyle(),
// showTitle: true,
//title: Text('Pick date and time'),
itemTextStyle: valuesTextStyle(),
),
onConfirm: (dateTime, List<int> index)async {
DateTime selectdate = dateTime;
setState(() {
startdate = DateFormat('dd-MMM-yyyy - HH:mm').format(selectdate);
});
if(startdate!=''){
setState(() {
updateOfferStartDateController.text=startdate.toString();
});
}
else {
AppSettings.longFailedToast('please select date');
}
},
);
},
),
labelStyle: const TextStyle(
color: greyColor, //<-- SEE HERE
),
border: const OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
),
),
),
const SizedBox(
height: 20,
),
Container(
child: TextFormField(
readOnly: true,
cursorColor: greyColor,
controller: updateOfferEndDateController,
decoration: InputDecoration(
labelText: 'Select End Date',
prefixIcon: IconButton(
icon: Icon(
Icons.date_range,
color: primaryColor,
),
onPressed: () async {
DatePicker.showDatePicker(
context,
dateFormat: 'dd MMMM yyyy HH:mm',
initialDateTime: DateTime.now(),
minDateTime:DateTime.now(),
maxDateTime: DateTime.now().add(Duration(days: 15)),
onMonthChangeStartWithFirstDate: true,
pickerMode: DateTimePickerMode.datetime,
pickerTheme: DateTimePickerTheme(
// backgroundColor: Colors.white,
cancelTextStyle: labelTextStyle(),
confirmTextStyle: labelTextStyle(),
// showTitle: true,
//title: Text('Pick date and time'),
itemTextStyle: valuesTextStyle(),
),
onConfirm: (dateTime, List<int> index)async {
DateTime selectdate = dateTime;
setState(() {
enddate = DateFormat('dd-MMM-yyyy - HH:mm').format(selectdate);
});
if(enddate!=''){
setState(() {
updateOfferEndDateController.text=enddate.toString();
});
}
else {
AppSettings.longFailedToast('please select date');
}
},
);
},
),
labelStyle: const TextStyle(
color: greyColor, //<-- SEE HERE
),
border: const OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
),
),
),//address description
const SizedBox(
height: 30,
),
],
),
),
actions: <Widget>[
TextButton(
child: Text('cancel', style: textButtonStyle()),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text('Update', style: textButtonStyle()),
onPressed: () async {
if (updateOfferNameController.text != '' ) {
AppSettings.preLoaderDialog(context);
var payload = new Map<String, dynamic>();
payload["offer_name"] = updateOfferNameController.text.toString();
payload["offer_code"] = updateOfferCodeController.text.toString();
payload["description"] = updateOfferDescriptionController.text.toString();
payload["discount_percentage"] = updateDiscountController.text.toString();
payload["starting_date"] = updateOfferStartDateController.text.toString();
payload["ending_date"] = updateOfferEndDateController.text.toString();
payload["offer_status"] ="active";
bool offerStatus = await AppSettings.updateOffers(object.offer_code, payload);
try {
if (offerStatus) {
Navigator.of(context, rootNavigator: true).pop();
AppSettings.longSuccessToast(
"Offer Updated Successfully");
updateOfferNameController.text = '';
updateOfferCodeController.text = '';
updateOfferDescriptionController.text = '';
updateDiscountController.text = '';
updateOfferStartDateController.text = '';
updateOfferEndDateController.text = '';
Navigator.of(context).pop();
await getActiveOffersViewData();
} 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);
}
},
),
],
);
});
},
);
}
@override
void initState() {
// TODO: implement initState
_controller = TabController(vsync: this, length: 2);
getActiveOffersViewData();
getInactiveOffersViewData();
super.initState();
}
Widget renderzActiveUi(){
if(activeOffersList.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child:ListView.builder(
padding: EdgeInsets.all(0),
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,
children: [
Container(
//width: MediaQuery.of(context).size.width * .55,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('OfferName :',style: labelTextStyle()),
Text('OfferCode :',style: labelTextStyle()),
Text('OfferDes :' ,style: labelTextStyle()),
Text('OfferDis(%) :' ,style: labelTextStyle()),
Text('StartDate :',style: labelTextStyle()),
Text('EndDate :' ,style: labelTextStyle()),
],
),
SizedBox(width: 5,),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(activeOffersList[index].offer_name,style: valuesTextStyle()),
Text(activeOffersList[index].offer_code,style: valuesTextStyle()),
Text(activeOffersList[index].description,style: valuesTextStyle()),
Text(activeOffersList[index].discount_percentage,style: valuesTextStyle()),
Text(activeOffersList[index].starting_date,style: valuesTextStyle()),
Text(activeOffersList[index].ending_date,style: valuesTextStyle())
],
),
],
),
],
),
),
Expanded(child:IconButton(
icon: const Icon(Icons.edit,color: primaryColor,),
onPressed: () {
showUpdateOfferDialog(activeOffersList[index]);
},
),),
Expanded(child:IconButton(
icon: const Icon(Icons.hide_source_rounded,color: primaryColor,),
onPressed: () async{
showDialog(
//if set to true allow to close popup by tapping out of the popup
//barrierDismissible: false,
context: context,
builder: (BuildContext context) => AlertDialog(
title: const Text('Do you want In_Active Offer??',
style: TextStyle(
color: primaryColor,
fontSize: 16,
)),
actionsAlignment: MainAxisAlignment.spaceBetween,
actions: [
TextButton(
onPressed: ()async {
bool deleteOfferStatus = await AppSettings.deleteOffers(activeOffersList[index].offer_code);
if(deleteOfferStatus){
getActiveOffersViewData();
AppSettings.longSuccessToast('Offer In_Active Successfully!!');
getInactiveOffersViewData();
Navigator.of(context).pop(true);
}
else{
AppSettings.longFailedToast('Offer In_Active failed');
}
},
child: const Text('Yes',
style: TextStyle(
color: primaryColor,
fontSize: 18,
)),
),
TextButton(
onPressed: () {
Navigator.of(context).pop(true);
},
child: const Text('No',
style: TextStyle(
color: primaryColor,
fontSize: 18,
)),
),
],
),
);
},
),)
],
),
),
);
}) ),
Padding(
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
child: CircleAvatar(
backgroundColor: primaryColor,
radius: 40,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
iconSize: 40,
icon: const Icon(
Icons.add,
color: Colors.white,
),
onPressed: () async{
Navigator.pop(context);
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => offers()),
);
//showBoreAddingDialog();
},
),
/* Padding(
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
child: Text(
'Add Tanks ',
style: TextStyle(color: Colors.white),
),
)*/
],
),
),
),
]);
}
else{
return Center(
child: Padding(
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: MediaQuery.of(context).size.height * .25,),
Text('Click below icon to add new Offer'),
SizedBox(
height: 20,
),
CircleAvatar(
backgroundColor: primaryColor,
radius: 40,
child: IconButton(
iconSize: 40,
icon: const Icon(
Icons.add,
color: Colors.white,
),
onPressed: () async {
Navigator.pop(context);
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => offers()),
);
},
),
)
],
),
)
);
}
}
Widget renderzInactiveUi(){
if(inactiveOffersList.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child:ListView.builder(
padding: EdgeInsets.all(0),
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,
children: [
Container(
//width: MediaQuery.of(context).size.width * .55,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('OfferName :',style: labelTextStyle()),
Text('OfferCode :',style: labelTextStyle()),
Text('OfferDes :' ,style: labelTextStyle()),
Text('OfferDis(%) :' ,style: labelTextStyle()),
Text('StartDate :',style: labelTextStyle()),
Text('EndDate :' ,style: labelTextStyle()),
],
),
SizedBox(width: 5,),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(inactiveOffersList[index].offer_name,style: valuesTextStyle()),
Text(inactiveOffersList[index].offer_code,style: valuesTextStyle()),
Text(inactiveOffersList[index].description,style: valuesTextStyle()),
Text(inactiveOffersList[index].discount_percentage,style: valuesTextStyle()),
Text(inactiveOffersList[index].starting_date,style: valuesTextStyle()),
Text(inactiveOffersList[index].ending_date,style: valuesTextStyle())
],
),
],
),
],
),
),
Expanded(child:TextButton(
onPressed: () {
showDialog(
//if set to true allow to close popup by tapping out of the popup
//barrierDismissible: false,
context: context,
builder: (BuildContext context) => AlertDialog(
title: const Text('Do you want to Re_Active offer ??',
style: TextStyle(
color: primaryColor,
fontSize: 16,
)),
actionsAlignment: MainAxisAlignment.spaceBetween,
actions: [
TextButton(
onPressed: ()async {
bool deleteTankStatus = await AppSettings.reactiveOffers(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,
)),
),
],
),
);
},
child: const Text(
'RE_ACTIVE',
style: TextStyle(
color: primaryColor,
fontSize: 15,
fontWeight: FontWeight.bold
/* decoration: TextDecoration.underline,*/
),
),
),
),
],
),
),
);
}) ),
Padding(
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
child: CircleAvatar(
backgroundColor: primaryColor,
radius: 40,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
iconSize: 40,
icon: const Icon(
Icons.add,
color: Colors.white,
),
onPressed: () async{
Navigator.pop(context);
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => offers()),
);
//showBoreAddingDialog();
},
),
/* Padding(
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
child: Text(
'Add Tanks ',
style: TextStyle(color: Colors.white),
),
)*/
],
),
),
),
]);
}
else{
return Center(
child: Padding(
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: MediaQuery.of(context).size.height * .25,),
Text('Click below icon to add new Offer'),
SizedBox(
height: 20,
),
CircleAvatar(
backgroundColor: primaryColor,
radius: 40,
child: IconButton(
iconSize: 40,
icon: const Icon(
Icons.add,
color: Colors.white,
),
onPressed: () async {
Navigator.pop(context);
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => offers()),
);
},
),
)
],
),
)
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Offers'),
backgroundColor: primaryColor,
bottom: TabBar(
controller: _controller,
tabs: topTabs,
indicatorColor: Colors.blue,
unselectedLabelColor: Colors.white60,
indicatorWeight: 2,
),),
/* body: */
body: TabBarView(controller: _controller, children: [
/*Container(
// color: Colors.lightGreenAccent,
child: isTankerDataLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):_tanker(),
),*/
Container(
//color: Colors.lightBlueAccent,
child: isActiveDataLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):renderzActiveUi(),
),
Container(
//color: Colors.lightBlueAccent,
child: isinactiveDataLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):renderzInactiveUi(),
),
]),
);
}
}

@ -0,0 +1,226 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:healthcare_pharmacy/models/pending_suppliers_model.dart';
import 'package:healthcare_pharmacy/settings.dart';
class PendingCustomers extends StatefulWidget {
@override
State<PendingCustomers> createState() => _PendingCustomersState();
}
class _PendingCustomersState extends State<PendingCustomers> {
TextEditingController tankerNameController = TextEditingController();
TextEditingController tankerPhoneController = TextEditingController();
TextEditingController tankerAlterPhoneController = TextEditingController();
bool isPendingDataLoading=false;
List<PendingSuppliersModel> pendingSuppliersList = [];
bool isSereverIssuePending = false;
bool isLoading=false;
Future<void> getPendingSuppliersData() async {
isPendingDataLoading = true;
try {
/* var response = await AppSettings.getPendingSuppliers();
setState(() {
pendingSuppliersList =
((jsonDecode(response)['data']) as List).map((dynamic model) {
return PendingSuppliersModel.fromJson(model);
}).toList();
isPendingDataLoading = false;
});*/
} catch (e) {
setState(() {
isPendingDataLoading = false;
isSereverIssuePending = true;
});
}
}
@override
void initState() {
isLoading=true;
getPendingSuppliersData();
super.initState();
}
Widget renderzUi(){
if(pendingSuppliersList.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child:ListView.builder(
padding: EdgeInsets.all(0),
itemCount: pendingSuppliersList.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 * .50,
child: Row(
children: [
Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('username :',
style: labelTextStyle()),
SizedBox(height: 10,),
Text('contactNumber:',
style: labelTextStyle()),
SizedBox(height: 10,),
Text('address:',
style: labelTextStyle()),
],
),
SizedBox(width: 10,),
Expanded(child:Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
pendingSuppliersList[index]
.customer_name
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
pendingSuppliersList[index]
.customer_phone_number
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
pendingSuppliersList[index]
.customer_address
.toUpperCase(),
style: valuesTextStyle())
],
),)
],
)
),
TextButton(
child: Text(
'Accept',
style: TextStyle(fontSize: 15,
color:primaryColor/*FilteredList[index].text_color*/ ),
),
onPressed: () async{
var payload = new Map<String, dynamic>();
payload["supplierId"] =AppSettings.pharmacyId;
payload["customerId"] = pendingSuppliersList[index].customer_id;
/* bool requestStatus = await AppSettings.acceptRequest(payload);
if(requestStatus){
AppSettings.longSuccessToast("Request Accepted Successfully");
// await getConnectedSuppliersData();
await getPendingSuppliersData();
}
else{
}*/
},
),
TextButton(
child: Text(
'Reject',
style: TextStyle(fontSize: 15,
color:primaryColor/*FilteredList[index].text_color*/ ),
),
onPressed: () async{
var payload = new Map<String, dynamic>();
payload["supplierId"] =AppSettings.pharmacyId;
payload["customerId"] = pendingSuppliersList[index].customer_id;
/* bool requestStatus = await AppSettings.rejectRequest(payload);
if(requestStatus){
AppSettings.longSuccessToast("Request Sent Successfully");
await getPendingSuppliersData();
}
else{
}*/
},
),
],
),
),
);
}) ),
]);
}
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('No Data Found'),
SizedBox(
height: 20,
),
],
),
)
);
}
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppSettings.appBar('Pending Customers'),
body: isPendingDataLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):renderzUi(),
));
}
}

@ -166,6 +166,7 @@ class AppSettings {
static String updatePharmacyUrl = host + 'update/currentPharmacy'; static String updatePharmacyUrl = host + 'update/currentPharmacy';
static String verifyPhnUrl = host + 'phone'; static String verifyPhnUrl = host + 'phone';
static String profilePicUrl = host + 'users/profile-picture'; static String profilePicUrl = host + 'users/profile-picture';
static String uploadPicUrl = host + 'uploadsPharmacy';
static String resetTokenUrl = host + 'reset_token'; static String resetTokenUrl = host + 'reset_token';
static String forgotPasswordUrl = host + 'forgotpassword'; static String forgotPasswordUrl = host + 'forgotpassword';
static String resetPasswordUrl = host + 'resetpassword'; static String resetPasswordUrl = host + 'resetpassword';
@ -189,8 +190,10 @@ class AppSettings {
static File? updatedImage; static File? updatedImage;
static String image = ''; static String image = '';
static String profilePictureUrl = '';
static var api = { static var api = {
'signIn': host + '/login', 'signIn': host + '/login',
}; };
@ -256,7 +259,6 @@ class AppSettings {
} }
} }
static getData(String _key, type) async { static getData(String _key, type) async {
sharedPreferences = await SharedPreferences.getInstance(); sharedPreferences = await SharedPreferences.getInstance();
if (type == 'STRING') { if (type == 'STRING') {
@ -270,6 +272,7 @@ class AppSettings {
} }
} }
static clearSharedPreferences() async { static clearSharedPreferences() async {
sharedPreferences = await SharedPreferences.getInstance(); sharedPreferences = await SharedPreferences.getInstance();
await sharedPreferences.clear(); await sharedPreferences.clear();
@ -346,6 +349,18 @@ class AppSettings {
} }
} }
static Future<String> uploadImageHTTPNew(file) async {
var request = http.MultipartRequest('POST', Uri.parse(uploadPicUrl + '/' + 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<bool> updatePharmaData(payload) async { static Future<bool> updatePharmaData(payload) async {
try { try {
var response = await http.put( var response = await http.put(
@ -359,6 +374,10 @@ class AppSettings {
phoneNumber = _response['phone']; phoneNumber = _response['phone'];
email = _response['emails'][0]['email']; email = _response['emails'][0]['email'];
pharmacyDescription = _response['description']; pharmacyDescription = _response['description'];
await saveData('pharmacyname', _response['simplydata']['pharmacyname'], 'STRING');
await saveData('phone', _response['simplydata']['phone'], 'STRING');
await saveData('email', _response['simplydata']['email'][0]['email'], 'STRING');
await loadDataFromMemory();
return true; return true;
} else { } else {
return false; return false;
@ -635,7 +654,6 @@ class AppSettings {
var uri = Uri.parse(profilePicUrl + '/' + pharmacyId); var uri = Uri.parse(profilePicUrl + '/' + pharmacyId);
var response = await http.post(uri, var response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders()); body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) { if (response.statusCode == 200) {
try { try {
var _response = json.decode(response.body); var _response = json.decode(response.body);
@ -674,13 +692,13 @@ class AppSettings {
dynamic input) async { dynamic input) async {
// save login name information // save login name information
await saveData('pharmacyname', input['simplydata']['pharmacyname'], 'STRING'); 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( await saveData(
'access_token', input['simplydata']['access_token'], 'STRING'); 'access_token', input['simplydata']['access_token'], 'STRING');
await saveData('phone', input['simplydata']['phone'], 'STRING');
await saveData('pharmacyId', input['simplydata']['pharmacyId'], 'STRING'); await saveData('pharmacyId', input['simplydata']['pharmacyId'], 'STRING');
await saveData('email', input['simplydata']['email'][0]['email'], 'STRING');
// await saveData('customerId', input['simplydata']['customerId'], 'STRING'); // await saveData('customerId', input['simplydata']['customerId'], 'STRING');
// await saveData('profile', input['simplydata']['picture'], 'STRING'); await saveData('profile', input['simplydata']['picture'], 'STRING');
await saveData('pharmacy_address', input['simplydata']['pharmacy_address'], 'STRING'); await saveData('pharmacy_address', input['simplydata']['pharmacy_address'], 'STRING');
await saveData('latitude', input['simplydata']['latitude'], 'DOUBLE'); await saveData('latitude', input['simplydata']['latitude'], 'DOUBLE');
await saveData('longitude', input['simplydata']['longitude'], 'DOUBLE'); await saveData('longitude', input['simplydata']['longitude'], 'DOUBLE');
@ -707,6 +725,7 @@ class AppSettings {
phoneNumber = await getData('phone', 'STRING'); phoneNumber = await getData('phone', 'STRING');
healthpharmaIdsign = await getData('pharmacyId', 'STRING'); healthpharmaIdsign = await getData('pharmacyId', 'STRING');
userLatitude = await getData('latitude', 'DOUBLE'); userLatitude = await getData('latitude', 'DOUBLE');
profilePictureUrl=await getData('profile', 'STRING');
userLongitude =await getData('longitude', 'DOUBLE'); userLongitude =await getData('longitude', 'DOUBLE');
fcmId =await getData('fcmId', 'STRING'); fcmId =await getData('fcmId', 'STRING');
} }

@ -1,4 +1,4 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -6,6 +6,8 @@ import 'package:healthcare_pharmacy/dashboard.dart';
import 'package:healthcare_pharmacy/settings.dart'; import 'package:healthcare_pharmacy/settings.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'dart:io'; import 'dart:io';
import 'package:photo_view/photo_view.dart';
class UpdateProfile extends StatefulWidget { class UpdateProfile extends StatefulWidget {
@ -16,6 +18,7 @@ class UpdateProfile extends StatefulWidget {
class _UpdateprofileState extends State<UpdateProfile> { class _UpdateprofileState extends State<UpdateProfile> {
String Url = '';
bool isPwdObscureText=true; bool isPwdObscureText=true;
bool isConfirmPwdObscureText=true; bool isConfirmPwdObscureText=true;
TextEditingController nameController = TextEditingController(); TextEditingController nameController = TextEditingController();
@ -36,18 +39,22 @@ class _UpdateprofileState extends State<UpdateProfile> {
super.initState(); super.initState();
} }
final ImagePicker _picker = ImagePicker(); final ImagePicker _picker = ImagePicker();
Future pickImageFromGallery() async { Future pickImageFromGallery() async {
try { try {
final image = await _picker.pickImage(source: ImageSource.gallery); final image = await _picker.pickImage(source: ImageSource.gallery);
if (image == null) return; if (image == null) return;
final imageTemp = File(image.path); final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageHTTPNew(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
AppSettings.updatedImage = imageTemp; AppSettings.profilePictureUrl = jsonDecode(res)['picture'];
}); });
//uploadProfileApi(AppSettings.updatedImage); AppSettings.saveData('profile', jsonDecode(res)['picture'], 'STRING');
AppSettings.saveProfile(image.path);
} on PlatformException catch (e) { } on PlatformException catch (e) {
print('Failed to pick image: $e'); print('Failed to pick image: $e');
} }
@ -58,10 +65,14 @@ class _UpdateprofileState extends State<UpdateProfile> {
final image = await _picker.pickImage(source: ImageSource.camera); final image = await _picker.pickImage(source: ImageSource.camera);
if (image == null) return; if (image == null) return;
final imageTemp = File(image.path); final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageHTTPNew(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
AppSettings.updatedImage = imageTemp; AppSettings.profilePictureUrl = jsonDecode(res)['picture'];
}); });
AppSettings.saveData('profile', jsonDecode(res)['picture'], 'STRING');
// uploadProfileApi(AppSettings.updatedImage); // uploadProfileApi(AppSettings.updatedImage);
AppSettings.saveProfile(image.path); AppSettings.saveProfile(image.path);
@ -103,20 +114,13 @@ class _UpdateprofileState extends State<UpdateProfile> {
Container(child: GestureDetector( Container(child: GestureDetector(
child: Container( child: Container(
width: MediaQuery.of(context).size.width * .60, width: MediaQuery.of(context).size.width * .60,
height: height: MediaQuery.of(context).size.height * .15,
MediaQuery.of(context).size.height * .15,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
border: Border.all(width: 5, color: Colors.blueGrey), border: Border.all(width: 5, color: Colors.blueGrey),
image: DecorationImage( image: DecorationImage(
image: (AppSettings.updatedImage != image: (AppSettings.profilePictureUrl != ''&& AppSettings.profilePictureUrl != 'null') ? NetworkImage(AppSettings.profilePictureUrl) as ImageProvider : AssetImage("images/mobilebg.png"), // picked file
null) fit: BoxFit.fitWidth)),
? FileImage(
AppSettings.updatedImage!)
as ImageProvider
: AssetImage(
"images/mobilebg.png"), // picked file
fit: BoxFit.cover)),
), ),
onTap: () { onTap: () {
showModalBottomSheet<void>( showModalBottomSheet<void>(
@ -126,14 +130,13 @@ class _UpdateprofileState extends State<UpdateProfile> {
height: 200, height: 200,
child: Center( child: Center(
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.center,
MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
GestureDetector( GestureDetector(
child: Icon( child: Icon(
Icons.camera_alt_outlined, Icons.camera_alt_outlined,
size: 100, size: 100,
color: greyColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
await takeImageFromCamera(); await takeImageFromCamera();
@ -141,16 +144,14 @@ class _UpdateprofileState extends State<UpdateProfile> {
}, },
), ),
SizedBox( SizedBox(
width: MediaQuery.of(context) width:
.size MediaQuery.of(context).size.width * .20,
.width *
.20,
), ),
GestureDetector( GestureDetector(
child: Icon( child: Icon(
Icons.photo, Icons.photo,
size: 100, size: 100,
color: greyColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
await pickImageFromGallery(); await pickImageFromGallery();

@ -0,0 +1,449 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter_svg/flutter_svg.dart';import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
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:healthcare_pharmacy/models/active_orders_model.dart';
import 'package:healthcare_pharmacy/models/pending_orders_model.dart';
import 'package:healthcare_pharmacy/settings.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';
import 'package:url_launcher/url_launcher.dart';
/*class ConectedPendingCustomers extends StatefulWidget {
const ConectedPendingCustomers({Key? key}) : super(key: key);
@override
State<ConectedPendingCustomers> createState() => _ConectedPendingCustomersState();
}
class _ConectedPendingCustomersState extends State<ConectedPendingCustomers> with TickerProviderStateMixin {
bool isSupplierDataLoading=false;
bool isSereverIssue = false;
bool isSereverIssueConnected = false;
bool isSereverIssuePending = false;
List<ConnectedCustomersModel> connectedCustomersList = [];
List<PendingSuppliersModel> pendingSuppliersList = [];
late TabController _controller;
bool isConnectedDataLoading=false;
bool isPendingDataLoading=false;
final List<Tab> topTabs = <Tab>[
Tab(
child: Column(
children: [Text('Pending Customers')],
),
),
Tab(
child: Column(
children: [Text('Conected Customers')],
),
),
];
Future<void> getConnectedSuppliersData() async {
isConnectedDataLoading = true;
try {
var response = await AppSettings.getConnectedCustomers();
setState(() {
connectedCustomersList =
((jsonDecode(response)['data']) as List).map((dynamic model) {
return ConnectedCustomersModel.fromJson(model);
}).toList();
isConnectedDataLoading = false;
});
} catch (e) {
setState(() {
isConnectedDataLoading = false;
isSereverIssuePending = true;
});
}
}
Future<void> getPendingSuppliersData() async {
isPendingDataLoading = true;
try {
var response = await AppSettings.getPendingSuppliers();
setState(() {
pendingSuppliersList =
((jsonDecode(response)['data']) as List).map((dynamic model) {
return PendingSuppliersModel.fromJson(model);
}).toList();
isPendingDataLoading = false;
});
} catch (e) {
setState(() {
isPendingDataLoading = false;
isSereverIssuePending = true;
});
}
}
@override
void initState() {
// TODO: implement initState
_controller = TabController(vsync: this, length: 2);
getConnectedSuppliersData();
getPendingSuppliersData();
super.initState();
}
Widget connectedCustomers(){
if(connectedCustomersList.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child:ListView.builder(
padding: EdgeInsets.all(0),
itemCount: connectedCustomersList.length,
itemBuilder: (BuildContext context, int index) {
return Card(
child: Padding(
padding:EdgeInsets.all(8) ,
child: Container(
//width: MediaQuery.of(context).size.width * .50,
child: Row(
children: [
*//* Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('username :',
style: labelTextStyle()),
SizedBox(height: 10,),
Text('phone:',
style: labelTextStyle()),
SizedBox(height: 10,),
Text('buildingname:',
style: labelTextStyle()),
SizedBox(height: 10,),
Text('address:',
style: labelTextStyle()),
],
),
SizedBox(width: 10,),*//*
Expanded(child:Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
*//* children: [
Text(
connectedCustomersList[index]
.customer_name
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
connectedCustomersList[index]
.customer_phone_number
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
connectedCustomersList[index]
.customer_building_name
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(maxLines:3,
connectedCustomersList[index]
.customer_address
.toUpperCase(),
style: valuesTextStyle())
],*//*
children: [
Text(
connectedCustomersList[index]
.customer_name
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
connectedCustomersList[index]
.customer_phone_number
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
connectedCustomersList[index]
.customer_building_name
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
connectedCustomersList[index]
.customer_address
.toUpperCase(),
style: valuesTextStyle())
],
),),
Column(
children: [
IconButton(
iconSize: 30,
icon: const Icon(
Icons.phone,
color: primaryColor,
),
onPressed: () async {
final Uri _phoneUri = Uri(
scheme: "tel",
path: connectedCustomersList[index]
.customer_phone_number);
try {
await launch(
_phoneUri.toString());
} catch (error) {
throw ("Cannot dial");
}
},
),
Text(
'Call now',
style: iconBelowTextStyle(),
),
],
),
],
)
),
),
);
}) ),
]);
}
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('No Data Found'),
SizedBox(
height: 20,
),
],
),
)
);
}
}
Widget pendingCustomers(){
if(pendingSuppliersList.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child:ListView.builder(
padding: EdgeInsets.all(0),
itemCount: pendingSuppliersList.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 * .50,
child: Row(
children: [
*//* Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('username :',
style: labelTextStyle()),
SizedBox(height: 10,),
Text('contactNumber:',
style: labelTextStyle()),
SizedBox(height: 10,),
Text('address:',
style: labelTextStyle()),
],
),
SizedBox(width: 10,),*//*
Expanded(child:Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
pendingSuppliersList[index]
.customer_name
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
pendingSuppliersList[index]
.customer_phone_number
.toUpperCase(),
style: valuesTextStyle()),
SizedBox(height: 10,),
Text(
pendingSuppliersList[index]
.customer_address
.toUpperCase(),
style: valuesTextStyle())
],
),)
],
)
),
TextButton(
child: Text(
'Accept',
style: TextStyle(fontSize: 15,
color:primaryColor*//*FilteredList[index].text_color*//* ),
),
onPressed: () async{
var payload = new Map<String, dynamic>();
payload["supplierId"] =AppSettings.supplierId;
payload["customerId"] = pendingSuppliersList[index].customer_id;
bool requestStatus = await AppSettings.acceptRequest(payload);
if(requestStatus){
AppSettings.longSuccessToast("Request Accepted Successfully");
await getPendingSuppliersData();
await getConnectedSuppliersData();
}
else{
}
},
),
TextButton(
child: Text(
'Reject',
style: TextStyle(fontSize: 15,
color:primaryColor*//*FilteredList[index].text_color*//* ),
),
onPressed: () async{
var payload = new Map<String, dynamic>();
payload["supplierId"] =AppSettings.supplierId;
payload["customerId"] = pendingSuppliersList[index].customer_id;
bool requestStatus = await AppSettings.rejectRequest(payload);
if(requestStatus){
AppSettings.longSuccessToast("Rejected request Successfully");
await getPendingSuppliersData();
}
else{
}
},
),
],
),
),
);
}) ),
]);
}
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('No Data Found'),
SizedBox(
height: 20,
),
],
),
)
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Costumers'),
backgroundColor: primaryColor,
bottom: TabBar(
controller: _controller,
tabs: topTabs,
indicatorColor: Colors.blue,
unselectedLabelColor: Colors.white60,
indicatorWeight: 2,
),),
*//* body: *//*
body: TabBarView(controller: _controller, children: [
*//*Container(
// color: Colors.lightGreenAccent,
child: isTankerDataLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):_tanker(),
),*//*
Container(
//color: Colors.lightBlueAccent,
child: isPendingDataLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):pendingCustomers(),
),
Container(
//color: Colors.lightBlueAccent,
child: isConnectedDataLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):connectedCustomers(),
),
]),
);
}
}*/
Loading…
Cancel
Save