After Width: | Height: | Size: 367 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 924 B |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 102 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 7.4 KiB |
@ -1,365 +1,441 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
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:flutter/services.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:watermanagement_deliveryboy/model/getdeliveryboy_model.dart';
|
||||
import 'package:watermanagement_deliveryboy/settings.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:watermanagement/delivrybookingdata.dart';
|
||||
import 'package:watermanagement/login.dart';
|
||||
import 'package:watermanagement/settings.dart';
|
||||
import 'dart:io';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Dashboard extends StatefulWidget {
|
||||
const Dashboard({Key? key}) : super(key: key);
|
||||
const Dashboard({super.key});
|
||||
|
||||
@override
|
||||
State<Dashboard> createState() => _DashboardState();
|
||||
}
|
||||
|
||||
class _DashboardState extends State<Dashboard> with TickerProviderStateMixin {
|
||||
bool isSupplierDataLoading=false;
|
||||
bool isSereverIssue = false;
|
||||
bool isSereverIssueConnected = false;
|
||||
bool isSereverIssuePending = false;
|
||||
class _DashboardState extends State<Dashboard> {
|
||||
int _selectedIndex = 0;
|
||||
|
||||
TextEditingController tankNameController = TextEditingController();
|
||||
TextEditingController blockNameController = TextEditingController();
|
||||
TextEditingController capacityController = TextEditingController();
|
||||
|
||||
List<GetDeliveryboyDetailsModel> connectedSuppliersList = [];
|
||||
bool isLoading=false;
|
||||
|
||||
Future<void> getConnectedSuppliersData() async {
|
||||
isLoading = true;
|
||||
static const TextStyle optionStyle =
|
||||
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
|
||||
|
||||
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
|
||||
Future pickImageFromGallery() async {
|
||||
try {
|
||||
var response = await AppSettings.getdeliveryboybookings();
|
||||
final image = await _picker.pickImage(source: ImageSource.gallery);
|
||||
if (image == null) return;
|
||||
final imageTemp = File(image.path);
|
||||
setState(() {
|
||||
connectedSuppliersList =
|
||||
((jsonDecode(response)['data']) as List).map((dynamic model) {
|
||||
return GetDeliveryboyDetailsModel.fromJson(model);
|
||||
}).toList();
|
||||
isLoading = false;
|
||||
AppSettings.updatedImage = imageTemp;
|
||||
});
|
||||
// uploadProfileApi(AppSettings.updatedImage);
|
||||
AppSettings.saveProfile(image.path);
|
||||
|
||||
|
||||
} catch (e) {
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future takeImageFromCamera() async {
|
||||
try {
|
||||
final image = await _picker.pickImage(source: ImageSource.camera);
|
||||
if (image == null) return;
|
||||
final imageTemp = File(image.path);
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
isSereverIssueConnected = true;
|
||||
AppSettings.updatedImage = imageTemp;
|
||||
});
|
||||
|
||||
//uploadProfileApi(AppSettings.updatedImage);
|
||||
AppSettings.saveProfile(image.path);
|
||||
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Widget _dashBoard() {
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
getConnectedSuppliersData();
|
||||
super.initState();
|
||||
}
|
||||
return Container(
|
||||
color: screenBackgroundColor,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height * .330,
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(0),
|
||||
),
|
||||
//color: Colors.red,
|
||||
child: FittedBox(
|
||||
child:Image(
|
||||
image: const AssetImage('images/appbgsuplier.png'),
|
||||
|
||||
),
|
||||
fit: BoxFit.fill,
|
||||
)
|
||||
),
|
||||
SizedBox(
|
||||
height: 5
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => DelivryBookingData()),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(05),
|
||||
margin: EdgeInsets.only(left:15, top:10, right: 0, bottom:0),
|
||||
//height: MediaQuery.of(context).size.height * .05,
|
||||
//width: MediaQuery.of(context).size.width * .45,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
// Change button text when light changes state.
|
||||
|
||||
Widget connectedTankers(){
|
||||
if (connectedSuppliersList.length != 0) {
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.all(8),
|
||||
itemCount: connectedSuppliersList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
// width: MediaQuery.of(context).size.width * .75,
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text('TankerName :',
|
||||
style: labelTextStyle()),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Text(
|
||||
connectedSuppliersList[index]
|
||||
.tankerName
|
||||
.toUpperCase(),
|
||||
style: valuesTextStyle()),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text('Bookingid :',
|
||||
style: labelTextStyle()),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Text(
|
||||
connectedSuppliersList [index]
|
||||
.bookingid
|
||||
.toString(),
|
||||
style: valuesTextStyle()),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text('SupplierId :',
|
||||
style: labelTextStyle()),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Text(connectedSuppliersList[index].supplierId,
|
||||
style: valuesTextStyle()),
|
||||
],
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.fromLTRB(35, 10,0,0),
|
||||
child: new SvgPicture.asset("assets/images/tanklevels.svg")
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text('DateOfOrder :',
|
||||
style: labelTextStyle()),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Text(connectedSuppliersList[index].dateOfOrder,
|
||||
style: valuesTextStyle()),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text('Typeofwater :',
|
||||
style: labelTextStyle()),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Text(connectedSuppliersList[index].typeofwater,
|
||||
style: valuesTextStyle()),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
IconButton(
|
||||
iconSize: 30,
|
||||
icon: const Icon(
|
||||
Icons.phone,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
final Uri _phoneUri = Uri(
|
||||
scheme: "tel",
|
||||
path: connectedSuppliersList[index]
|
||||
.delivery_agent_mobile);
|
||||
try {
|
||||
await launch(
|
||||
_phoneUri.toString());
|
||||
} catch (error) {
|
||||
throw ("Cannot dial");
|
||||
}
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'Call now',
|
||||
style: iconBelowTextStyle(),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 30,
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
IconButton(
|
||||
iconSize: 30,
|
||||
icon: const Icon(
|
||||
Icons.start,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
/* showTankerBookingDialog(
|
||||
tankersList[index]);*/
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'Start Trip',
|
||||
style: iconBelowTextStyle(),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 30,
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
IconButton(
|
||||
iconSize: 30,
|
||||
icon: const Icon(
|
||||
Icons.download,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
|
||||
/* Navigator.push(
|
||||
context,
|
||||
new MaterialPageRoute(
|
||||
builder: (__) => new BookedTanerDetails(myObject:tankersList[index].tanker_name)));*/
|
||||
|
||||
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'Download Water',
|
||||
style: iconBelowTextStyle(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
],
|
||||
)
|
||||
Text('Booking Data',style: dashboardTextStyle(),),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
/* Expanded(
|
||||
child:TextButton(
|
||||
child: const Text(
|
||||
'Connect',
|
||||
style: TextStyle(fontSize: 15,
|
||||
decoration: TextDecoration.underline,color: primaryColor),
|
||||
),
|
||||
onPressed: () {
|
||||
},
|
||||
)),*/
|
||||
/* Expanded(
|
||||
child: IconButton(
|
||||
)),
|
||||
|
||||
],
|
||||
),
|
||||
|
||||
//==============================list2
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
showLogoutAlertDialog(context){
|
||||
return showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return AlertDialog(
|
||||
title: const Text('Do you really want to logout?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('No',style:textButtonStyle()),
|
||||
onPressed: () {
|
||||
//showTankerUpdateDialog(tankersList[index]);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
icon: Icon(Icons.edit),
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Expanded(
|
||||
child: IconButton(
|
||||
onPressed: () async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) =>
|
||||
AlertDialog(
|
||||
title: const Text(
|
||||
'Do you want to delete Tanker?',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontSize: 20,
|
||||
)),
|
||||
actionsAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
bool deletePipelineStatus =
|
||||
await AppSettings.deleteTanker(
|
||||
tankersList[index]
|
||||
.tanker_name);
|
||||
|
||||
if (deletePipelineStatus) {
|
||||
getTankers();
|
||||
AppSettings.longSuccessToast(
|
||||
'Tanker deleted successfully');
|
||||
Navigator.of(context).pop(true);
|
||||
} else {
|
||||
AppSettings.longFailedToast(
|
||||
'Tanker deletion failed');
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
},
|
||||
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,
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
TextButton(
|
||||
child: Text('Yes',style:textButtonStyle()),
|
||||
onPressed: () async{
|
||||
await AppSettings.clearSharedPreferences();
|
||||
await Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => Login()),(Route<dynamic> route) => false,);
|
||||
|
||||
},
|
||||
icon: Icon(Icons.delete),
|
||||
color: primaryColor,
|
||||
),
|
||||
)*/
|
||||
],
|
||||
]
|
||||
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
if(_selectedIndex==0){
|
||||
final shouldPop = await showDialog<bool>(context: context, builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Do you want to exit app?',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontSize: 20,
|
||||
)),
|
||||
actionsAlignment: MainAxisAlignment.spaceBetween,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
SystemNavigator.pop();
|
||||
},
|
||||
child: const Text('Yes',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontSize: 20,
|
||||
)),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(false);
|
||||
},
|
||||
child: const Text('No',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontSize: 20,
|
||||
)),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
return shouldPop!;
|
||||
}
|
||||
else{
|
||||
setState(() {
|
||||
_selectedIndex=0;
|
||||
});
|
||||
}
|
||||
else {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
|
||||
child: isSereverIssueConnected
|
||||
? Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image(
|
||||
image: AssetImage('images/serverissue.png'),
|
||||
// height: MediaQuery.of(context).size.height * .10,
|
||||
return false;
|
||||
}
|
||||
|
||||
},
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar:AppSettings.appBar('Arminta Water Management'),
|
||||
drawer: Drawer(
|
||||
// Add a ListView to the drawer. This ensures the user can scroll
|
||||
// through the options in the drawer if there isn't enough vertical
|
||||
// space to fit everything.
|
||||
//backgroundColor: screenBackgroundColor,
|
||||
child: ListView(
|
||||
// Important: Remove any padding from the ListView.
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
DrawerHeader(
|
||||
decoration: const BoxDecoration(
|
||||
color: primaryColor,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
|
||||
Expanded(child: GestureDetector(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width * .20,
|
||||
height: MediaQuery.of(context).size.height * .15,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
image: DecorationImage(
|
||||
image: (AppSettings.updatedImage != null) ? FileImage(AppSettings.updatedImage!) as ImageProvider : AssetImage("images/profile_pic.png"), // picked file
|
||||
fit: BoxFit.cover)),
|
||||
),
|
||||
onTap: () {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.camera_alt_outlined,
|
||||
size: 100,
|
||||
color: greyColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await takeImageFromCamera();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width:
|
||||
MediaQuery.of(context).size.width * .20,
|
||||
),
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.photo,
|
||||
size: 100,
|
||||
color: greyColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await pickImageFromGallery();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
),),
|
||||
|
||||
Text(
|
||||
AppSettings.deliveryBoyname,
|
||||
style: TextStyle(color: Colors.white, fontSize: 15),
|
||||
),
|
||||
Text(
|
||||
AppSettings.phoneNumber,
|
||||
style: TextStyle(color: Colors.white, fontSize: 15),
|
||||
),
|
||||
/* Text(
|
||||
AppSettings.email,
|
||||
style: TextStyle(color: Colors.white, fontSize: 15),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
Container()
|
||||
],
|
||||
)),
|
||||
|
||||
ListTile(
|
||||
title: Row(
|
||||
children: const [
|
||||
|
||||
Image(image: const AssetImage('images/editprofileblue.png'),height: 25,width: 25,fit: BoxFit.fill),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text('Edit Profile',style: TextStyle(color:primaryColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
onTap: () {
|
||||
|
||||
/* Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => UpdateProfile()),
|
||||
);*/
|
||||
|
||||
},
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
),
|
||||
// Add Tanks
|
||||
ListTile(
|
||||
title: Row(
|
||||
children: const [
|
||||
Image(image: const AssetImage('images/connectionsblue.png'),height: 25,width: 25,fit: BoxFit.fill),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text('Booking Data',style: TextStyle(color:primaryColor)),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'There is an issue at server please try after some time',style:serverIssueTextStyle() ,),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image(
|
||||
image: AssetImage('images/no_data.png'),
|
||||
// height: MediaQuery.of(context).size.height * .10,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => DelivryBookingData()),
|
||||
);
|
||||
},
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
),
|
||||
ListTile(
|
||||
title: Row(
|
||||
children: const [
|
||||
Image(image: const AssetImage('images/customercareblue.png'),height: 25,width: 25,fit: BoxFit.fill),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text('Customer Support', style: TextStyle(color:primaryColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
onTap: () {},
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
),
|
||||
ListTile(
|
||||
title: Row(
|
||||
children: const [
|
||||
Image(image: const AssetImage('images/logoutblue.png'),height: 25,width: 25,fit: BoxFit.fill),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text('Logout', style: TextStyle(color:primaryColor)),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'No Connected Tankers',style:serverIssueTextStyle() ,),
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
onTap: () async{
|
||||
|
||||
|
||||
showLogoutAlertDialog(context);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppSettings.appBar('Deliveryboy'),
|
||||
body: isLoading?Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: primaryColor,
|
||||
strokeWidth: 5.0,
|
||||
),
|
||||
):connectedTankers(),
|
||||
));
|
||||
}
|
||||
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: _dashBoard(),
|
||||
/*body: IndexedStack(
|
||||
index: _selectedIndex,
|
||||
children: screens,
|
||||
),*/
|
||||
/* bottomNavigationBar: Container(
|
||||
//height: MediaQuery.of(context).size.height,
|
||||
child: BottomNavigationBar(
|
||||
items: const <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(
|
||||
Icons.home,
|
||||
),
|
||||
label: 'Home',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.propane_tank),
|
||||
label: 'Add Tanks',
|
||||
),
|
||||
*//*BottomNavigationBarItem(
|
||||
icon: Icon(Icons.private_connectivity_outlined),
|
||||
label: 'CreateConnections',
|
||||
),*//*
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.list_alt),
|
||||
label: 'Add Tanker',
|
||||
),
|
||||
],
|
||||
currentIndex: _selectedIndex,
|
||||
selectedItemColor: primaryColor,
|
||||
unselectedItemColor: greyColor,
|
||||
showUnselectedLabels: true,
|
||||
onTap: _onItemTapped,
|
||||
),
|
||||
),*/
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,366 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
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:flutter/services.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:watermanagement/model/getdeliveryboy_model.dart';
|
||||
import 'package:watermanagement/settings.dart';
|
||||
|
||||
|
||||
class DelivryBookingData extends StatefulWidget {
|
||||
const DelivryBookingData({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<DelivryBookingData> createState() => _DelivryBookingDataState();
|
||||
}
|
||||
|
||||
class _DelivryBookingDataState extends State<DelivryBookingData> with TickerProviderStateMixin {
|
||||
bool isSupplierDataLoading=false;
|
||||
bool isSereverIssue = false;
|
||||
bool isSereverIssueConnected = false;
|
||||
bool isSereverIssuePending = false;
|
||||
|
||||
List<GetDeliveryboyDetailsModel> connectedSuppliersList = [];
|
||||
bool isLoading=false;
|
||||
|
||||
Future<void> getConnectedSuppliersData() async {
|
||||
isLoading = true;
|
||||
try {
|
||||
var response = await AppSettings.getdeliveryboybookings();
|
||||
setState(() {
|
||||
connectedSuppliersList =
|
||||
((jsonDecode(response)['data']) as List).map((dynamic model) {
|
||||
return GetDeliveryboyDetailsModel.fromJson(model);
|
||||
}).toList();
|
||||
isLoading = false;
|
||||
});
|
||||
|
||||
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
isSereverIssueConnected = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
getConnectedSuppliersData();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Widget connectedTankers(){
|
||||
if (connectedSuppliersList.length != 0) {
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.all(8),
|
||||
itemCount: connectedSuppliersList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
// width: MediaQuery.of(context).size.width * .75,
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text('TankerName :',
|
||||
style: labelTextStyle()),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Text(
|
||||
connectedSuppliersList[index]
|
||||
.tankerName
|
||||
.toUpperCase(),
|
||||
style: valuesTextStyle()),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text('Bookingid :',
|
||||
style: labelTextStyle()),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Text(
|
||||
connectedSuppliersList [index]
|
||||
.bookingid
|
||||
.toString(),
|
||||
style: valuesTextStyle()),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text('SupplierId :',
|
||||
style: labelTextStyle()),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Text(connectedSuppliersList[index].supplierId,
|
||||
style: valuesTextStyle()),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text('DateOfOrder :',
|
||||
style: labelTextStyle()),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Text(connectedSuppliersList[index].dateOfOrder,
|
||||
style: valuesTextStyle()),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text('Typeofwater :',
|
||||
style: labelTextStyle()),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Text(connectedSuppliersList[index].typeofwater,
|
||||
style: valuesTextStyle()),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
IconButton(
|
||||
iconSize: 30,
|
||||
icon: const Icon(
|
||||
Icons.phone,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
final Uri _phoneUri = Uri(
|
||||
scheme: "tel",
|
||||
path: connectedSuppliersList[index]
|
||||
.delivery_agent_mobile);
|
||||
try {
|
||||
await launch(
|
||||
_phoneUri.toString());
|
||||
} catch (error) {
|
||||
throw ("Cannot dial");
|
||||
}
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'Call now',
|
||||
style: iconBelowTextStyle(),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 30,
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
IconButton(
|
||||
iconSize: 30,
|
||||
icon: const Icon(
|
||||
Icons.start,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
/* showTankerBookingDialog(
|
||||
tankersList[index]);*/
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'Start Trip',
|
||||
style: iconBelowTextStyle(),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 30,
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
IconButton(
|
||||
iconSize: 30,
|
||||
icon: const Icon(
|
||||
Icons.download,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
|
||||
/* Navigator.push(
|
||||
context,
|
||||
new MaterialPageRoute(
|
||||
builder: (__) => new BookedTanerDetails(myObject:tankersList[index].tanker_name)));*/
|
||||
|
||||
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'Download Water',
|
||||
style: iconBelowTextStyle(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
],
|
||||
)
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
/* Expanded(
|
||||
child:TextButton(
|
||||
child: const Text(
|
||||
'Connect',
|
||||
style: TextStyle(fontSize: 15,
|
||||
decoration: TextDecoration.underline,color: primaryColor),
|
||||
),
|
||||
onPressed: () {
|
||||
},
|
||||
)),*/
|
||||
/* Expanded(
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
//showTankerUpdateDialog(tankersList[index]);
|
||||
},
|
||||
icon: Icon(Icons.edit),
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Expanded(
|
||||
child: IconButton(
|
||||
onPressed: () async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) =>
|
||||
AlertDialog(
|
||||
title: const Text(
|
||||
'Do you want to delete Tanker?',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontSize: 20,
|
||||
)),
|
||||
actionsAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
bool deletePipelineStatus =
|
||||
await AppSettings.deleteTanker(
|
||||
tankersList[index]
|
||||
.tanker_name);
|
||||
|
||||
if (deletePipelineStatus) {
|
||||
getTankers();
|
||||
AppSettings.longSuccessToast(
|
||||
'Tanker deleted successfully');
|
||||
Navigator.of(context).pop(true);
|
||||
} else {
|
||||
AppSettings.longFailedToast(
|
||||
'Tanker deletion failed');
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
},
|
||||
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,
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: Icon(Icons.delete),
|
||||
color: primaryColor,
|
||||
),
|
||||
)*/
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
else {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
|
||||
child: isSereverIssueConnected
|
||||
? Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image(
|
||||
image: AssetImage('images/serverissue.png'),
|
||||
// height: MediaQuery.of(context).size.height * .10,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Text(
|
||||
'There is an issue at server please try after some time',style:serverIssueTextStyle() ,),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image(
|
||||
image: AssetImage('images/no_data.png'),
|
||||
// height: MediaQuery.of(context).size.height * .10,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Text(
|
||||
'No Connected Tankers',style:serverIssueTextStyle() ,),
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppSettings.appBar('Deliveryboy'),
|
||||
body: isLoading?Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: primaryColor,
|
||||
strokeWidth: 5.0,
|
||||
),
|
||||
):connectedTankers(),
|
||||
));
|
||||
}
|
||||
|
||||
}
|