You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
554 lines
18 KiB
554 lines
18 KiB
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:watermanagement/adddeliveryboy.dart';
|
|
import 'package:watermanagement/addtankers.dart';
|
|
import 'package:watermanagement/conected_customers.dart';
|
|
import 'package:watermanagement/getdeliveryboydata.dart';
|
|
import 'package:watermanagement/login.dart';
|
|
import 'package:watermanagement/place_picker.dart';
|
|
import 'package:watermanagement/request_customers.dart';
|
|
import 'package:watermanagement/settings.dart';
|
|
import 'package:image_picker/image_picker.dart';
|
|
import 'package:watermanagement/tankersview.dart';
|
|
import 'dart:io';
|
|
|
|
import 'package:watermanagement/updateprofile.dart';
|
|
|
|
import 'booking_requests.dart';
|
|
|
|
|
|
class Dashboard extends StatefulWidget {
|
|
const Dashboard({super.key});
|
|
|
|
@override
|
|
State<Dashboard> createState() => _DashboardState();
|
|
}
|
|
|
|
class _DashboardState extends State<Dashboard> {
|
|
int _selectedIndex = 0;
|
|
|
|
TextEditingController tankNameController = TextEditingController();
|
|
TextEditingController blockNameController = TextEditingController();
|
|
TextEditingController capacityController = TextEditingController();
|
|
|
|
|
|
static const TextStyle optionStyle =
|
|
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
|
|
|
|
|
|
final ImagePicker _picker = ImagePicker();
|
|
|
|
|
|
|
|
/*Future<void> uploadProfileApi(image) async {
|
|
|
|
var payload = new Map<String, dynamic>();
|
|
payload["picture"] = image.toString();
|
|
var response1= await AppSettings.updateProfilePicture(payload);
|
|
|
|
print(response1);
|
|
}*/
|
|
|
|
|
|
Future pickImageFromGallery() async {
|
|
try {
|
|
final image = await _picker.pickImage(source: ImageSource.gallery);
|
|
if (image == null) return;
|
|
final imageTemp = File(image.path);
|
|
setState(() {
|
|
AppSettings.updatedImage = imageTemp;
|
|
});
|
|
// uploadProfileApi(AppSettings.updatedImage);
|
|
AppSettings.saveProfile(image.path);
|
|
|
|
|
|
} on PlatformException catch (e) {
|
|
print('Failed to pick image: $e');
|
|
}
|
|
}
|
|
|
|
Future takeImageFromCamera() async {
|
|
try {
|
|
final image = await _picker.pickImage(source: ImageSource.camera);
|
|
if (image == null) return;
|
|
final imageTemp = File(image.path);
|
|
setState(() {
|
|
AppSettings.updatedImage = imageTemp;
|
|
});
|
|
|
|
//uploadProfileApi(AppSettings.updatedImage);
|
|
AppSettings.saveProfile(image.path);
|
|
|
|
} on PlatformException catch (e) {
|
|
print('Failed to pick image: $e');
|
|
}
|
|
}
|
|
|
|
Widget _dashBoard() {
|
|
|
|
|
|
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
|
|
),
|
|
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
|
|
|
|
|
|
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: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
TextButton(
|
|
child: Text('Yes',style:textButtonStyle()),
|
|
onPressed: () async{
|
|
await AppSettings.clearSharedPreferences();
|
|
await Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => Login()),(Route<dynamic> route) => false,);
|
|
|
|
},
|
|
),
|
|
]
|
|
|
|
);
|
|
});
|
|
}
|
|
);
|
|
}
|
|
|
|
|
|
|
|
@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;
|
|
});
|
|
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.suppliername,
|
|
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/ic_launcher.png'),height: 25,width: 25,fit: BoxFit.fill),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
Text('Edit Profile',style: TextStyle(color:primaryColor)),
|
|
],
|
|
),
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => UpdateProfile()),
|
|
);
|
|
|
|
},
|
|
),
|
|
Divider(
|
|
color: Colors.grey,
|
|
),
|
|
// Add Tanks
|
|
ListTile(
|
|
title: Row(
|
|
children: const [
|
|
Image(image: const AssetImage('images/ic_launcher.png'),height: 25,width: 25,fit: BoxFit.fill),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
Text('Add Tankers',style: TextStyle(color:primaryColor)),
|
|
],
|
|
),
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => AddTankers()),
|
|
);
|
|
},
|
|
),
|
|
Divider(
|
|
color: Colors.grey,
|
|
),
|
|
// Add Tanks
|
|
ListTile(
|
|
title: Row(
|
|
children: const [
|
|
Image(image: const AssetImage('images/ic_launcher.png'),height: 25,width: 25,fit: BoxFit.fill),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
Text('Add Deliveryboy',style: TextStyle(color:primaryColor)),
|
|
],
|
|
),
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => Deliverboy()),
|
|
);
|
|
},
|
|
),
|
|
Divider(
|
|
color: Colors.grey,
|
|
),
|
|
// Add Tanks
|
|
ListTile(
|
|
title: Row(
|
|
children: const [
|
|
Image(image: const AssetImage('images/ic_launcher.png'),height: 25,width: 25,fit: BoxFit.fill),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
Text('Deliveryboys View',style: TextStyle(color:primaryColor)),
|
|
],
|
|
),
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => GetDeliveryboyData()),
|
|
);
|
|
},
|
|
),
|
|
|
|
Divider(
|
|
color: Colors.grey,
|
|
),
|
|
// Add Tanks
|
|
ListTile(
|
|
title: Row(
|
|
children: const [
|
|
Image(image: const AssetImage('images/ic_launcher.png'),height: 25,width: 25,fit: BoxFit.fill),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
Text('Tankers View',style: TextStyle(color:primaryColor)),
|
|
],
|
|
),
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => TankersView()),
|
|
);
|
|
},
|
|
),
|
|
Divider(
|
|
color: Colors.grey,
|
|
),
|
|
ListTile(
|
|
title: Row(
|
|
children: const [
|
|
Image(image: const AssetImage('images/ic_launcher.png'),height: 25,width: 25,fit: BoxFit.fill),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
Text('Pending Customers', style: TextStyle(color:primaryColor)),
|
|
],
|
|
),
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => PendingCustomers()),
|
|
);
|
|
|
|
},
|
|
),
|
|
|
|
Divider(
|
|
color: Colors.grey,
|
|
),
|
|
ListTile(
|
|
title: Row(
|
|
children: const [
|
|
Image(image: const AssetImage('images/ic_launcher.png'),height: 25,width: 25,fit: BoxFit.fill),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
Text('Conected Customers', style: TextStyle(color:primaryColor)),
|
|
],
|
|
),
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => ConectedCustomers()),
|
|
);
|
|
|
|
},
|
|
),
|
|
|
|
Divider(
|
|
color: Colors.grey,
|
|
),
|
|
// Add Tanks
|
|
ListTile(
|
|
title: Row(
|
|
children: const [
|
|
Image(image: const AssetImage('images/ic_launcher.png'),height: 25,width: 25,fit: BoxFit.fill),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
Text('Booking Requests',style: TextStyle(color:primaryColor)),
|
|
],
|
|
),
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => BookingRequets()),
|
|
);
|
|
},
|
|
),
|
|
|
|
Divider(
|
|
color: Colors.grey,
|
|
),
|
|
ListTile(
|
|
title: Row(
|
|
children: const [
|
|
Image(image: const AssetImage('images/ic_launcher.png'),height: 25,width: 25,fit: BoxFit.fill),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
Text('Customer Support', style: TextStyle(color:primaryColor)),
|
|
],
|
|
),
|
|
onTap: () {},
|
|
),
|
|
Divider(
|
|
color: Colors.grey,
|
|
),
|
|
ListTile(
|
|
title: Row(
|
|
children: const [
|
|
Image(image: const AssetImage('images/ic_launcher.png'),height: 25,width: 25,fit: BoxFit.fill),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
Text('Logout', style: TextStyle(color:primaryColor)),
|
|
],
|
|
),
|
|
onTap: () async{
|
|
|
|
|
|
showLogoutAlertDialog(context);
|
|
|
|
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
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,
|
|
),
|
|
),*/
|
|
),
|
|
);
|
|
}
|
|
}
|