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
),
),
);
}
This diff is collapsed.
This diff is collapsed.
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