Commit 2d144052 authored by Sai Srinivas's avatar Sai Srinivas
Browse files

13-05-2025 By Sai Srinivas

Attendance, JKS file
parent 479f7f07
File added
......@@ -384,7 +384,7 @@ class Generatordetailsprovider extends ChangeNotifier {
_genID = scanData.code;
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Generatordetails()),
MaterialPageRoute(builder: (context) => Generatordetails(generatorId: scanData.code,)),
);
} else if (from == "Register Complaint") {
_genID = scanData.code;
......@@ -420,7 +420,7 @@ class Generatordetailsprovider extends ChangeNotifier {
if (data != null) {
if (data.error == 0) {
_genID = genID;
_genID = data.genId;
_aname = data.aname;
_emodel = data.emodel;
_spname = data.spname;
......@@ -464,12 +464,11 @@ class Generatordetailsprovider extends ChangeNotifier {
_selectedDescription = "";
_selectedDescriptionId = "";
}
notifyListeners();
if (from == "Generator Details") {
this._qrViewController!.pauseCamera();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Generatordetails()),
MaterialPageRoute(builder: (context) => Generatordetails(generatorId: _genID,)),
);
} else if (from == "Register Complaint") {
this._qrViewController!.pauseCamera();
......@@ -479,7 +478,6 @@ class Generatordetailsprovider extends ChangeNotifier {
);
}
notifyListeners();
} else if (data.error == 1) {
toast(context, "Enter Correct ID");
} else {}
......@@ -491,6 +489,92 @@ class Generatordetailsprovider extends ChangeNotifier {
}
}
Future<void> LoadTechniciangeneratorDetailsApifunction(
homeProvider,
BuildContext context,
from,
genID,
) async {
try {
final data = await ApiCalling.LoadTechnicianGeneratorDetailsAPI(
homeProvider.empId,
homeProvider.session,
genID,
);
if (data != null) {
if (data.error == 0) {
_genID = genID;
_aname = data.aname;
_emodel = data.emodel;
_spname = data.spname;
_mob1 = data.mob1;
_mob2 = data.mob2;
_mail = data.mail;
_cname = data.cname;
_engineNo = data.engineNo;
_dateOfEngineSale = data.dateOfEngineSale;
_altNo = data.altNo;
_btryNo = data.btryNo;
_dgSetNo = data.dgSetNo;
_state = data.state;
_district = data.district;
_address = data.address;
_dispDate = data.dispDate;
_cmsngDate = data.cmsngDate;
_status = data.status;
_complaintTypeDropdown = data.complaintTypeList!;
_complaintCategorydropdown = data.complaintCategoryList!;
_complaintDescriptionDropdown = data.complaintDescriptionList!;
if (_selectedComplaintType != null &&
!_complaintTypeDropdown.contains(_selectedComplaintType)) {
_selectedComplaintType = null;
_selectedType = "";
_selectedTypeId = "";
}
if (_selectedCategoryType != null &&
!_complaintCategorydropdown.contains(_selectedCategoryType)) {
_selectedCategoryType = null;
_selectedCategory = "";
_selectedCategoryId = "";
}
if (_selectedDescriptionType != null &&
!_complaintDescriptionDropdown.contains(
_selectedDescriptionType,
)) {
_selectedDescriptionType = null;
_selectedDescription = "";
_selectedDescriptionId = "";
}
if (from == "Generator Details") {
this._qrViewController!.pauseCamera();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Generatordetails(generatorId: _genID,)),
);
} else if (from == "Register Complaint") {
this._qrViewController!.pauseCamera();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Registercomplaint()),
);
}
}
else if (data.error == 1) {
toast(context, "Enter Correct ID");
} else {}
notifyListeners();
}
} on Error catch (e) {
print(e.toString());
}
}
Future<void> LoadgeneratorComplaintHistoryApifunction(
homeProvider,
BuildContext context,
......
......@@ -43,7 +43,7 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
bool _isLoading = true;
String _selectedItem = 'Active';
double _currentValue = 1.0;
Timer? _debounceTimer;
List<Nearbygenerators> get generatorsList => _generatorslist;
......@@ -64,6 +64,19 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
String get selectedItem => _selectedItem;
double get currentValue => _currentValue;
set currentValue(value){
_currentValue = value;
notifyListeners();
}
set selectedItem(String value){
_selectedItem = value;
notifyListeners();
}
set markers(List<Marker> value){
_markers = value;
notifyListeners();
}
set mapController(value){
_mapController = value;
notifyListeners();
......@@ -120,9 +133,17 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
getLocationPermission(context);
});
}
void debounce(VoidCallback callback, Duration duration) {
_debounceTimer?.cancel();
_debounceTimer = Timer(duration, callback);
}
Future<void> LoadNearbyGeneratorsAPI(BuildContext context) async {
if (_latlongs.isEmpty || _currentValue <= 0) {
print("Invalid parameters: latlongs=$_latlongs, currentValue=$_currentValue");
return;
}
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.loadNearbyGeneratorsAPI(
......@@ -138,7 +159,7 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
if (data.error == 0) {
_generatorslist = data.list!;
updateMarkersFromApiResponse(context, data.list!);
await updateMarkersFromApiResponse(context, data.list!);
_isLoading = false;
notifyListeners();
} else {}
......@@ -162,16 +183,17 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
List<Nearbygenerators> generatorslist,
) async {
_markers = await createMarkersFromApiResponse(context, generatorslist);
_addresses.clear();
await Future.forEach(generatorslist, (store) async {
String address = await _getAddressFromLatLng(store.loc);
_addresses.add(address);
notifyListeners();
});
for (int i = 0; i < _addresses.length; i++) {
//print('List of Addresses:' "${addresses[i]}");
// print('List of Addresses:' "${addresses[1]}" );
}
notifyListeners();
// for (int i = 0; i < _addresses.length; i++) {
// //print('List of Addresses:' "${addresses[i]}");
// // print('List of Addresses:' "${addresses[1]}" );
// }
}
Future<List<Marker>> createMarkersFromApiResponse(
......@@ -217,9 +239,9 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
MaterialPageRoute(
builder:
(context) => Generatordetails(
// actName: "NearByGenerators",
// location: generator.loc,
// generatorId: generator.generatorId,
activityName: "NearByGenerators",
genLocation: generator.loc,
generatorId: generator.generatorId,
),
),
);
......@@ -273,171 +295,4 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
return "Address not found";
}
Future infoDialogue(BuildContext context) async {
return await showDialog(
context: context,
builder:
(context) => StatefulBuilder(
builder:
(context, setState) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
title: Column(
children: [
Row(
children: [
Expanded(
child: Align(
alignment: Alignment.topLeft,
child: Text(
'Filter',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
),
),
InkWell(
child: SvgPicture.asset(
"assets/ic_cancel.svg",
height: 35,
width: 35,
),
onTap: () {
setState(() {
_currentValue = 0.0;
_selectedItem = "Active";
});
Navigator.pop(context);
},
),
],
),
Divider(
color: Colors.grey,
thickness: 1.0,
height: 0.0,
),
],
),
content: Container(
height: 230,
child: Column(
children: [
Row(
children: [
Text(
"Radius",
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w500,
),
),
Spacer(),
Text(
'${_currentValue.toStringAsFixed(2)} KM',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w500,
),
),
],
),
Slider(
value: _currentValue,
max: 100,
divisions: 100,
label: _currentValue.toStringAsFixed(2),
inactiveColor: Colors.grey,
onChanged: (value) {
_currentValue = value;
notifyListeners();
},
),
Text(
'Status',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
Container(
width: 200, // Set the desired width here
child: DropdownButton<String>(
value: _selectedItem,
items:
<String>[
'Active',
'Inactive',
'Suspense',
].map<DropdownMenuItem<String>>((
String value,
) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
_selectedItem = newValue!;
});
},
icon: Icon(
CupertinoIcons.arrowtriangle_down_fill,
),
iconSize: 12,
iconEnabledColor:
Colors
.black, // Remove the default dropdown icon
),
),
SizedBox(height: 30.0),
Container(
child: InkWell(
onTap: () {
_markers = [];
LoadNearbyGeneratorsAPI(context);
Navigator.pop(context);
_currentValue = 0.0;
_selectedItem = "Active";
notifyListeners();
},
child: Container(
alignment: Alignment.center,
height: 45,
margin: EdgeInsets.only(
left: 15.0,
right: 15.0,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
),
child: Text(
"Search",
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Nexa',
fontWeight: FontWeight.w700,
),
),
),
),
),
],
),
),
),
),
barrierDismissible: true,
) ??
false;
}
}
......@@ -33,3 +33,37 @@ PreferredSizeWidget appbar(BuildContext context, title) {
),
);
}
PreferredSizeWidget appbar2(BuildContext context, title,widget) {
return AppBar(
automaticallyImplyLeading: false,
elevation: 2.0,
title: SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkResponse(
onTap: () => Navigator.pop(context, true),
child: SvgPicture.asset("assets/svg/app_bar_back.svg", height: 25),
),
Text(
title,
style: TextStyle(
fontSize: 16,
height: 1.1,
color: AppColors.semi_black,
),
),
Spacer(),
widget
],
),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30), // Adjust the radius as needed
),
),
);
}
......@@ -91,530 +91,546 @@ class _AttendanceScreenState extends State<AttendanceScreen> {
? '$currentMonthName $year'
: '$prevMonthName - $currentMonthName $year';
return Scaffold(
backgroundColor: AppColors.scaffold_bg_color,
appBar: appbar(context, "Attendance"),
body: Container(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(top: 15, bottom: 15),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(
left: 10,
right: 10,
top: 15,
),
child: Row(
children: [
Expanded(child: Text("Check-in")),
Expanded(child: Text("Check-out")),
],
return RefreshIndicator.adaptive(
color: AppColors.app_blue,
onRefresh: () async {
await Future.delayed(const Duration(milliseconds: 600));
attendance.getAttendanceList(homeProvider, context);
},
child: Scaffold(
backgroundColor: AppColors.scaffold_bg_color,
appBar: appbar(context, "Attendance"),
body: Container(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(top: 15, bottom: 15),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(
left: 10,
right: 10,
top: 15,
),
child: Row(
children: [
Expanded(child: Text("Check-in")),
Expanded(child: Text("Check-out")),
],
),
),
),
SizedBox(
child: Row(
children: [
Expanded(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
margin: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
decoration: BoxDecoration(
color: Color(0xFFFFEFEF),
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
children: [
TextSpan(
text: "$formattedTime",
style: TextStyle(
color: Color(0xFFED3424),
fontSize: 18,
SizedBox(
child: Row(
children: [
Expanded(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
margin: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
decoration: BoxDecoration(
color: Color(0xFFFFEFEF),
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
children: [
TextSpan(
text: formattedTime,
style: TextStyle(
color: Color(0xFFED3424),
fontSize: 18,
),
),
),
TextSpan(
text: "$period",
style: TextStyle(
color: Color(0xFFED3424),
TextSpan(
text: period,
style: TextStyle(
color: Color(0xFFED3424),
),
),
),
],
],
),
),
),
Text(
"${attendance.attendanceHistory.firstOrNull?['check_in_location']}",
),
],
Text(
"${attendance.attendanceHistory.firstOrNull?['check_in_location']}",
),
],
),
),
),
),
Expanded(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
margin: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
decoration: BoxDecoration(
color: Color(0xFFFFEFEF),
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
children: [
TextSpan(
text: "$formattedTime2",
style: TextStyle(
color: Color(0xFFED3424),
fontSize: 18,
Expanded(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
margin: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
decoration: BoxDecoration(
color: Color(0xFFFFEFEF),
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
children: [
TextSpan(
text: formattedTime2,
style: TextStyle(
color: Color(0xFFED3424),
fontSize: 18,
),
),
),
TextSpan(
text: "$period2",
style: TextStyle(
color: Color(0xFFED3424),
TextSpan(
text: period2,
style: TextStyle(
color: Color(0xFFED3424),
),
),
),
],
],
),
),
),
Text(
"${attendance.attendanceHistory.firstOrNull?['check_out_location']}",
),
],
Text(
"${attendance.attendanceHistory.firstOrNull?['check_out_location']}",
),
],
),
),
),
),
],
],
),
),
),
],
],
),
),
),
Text(
"Attendance Details",
style: TextStyle(color: Color(0xFF818181)),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
Text(
"Attendance Details",
style: TextStyle(color: Color(0xFF818181)),
),
child: GridView.builder(
itemCount: 4,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 20 / 10,
Container(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
itemBuilder: (context, index) {
final numbers = [
attendance.presentDays,
attendance.absentDays,
attendance.holidays,
attendance.latePenalties,
];
final names = [
"Present Days",
"Absent Days",
"Holidays",
"Late Points",
];
final colors = [
0xFFE7FFE5,
0xFFFFEFEF,
0xFFF3EDFF,
0xFFFFF6F0,
];
final textcolors = [
0xFF0D9C00,
0xFFFF0000,
0xFF493272,
0xFF91481B,
];
return Container(
padding: EdgeInsets.symmetric(horizontal: 13),
decoration: BoxDecoration(
color: Color(colors[index]),
borderRadius: BorderRadius.circular(12),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
numbers[index].toString(),
style: TextStyle(
fontSize: 30,
color: Color(textcolors[index]),
child: GridView.builder(
itemCount: 4,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 20 / 10,
),
itemBuilder: (context, index) {
final numbers = [
attendance.presentDays,
attendance.absentDays,
attendance.holidays,
attendance.latePenalties,
];
final names = [
"Present Days",
"Absent Days",
"Holidays",
"Late Points",
];
final colors = [
0xFFE7FFE5,
0xFFFFEFEF,
0xFFF3EDFF,
0xFFFFF6F0,
];
final textcolors = [
0xFF0D9C00,
0xFFFF0000,
0xFF493272,
0xFF91481B,
];
return Container(
padding: EdgeInsets.symmetric(horizontal: 13),
decoration: BoxDecoration(
color: Color(colors[index]),
borderRadius: BorderRadius.circular(12),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
numbers[index].toString(),
style: TextStyle(
fontSize: 30,
color: Color(textcolors[index]),
),
),
),
Text(
names[index],
style: TextStyle(color: Color(0xFF818181)),
),
],
),
);
},
Text(
names[index],
style: TextStyle(color: Color(0xFF818181)),
),
],
),
);
},
),
),
),
///calendar
Container(
// padding: EdgeInsets.symmetric(horizontal: 10,vertical: 5),
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
color: Colors.white,
),
child: Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(30, 10, 30, 0),
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
child: Row(
children: [
GestureDetector(
onTap: () {
attendance.setPreviousMonth(
homeProvider,
context,
);
},
child: const Icon(
Icons.arrow_back_ios,
color: Colors.black,
size: 30.0,
///calendar
Container(
// padding: EdgeInsets.symmetric(horizontal: 10,vertical: 5),
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
color: Colors.white,
),
child: Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(30, 10, 30, 0),
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
child: Row(
children: [
GestureDetector(
onTap: () {
attendance.setPreviousMonth(
homeProvider,
context,
);
},
child: Icon(
Icons.arrow_back_ios,
color: AppColors.semi_black,
size: 20.0,
),
),
),
Text(
monthLabel,
style: TextStyle(
fontWeight: FontWeight.w500,
overflow: TextOverflow.ellipsis,
color: Colors.black,
Text(
monthLabel,
style: TextStyle(
fontWeight: FontWeight.w500,
overflow: TextOverflow.ellipsis,
color: Colors.black,
),
),
),
GestureDetector(
onTap: () {
attendance.setNextMonth(
homeProvider,
context,
);
},
child: const Icon(
Icons.arrow_forward_ios,
color: Colors.black,
size: 30.0,
GestureDetector(
onTap: () {
attendance.setNextMonth(
homeProvider,
context,
);
},
child: Icon(
Icons.arrow_forward_ios,
color: AppColors.semi_black,
size: 20.0,
),
),
),
],
],
),
),
),
InkResponse(
onTap: () {
_showInfoBottomSheet(context);
},
child: SizedBox(
width: 25,
height: 25,
child: SvgPicture.asset(
"assets/svg/ic_info_new.svg",
width: 25,
height: 25,
InkResponse(
onTap: () {
_showInfoBottomSheet(context);
},
child: SizedBox(
width: 20,
height: 20,
child: SvgPicture.asset(
"assets/svg/ic_info_new.svg",
width: 20,
height: 20,
),
),
),
),
],
],
),
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(8, 10, 8, 0),
child: Container(
child: Row(
children: [
for (
var i = 0;
i <
[
'S',
'M',
'T',
'W',
'T',
'F',
'S',
].length;
i++
)
Expanded(
child: Text(
['S', 'M', 'T', 'W', 'T', 'F', 'S'][i],
textAlign: TextAlign.center,
style: TextStyle(
overflow: TextOverflow.ellipsis,
color:
i == 0
? Color(0xFFFF0000)
: AppColors.semi_black,
SizedBox(height: 5,),
Padding(
padding: const EdgeInsets.fromLTRB(8, 10, 8, 0),
child: Container(
child: Row(
children: [
for (
var i = 0;
i <
[
'S',
'M',
'T',
'W',
'T',
'F',
'S',
].length;
i++
)
Expanded(
child: Text(
['S', 'M', 'T', 'W', 'T', 'F', 'S'][i],
textAlign: TextAlign.center,
style: TextStyle(
overflow: TextOverflow.ellipsis,
color:
i == 0
? Color(0xFFFF0000)
: AppColors.semi_black,
),
),
),
),
],
],
),
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 10),
child: Container(
child: GridView.builder(
itemCount: daysInPeriod + startingIndex,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7,
crossAxisSpacing: 2,
mainAxisSpacing: 1,
childAspectRatio: (255 / 245),
),
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
if (index < startingIndex) {
return SizedBox.shrink();
}
final dayIndex = index - startingIndex;
final currentDateInPeriod = startDate.add(
Duration(days: dayIndex),
);
final currentDay = currentDateInPeriod.day;
final isFutureDate = currentDateInPeriod
.isAfter(currentDate);
// Find matching date in dateArrayList
Map<String, dynamic>? dateMap;
try {
dateMap = dateArrayList[dayIndex];
} catch (e) {
dateMap = {};
}
// Find matching penalty
Map<String, dynamic>? penaltyMap;
try {
penaltyMap = penalityArrayList[dayIndex];
} catch (e) {
penaltyMap = {};
}
String? dateColor =
dateMap.isNotEmpty
? dateMap.values.first
: null;
String? penaltyKey =
penaltyMap.isNotEmpty
? penaltyMap.keys.first
: null;
int? datePenalty =
penaltyMap.isNotEmpty
? penaltyMap.values.first
: 0;
// Determine if this is the current day
final isCurrentDay =
currentDateInPeriod.day ==
currentDate.day &&
currentDateInPeriod.month ==
currentDate.month &&
currentDateInPeriod.year ==
currentDate.year;
return InkWell(
onTap:
isFutureDate
? null
: () {
selectedIndex = index;
if (penaltyKey != null) {
attendance.dateWiseAttendance(
homeProvider,
penaltyKey,
context,
);
}
attendance.selectedDate =
currentDay.toString();
},
child: Card(
elevation: 0,
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(
datePenalty != 0
? "($datePenalty)"
: "",
style: TextStyle(
fontWeight: FontWeight.w400,
color: Colors.black,
),
),
],
),
Center(
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color:
isFutureDate
? Colors.transparent
: (isCurrentDay ||
(selectedIndex ==
index))
? Color(0xFFFFE8D0)
: dateColor == 'g'
? Color(0xFFE8FFE6)
: dateColor == 'r'
? Color(0xFFFFEFEF)
: dateColor == 'b'
? Color(0xFFF6F0FF)
: dateColor == 'br'
? Colors.brown
: dateColor == 'y'
? Color(0xFFFFF9B2)
: Colors.transparent,
),
child: Center(
child: Text(
currentDay.toString(),
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 10),
child: Container(
child: GridView.builder(
itemCount: daysInPeriod + startingIndex,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7,
crossAxisSpacing: 2,
mainAxisSpacing: 1,
childAspectRatio: (255 / 245),
),
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
if (index < startingIndex) {
return SizedBox.shrink();
}
final dayIndex = index - startingIndex;
final currentDateInPeriod = startDate.add(
Duration(days: dayIndex),
);
final currentDay = currentDateInPeriod.day;
final isFutureDate = currentDateInPeriod
.isAfter(currentDate);
// Find matching date in dateArrayList
Map<String, dynamic>? dateMap;
try {
dateMap = dateArrayList[dayIndex];
} catch (e) {
dateMap = {};
}
// Find matching penalty
Map<String, dynamic>? penaltyMap;
try {
penaltyMap = penalityArrayList[dayIndex];
} catch (e) {
penaltyMap = {};
}
String? dateColor =
dateMap.isNotEmpty
? dateMap.values.first
: null;
String? penaltyKey =
penaltyMap.isNotEmpty
? penaltyMap.keys.first
: null;
int? datePenalty =
penaltyMap.isNotEmpty
? penaltyMap.values.first
: 0;
// Determine if this is the current day
final isCurrentDay =
currentDateInPeriod.day ==
currentDate.day &&
currentDateInPeriod.month ==
currentDate.month &&
currentDateInPeriod.year ==
currentDate.year;
return InkWell(
onTap:
isFutureDate
? null
: () {
selectedIndex = index;
if (penaltyKey != null) {
attendance.dateWiseAttendance(
homeProvider,
penaltyKey,
context,
);
}
attendance.selectedDate =
currentDay.toString();
_showAttDetailsBottomSheet(context);
},
child: Card(
elevation: 0,
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(
datePenalty != 0
? "($datePenalty)"
: "",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color:
isFutureDate
? AppColors.semi_black
: (isCurrentDay ||
(selectedIndex ==
index))
? Color(0xFF493272)
: dateColor == 'g'
? Color(0xFF6B3A02)
: dateColor == 'r'
? Color(0xFFFF0000)
: dateColor == 'b'
? Color(0xFF493272)
: dateColor == 'br'
? Colors.brown
: dateColor == 'y'
? Color(0xFF605C00)
: Colors.transparent,
color: Colors.black,
),
),
],
),
Center(
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color:
isFutureDate
? Colors.transparent
: (isCurrentDay ||
(selectedIndex ==
index))
? Color(0xFFF6F0FF)
: dateColor == 'g'
? Color(0xFFE8FFE6)
: dateColor == 'r'
? Color(0xFFFFEFEF)
: dateColor == 'b'
? Color(0xFFFFE8D0)
: dateColor == 'br'
? Colors.brown
: dateColor == 'y'
? Color(0xFFFFF9B2)
: Colors.transparent,
),
child: Center(
child: Text(
currentDay.toString(),
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color:
isFutureDate
? AppColors.semi_black
: (isCurrentDay ||
(selectedIndex ==
index))
? Color(0xFF493272)
: dateColor == 'g'
? Color(0xFF6B3A02)
: dateColor == 'r'
? Color(0xFFFF0000)
: dateColor == 'b'
? Color(0xFF493272)
: dateColor == 'br'
? Colors.brown
: dateColor == 'y'
? Color(0xFF605C00)
: Colors.transparent,
),
),
),
),
),
),
],
],
),
),
),
);
},
);
},
),
),
),
),
],
],
),
),
),
SizedBox(height: 60),
],
SizedBox(height: 70),
],
),
),
),
),
floatingActionButton: Align(
alignment: Alignment.bottomCenter,
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder:
(context) => CheckInOutScreen(
getAttendanceStatus: attendance.attendanceStatus,
),
),
);
floatingActionButton:attendance.attendanceStatus==0||attendance.attendanceStatus==1? Align(
alignment: Alignment.bottomCenter,
child: InkWell(
onTap: () async {
var res = await Navigator.push(
context,
MaterialPageRoute(
builder:
(context) => CheckInOutScreen(
getAttendanceStatus: attendance.attendanceStatus,
),
),
);
if(res==true){
attendance.getAttendanceList(homeProvider, context);
}
var f = FocusScope.of(context);
if (!f.hasPrimaryFocus) {
f.unfocus();
}
},
child: Container(
alignment: Alignment.bottomCenter,
height: 45,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: AppColors.app_blue,
borderRadius: BorderRadius.circular(30.0),
),
child: Center(
child: Text(
attendance.attendanceStatus == 0 ? "Check In" : "Check Out",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
var f = FocusScope.of(context);
if (!f.hasPrimaryFocus) {
f.unfocus();
}
},
child: Container(
alignment: Alignment.bottomCenter,
height: 45,
margin: EdgeInsets.symmetric(horizontal: 10),
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: AppColors.app_blue,
borderRadius: BorderRadius.circular(30.0),
),
child: Center(
child: Text(
attendance.attendanceStatus == 0 ? "Check In" : "Check Out",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
),
),
),
),
),
):SizedBox(height: 0,),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
);
},
);
}
Future<void> _showInfoBottomSheet(BuildContext context) {
return showModalBottomSheet(
useSafeArea: true,
......@@ -637,74 +653,204 @@ class _AttendanceScreenState extends State<AttendanceScreen> {
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Indicators Info",
style: TextStyle(
color: AppColors.app_blue,
fontSize: 16,
),
),
SizedBox(height: 15),
GridView.builder(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 5 / 1,
),
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: 5,
itemBuilder: (context, index) {
final colors = [
0xFF493272,
0xFF0D9C00,
0xFFFF0000,
0xFF6B3A02,
0xFFFFEC1C,
];
final text = [
"Holiday",
"Present",
"Absent",
"Half Day",
"Not Checked Out",
];
return Row(
children: [
Container(
width: 13,
height: 13,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color(colors[index]),
),
),
SizedBox(width: 5),
Expanded(
child: Text(
text[index],
maxLines: 2,
style: TextStyle(
fontSize: 14,
color: Colors.black,
),
),
),
],
);
},
),
],
),
],
),
),
),
);
},
);
},
);
}
Future<void> _showAttDetailsBottomSheet(BuildContext context) {
return showModalBottomSheet(
useSafeArea: true,
isDismissible: true,
isScrollControlled: true,
showDragHandle: true,
enableDrag: true,
context: context,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return Consumer<AttendanceNotifier>(
builder: (context, provider, child) {
return SafeArea(
child: Container(
margin: EdgeInsets.only(
bottom: 15,
left: 15,
right: 15,
top: 15,
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
Row(
children: [
Text(
"Indicators Info",
style: TextStyle(
color: AppColors.app_blue,
fontSize: 16,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Attendance Info",
style: TextStyle(
color: AppColors.app_blue,
fontSize: 16,
),
),
Text(
provider.date,
style: TextStyle(
color: Color(0xFF818181),
fontSize: 12,
),
),
],
),
Spacer(),
Container(
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
decoration: BoxDecoration(
color: Color(0xFFFFF6F0),
borderRadius: BorderRadius.circular(12),
),
child: Row(
children: [
Text("Late Points "),
Text(
provider.penalties,
style: TextStyle(
color: Color(0xFF91481B),
),
),
],
),
),
SizedBox(height: 15,),
GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3,childAspectRatio: 5/1),
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: 5,
itemBuilder: (context, index) {
final colors = [
0xFF493272,
0xFF0D9C00,
0xFFFF0000,
0xFF6B3A02,
0xFFFFEC1C,
];
final text = ["Holiday",
"Present",
"Absent",
"Half Day",
"Not Checked Out"];
return Row(
children: [
Container(
width: 13,
height: 13,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color(colors[index]),
),
),
SizedBox(width: 5),
Expanded(
child: Text(
text[index],
maxLines:2,
style: TextStyle(
fontSize: 14,
color: Colors.black,
),
),
),
],
);
},)
],
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: Divider(
color: Color(0xFFD7D7D7),
thickness: 0.5,
),
),
SizedBox(height: 15),
...List.generate(4, (j) {
final values = [
"Check-in Time",
"Check-in Location",
"Check-out Time",
"Check-out Location",
];
final subvalues = [
(provider.intime),
(provider.inlocation),
(provider.outtime),
(provider.outlocation),
];
return SizedBox(
height: 35,
child: Row(
children: [
Expanded(
child: Text(
values[j],
style: TextStyle(
color: AppColors.semi_black,
),
),
),
Expanded(
child: Text(
subvalues[j],
style: TextStyle(color: Color(0xFF818181)),
),
),
],
),
);
}),
],
),
)
),
),
),
);
},
);
},
);
......
......@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:generp/Notifiers/Counter.dart';
import 'package:generp/Notifiers/HomeScreenNotifier.dart';
......@@ -45,245 +46,303 @@ class _MyHomePageState extends State<MyHomePage> {
});
super.initState();
}
Future<bool> onBackPressed() async {
return await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Are you sure?'),
content: const Text('Do you want to exit the App'),
actions: [
TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.white),
overlayColor: MaterialStateProperty.all(Colors.white),
),
onPressed: () => Navigator.of(context).pop(false),
child: Text(
"NO",
style: TextStyle(
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 16),
TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.white),
overlayColor: MaterialStateProperty.all(Colors.white70),
),
onPressed: () =>
SystemChannels.platform.invokeMethod('SystemNavigator.pop'),
child: Text(
"YES",
style: TextStyle(
fontWeight: FontWeight.w500,
),
),
),
],
elevation: 30.0,
),
barrierDismissible: false,
) ??
false;
}
@override
Widget build(BuildContext context) {
return Consumer2<HomescreenNotifier, ProfileNotifer>(
builder: (context, homescreen, profile, child) {
return Scaffold(
backgroundColor: AppColors.scaffold_bg_color,
body: Container(
child: Column(
children: [
Expanded(
flex: 3,
child: Container(
padding: EdgeInsets.symmetric(vertical: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30),
),
),
child: Container(
margin: EdgeInsets.only(
bottom: 15,
left: 15,
right: 15,
top: 30,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
gradient: LinearGradient(
colors: [AppColors.profile_card_gradient1, AppColors.profile_card_gradient2],
return WillPopScope(
onWillPop: onBackPressed,
child: RefreshIndicator.adaptive(
color: AppColors.app_blue,
onRefresh: () async {
await Future.delayed(const Duration(milliseconds: 600));
homescreen.DashboardApiFunction(context);
},
child: Scaffold(
backgroundColor: AppColors.scaffold_bg_color,
body: Container(
child: Column(
children: [
Expanded(
flex: 3,
child: Container(
padding: EdgeInsets.symmetric(vertical: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30),
),
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 2,
child: SizedBox(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width:66,
height: 66,
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child: CachedNetworkImage(
cacheKey: profile.profileImage,
fit: BoxFit.cover,
imageUrl: "${profile.profileImage}",
useOldImageOnUrlChange: false,
placeholder: (context, url) => CircularProgressIndicator.adaptive(
child: Container(
margin: EdgeInsets.only(
bottom: 15,
left: 15,
right: 15,
top: 30,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
gradient: LinearGradient(
colors: [AppColors.profile_card_gradient1, AppColors.profile_card_gradient2],
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 2,
child: SizedBox(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width:66,
height: 66,
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child: CachedNetworkImage(
cacheKey: profile.profileImage,
fit: BoxFit.cover,
imageUrl: "${profile.profileImage}",
useOldImageOnUrlChange: false,
placeholder: (context, url) => CircularProgressIndicator.adaptive(
),
errorWidget: (context, url, error) => Icon(Icons.error),
),
),
errorWidget: (context, url, error) => Icon(Icons.error),
),
),
),
Row(
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 10,
height: 10,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: homescreen.onlineStatus=="Online"?Colors.green:Colors.yellow,
),
),
SizedBox(width: 5),
Text(
"${homescreen.onlineStatus}",
style: TextStyle(
fontSize: 14,
color: Colors.black,
),
),
],
),
],
),
),
),
Expanded(
flex: 3,
child: SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 10,
height: 10,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: homescreen.onlineStatus=="Online"?Colors.green:Colors.yellow,
Text(
"${profile.employeeName}",
style: TextStyle(
color: AppColors.app_blue,
fontSize: 16,
),
),
SizedBox(width: 5),
Text(
"${homescreen.onlineStatus}",
"${profile.designation}",
style: TextStyle(
color: AppColors.semi_black,
fontSize: 14,
color: Colors.black,
),
),
],
),
],
),
),
),
Expanded(
flex: 3,
child: SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"${profile.employeeName}",
style: TextStyle(
color: AppColors.app_blue,
fontSize: 16,
),
),
Text(
"${profile.designation}",
style: TextStyle(
color: AppColors.semi_black,
fontSize: 14,
),
),
Text(
"${profile.employeeeID}",
style: TextStyle(
color: AppColors.semi_black,
fontSize: 14,
),
),
InkResponse(
onTap: () {
_showProfileBottomSheet(context);
},
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Text(
"View Profile",
style: TextStyle(
color: AppColors.app_blue,
fontSize: 16,
),
Text(
"${profile.employeeeID}",
style: TextStyle(
color: AppColors.semi_black,
fontSize: 14,
),
SizedBox(width: 5),
SizedBox(
width: 15,
height: 15,
child: Center(
child: SvgPicture.asset(
"assets/svg/next_button.svg",
),
InkResponse(
onTap: () {
_showProfileBottomSheet(context);
},
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Text(
"View Profile",
style: TextStyle(
color: AppColors.app_blue,
fontSize: 16,
),
),
),
SizedBox(width: 5),
SizedBox(
width: 15,
height: 15,
child: Center(
child: SvgPicture.asset(
"assets/svg/next_button.svg",
),
),
),
],
),
],
),
),
],
),
],
),
),
),
],
),
],
),
),
),
),
),
Expanded(
flex: 8,
child: Container(
padding: EdgeInsets.only(
left: 20,
right: 20,
top: 0,
bottom: 10,
),
child: GridView.builder(
itemCount: 8,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
),
itemBuilder: (context, index) {
var roles = homescreen.roleStatus;
final names = [
"Attendance",
"ERP",
"Gen Tracker",
"Service Engineer",
"Nearby",
"Inventory",
"Whizzdom",
"CRM",
];
return InkResponse(
onTap: () {
switch (names[index]) {
case "Attendance":
Navigator.push(context,MaterialPageRoute(builder: (context) => AttendanceScreen()));
break;
case "ERP":
Navigator.push(context,MaterialPageRoute(builder: (context) => WebErpScreen(erp_url: homescreen.webPageUrl)));
break;
case "Gen Tracker":
Navigator.push(context, MaterialPageRoute(builder: (context)=>Gentrackerdashboard()));
break;
case "Service Engineer":
Navigator.push(context, MaterialPageRoute(builder: (context)=>Serviceengineerdashboard()));
break;
case "Nearby":
// Navigator.push(context, MaterialPageRoute(builder: (context)=>NearByGeneratorsScreen()));
break;
case "Inventory":
Navigator.push(context, MaterialPageRoute(builder: (context)=>InventoryScreen()));
break;
case "Whizzdom":
Navigator.push(context, MaterialPageRoute(builder: (context)=>WebWhizzdomScreen(
whizzdom_url:
homescreen.whizzdomPageUrl
)));
break;
case "CRM":
// Navigator.push(context, MaterialPageRoute(builder: (context)=>CRMScreen()));
break;
default:
print("111");
break;
}
},
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(30),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
"assets/svg/home_icons_${index + 1}.svg",
),
Text(names[index]),
],
),
Expanded(
flex: 8,
child: Container(
padding: EdgeInsets.only(
left: 20,
right: 20,
top: 0,
bottom: 10,
),
child: GridView.builder(
itemCount: 8,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
),
);
},
itemBuilder: (context, index) {
var roles = homescreen.roleStatus;
final names = [
"Attendance",
"ERP",
"Gen Tracker",
"Service Engineer",
"Nearby",
"Inventory",
"Whizzdom",
"CRM",
];
return InkResponse(
onTap: () async {
var res;
switch (names[index]) {
case "Attendance":
res = await Navigator.push(context,MaterialPageRoute(builder: (context) => AttendanceScreen()));
break;
case "ERP":
res = await Navigator.push(context,MaterialPageRoute(builder: (context) => WebErpScreen(erp_url: homescreen.webPageUrl)));
break;
case "Gen Tracker":
res = await Navigator.push(context, MaterialPageRoute(builder: (context)=>Gentrackerdashboard()));
break;
case "Service Engineer":
res = await Navigator.push(context, MaterialPageRoute(builder: (context)=>Serviceengineerdashboard()));
break;
case "Nearby":
//res = await Navigator.push(context, MaterialPageRoute(builder: (context)=>NearByGeneratorsScreen()));
break;
case "Inventory":
res = await Navigator.push(context, MaterialPageRoute(builder: (context)=>InventoryScreen()));
break;
case "Whizzdom":
res = await Navigator.push(context, MaterialPageRoute(builder: (context)=>WebWhizzdomScreen(
whizzdom_url:
homescreen.whizzdomPageUrl
)));
break;
case "CRM":
//res = await Navigator.push(context, MaterialPageRoute(builder: (context)=>CRMScreen()));
break;
default:
print("111");
break;
}
if(res==true){
homescreen.DashboardApiFunction(context);
}
},
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(30),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
"assets/svg/home_icons_${index + 1}.svg",
),
Text(names[index]),
],
),
),
);
},
),
),
),
),
],
),
],
),
),
),
);
......
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:generp/Notifiers/GeneratorDetailsProvider.dart';
import 'package:generp/screens/genTracker/ComplaintHistory.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../Notifiers/HomeScreenNotifier.dart';
import '../../Utils/app_colors.dart';
import '../../Utils/commonWidgets.dart';
class Generatordetails extends StatefulWidget {
const Generatordetails({super.key});
final activityName;
final genLocation;
final generatorId;
const Generatordetails({
super.key,
this.activityName,
this.genLocation,
required this.generatorId,
});
@override
State<Generatordetails> createState() => _GeneratordetailsState();
......@@ -24,8 +37,25 @@ class _GeneratordetailsState extends State<Generatordetails> {
context,
listen: false,
);
var homeProvider = Provider.of<HomescreenNotifier>(context,listen: false);
details.LoadgeneratorDetailsApifunction(homeProvider,context, "",details.genID);
var homeProvider = Provider.of<HomescreenNotifier>(
context,
listen: false,
);
if (widget.activityName == "NearByGenerators") {
details.LoadTechniciangeneratorDetailsApifunction(
homeProvider,
context,
"",
widget.generatorId,
);
} else {
details.LoadgeneratorDetailsApifunction(
homeProvider,
context,
"",
details.genID,
);
}
});
}
......@@ -33,9 +63,37 @@ class _GeneratordetailsState extends State<Generatordetails> {
Widget build(BuildContext context) {
return Consumer<Generatordetailsprovider>(
builder: (context, provider, child) {
var sendwidget = Container(
padding: EdgeInsets.only(right: 10.0),
child: InkWell(
onTap: () async {
if (widget.genLocation != null) {
var loc = widget.genLocation?.split(",").toString();
var uri = Uri.parse(
"google.navigation:q=${loc![0]},${loc![1]}&mode=d",
);
if (Platform.isIOS) {
uri = Uri.parse(
"maps://?q=${loc![0]},${loc![1]}&z=10&daddr=${loc![0]},${loc![1]}&dirflg=d",
);
}
if (await canLaunch(uri.toString())) {
await launch(uri.toString());
} else {
throw 'Could not launch ${uri.toString()}';
}
// val intent = Intent(Intent.ACTION_VIEW, Uri.parse(uri))
}
},
child: Icon(Icons.directions),
),
);
return Scaffold(
appBar: appbar(context, "Visit Details"),
appBar:
widget.activityName == "NearByGenerators"
? appbar2(context, "Generator Details", sendwidget)
: appbar(context, "Generator Details"),
backgroundColor: AppColors.scaffold_bg_color,
body: Container(
child: SingleChildScrollView(
......@@ -80,7 +138,7 @@ class _GeneratordetailsState extends State<Generatordetails> {
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
MainAxisAlignment.spaceBetween,
children: [
if (j == 0) ...[
SvgPicture.asset(
......@@ -90,21 +148,29 @@ class _GeneratordetailsState extends State<Generatordetails> {
],
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: [
Text(textheads[j].toString()),
SizedBox(
// height:45,
width:
MediaQuery.of(
context,
).size.width *
0.75,
child: Text(textheads[j].toString(),maxLines: 2,
overflow: TextOverflow.ellipsis,),
),
SizedBox(
// height:45,
width:
MediaQuery.of(
context,
).size.width *
0.75,
child: Text(
textSubheads[j],
maxLines: 2,
overflow:
TextOverflow.ellipsis,
TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF818181),
),
......@@ -164,7 +230,7 @@ class _GeneratordetailsState extends State<Generatordetails> {
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
MainAxisAlignment.spaceBetween,
children: [
Container(
padding: EdgeInsets.symmetric(
......@@ -173,21 +239,21 @@ class _GeneratordetailsState extends State<Generatordetails> {
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: [
Text(textheads[j].toString()),
SizedBox(
// height:45,
width:
MediaQuery.of(
context,
).size.width *
MediaQuery.of(
context,
).size.width *
0.8,
child: Text(
textSubheads[j],
maxLines: 2,
overflow:
TextOverflow.ellipsis,
TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF818181),
),
......@@ -209,7 +275,6 @@ class _GeneratordetailsState extends State<Generatordetails> {
),
),
SizedBox(height: 75),
],
),
......@@ -219,8 +284,10 @@ class _GeneratordetailsState extends State<Generatordetails> {
alignment: Alignment.bottomCenter,
child: InkWell(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => Complainthistory(),));
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Complainthistory()),
);
},
child: Container(
alignment: Alignment.bottomCenter,
......@@ -242,7 +309,7 @@ class _GeneratordetailsState extends State<Generatordetails> {
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
FloatingActionButtonLocation.centerFloat,
);
},
);
......
......@@ -23,28 +23,203 @@ class _NearbygeneratorsState extends State<Nearbygenerators> {
},);
}
Future infoDialogue(BuildContext context) async {
return await showDialog(
context: context,
builder:
(context) => Consumer<Nearbygeneratorsprovider>(
builder: (context,provider,child) {
return StatefulBuilder(
builder:
(context, setState) =>
AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
title: Column(
children: [
Row(
children: [
Expanded(
child: Align(
alignment: Alignment.topLeft,
child: Text(
'Filter',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
),
),
InkWell(
child: Icon(Icons.close),
onTap: () {
setState(() {
provider.currentValue = 0.0;
provider.selectedItem = "Active";
});
Navigator.pop(context);
},
),
],
),
Divider(
color: Colors.grey,
thickness: 1.0,
height: 0.0,
),
],
),
content: Container(
height: 230,
child: Column(
children: [
Row(
children: [
Text(
"Radius",
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w500,
),
),
Spacer(),
Text(
'${provider.currentValue.toStringAsFixed(2)} KM',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w500,
),
),
],
),
Slider(
value: provider.currentValue,
max: 100,
divisions: 100,
label: provider.currentValue.toStringAsFixed(2),
inactiveColor: Colors.grey,
onChanged: (value) {
provider.currentValue = value;
provider.debounce(() {
provider.LoadNearbyGeneratorsAPI(context);
}, Duration(milliseconds: 500));
},
),
Text(
'Status',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
Container(
width: 200, // Set the desired width here
child: DropdownButton<String>(
value: provider.selectedItem,
items:
<String>[
'Active',
'Inactive',
'Suspense',
].map<DropdownMenuItem<String>>((String value,) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
provider.selectedItem = newValue!;
});
},
icon: Icon(
Icons.keyboard_arrow_down,
),
iconSize: 12,
iconEnabledColor:
Colors
.black, // Remove the default dropdown icon
),
),
SizedBox(height: 30.0),
Container(
child: InkWell(
onTap: () {
provider.debounce(() {
provider.LoadNearbyGeneratorsAPI(context);
Navigator.pop(context);
}, Duration(milliseconds: 500));
},
child: Container(
alignment: Alignment.center,
height: 45,
margin: EdgeInsets.only(
left: 15.0,
right: 15.0,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
),
child: Text(
"Search",
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Nexa',
fontWeight: FontWeight.w700,
),
),
),
),
),
],
),
),
),
);
}),
barrierDismissible: true,
) ??
false;
}
@override
Widget build(BuildContext context) {
debugPrint("Nearbygenerators widget rebuilt");
return Consumer<Nearbygeneratorsprovider>(builder: (context, provider, child) {
var sendWidget = GestureDetector(
onTap: () {
infoDialogue(context);
},
child: InkWell(
child: Icon(Icons.filter_alt_outlined),
));
return Scaffold(
appBar: appbar(context, "Nearby Generators"),
appBar: appbar2(context, "Nearby Generators",sendWidget),
backgroundColor: AppColors.scaffold_bg_color,
body: Container(
child: SingleChildScrollView(
child:Column(
children: [
Expanded(
child: ClipRRect(
// Apply border radius using ClipRRect
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0),
topRight: Radius.circular(30.0),
),
// padding: EdgeInsets.fromLTRB(10, 20, 10, 20),
ClipRRect(
// Apply border radius using ClipRRect
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0),
topRight: Radius.circular(30.0),
),
// padding: EdgeInsets.fromLTRB(10, 20, 10, 20),
child: Container(
height: MediaQuery.of(context).size.height,
child: Stack(children: [
GoogleMap(
myLocationEnabled: true,
zoomGesturesEnabled: true,
initialCameraPosition: CameraPosition(
target: provider.startLocation,
zoom: 14.0,
......
......@@ -4,6 +4,7 @@ import 'package:generp/Notifiers/ServiceEngineerDashboardProvider.dart';
import 'package:generp/Utils/app_colors.dart';
import 'package:generp/Utils/commonWidgets.dart';
import 'package:generp/screens/serviceEngineer/MonthlyCollection.dart';
import 'package:generp/screens/serviceEngineer/NearbyGenerators.dart';
import 'package:generp/screens/serviceEngineer/PCWallet.dart';
import 'package:generp/screens/serviceEngineer/PendingComplaints.dart';
import 'package:generp/screens/serviceEngineer/TodayMontlyVisists.dart';
......@@ -261,27 +262,32 @@ class _ServiceengineerdashboardState extends State<Serviceengineerdashboard> {
},
),
),
Container(
height: 60,
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
InkResponse(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => Nearbygenerators(),));
},
child: Container(
height: 60,
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
child: Row(
children: [
Expanded(
flex: 1,
child: SvgPicture.asset(
"assets/svg/find_generator.svg",
child: Row(
children: [
Expanded(
flex: 1,
child: SvgPicture.asset(
"assets/svg/find_generator.svg",
),
),
),
Expanded(
flex: 4,
child: Text("Find Nearby Generators"),
),
],
Expanded(
flex: 4,
child: Text("Find Nearby Generators"),
),
],
),
),
),
],
......
......@@ -691,6 +691,7 @@ class ApiCalling {
};
final res = await post(data, technicianNearbyGeneratorsUrl, {});
if (res != null) {
print(data);
debugPrint(res.body);
return NearbyGeneratorsResponse.fromJson(jsonDecode(res.body));
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment