Commit 479f7f07 authored by Sai Srinivas's avatar Sai Srinivas
Browse files

12-05-2025 By Sai Srinivas

Gen Tracker Module and Nearby Generators
parent b269a97b
<svg
xmlns="http://www.w3.org/2000/svg"
width="70"
height="70"
viewBox="0 0 70 70"
>
<path
d="M42,27.6A4,4 0,0 0,40.2 24c-3.6,-2.3 -11.5,1.2 -13,1.9a1.4,1.4 0,0 0,-0.7 2,1.5 1.5,0 0,0 1.9,0.7c3.1,-1.5 8.6,-3.2 10.2,-2.2s0.5,0.3 0.5,1.2 -4.6,9.3 -7.6,14 -5,8 -5.2,9.6a3.9,3.9 0,0 0,1.8 3.6,5.5 5.5,0 0,0 3.2,0.8c3.8,0 8.7,-2.1 9.8,-2.7a1.4,1.4 0,0 0,0.7 -1.9,1.5 1.5,0 0,0 -1.9,-0.7c-3.2,1.5 -8.6,3.2 -10.3,2.1a1.1,1.1 0,0 1,-0.4 -1c0.1,-1 2.7,-5 4.8,-8.2C38.6,35.9 41.9,30.5 42,27.6Z"
fill="#000"
/>
<path
d="M36.1,16m-4.1,0a4.1,4.1 0,1 1,8.2 0a4.1,4.1 0,1 1,-8.2 0"
fill="#000"
/>
<path
d="M35,0A35,35 0,1 0,70 35,35 35,0 0,0 35,0ZM35,67.1A32.1,32.1 0,1 1,67.1 35,32.1 32.1,0 0,1 35,67.1Z"
fill="#000"
/>
</svg>
<svg
xmlns="http://www.w3.org/2000/svg"
width="70"
height="70"
viewBox="0 0 70 70"
>
<path
d="M42,27.6A4,4 0,0 0,40.2 24c-3.6,-2.3 -11.5,1.2 -13,1.9a1.4,1.4 0,0 0,-0.7 2,1.5 1.5,0 0,0 1.9,0.7c3.1,-1.5 8.6,-3.2 10.2,-2.2s0.5,0.3 0.5,1.2 -4.6,9.3 -7.6,14 -5,8 -5.2,9.6a3.9,3.9 0,0 0,1.8 3.6,5.5 5.5,0 0,0 3.2,0.8c3.8,0 8.7,-2.1 9.8,-2.7a1.4,1.4 0,0 0,0.7 -1.9,1.5 1.5,0 0,0 -1.9,-0.7c-3.2,1.5 -8.6,3.2 -10.3,2.1a1.1,1.1 0,0 1,-0.4 -1c0.1,-1 2.7,-5 4.8,-8.2C38.6,35.9 41.9,30.5 42,27.6Z"
fill="#000"
/>
<path
d="M36.1,16m-4.1,0a4.1,4.1 0,1 1,8.2 0a4.1,4.1 0,1 1,-8.2 0"
fill="#000"
/>
<path
d="M35,0A35,35 0,1 0,70 35,35 35,0 0,0 35,0ZM35,67.1A32.1,32.1 0,1 1,67.1 35,32.1 32.1,0 0,1 35,67.1Z"
fill="#000"
/>
</svg>
This diff is collapsed.
import 'dart:async';
import 'dart:io';
import 'dart:ui' as ui;
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/svg.dart';
import 'package:generp/Notifiers/HomeScreenNotifier.dart';
import 'package:generp/Utils/SharedpreferencesService.dart';
import 'package:generp/screens/LoginScreen.dart';
import 'package:generp/screens/genTracker/GeneratorDetails.dart';
import 'package:generp/services/api_calling.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:image_picker/image_picker.dart';
import 'package:geocoding/geocoding.dart' as geocoding;
import 'package:location/location.dart' as Location;
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import '../Models/NearbyGeneratorsResponse.dart';
import '../Utils/commonServices.dart';
class Nearbygeneratorsprovider extends ChangeNotifier {
final ImagePicker _picker = ImagePicker();
List<Nearbygenerators> _generatorslist = [];
TextEditingController _locationController = TextEditingController();
String _googleApikey = "AIzaSyBGzvgMMKwPBAANTwaoRsAnrCpiWCj8wVs";
GoogleMapController? _mapController;
CameraPosition? _cameraPosition;
LatLng _startLocation = const LatLng(17.439112226708446, 78.43292499146135);
String _latlongs = "";
List<Marker> _markers = [];
List<String> _addresses = [];
Location.LocationData? _currentLocation;
bool _isLocationEnabled = false;
bool _hasLocationPermission = false;
Timer? _timer;
File? _image;
bool _isLoading = true;
String _selectedItem = 'Active';
double _currentValue = 1.0;
List<Nearbygenerators> get generatorsList => _generatorslist;
TextEditingController get LocationController => _locationController;
String get googleAPIKey => _googleApikey;
GoogleMapController? get mapController => _mapController;
CameraPosition? get cameraPosition => _cameraPosition;
LatLng get startLocation => _startLocation;
String get latlongs => _latlongs;
List<Marker> get markers => _markers;
List<String> get addresses => _addresses;
Location.LocationData? get currentLocation => _currentLocation;
bool get isLocationEnabled => _isLocationEnabled;
bool get hasLocationPermission => _hasLocationPermission;
bool get isLoading => _isLoading;
Timer? get timer => _timer;
File? get image => _image;
String get selectedItem => _selectedItem;
double get currentValue => _currentValue;
set mapController(value){
_mapController = value;
notifyListeners();
}
Future<void> getLocationPermission(context) async {
// Check if location services are enabled
_isLocationEnabled = await Geolocator.isLocationServiceEnabled();
// Check if the app has been granted location permission
LocationPermission permission = await Geolocator.checkPermission();
_hasLocationPermission =
permission == LocationPermission.always ||
permission == LocationPermission.whileInUse;
final Location.Location location = Location.Location();
bool serviceEnabled;
Location.PermissionStatus permissionGranted;
serviceEnabled = await location.serviceEnabled();
if (!serviceEnabled) {
serviceEnabled = await location.requestService();
if (!serviceEnabled) {
return;
}
}
_isLoading = false;
permissionGranted = (await location.hasPermission());
if (permissionGranted == PermissionStatus) {
permissionGranted = (await location.requestPermission());
if (permissionGranted != PermissionStatus) {
return;
}
}
final Location.LocationData locData = await location.getLocation();
_currentLocation = locData;
if (_currentLocation != null) {
_mapController?.animateCamera(
CameraUpdate.newLatLng(
LatLng(_currentLocation!.latitude!, _currentLocation!.longitude!),
),
);
final lat = _currentLocation!.latitude;
final lang = _currentLocation!.longitude!;
_latlongs = '$lat,$lang';
LoadNearbyGeneratorsAPI(context);
}
}
void onCameraMove(context, CameraPosition position) {
_timer?.cancel(); // Cancel any previous timer
_timer = Timer(Duration(seconds: 1), () {
getLocationPermission(context);
});
}
Future<void> LoadNearbyGeneratorsAPI(BuildContext context) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.loadNearbyGeneratorsAPI(
provider.empId,
provider.session,
_latlongs,
_currentValue,
_selectedItem,
);
if (data != null) {
if (data.sessionExists == 1) {
if (data.error == 0) {
_generatorslist = data.list!;
updateMarkersFromApiResponse(context, data.list!);
_isLoading = false;
notifyListeners();
} else {}
} else {
SharedpreferencesService().clearPreferences();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => LoginScreen()),
);
}
} else {
toast(context, "Something went wrong, Please try again.");
}
} on Exception catch (e) {
print("$e");
}
}
Future<void> updateMarkersFromApiResponse(
BuildContext context,
List<Nearbygenerators> generatorslist,
) async {
_markers = await createMarkersFromApiResponse(context, generatorslist);
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]}" );
}
}
Future<List<Marker>> createMarkersFromApiResponse(
BuildContext context,
List<Nearbygenerators> generatorslist,
) async {
List<Marker> markers = [];
// print("Hello Nutsby!");
ByteData data = await rootBundle.load("assets/images/dg_set.png");
Uint8List bytes = data.buffer.asUint8List();
await Future.forEach(generatorslist, (generator) async {
ui.Codec codec = await ui.instantiateImageCodec(
bytes,
targetWidth: 75,
targetHeight: 95,
);
ui.FrameInfo fi = await codec.getNextFrame();
Uint8List resizedBytes =
(await fi.image.toByteData(
format: ui.ImageByteFormat.png,
))!.buffer.asUint8List();
markers.add(
Marker(
markerId: MarkerId(generator.generatorId.toString()),
position: _parseLatLng(generator.loc),
icon: BitmapDescriptor.fromBytes(resizedBytes),
infoWindow: InfoWindow(
title: "Customer Name: ${generator.accName}",
snippet: "Product Name: ${generator.productName}",
),
onTap: () {
int index = generatorslist.indexWhere(
(techResponse) =>
techResponse.generatorId == generator.generatorId,
);
print("index:${index}");
if (index != -1) {
Navigator.push(
context,
MaterialPageRoute(
builder:
(context) => Generatordetails(
// actName: "NearByGenerators",
// location: generator.loc,
// generatorId: generator.generatorId,
),
),
);
}
},
),
);
});
return markers;
}
LatLng _parseLatLng(String? location) {
if (location != null) {
List<String> parts = location.split(',');
if (parts.length == 2) {
double lat = double.tryParse(parts[0]) ?? 0.0;
double lng = double.tryParse(parts[1]) ?? 0.0;
return LatLng(lat, lng);
}
}
return const LatLng(0.0, 0.0);
}
Future<String> _getAddressFromLatLng(String? location) async {
if (location != null) {
List<String> parts = location.split(',');
if (parts.length == 2) {
double lat = double.tryParse(parts[0]) ?? 0.0;
double lng = double.tryParse(parts[1]) ?? 0.0;
List<geocoding.Placemark> placemarks = await geocoding
.placemarkFromCoordinates(lat, lng);
if (placemarks.isNotEmpty) {
final placemark = placemarks.first;
String address =
'${placemark.street ?? ''}, '
'${placemark.thoroughfare ?? ''} '
// '${placemark.subThoroughfare ?? ''}, '
// '${placemark.name ?? ''}, '
'${placemark.subLocality ?? ''}, '
'${placemark.locality ?? ''}, '
'${placemark.administrativeArea ?? ''}, '
'${placemark.subAdministrativeArea ?? ''} '
'${placemark.postalCode ?? ''}, '
'${placemark.country ?? ''}';
return address.trim();
}
}
}
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;
}
}
......@@ -57,6 +57,7 @@ class Paymentdetailsprovider extends ChangeNotifier {
set enteredOtp(String value){
_enteredOtp = value;
notifyListeners();
}
set selectContact(value){
......
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:generp/services/api_calling.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
import '../Utils/commonServices.dart';
import 'HomeScreenNotifier.dart';
class Scanloginprovider extends ChangeNotifier{
PermissionStatus _cameraPermissionStatus = PermissionStatus.denied;
QRViewController? _qrViewController;
bool _hasPermission = false;
final GlobalKey scannerKey = GlobalKey(debugLabel: 'QR');
bool get hasPermission => _hasPermission;
Future<void> checkPermission1() async {
// Check camera permissions
var status = await Permission.camera.status;
try {
if (status.isGranted) {
_hasPermission = true;
} else if (status.isDenied || status.isRestricted) {
// Request camera permissions if denied or restricted
await Permission.camera.request();
status = await Permission.camera.request();
if (status.isGranted) {
_hasPermission = true;
} else {
_hasPermission = false;
}
}
} catch (e, s) {}
}
Future<void> requestCameraPermission() async {
PermissionStatus status = await Permission.camera.request();
_cameraPermissionStatus = status;
// print(_cameraPermissionStatus);
try {
if (_cameraPermissionStatus.isGranted) {
_hasPermission = true;
} else if (_cameraPermissionStatus.isDenied ||
_cameraPermissionStatus.isRestricted ||
_cameraPermissionStatus.isPermanentlyDenied) {
_hasPermission = false;
await Permission.camera.request();
}
} catch (e, s) {}
}
void onQRViewCreated(QRViewController controller, context) {
// print("QRVIEW");
var HomeProvider = Provider.of<HomescreenNotifier>(context, listen: false);
this._qrViewController = controller;
controller.scannedDataStream.listen((scanData) {
controller!.pauseCamera();
Map<String, dynamic> obj = jsonDecode(scanData.code!);
if (obj["type"] == "login") {
if(kDebugMode){
print("type:" + obj["type"]);
print("token:" + (obj["data"]["token"]));
}
controller!.pauseCamera();
LoadQRAPIFunction(context,obj["type"], (obj["data"]["token"]));
}
});
}
Future<void> LoadQRAPIFunction(context,type, token) async {
try {
var homeProvider = Provider.of<HomescreenNotifier>(context,listen: false);
final data = await ApiCalling.QRLoginRequestAPI(homeProvider.empId, homeProvider.session, type, token);
if (data != null)
{
if (data.sessionExists == 1) {
if (data.error == 0) {
Navigator.pop(context);
toast(context, data.message);
} else if (data.error == 1) {
toast(context, data.message);
} else if (data.error == 2) {
toast(context, data.message);
} else {
toast(context,
"Something Went wrong, Please Try Again!");
}
} else {
toast(context,
"Your session has expired, please login again!");
}
}
else
{}
} on Error catch (e) {
print(e.toString());
}
}
}
\ No newline at end of file
......@@ -9,9 +9,11 @@ import 'package:flutter_ringtone_player/flutter_ringtone_player.dart';
import 'package:generp/Notifiers/AttendanceNotifier.dart';
import 'package:generp/Notifiers/CheckInProvider.dart';
import 'package:generp/Notifiers/Counter.dart';
import 'package:generp/Notifiers/GeneratorDetailsProvider.dart';
import 'package:generp/Notifiers/HomeScreenNotifier.dart';
import 'package:generp/Notifiers/InventoryProvider.dart';
import 'package:generp/Notifiers/LogoutNotifier.dart';
import 'package:generp/Notifiers/NearByGeneratorsProvider.dart';
import 'package:generp/Notifiers/PCWalletProvider.dart';
import 'package:generp/Notifiers/PaymentCollectionProvider.dart';
import 'package:generp/Notifiers/PaymentDetailsProvider.dart';
......@@ -21,6 +23,7 @@ import 'package:generp/Notifiers/ServiceEngineerDashboardProvider.dart';
import 'package:generp/Notifiers/TodayMontlyVisitsProvider.dart';
import 'package:generp/Notifiers/VisitDetailsProvider.dart';
import 'package:generp/Notifiers/loginNotifier.dart';
import 'package:generp/Notifiers/scanLoginProvider.dart';
import 'package:generp/Notifiers/splashVersionNotifier.dart';
import 'package:generp/Utils/SharedpreferencesService.dart';
import 'package:generp/screens/HomeScreen.dart';
......@@ -179,6 +182,7 @@ class MyApp extends StatelessWidget {
});
return MultiProvider(providers: [
ChangeNotifierProvider(create: (_)=>SplashVersionNotifier()),
ChangeNotifierProvider(create: (_)=>Scanloginprovider()),
ChangeNotifierProvider(create: (_)=>Loginnotifier()),
ChangeNotifierProvider(create: (_)=>Counter()),
ChangeNotifierProvider(create: (_)=>HomescreenNotifier()),
......@@ -194,6 +198,8 @@ class MyApp extends StatelessWidget {
ChangeNotifierProvider(create: (_)=>Visitdetailsprovider()),
ChangeNotifierProvider(create: (_)=>Pcwalletprovider()),
ChangeNotifierProvider(create: (_)=>Paymentdetailsprovider()),
ChangeNotifierProvider(create: (_)=>Generatordetailsprovider()),
ChangeNotifierProvider(create: (_)=>Nearbygeneratorsprovider()),
],
child: Builder(
builder: (BuildContext context){
......
This diff is collapsed.
......@@ -8,10 +8,13 @@ import 'package:generp/Notifiers/HomeScreenNotifier.dart';
import 'package:generp/Notifiers/LogoutNotifier.dart';
import 'package:generp/Notifiers/ProfileNotifier.dart';
import 'package:generp/screens/LoginScreen.dart';
import 'package:generp/screens/ScannerLogin.dart';
import 'package:generp/screens/WebERPScreen.dart';
import 'package:generp/screens/WebWhizzdomScreen.dart';
import 'package:generp/screens/genTracker/GenTrackerDashboard.dart';
import 'package:generp/screens/serviceEngineer/serviceEngineerDashboard.dart';
import 'package:provider/provider.dart';
import 'package:cached_network_image/cached_network_image.dart';
import '../Utils/app_colors.dart';
import 'AttendanceScreen.dart';
......@@ -86,10 +89,22 @@ class _MyHomePageState extends State<MyHomePage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircleAvatar(
radius: 32.5, // 65 / 2
backgroundImage: NetworkImage(profile.profileImage),
backgroundColor: Colors.transparent,
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),
),
),
),
Row(
......@@ -100,7 +115,7 @@ class _MyHomePageState extends State<MyHomePage> {
height: 10,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.green,
color: homescreen.onlineStatus=="Online"?Colors.green:Colors.yellow,
),
),
SizedBox(width: 5),
......@@ -222,7 +237,7 @@ class _MyHomePageState extends State<MyHomePage> {
Navigator.push(context,MaterialPageRoute(builder: (context) => WebErpScreen(erp_url: homescreen.webPageUrl)));
break;
case "Gen Tracker":
// Navigator.push(context, MaterialPageRoute(builder: (context)=>GenTrackerDashboard()));
Navigator.push(context, MaterialPageRoute(builder: (context)=>Gentrackerdashboard()));
break;
case "Service Engineer":
Navigator.push(context, MaterialPageRoute(builder: (context)=>Serviceengineerdashboard()));
......@@ -320,11 +335,16 @@ class _MyHomePageState extends State<MyHomePage> {
),
),
Spacer(),
SizedBox(
height: 25,
width: 25,
child: SvgPicture.asset(
"assets/svg/scanner.svg",
InkResponse(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => Scannerlogin(),));
},
child: SizedBox(
height: 25,
width: 25,
child: SvgPicture.asset(
"assets/svg/scanner.svg",
),
),
),
],
......@@ -343,10 +363,21 @@ class _MyHomePageState extends State<MyHomePage> {
children: [
Padding(
padding: EdgeInsets.all(10),
child: CircleAvatar(
radius: 55,
foregroundImage: NetworkImage(
profile.profileImage,
child:SizedBox(
width:70,
height: 70,
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),
),
),
),
),
......@@ -452,7 +483,7 @@ class _MyHomePageState extends State<MyHomePage> {
if (!f.hasPrimaryFocus) {
f.unfocus();
}
logout.LogoutApiFunction(home, context);
_showLogoutBottomSheet(context);
// Navigator.push(context,MaterialPageRoute(builder: (context)=>Profile()));
},
child: Container(
......@@ -497,4 +528,129 @@ class _MyHomePageState extends State<MyHomePage> {
},
);
}
Future<void> _showLogoutBottomSheet(BuildContext context) {
return showModalBottomSheet(
useSafeArea: true,
isDismissible: true,
isScrollControlled: true,
showDragHandle: true,
enableDrag: true,
context: context,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return SafeArea(
child: Container(
margin: EdgeInsets.only(
bottom: 15,
left: 15,
right: 15,
top: 30,
),
child: Consumer3<
HomescreenNotifier,
ProfileNotifer,
LogoutNotifier
>(
builder: (context, home, profile, logout, child) {
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"Are you sure you want \nto logout ?",
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.semi_black,
fontSize: 18,
),
),
],
),
SizedBox(height: 20),
InkWell(
onTap: () {
// LoginApiFunction();
var f = FocusScope.of(context);
if (!f.hasPrimaryFocus) {
f.unfocus();
}
logout.LogoutApiFunction(home, context);
// Navigator.push(context,MaterialPageRoute(builder: (context)=>Profile()));
},
child: Container(
alignment: Alignment.center,
height: 45,
margin: EdgeInsets.only(
left: 5.0,
right: 5.0,
top: 5.0,
bottom: 5.0,
),
decoration: BoxDecoration(
color: AppColors.app_blue, //1487C9
borderRadius: BorderRadius.circular(30.0),
),
child: Center(
child: Text(
"Yes, Logout",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
),
),
),
),
InkWell(
onTap: () {
// LoginApiFunction();
var f = FocusScope.of(context);
if (!f.hasPrimaryFocus) {
f.unfocus();
}
Navigator.pop(context);
},
child: Container(
alignment: Alignment.center,
height: 45,
margin: EdgeInsets.only(
left: 5.0,
right: 5.0,
top: 5.0,
bottom: 5.0,
),
child: Center(
child: Text(
"Cancel",
textAlign: TextAlign.center,
style: TextStyle(color: AppColors.app_blue),
),
),
),
),
],
),
);
},
),
),
);
},
);
},
);
}
}
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
import '../Notifiers/scanLoginProvider.dart';
import '../Utils/app_colors.dart';
import '../Utils/commonWidgets.dart';
class Scannerlogin extends StatefulWidget {
const Scannerlogin({super.key});
@override
State<Scannerlogin> createState() => _ScannerloginState();
}
class _ScannerloginState extends State<Scannerlogin> {
@override
Widget build(BuildContext context) {
return Consumer<Scanloginprovider>(
builder: (context, provider, child) {
return Scaffold(
backgroundColor: AppColors.scaffold_bg_color,
appBar: appbar(context, "QR Login"),
body: Container(
decoration: BoxDecoration(color: Colors.black),
child: Column(
children: [
Spacer(),
Container(
height: 250,
child: QRView(
key: provider.scannerKey,
onQRViewCreated: (p0) {
provider.onQRViewCreated(p0, context);
},
formatsAllowed: [BarcodeFormat.qrcode],
cameraFacing: CameraFacing.back,
overlay: QrScannerOverlayShape(
borderColor: AppColors.app_blue,
borderRadius: 20,
borderLength: 60,
borderWidth: 10,
cutOutSize: 250.0,
),
),
),
SizedBox(height: 25),
Text(
"Scan QR",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18, color: Colors.white),
),
Text(
"to Login",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.white),
),
Spacer(),
SizedBox(height: 50),
],
),
),
);
},
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
import '../../Notifiers/GeneratorDetailsProvider.dart';
import '../../Notifiers/HomeScreenNotifier.dart';
import '../../Utils/app_colors.dart';
import '../../Utils/commonWidgets.dart';
class Complainthistory extends StatefulWidget {
const Complainthistory({super.key});
@override
State<Complainthistory> createState() => _ComplainthistoryState();
}
class _ComplainthistoryState extends State<Complainthistory> {
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
var details = Provider.of<Generatordetailsprovider>(
context,
listen: false,
);
var homeProvider = Provider.of<HomescreenNotifier>(context,listen: false);
details.LoadgeneratorComplaintHistoryApifunction(homeProvider,context, details.genID);
});
}
@override
Widget build(BuildContext context) {
return Consumer<Generatordetailsprovider>(
builder: (context, provider, child) {
return Scaffold(
appBar: appbar(context, "Complaint History"),
backgroundColor: AppColors.scaffold_bg_color,
body: Container(
child: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: provider.complaintList.length,
itemBuilder: (context, index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("${ provider.complaintList[index].compRegdate}",style: TextStyle(
color: Color(0xFF818181)
),),
Container(
margin: EdgeInsets.symmetric(horizontal: 10,vertical: 5),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
children: [
...List.generate(4, (index) {
final headings = [
"Technician Name",
"ID",
"Complaint Type",
"Complaint Status",];
final values = [
provider.complaintList[index].techName,
provider.complaintList[index].compId,
provider.complaintList[index].compType,
provider.complaintList[index].compStatus,
];
return Container(
padding: EdgeInsets.symmetric(horizontal: 15,vertical: 15),
child: Row(
children: [
Expanded(
child: SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text("${headings[index]}"),
],
),
),
),
Expanded(
child: SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text("${values[index]}",
style: TextStyle(
color: Color(0xFF818181)
),),
],
),
),
),
],
),
);
},),
]
),
),
],
);
},),
],
),
),
),
);
},
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:generp/Utils/commonWidgets.dart';
import 'package:generp/screens/genTracker/GeneratorDetails.dart';
import 'package:generp/screens/genTracker/RegisterComplaint.dart';
import 'package:generp/screens/genTracker/ScanEnterGeneratorIDScreen.dart';
import 'package:generp/screens/genTracker/TagGenerator.dart';
import 'package:generp/screens/genTracker/TagLocation.dart';
import '../../Utils/app_colors.dart';
class Gentrackerdashboard extends StatefulWidget {
const Gentrackerdashboard({super.key});
@override
State<Gentrackerdashboard> createState() => _GentrackerdashboardState();
}
class _GentrackerdashboardState extends State<Gentrackerdashboard> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.scaffold_bg_color,
appBar: appbar(context, "Gen Tracker"),
body: GridView.builder(
padding: EdgeInsets.symmetric(vertical: 10,horizontal: 10),
itemCount: 4,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
),
itemBuilder: (context, index) {
final names = [
"Generator Details",
"Register Complaint",
"Tag Location",
"Tag Generator",
];
return InkResponse(
onTap: () {
switch (names[index]) {
case "Generator Details":
Navigator.push(context,MaterialPageRoute(builder: (context) => Scanentergeneratoridscreen(from: "Generator Details",)));
break;
case "Register Complaint":
Navigator.push(context,MaterialPageRoute(builder: (context) => Scanentergeneratoridscreen(from: "Register Complaint",)));
break;
case "Tag Location":
Navigator.push(context, MaterialPageRoute(builder: (context)=>Scanentergeneratoridscreen(from: "Tag Location",)));
break;
case "Tag Generator":
Navigator.push(context, MaterialPageRoute(builder: (context)=>Scanentergeneratoridscreen(from: "Tag Generator",)));
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]),
],
),
),
);
},
),
);
}
}
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 '../../Notifiers/HomeScreenNotifier.dart';
import '../../Utils/app_colors.dart';
import '../../Utils/commonWidgets.dart';
class Generatordetails extends StatefulWidget {
const Generatordetails({super.key});
@override
State<Generatordetails> createState() => _GeneratordetailsState();
}
class _GeneratordetailsState extends State<Generatordetails> {
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
var details = Provider.of<Generatordetailsprovider>(
context,
listen: false,
);
var homeProvider = Provider.of<HomescreenNotifier>(context,listen: false);
details.LoadgeneratorDetailsApifunction(homeProvider,context, "",details.genID);
});
}
@override
Widget build(BuildContext context) {
return Consumer<Generatordetailsprovider>(
builder: (context, provider, child) {
return Scaffold(
appBar: appbar(context, "Visit Details"),
backgroundColor: AppColors.scaffold_bg_color,
body: Container(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Customer Details"),
Container(
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
child: Column(
children: [
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(4, (j) {
final textheads = [
"${provider.cname}",
"Mobile Number",
"Contact Person Number",
"Mail ID",
];
final textSubheads = [
"${provider.aname}",
"${provider.mob1}",
"${provider.mob2}",
"${provider.mail}",
];
return Container(
padding: EdgeInsets.symmetric(vertical: 3),
child: Container(
padding: EdgeInsets.symmetric(
vertical: 3,
horizontal: 0,
),
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
if (j == 0) ...[
SvgPicture.asset(
"assets/svg/se_block_head.svg",
),
SizedBox(width: 5),
],
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(textheads[j].toString()),
SizedBox(
// height:45,
width:
MediaQuery.of(
context,
).size.width *
0.75,
child: Text(
textSubheads[j],
maxLines: 2,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF818181),
),
),
),
],
),
],
),
],
),
),
);
}),
),
],
),
],
),
),
Text("Generator Details"),
Container(
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
child: Column(
children: [
Row(
children: [
SvgPicture.asset("assetName"),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(6, (j) {
final textheads = [
"Gen ID",
"Engine Number",
"Address",
"Product Name",
"Engine Model",
"Date Of Supply",
];
final textSubheads = [
"${provider.genID}",
"${provider.engineNo}",
"${provider.address}",
"${provider.spname}",
"${provider.emodel}",
"${provider.dateOfEngineSale}",
];
return Container(
padding: EdgeInsets.symmetric(vertical: 3),
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Container(
padding: EdgeInsets.symmetric(
vertical: 3,
horizontal: 0,
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(textheads[j].toString()),
SizedBox(
// height:45,
width:
MediaQuery.of(
context,
).size.width *
0.8,
child: Text(
textSubheads[j],
maxLines: 2,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF818181),
),
),
),
],
),
),
],
),
],
),
);
}),
),
],
),
],
),
),
SizedBox(height: 75),
],
),
),
),
floatingActionButton: Align(
alignment: Alignment.bottomCenter,
child: InkWell(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => Complainthistory(),));
},
child: Container(
alignment: Alignment.bottomCenter,
height: 45,
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(
color: AppColors.app_blue,
borderRadius: BorderRadius.circular(30.0),
),
child: Center(
child: Text(
"Complaint History",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
),
),
),
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
);
},
);
}
}
This diff is collapsed.
import 'package:flutter/material.dart';
import 'package:generp/Notifiers/GeneratorDetailsProvider.dart';
import 'package:provider/provider.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
import '../../Notifiers/HomeScreenNotifier.dart';
import '../../Notifiers/InventoryProvider.dart';
import '../../Utils/app_colors.dart';
import '../../Utils/commonWidgets.dart';
class Scanentergeneratoridscreen extends StatefulWidget {
final from;
const Scanentergeneratoridscreen({super.key,required this.from});
@override
State<Scanentergeneratoridscreen> createState() => _ScanentergeneratoridscreenState();
}
class _ScanentergeneratoridscreenState extends State<Scanentergeneratoridscreen> {
FocusNode genIDFocusNode = FocusNode();
TextEditingController genIDcontroller = TextEditingController();
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
var provider = Provider.of<Generatordetailsprovider>(
context,
listen: false,
);
provider.initialFunction(widget.from);
provider.checkPermission1();
provider.requestCameraPermission();
if(widget.from=="Tag Location"){
provider.checkLocationPermission1();
provider.getLocationPermission(context);
}
});
}
@override
Widget build(BuildContext context) {
return Consumer<Generatordetailsprovider>(
builder: (context, provider, child) {
return Scaffold(
backgroundColor: AppColors.scaffold_bg_color,
appBar: appbar(context, "${widget.from}"),
body: Container(
decoration: BoxDecoration(color: Colors.black),
child: Column(
children: [
Spacer(),
Container(
height: 250,
child: QRView(
key: provider.scannerKey,
onQRViewCreated: (p0) {
provider.onQRViewCreated(p0, provider.title, context);
},
formatsAllowed: [BarcodeFormat.qrcode],
cameraFacing: CameraFacing.back,
overlay: QrScannerOverlayShape(
borderColor: AppColors.app_blue,
borderRadius: 20,
borderLength: 60,
borderWidth: 10,
cutOutSize: 250.0,
),
),
),
SizedBox(height: 25),
Text(
"Scan QR",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18, color: Colors.white),
),
Text(
provider.subTitle,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.white),
),
Spacer(),
Text(
"or",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18, color: Colors.white),
),
InkResponse(
onTap: () async {
_showgenIdBottomSheet(context);
},
child: Text(
"Tap to Enter Generator ID",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.white),
),
),
SizedBox(height: 50),
],
),
),
);
},
);
}
Future<void> _showgenIdBottomSheet(BuildContext context) {
return showModalBottomSheet(
useSafeArea: true,
isDismissible: true,
isScrollControlled: true,
showDragHandle: true,
useRootNavigator: true,
enableDrag: true,
context: context,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return SafeArea(
child: Padding(
padding: EdgeInsets.only(
bottom:
MediaQuery.of(
context,
).viewInsets.bottom, // This handles keyboard
),
child: Container(
margin: EdgeInsets.only(
bottom: 15,
left: 15,
right: 15,
top: 30,
),
child: Consumer2<Generatordetailsprovider, HomescreenNotifier>(
builder: (context, provider, homeProvider, child) {
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
alignment: Alignment.topLeft,
child: Text(
"Generator ID",
style: TextStyle(
color: AppColors.semi_black,
fontSize: 12,
),
),
),
Container(
height: 48,
alignment: Alignment.center,
decoration: BoxDecoration(
color: AppColors.text_field_color,
borderRadius: BorderRadius.circular(20),
border:
genIDFocusNode.hasFocus
? Border.all(
color: AppColors.app_blue,
width: 0.5,
)
: null,
),
// alignment: Alignment.center,
margin: EdgeInsets.only(left: 5.0, right: 5.0),
child: Padding(
padding: const EdgeInsets.fromLTRB(
10.0,
0.0,
15,
0,
),
child: TextField(
controller: genIDcontroller,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.characters,
focusNode: genIDFocusNode,
style: TextStyle(fontSize: 14),
onChanged: (value) {},
onTapOutside: (event) {
// Handle onTapOutside
FocusScope.of(context).unfocus();
},
decoration: InputDecoration(
isDense: true,
hintStyle: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 14,
),
//contentPadding: EdgeInsets.fromLTRB(5.0, 10.0, 5.0, 10.0),
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
hintText: 'Enter Generator ID',
),
),
),
),
InkWell(
onTap: () {
switch(widget.from){
case "Generator Details":
provider.LoadgeneratorDetailsApifunction(
homeProvider,
context,
widget.from,
genIDcontroller.text,
);
break;
case "Register Complaint":
provider.LoadgeneratorDetailsApifunction(
homeProvider,
context,
widget.from,
genIDcontroller.text,
);
break;
case "Tag Location":
provider.TagLocationAPIFunction(homeProvider, context, genIDcontroller.text);
break;
case "Tag Generator":
provider.showTagGeneratorBottomSheet(context, genIDcontroller.text);
break;
default:
break;
}
},
child: Container(
alignment: Alignment.center,
height: 45,
margin: EdgeInsets.only(
left: 5.0,
right: 5.0,
top: 5.0,
bottom: 5.0,
),
decoration: BoxDecoration(
color: AppColors.app_blue, //1487C9
borderRadius: BorderRadius.circular(30.0),
),
child: Center(
child: Text(
"Submit",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
);
},
),
),
),
);
},
);
},
);
}
}
import 'package:flutter/material.dart';
class Taggenerator extends StatefulWidget {
const Taggenerator({super.key});
@override
State<Taggenerator> createState() => _TaggeneratorState();
}
class _TaggeneratorState extends State<Taggenerator> {
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
import 'package:flutter/material.dart';
class Taglocation extends StatefulWidget {
const Taglocation({super.key});
@override
State<Taglocation> createState() => _TaglocationState();
}
class _TaglocationState extends State<Taglocation> {
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
import 'package:flutter/material.dart';
import 'package:generp/Notifiers/NearByGeneratorsProvider.dart';
import 'package:generp/Utils/app_colors.dart';
import 'package:generp/Utils/commonWidgets.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:provider/provider.dart';
class Nearbygenerators extends StatefulWidget {
const Nearbygenerators({super.key});
......@@ -8,8 +13,61 @@ class Nearbygenerators extends StatefulWidget {
}
class _NearbygeneratorsState extends State<Nearbygenerators> {
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
var provider = Provider.of<Nearbygeneratorsprovider>(context,listen: false);
provider.getLocationPermission(context);
},);
}
@override
Widget build(BuildContext context) {
return const Placeholder();
return Consumer<Nearbygeneratorsprovider>(builder: (context, provider, child) {
return Scaffold(
appBar: appbar(context, "Nearby Generators"),
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),
child: Stack(children: [
GoogleMap(
myLocationEnabled: true,
zoomGesturesEnabled: true,
initialCameraPosition: CameraPosition(
target: provider.startLocation,
zoom: 14.0,
),
markers:provider.markers.toSet(),
mapType: MapType.normal,
onMapCreated: (controller) {
setState(() {
provider.mapController = controller;
});
},
onCameraMove: (position) {
provider.onCameraMove(context,position);
},
),
]),
),
),
],
),
),
),
);
},);
}
}
......@@ -78,10 +78,10 @@ class _PaymentdetailsState extends State<Paymentdetails> {
style: TextStyle(color: AppColors.app_blue),)),
SizedBox(height: 10,),
Text("Phone Number"),
Row(
children: [
Expanded(
child: DropdownButtonHideUnderline(
DropdownButtonHideUnderline(
child: Row(
children: [
Expanded(
child: DropdownButton2<Contacts>(
isExpanded: true,
hint: const Row(
......@@ -208,15 +208,15 @@ class _PaymentdetailsState extends State<Paymentdetails> {
),
),
),
),
],
],
),
),
SizedBox(height: 10,),
Text("Complaint Type"),
Row(
children: [
Expanded(
child: DropdownButtonHideUnderline(
DropdownButtonHideUnderline(
child: Row(
children: [
Expanded(
child: DropdownButton2<PaymentModeList>(
isExpanded: true,
hint: const Row(
......@@ -303,8 +303,8 @@ class _PaymentdetailsState extends State<Paymentdetails> {
),
),
),
),
],
],
),
),
SizedBox(height: 10,),
Text("Amount"),
......
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