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 { ...@@ -384,7 +384,7 @@ class Generatordetailsprovider extends ChangeNotifier {
_genID = scanData.code; _genID = scanData.code;
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => Generatordetails()), MaterialPageRoute(builder: (context) => Generatordetails(generatorId: scanData.code,)),
); );
} else if (from == "Register Complaint") { } else if (from == "Register Complaint") {
_genID = scanData.code; _genID = scanData.code;
...@@ -420,7 +420,7 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -420,7 +420,7 @@ class Generatordetailsprovider extends ChangeNotifier {
if (data != null) { if (data != null) {
if (data.error == 0) { if (data.error == 0) {
_genID = genID; _genID = data.genId;
_aname = data.aname; _aname = data.aname;
_emodel = data.emodel; _emodel = data.emodel;
_spname = data.spname; _spname = data.spname;
...@@ -464,12 +464,11 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -464,12 +464,11 @@ class Generatordetailsprovider extends ChangeNotifier {
_selectedDescription = ""; _selectedDescription = "";
_selectedDescriptionId = ""; _selectedDescriptionId = "";
} }
notifyListeners();
if (from == "Generator Details") { if (from == "Generator Details") {
this._qrViewController!.pauseCamera(); this._qrViewController!.pauseCamera();
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => Generatordetails()), MaterialPageRoute(builder: (context) => Generatordetails(generatorId: _genID,)),
); );
} else if (from == "Register Complaint") { } else if (from == "Register Complaint") {
this._qrViewController!.pauseCamera(); this._qrViewController!.pauseCamera();
...@@ -479,7 +478,6 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -479,7 +478,6 @@ class Generatordetailsprovider extends ChangeNotifier {
); );
} }
notifyListeners();
} else if (data.error == 1) { } else if (data.error == 1) {
toast(context, "Enter Correct ID"); toast(context, "Enter Correct ID");
} else {} } else {}
...@@ -491,6 +489,92 @@ class Generatordetailsprovider extends ChangeNotifier { ...@@ -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( Future<void> LoadgeneratorComplaintHistoryApifunction(
homeProvider, homeProvider,
BuildContext context, BuildContext context,
......
...@@ -43,7 +43,7 @@ class Nearbygeneratorsprovider extends ChangeNotifier { ...@@ -43,7 +43,7 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
bool _isLoading = true; bool _isLoading = true;
String _selectedItem = 'Active'; String _selectedItem = 'Active';
double _currentValue = 1.0; double _currentValue = 1.0;
Timer? _debounceTimer;
List<Nearbygenerators> get generatorsList => _generatorslist; List<Nearbygenerators> get generatorsList => _generatorslist;
...@@ -64,6 +64,19 @@ class Nearbygeneratorsprovider extends ChangeNotifier { ...@@ -64,6 +64,19 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
String get selectedItem => _selectedItem; String get selectedItem => _selectedItem;
double get currentValue => _currentValue; 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){ set mapController(value){
_mapController = value; _mapController = value;
notifyListeners(); notifyListeners();
...@@ -120,9 +133,17 @@ class Nearbygeneratorsprovider extends ChangeNotifier { ...@@ -120,9 +133,17 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
getLocationPermission(context); getLocationPermission(context);
}); });
} }
void debounce(VoidCallback callback, Duration duration) {
_debounceTimer?.cancel();
_debounceTimer = Timer(duration, callback);
}
Future<void> LoadNearbyGeneratorsAPI(BuildContext context) async { Future<void> LoadNearbyGeneratorsAPI(BuildContext context) async {
if (_latlongs.isEmpty || _currentValue <= 0) {
print("Invalid parameters: latlongs=$_latlongs, currentValue=$_currentValue");
return;
}
try { try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false); var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.loadNearbyGeneratorsAPI( final data = await ApiCalling.loadNearbyGeneratorsAPI(
...@@ -138,7 +159,7 @@ class Nearbygeneratorsprovider extends ChangeNotifier { ...@@ -138,7 +159,7 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
if (data.error == 0) { if (data.error == 0) {
_generatorslist = data.list!; _generatorslist = data.list!;
updateMarkersFromApiResponse(context, data.list!); await updateMarkersFromApiResponse(context, data.list!);
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
} else {} } else {}
...@@ -162,16 +183,17 @@ class Nearbygeneratorsprovider extends ChangeNotifier { ...@@ -162,16 +183,17 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
List<Nearbygenerators> generatorslist, List<Nearbygenerators> generatorslist,
) async { ) async {
_markers = await createMarkersFromApiResponse(context, generatorslist); _markers = await createMarkersFromApiResponse(context, generatorslist);
_addresses.clear();
await Future.forEach(generatorslist, (store) async { await Future.forEach(generatorslist, (store) async {
String address = await _getAddressFromLatLng(store.loc); String address = await _getAddressFromLatLng(store.loc);
_addresses.add(address); _addresses.add(address);
notifyListeners();
}); });
for (int i = 0; i < _addresses.length; i++) { notifyListeners();
//print('List of Addresses:' "${addresses[i]}"); // for (int i = 0; i < _addresses.length; i++) {
// print('List of Addresses:' "${addresses[1]}" ); // //print('List of Addresses:' "${addresses[i]}");
} // // print('List of Addresses:' "${addresses[1]}" );
// }
} }
Future<List<Marker>> createMarkersFromApiResponse( Future<List<Marker>> createMarkersFromApiResponse(
...@@ -217,9 +239,9 @@ class Nearbygeneratorsprovider extends ChangeNotifier { ...@@ -217,9 +239,9 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
MaterialPageRoute( MaterialPageRoute(
builder: builder:
(context) => Generatordetails( (context) => Generatordetails(
// actName: "NearByGenerators", activityName: "NearByGenerators",
// location: generator.loc, genLocation: generator.loc,
// generatorId: generator.generatorId, generatorId: generator.generatorId,
), ),
), ),
); );
...@@ -273,171 +295,4 @@ class Nearbygeneratorsprovider extends ChangeNotifier { ...@@ -273,171 +295,4 @@ class Nearbygeneratorsprovider extends ChangeNotifier {
return "Address not found"; 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) { ...@@ -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> { ...@@ -91,530 +91,546 @@ class _AttendanceScreenState extends State<AttendanceScreen> {
? '$currentMonthName $year' ? '$currentMonthName $year'
: '$prevMonthName - $currentMonthName $year'; : '$prevMonthName - $currentMonthName $year';
return Scaffold( return RefreshIndicator.adaptive(
backgroundColor: AppColors.scaffold_bg_color, color: AppColors.app_blue,
appBar: appbar(context, "Attendance"),
body: Container( onRefresh: () async {
child: SingleChildScrollView( await Future.delayed(const Duration(milliseconds: 600));
child: Column( attendance.getAttendanceList(homeProvider, context);
crossAxisAlignment: CrossAxisAlignment.start,
children: [ },
Container( child: Scaffold(
margin: EdgeInsets.only(top: 15, bottom: 15), backgroundColor: AppColors.scaffold_bg_color,
decoration: BoxDecoration( appBar: appbar(context, "Attendance"),
color: Colors.white, body: Container(
borderRadius: BorderRadius.circular(16), child: SingleChildScrollView(
), child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ Container(
Container( margin: EdgeInsets.only(top: 15, bottom: 15),
padding: EdgeInsets.only( decoration: BoxDecoration(
left: 10, color: Colors.white,
right: 10, borderRadius: BorderRadius.circular(16),
top: 15, ),
), child: Column(
child: Row( crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded(child: Text("Check-in")), Container(
Expanded(child: Text("Check-out")), padding: EdgeInsets.only(
], left: 10,
right: 10,
top: 15,
),
child: Row(
children: [
Expanded(child: Text("Check-in")),
Expanded(child: Text("Check-out")),
],
),
), ),
), SizedBox(
SizedBox( child: Row(
child: Row( children: [
children: [ Expanded(
Expanded( child: Container(
child: Container( padding: EdgeInsets.symmetric(
padding: EdgeInsets.symmetric( horizontal: 10,
horizontal: 10, vertical: 15,
vertical: 15, ),
), margin: EdgeInsets.symmetric(
margin: EdgeInsets.symmetric( horizontal: 10,
horizontal: 10, vertical: 15,
vertical: 15, ),
), decoration: BoxDecoration(
decoration: BoxDecoration( color: Color(0xFFFFEFEF),
color: Color(0xFFFFEFEF), borderRadius: BorderRadius.circular(16),
borderRadius: BorderRadius.circular(16), ),
), child: Column(
child: Column( crossAxisAlignment:
crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start, children: [
children: [ RichText(
RichText( text: TextSpan(
text: TextSpan( children: [
children: [ TextSpan(
TextSpan( text: formattedTime,
text: "$formattedTime", style: TextStyle(
style: TextStyle( color: Color(0xFFED3424),
color: Color(0xFFED3424), fontSize: 18,
fontSize: 18, ),
), ),
), TextSpan(
TextSpan( text: period,
text: "$period", style: TextStyle(
style: TextStyle( color: Color(0xFFED3424),
color: Color(0xFFED3424), ),
), ),
), ],
], ),
), ),
), Text(
Text( "${attendance.attendanceHistory.firstOrNull?['check_in_location']}",
"${attendance.attendanceHistory.firstOrNull?['check_in_location']}", ),
), ],
], ),
), ),
), ),
), Expanded(
Expanded( child: Container(
child: Container( padding: EdgeInsets.symmetric(
padding: EdgeInsets.symmetric( horizontal: 10,
horizontal: 10, vertical: 15,
vertical: 15, ),
), margin: EdgeInsets.symmetric(
margin: EdgeInsets.symmetric( horizontal: 10,
horizontal: 10, vertical: 15,
vertical: 15, ),
), decoration: BoxDecoration(
decoration: BoxDecoration( color: Color(0xFFFFEFEF),
color: Color(0xFFFFEFEF), borderRadius: BorderRadius.circular(16),
borderRadius: BorderRadius.circular(16), ),
), child: Column(
child: Column( crossAxisAlignment:
crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start, children: [
children: [ RichText(
RichText( text: TextSpan(
text: TextSpan( children: [
children: [ TextSpan(
TextSpan( text: formattedTime2,
text: "$formattedTime2", style: TextStyle(
style: TextStyle( color: Color(0xFFED3424),
color: Color(0xFFED3424), fontSize: 18,
fontSize: 18, ),
), ),
), TextSpan(
TextSpan( text: period2,
text: "$period2", style: TextStyle(
style: TextStyle( color: Color(0xFFED3424),
color: Color(0xFFED3424), ),
), ),
), ],
], ),
), ),
), Text(
Text( "${attendance.attendanceHistory.firstOrNull?['check_out_location']}",
"${attendance.attendanceHistory.firstOrNull?['check_out_location']}", ),
), ],
], ),
), ),
), ),
), ],
], ),
), ),
), ],
], ),
), ),
), Text(
Text( "Attendance Details",
"Attendance Details", style: TextStyle(color: Color(0xFF818181)),
style: TextStyle(color: Color(0xFF818181)),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
), ),
child: GridView.builder( Container(
itemCount: 4, padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
shrinkWrap: true, decoration: BoxDecoration(
physics: NeverScrollableScrollPhysics(), color: Colors.white,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( borderRadius: BorderRadius.circular(16),
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 20 / 10,
), ),
itemBuilder: (context, index) { child: GridView.builder(
final numbers = [ itemCount: 4,
attendance.presentDays, shrinkWrap: true,
attendance.absentDays, physics: NeverScrollableScrollPhysics(),
attendance.holidays, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
attendance.latePenalties, crossAxisCount: 2,
]; crossAxisSpacing: 10,
final names = [ mainAxisSpacing: 10,
"Present Days", childAspectRatio: 20 / 10,
"Absent Days", ),
"Holidays", itemBuilder: (context, index) {
"Late Points", final numbers = [
]; attendance.presentDays,
final colors = [ attendance.absentDays,
0xFFE7FFE5, attendance.holidays,
0xFFFFEFEF, attendance.latePenalties,
0xFFF3EDFF, ];
0xFFFFF6F0, final names = [
]; "Present Days",
final textcolors = [ "Absent Days",
0xFF0D9C00, "Holidays",
0xFFFF0000, "Late Points",
0xFF493272, ];
0xFF91481B, final colors = [
]; 0xFFE7FFE5,
return Container( 0xFFFFEFEF,
padding: EdgeInsets.symmetric(horizontal: 13), 0xFFF3EDFF,
decoration: BoxDecoration( 0xFFFFF6F0,
color: Color(colors[index]), ];
borderRadius: BorderRadius.circular(12), final textcolors = [
), 0xFF0D9C00,
child: Column( 0xFFFF0000,
crossAxisAlignment: CrossAxisAlignment.start, 0xFF493272,
mainAxisAlignment: MainAxisAlignment.center, 0xFF91481B,
children: [ ];
Text( return Container(
numbers[index].toString(), padding: EdgeInsets.symmetric(horizontal: 13),
style: TextStyle( decoration: BoxDecoration(
fontSize: 30, color: Color(colors[index]),
color: Color(textcolors[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(
Text( names[index],
names[index], style: TextStyle(color: Color(0xFF818181)),
style: TextStyle(color: Color(0xFF818181)), ),
), ],
], ),
), );
); },
}, ),
), ),
),
///calendar ///calendar
Container( Container(
// padding: EdgeInsets.symmetric(horizontal: 10,vertical: 5), // padding: EdgeInsets.symmetric(horizontal: 10,vertical: 5),
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 5), margin: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
color: Colors.white, color: Colors.white,
), ),
child: Column( child: Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.fromLTRB(30, 10, 30, 0), padding: const EdgeInsets.fromLTRB(30, 10, 30, 0),
child: Container( child: Container(
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
SizedBox( SizedBox(
child: Row( child: Row(
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
attendance.setPreviousMonth( attendance.setPreviousMonth(
homeProvider, homeProvider,
context, context,
); );
}, },
child: const Icon( child: Icon(
Icons.arrow_back_ios, Icons.arrow_back_ios,
color: Colors.black, color: AppColors.semi_black,
size: 30.0, size: 20.0,
),
), ),
), Text(
Text( monthLabel,
monthLabel, style: TextStyle(
style: TextStyle( fontWeight: FontWeight.w500,
fontWeight: FontWeight.w500, overflow: TextOverflow.ellipsis,
overflow: TextOverflow.ellipsis, color: Colors.black,
color: Colors.black, ),
), ),
), GestureDetector(
GestureDetector( onTap: () {
onTap: () { attendance.setNextMonth(
attendance.setNextMonth( homeProvider,
homeProvider, context,
context, );
); },
}, child: Icon(
child: const Icon( Icons.arrow_forward_ios,
Icons.arrow_forward_ios, color: AppColors.semi_black,
color: Colors.black, size: 20.0,
size: 30.0, ),
), ),
), ],
], ),
), ),
),
InkResponse( InkResponse(
onTap: () { onTap: () {
_showInfoBottomSheet(context); _showInfoBottomSheet(context);
}, },
child: SizedBox( child: SizedBox(
width: 25, width: 20,
height: 25, height: 20,
child: SvgPicture.asset( child: SvgPicture.asset(
"assets/svg/ic_info_new.svg", "assets/svg/ic_info_new.svg",
width: 25, width: 20,
height: 25, height: 20,
),
), ),
), ),
), ],
], ),
), ),
), ),
), SizedBox(height: 5,),
Padding( Padding(
padding: const EdgeInsets.fromLTRB(8, 10, 8, 0), padding: const EdgeInsets.fromLTRB(8, 10, 8, 0),
child: Container( child: Container(
child: Row( child: Row(
children: [ children: [
for ( for (
var i = 0; var i = 0;
i < i <
[ [
'S', 'S',
'M', 'M',
'T', 'T',
'W', 'W',
'T', 'T',
'F', 'F',
'S', 'S',
].length; ].length;
i++ i++
) )
Expanded( Expanded(
child: Text( child: Text(
['S', 'M', 'T', 'W', 'T', 'F', 'S'][i], ['S', 'M', 'T', 'W', 'T', 'F', 'S'][i],
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
color: color:
i == 0 i == 0
? Color(0xFFFF0000) ? Color(0xFFFF0000)
: AppColors.semi_black, : AppColors.semi_black,
),
), ),
), ),
), ],
], ),
), ),
), ),
),
Padding( Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 10), padding: const EdgeInsets.fromLTRB(0, 0, 0, 10),
child: Container( child: Container(
child: GridView.builder( child: GridView.builder(
itemCount: daysInPeriod + startingIndex, itemCount: daysInPeriod + startingIndex,
gridDelegate: gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount( SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7, crossAxisCount: 7,
crossAxisSpacing: 2, crossAxisSpacing: 2,
mainAxisSpacing: 1, mainAxisSpacing: 1,
childAspectRatio: (255 / 245), childAspectRatio: (255 / 245),
), ),
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
shrinkWrap: true, shrinkWrap: true,
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (index < startingIndex) { if (index < startingIndex) {
return SizedBox.shrink(); return SizedBox.shrink();
} }
final dayIndex = index - startingIndex; final dayIndex = index - startingIndex;
final currentDateInPeriod = startDate.add( final currentDateInPeriod = startDate.add(
Duration(days: dayIndex), Duration(days: dayIndex),
); );
final currentDay = currentDateInPeriod.day; final currentDay = currentDateInPeriod.day;
final isFutureDate = currentDateInPeriod final isFutureDate = currentDateInPeriod
.isAfter(currentDate); .isAfter(currentDate);
// Find matching date in dateArrayList // Find matching date in dateArrayList
Map<String, dynamic>? dateMap; Map<String, dynamic>? dateMap;
try { try {
dateMap = dateArrayList[dayIndex]; dateMap = dateArrayList[dayIndex];
} catch (e) { } catch (e) {
dateMap = {}; dateMap = {};
} }
// Find matching penalty // Find matching penalty
Map<String, dynamic>? penaltyMap; Map<String, dynamic>? penaltyMap;
try { try {
penaltyMap = penalityArrayList[dayIndex]; penaltyMap = penalityArrayList[dayIndex];
} catch (e) { } catch (e) {
penaltyMap = {}; penaltyMap = {};
} }
String? dateColor = String? dateColor =
dateMap.isNotEmpty dateMap.isNotEmpty
? dateMap.values.first ? dateMap.values.first
: null; : null;
String? penaltyKey = String? penaltyKey =
penaltyMap.isNotEmpty penaltyMap.isNotEmpty
? penaltyMap.keys.first ? penaltyMap.keys.first
: null; : null;
int? datePenalty = int? datePenalty =
penaltyMap.isNotEmpty penaltyMap.isNotEmpty
? penaltyMap.values.first ? penaltyMap.values.first
: 0; : 0;
// Determine if this is the current day // Determine if this is the current day
final isCurrentDay = final isCurrentDay =
currentDateInPeriod.day == currentDateInPeriod.day ==
currentDate.day && currentDate.day &&
currentDateInPeriod.month == currentDateInPeriod.month ==
currentDate.month && currentDate.month &&
currentDateInPeriod.year == currentDateInPeriod.year ==
currentDate.year; currentDate.year;
return InkWell( return InkWell(
onTap: onTap:
isFutureDate isFutureDate
? null ? null
: () { : () {
selectedIndex = index; selectedIndex = index;
if (penaltyKey != null) { if (penaltyKey != null) {
attendance.dateWiseAttendance( attendance.dateWiseAttendance(
homeProvider, homeProvider,
penaltyKey, penaltyKey,
context, context,
); );
} }
attendance.selectedDate = attendance.selectedDate =
currentDay.toString(); currentDay.toString();
}, _showAttDetailsBottomSheet(context);
child: Card( },
elevation: 0, child: Card(
child: Column( elevation: 0,
children: [ child: Column(
Row( children: [
mainAxisAlignment: Row(
MainAxisAlignment.center, mainAxisAlignment:
children: [ MainAxisAlignment.center,
Text( children: [
datePenalty != 0 Text(
? "($datePenalty)" 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(),
style: TextStyle( style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
color: color: Colors.black,
isFutureDate ),
? AppColors.semi_black ),
: (isCurrentDay || ],
(selectedIndex == ),
index)) Center(
? Color(0xFF493272) child: Container(
: dateColor == 'g' decoration: BoxDecoration(
? Color(0xFF6B3A02) shape: BoxShape.circle,
: dateColor == 'r' color:
? Color(0xFFFF0000) isFutureDate
: dateColor == 'b' ? Colors.transparent
? Color(0xFF493272) : (isCurrentDay ||
: dateColor == 'br' (selectedIndex ==
? Colors.brown index))
: dateColor == 'y' ? Color(0xFFF6F0FF)
? Color(0xFF605C00) : dateColor == 'g'
: Colors.transparent, ? 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: 70),
SizedBox(height: 60), ],
], ),
), ),
), ),
), floatingActionButton:attendance.attendanceStatus==0||attendance.attendanceStatus==1? Align(
floatingActionButton: Align( alignment: Alignment.bottomCenter,
alignment: Alignment.bottomCenter, child: InkWell(
child: InkWell( onTap: () async {
onTap: () { var res = await Navigator.push(
Navigator.push( context,
context, MaterialPageRoute(
MaterialPageRoute( builder:
builder: (context) => CheckInOutScreen(
(context) => CheckInOutScreen( getAttendanceStatus: attendance.attendanceStatus,
getAttendanceStatus: attendance.attendanceStatus, ),
), ),
), );
); if(res==true){
attendance.getAttendanceList(homeProvider, context);
}
var f = FocusScope.of(context); var f = FocusScope.of(context);
if (!f.hasPrimaryFocus) { if (!f.hasPrimaryFocus) {
f.unfocus(); f.unfocus();
} }
}, },
child: Container( child: Container(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
height: 45, height: 45,
width: MediaQuery.of(context).size.width, margin: EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration( width: MediaQuery.of(context).size.width,
color: AppColors.app_blue, decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0), color: AppColors.app_blue,
), borderRadius: BorderRadius.circular(30.0),
child: Center( ),
child: Text( child: Center(
attendance.attendanceStatus == 0 ? "Check In" : "Check Out", child: Text(
textAlign: TextAlign.center, attendance.attendanceStatus == 0 ? "Check In" : "Check Out",
style: TextStyle(color: Colors.white), textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
),
), ),
), ),
), ),
), ):SizedBox(height: 0,),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
), ),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
); );
}, },
); );
} }
Future<void> _showInfoBottomSheet(BuildContext context) { Future<void> _showInfoBottomSheet(BuildContext context) {
return showModalBottomSheet( return showModalBottomSheet(
useSafeArea: true, useSafeArea: true,
...@@ -637,74 +653,204 @@ class _AttendanceScreenState extends State<AttendanceScreen> { ...@@ -637,74 +653,204 @@ class _AttendanceScreenState extends State<AttendanceScreen> {
), ),
child: SingleChildScrollView( 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( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Column( Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Column(
Text( crossAxisAlignment: CrossAxisAlignment.start,
"Indicators Info", children: [
style: TextStyle( Text(
color: AppColors.app_blue, "Attendance Info",
fontSize: 16, 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'; ...@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:generp/Notifiers/Counter.dart'; import 'package:generp/Notifiers/Counter.dart';
import 'package:generp/Notifiers/HomeScreenNotifier.dart'; import 'package:generp/Notifiers/HomeScreenNotifier.dart';
...@@ -45,245 +46,303 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -45,245 +46,303 @@ class _MyHomePageState extends State<MyHomePage> {
}); });
super.initState(); 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer2<HomescreenNotifier, ProfileNotifer>( return Consumer2<HomescreenNotifier, ProfileNotifer>(
builder: (context, homescreen, profile, child) { builder: (context, homescreen, profile, child) {
return Scaffold( return WillPopScope(
backgroundColor: AppColors.scaffold_bg_color, onWillPop: onBackPressed,
child: RefreshIndicator.adaptive(
body: Container( color: AppColors.app_blue,
child: Column(
children: [ onRefresh: () async {
Expanded( await Future.delayed(const Duration(milliseconds: 600));
flex: 3, homescreen.DashboardApiFunction(context);
child: Container(
padding: EdgeInsets.symmetric(vertical: 10), },
decoration: BoxDecoration( child: Scaffold(
color: Colors.white, backgroundColor: AppColors.scaffold_bg_color,
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30), body: Container(
), child: Column(
), children: [
child: Container( Expanded(
margin: EdgeInsets.only( flex: 3,
bottom: 15, child: Container(
left: 15, padding: EdgeInsets.symmetric(vertical: 10),
right: 15, decoration: BoxDecoration(
top: 30, color: Colors.white,
), borderRadius: BorderRadius.vertical(
decoration: BoxDecoration( bottom: Radius.circular(30),
borderRadius: BorderRadius.circular(30), ),
gradient: LinearGradient(
colors: [AppColors.profile_card_gradient1, AppColors.profile_card_gradient2],
), ),
), child: Container(
child: Row( margin: EdgeInsets.only(
crossAxisAlignment: CrossAxisAlignment.center, bottom: 15,
children: [ left: 15,
Expanded( right: 15,
flex: 2, top: 30,
child: SizedBox( ),
child: Column( decoration: BoxDecoration(
mainAxisAlignment: MainAxisAlignment.center, borderRadius: BorderRadius.circular(30),
gradient: LinearGradient(
children: [ colors: [AppColors.profile_card_gradient1, AppColors.profile_card_gradient2],
SizedBox( ),
width:66, ),
height: 66, child: Row(
child: ClipRRect( crossAxisAlignment: CrossAxisAlignment.center,
borderRadius: BorderRadius.circular(50), children: [
child: CachedNetworkImage( Expanded(
cacheKey: profile.profileImage, flex: 2,
fit: BoxFit.cover, child: SizedBox(
imageUrl: "${profile.profileImage}", child: Column(
useOldImageOnUrlChange: false, mainAxisAlignment: MainAxisAlignment.center,
placeholder: (context, url) => CircularProgressIndicator.adaptive(
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, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Container( Text(
width: 10, "${profile.employeeName}",
height: 10, style: TextStyle(
decoration: BoxDecoration( color: AppColors.app_blue,
shape: BoxShape.circle, fontSize: 16,
color: homescreen.onlineStatus=="Online"?Colors.green:Colors.yellow,
), ),
), ),
SizedBox(width: 5),
Text( Text(
"${homescreen.onlineStatus}", "${profile.designation}",
style: TextStyle( style: TextStyle(
color: AppColors.semi_black,
fontSize: 14, fontSize: 14,
color: Colors.black,
), ),
), ),
], Text(
), "${profile.employeeeID}",
], style: TextStyle(
), color: AppColors.semi_black,
), fontSize: 14,
),
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,
),
), ),
SizedBox(width: 5), ),
SizedBox( InkResponse(
width: 15, onTap: () {
height: 15, _showProfileBottomSheet(context);
child: Center( },
child: SvgPicture.asset( child: Row(
"assets/svg/next_button.svg", 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,
Expanded( child: Container(
flex: 8, padding: EdgeInsets.only(
child: Container( left: 20,
padding: EdgeInsets.only( right: 20,
left: 20, top: 0,
right: 20, bottom: 10,
top: 0, ),
bottom: 10, child: GridView.builder(
), itemCount: 8,
child: GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
itemCount: 8, crossAxisCount: 2,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisSpacing: 10,
crossAxisCount: 2, mainAxisSpacing: 10,
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]),
],
),
), ),
); 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/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:generp/Notifiers/GeneratorDetailsProvider.dart'; import 'package:generp/Notifiers/GeneratorDetailsProvider.dart';
import 'package:generp/screens/genTracker/ComplaintHistory.dart'; import 'package:generp/screens/genTracker/ComplaintHistory.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../Notifiers/HomeScreenNotifier.dart'; import '../../Notifiers/HomeScreenNotifier.dart';
import '../../Utils/app_colors.dart'; import '../../Utils/app_colors.dart';
import '../../Utils/commonWidgets.dart'; import '../../Utils/commonWidgets.dart';
class Generatordetails extends StatefulWidget { 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 @override
State<Generatordetails> createState() => _GeneratordetailsState(); State<Generatordetails> createState() => _GeneratordetailsState();
...@@ -24,8 +37,25 @@ class _GeneratordetailsState extends State<Generatordetails> { ...@@ -24,8 +37,25 @@ class _GeneratordetailsState extends State<Generatordetails> {
context, context,
listen: false, listen: false,
); );
var homeProvider = Provider.of<HomescreenNotifier>(context,listen: false); var homeProvider = Provider.of<HomescreenNotifier>(
details.LoadgeneratorDetailsApifunction(homeProvider,context, "",details.genID); 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> { ...@@ -33,9 +63,37 @@ class _GeneratordetailsState extends State<Generatordetails> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer<Generatordetailsprovider>( return Consumer<Generatordetailsprovider>(
builder: (context, provider, child) { 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( 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, backgroundColor: AppColors.scaffold_bg_color,
body: Container( body: Container(
child: SingleChildScrollView( child: SingleChildScrollView(
...@@ -80,7 +138,7 @@ class _GeneratordetailsState extends State<Generatordetails> { ...@@ -80,7 +138,7 @@ class _GeneratordetailsState extends State<Generatordetails> {
children: [ children: [
Row( Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceBetween, MainAxisAlignment.spaceBetween,
children: [ children: [
if (j == 0) ...[ if (j == 0) ...[
SvgPicture.asset( SvgPicture.asset(
...@@ -90,21 +148,29 @@ class _GeneratordetailsState extends State<Generatordetails> { ...@@ -90,21 +148,29 @@ class _GeneratordetailsState extends State<Generatordetails> {
], ],
Column( Column(
crossAxisAlignment: crossAxisAlignment:
CrossAxisAlignment.start, CrossAxisAlignment.start,
children: [ children: [
Text(textheads[j].toString()),
SizedBox( SizedBox(
// height:45,
width: width:
MediaQuery.of( MediaQuery.of(
context, context,
).size.width * ).size.width *
0.75, 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( child: Text(
textSubheads[j], textSubheads[j],
maxLines: 2, maxLines: 2,
overflow: overflow:
TextOverflow.ellipsis, TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
color: Color(0xFF818181), color: Color(0xFF818181),
), ),
...@@ -164,7 +230,7 @@ class _GeneratordetailsState extends State<Generatordetails> { ...@@ -164,7 +230,7 @@ class _GeneratordetailsState extends State<Generatordetails> {
children: [ children: [
Row( Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceBetween, MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
...@@ -173,21 +239,21 @@ class _GeneratordetailsState extends State<Generatordetails> { ...@@ -173,21 +239,21 @@ class _GeneratordetailsState extends State<Generatordetails> {
), ),
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment:
CrossAxisAlignment.start, CrossAxisAlignment.start,
children: [ children: [
Text(textheads[j].toString()), Text(textheads[j].toString()),
SizedBox( SizedBox(
// height:45, // height:45,
width: width:
MediaQuery.of( MediaQuery.of(
context, context,
).size.width * ).size.width *
0.8, 0.8,
child: Text( child: Text(
textSubheads[j], textSubheads[j],
maxLines: 2, maxLines: 2,
overflow: overflow:
TextOverflow.ellipsis, TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
color: Color(0xFF818181), color: Color(0xFF818181),
), ),
...@@ -209,7 +275,6 @@ class _GeneratordetailsState extends State<Generatordetails> { ...@@ -209,7 +275,6 @@ class _GeneratordetailsState extends State<Generatordetails> {
), ),
), ),
SizedBox(height: 75), SizedBox(height: 75),
], ],
), ),
...@@ -219,8 +284,10 @@ class _GeneratordetailsState extends State<Generatordetails> { ...@@ -219,8 +284,10 @@ class _GeneratordetailsState extends State<Generatordetails> {
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => Complainthistory(),)); Navigator.push(
context,
MaterialPageRoute(builder: (context) => Complainthistory()),
);
}, },
child: Container( child: Container(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
...@@ -242,7 +309,7 @@ class _GeneratordetailsState extends State<Generatordetails> { ...@@ -242,7 +309,7 @@ class _GeneratordetailsState extends State<Generatordetails> {
), ),
), ),
floatingActionButtonLocation: floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat, FloatingActionButtonLocation.centerFloat,
); );
}, },
); );
......
...@@ -23,28 +23,203 @@ class _NearbygeneratorsState extends State<Nearbygenerators> { ...@@ -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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
debugPrint("Nearbygenerators widget rebuilt");
return Consumer<Nearbygeneratorsprovider>(builder: (context, provider, child) { return Consumer<Nearbygeneratorsprovider>(builder: (context, provider, child) {
var sendWidget = GestureDetector(
onTap: () {
infoDialogue(context);
},
child: InkWell(
child: Icon(Icons.filter_alt_outlined),
));
return Scaffold( return Scaffold(
appBar: appbar(context, "Nearby Generators"), appBar: appbar2(context, "Nearby Generators",sendWidget),
backgroundColor: AppColors.scaffold_bg_color, backgroundColor: AppColors.scaffold_bg_color,
body: Container( body: Container(
child: SingleChildScrollView( child: SingleChildScrollView(
child:Column( child:Column(
children: [ children: [
Expanded( ClipRRect(
child: ClipRRect( // Apply border radius using ClipRRect
// Apply border radius using ClipRRect borderRadius: BorderRadius.only(
borderRadius: BorderRadius.only( topLeft: Radius.circular(30.0),
topLeft: Radius.circular(30.0), topRight: Radius.circular(30.0),
topRight: Radius.circular(30.0), ),
), // padding: EdgeInsets.fromLTRB(10, 20, 10, 20),
// padding: EdgeInsets.fromLTRB(10, 20, 10, 20), child: Container(
height: MediaQuery.of(context).size.height,
child: Stack(children: [ child: Stack(children: [
GoogleMap( GoogleMap(
myLocationEnabled: true, myLocationEnabled: true,
zoomGesturesEnabled: true, zoomGesturesEnabled: true,
initialCameraPosition: CameraPosition( initialCameraPosition: CameraPosition(
target: provider.startLocation, target: provider.startLocation,
zoom: 14.0, zoom: 14.0,
......
...@@ -4,6 +4,7 @@ import 'package:generp/Notifiers/ServiceEngineerDashboardProvider.dart'; ...@@ -4,6 +4,7 @@ import 'package:generp/Notifiers/ServiceEngineerDashboardProvider.dart';
import 'package:generp/Utils/app_colors.dart'; import 'package:generp/Utils/app_colors.dart';
import 'package:generp/Utils/commonWidgets.dart'; import 'package:generp/Utils/commonWidgets.dart';
import 'package:generp/screens/serviceEngineer/MonthlyCollection.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/PCWallet.dart';
import 'package:generp/screens/serviceEngineer/PendingComplaints.dart'; import 'package:generp/screens/serviceEngineer/PendingComplaints.dart';
import 'package:generp/screens/serviceEngineer/TodayMontlyVisists.dart'; import 'package:generp/screens/serviceEngineer/TodayMontlyVisists.dart';
...@@ -261,27 +262,32 @@ class _ServiceengineerdashboardState extends State<Serviceengineerdashboard> { ...@@ -261,27 +262,32 @@ class _ServiceengineerdashboardState extends State<Serviceengineerdashboard> {
}, },
), ),
), ),
Container( InkResponse(
height: 60, onTap: () {
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), Navigator.push(context, MaterialPageRoute(builder: (context) => Nearbygenerators(),));
decoration: BoxDecoration( },
color: Colors.white, child: Container(
borderRadius: BorderRadius.circular(20), height: 60,
), margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
flex: 1, flex: 1,
child: SvgPicture.asset( child: SvgPicture.asset(
"assets/svg/find_generator.svg", "assets/svg/find_generator.svg",
),
), ),
), Expanded(
Expanded( flex: 4,
flex: 4, child: Text("Find Nearby Generators"),
child: Text("Find Nearby Generators"), ),
), ],
], ),
), ),
), ),
], ],
......
...@@ -691,6 +691,7 @@ class ApiCalling { ...@@ -691,6 +691,7 @@ class ApiCalling {
}; };
final res = await post(data, technicianNearbyGeneratorsUrl, {}); final res = await post(data, technicianNearbyGeneratorsUrl, {});
if (res != null) { if (res != null) {
print(data);
debugPrint(res.body); debugPrint(res.body);
return NearbyGeneratorsResponse.fromJson(jsonDecode(res.body)); return NearbyGeneratorsResponse.fromJson(jsonDecode(res.body));
} else { } 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