Commit b76cf1af authored by Sai Srinivas's avatar Sai Srinivas
Browse files

06-05-2025 By Sai Srinivas

First Commit
LoginScreen.dart
HomeScreen.dart
WebERPScreen.dart
WebWhizzdomScreen.dart
parent aaf72461
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
toast(context,text) {
// OwnToast(context, text, "0");
Fluttertoast.showToast(
msg: text,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.black45,
textColor: Colors.white,
fontSize: 15.0,
);
}
\ No newline at end of file
import 'dart:io';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_ringtone_player/flutter_ringtone_player.dart';
import 'package:generp/Notifiers/Counter.dart';
import 'package:generp/Notifiers/HomeScreenNotifier.dart';
import 'package:generp/Notifiers/LogoutNotifier.dart';
import 'package:generp/Notifiers/ProfileNotifier.dart';
import 'package:generp/Notifiers/loginNotifier.dart';
import 'package:generp/Notifiers/splashVersionNotifier.dart';
import 'package:generp/Utils/SharedpreferencesService.dart';
import 'package:generp/screens/HomeScreen.dart';
import 'package:generp/screens/splash.dart';
import 'package:provider/provider.dart';
const AndroidNotificationChannel channel = AndroidNotificationChannel(
'generp_channel', // id
'generp_channel_name',
importance: Importance.max,
playSound: false);
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
String type = message.data['type'] ?? '';
if (type == 'offline_reminder') {
FlutterRingtonePlayer().play(
fromAsset: "assets/offline_reminder.mp3",
ios: IosSounds.glass, // Specify the iOS sound
);
} else if (type == 'normal') {
FlutterRingtonePlayer().play(
fromAsset: "assets/notification_sound.mp3",
ios: IosSounds.glass, // Specify the iOS sound
);
} else if (type == 'web_erp_notification') {
FlutterRingtonePlayer().play(
fromAsset: "assets/notification_sound.mp3",
ios: IosSounds.glass, // Specify the iOS sound
);
} else {
FlutterRingtonePlayer().play(
fromAsset: "assets/notification_sound.mp3",
// will be the sound on Android
ios: IosSounds.glass // will be the sound on iOS
);
}
if(kDebugMode){
print('A Background message just showed up: ${message.messageId}');
}
}
void main() async{
WidgetsFlutterBinding.ensureInitialized();
if(kDebugMode){
if (Firebase.apps.isNotEmpty) {
print("Firebase is initialized");
} else {
print("Firebase is not initialized");
}
}
if (Platform.isAndroid) {
await Firebase.initializeApp(
options: FirebaseOptions(
apiKey: "AIzaSyBmkmKdYfBt2n5QRlmZJ9MV_Amh9xR3UOY",
appId: "1:329382566569:android:26dc8519537b04deff67b8",
messagingSenderId: "329382566569",
projectId: "generp-fe09d",
),
);
} else if (Platform.isIOS) {
await Firebase.initializeApp();
}
FirebaseMessaging messaging = FirebaseMessaging.instance;
NotificationSettings settings = await messaging.requestPermission(
alert: true,
announcement: true,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: false,
);
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
RemoteNotification? notification = message.notification;
AndroidNotification? android = message.notification?.android;
print("msg");
String type = message.data['type'] ?? '';
if (type == 'offline_reminder') {
FlutterRingtonePlayer().play(
fromAsset: "assets/offline_reminder.mp3",
ios: IosSounds.glass, // Specify the iOS sound
);
} else if (type == 'normal') {
FlutterRingtonePlayer().play(
fromAsset: "assets/notification_sound.mp3",
ios: IosSounds.glass, // Specify the iOS sound
);
} else if (type == 'web_erp_notification') {
FlutterRingtonePlayer().play(
fromAsset: "assets/notification_sound.mp3",
ios: IosSounds.glass, // Specify the iOS sound
);
} else {
FlutterRingtonePlayer().play(
fromAsset:
"assets/notification_sound.mp3", // will be the sound on Android
ios: IosSounds.glass // will be the sound on iOS
);
}
});
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(channel);
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);
FirebaseMessaging.instance.getToken().then((value) {
String? token = value;
if(kDebugMode){
print("fbstoken:{$token}");
}
SharedpreferencesService().saveString("fbstoken", token!);
});
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
String type = message.data['type'] ?? '';
String redirectUrl = message.data['redirect_url'] ?? '';
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => Dashboard()),
// );
if(kDebugMode){
print('A new onMessageOpenedApp event was published!');
}
});
return MultiProvider(providers: [
ChangeNotifierProvider(create: (_)=>SplashVersionNotifier()),
ChangeNotifierProvider(create: (_)=>Loginnotifier()),
ChangeNotifierProvider(create: (_)=>Counter()),
ChangeNotifierProvider(create: (_)=>HomescreenNotifier()),
ChangeNotifierProvider(create: (_)=>ProfileNotifer()),
ChangeNotifierProvider(create: (_)=>LogoutNotifier()),
],
child: Builder(
builder: (BuildContext context){
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
fontFamily: 'Lexend',
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
hoverColor: Colors.transparent,
scaffoldBackgroundColor: Colors.white,
dialogBackgroundColor: Colors.white,
cardColor: Colors.white,
shadowColor: Colors.white54,
searchBarTheme: const SearchBarThemeData(),
tabBarTheme: const TabBarTheme(),
dialogTheme: const DialogTheme(
shadowColor: Colors.white,
surfaceTintColor: Colors.white,
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(5.0)), // Set the border radius of the dialog
),
),
buttonTheme: const ButtonThemeData(),
appBarTheme: const AppBarTheme(
shadowColor: Colors.white,
surfaceTintColor: Colors.white,
color: Colors.white,
),
cardTheme: const CardTheme(
shadowColor: Colors.white,
surfaceTintColor: Colors.white,
color: Colors.white,
//),
),
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
// overlayColor: MaterialStateProperty.all(Colors.white),
),
),
bottomSheetTheme: const BottomSheetThemeData(
surfaceTintColor: Colors.white, backgroundColor: Colors.white),
colorScheme: const ColorScheme.light(background: Colors.white)
.copyWith(background: Colors.white),
),
home: const Splash(),
);
},
),);
}
}
import 'package:flutter/material.dart';
class AttendanceScreen extends StatefulWidget {
const AttendanceScreen({super.key});
@override
State<AttendanceScreen> createState() => _AttendanceScreenState();
}
class _AttendanceScreenState extends State<AttendanceScreen> {
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:generp/Notifiers/Counter.dart';
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/WebERPScreen.dart';
import 'package:generp/screens/WebWhizzdomScreen.dart';
import 'package:provider/provider.dart';
import '../Utils/app_colors.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Timer? timer;
@override
void initState() {
// TODO: implement initState
var prov = Provider.of<HomescreenNotifier>(context, listen: false);
var prof_prov = Provider.of<ProfileNotifer>(context, listen: false);
Future.microtask(() {
prov.DashboardApiFunction(context);
});
Future.delayed(Duration(milliseconds: 600), () {
prof_prov.ProfileApiFunction(prov, context);
prof_prov.VersionApiFunction();
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Consumer2<HomescreenNotifier, ProfileNotifer>(
builder: (context, homescreen, profile, child) {
return Scaffold(
backgroundColor: AppColors.scaffold_bg_color,
body: Container(
child: Column(
children: [
Expanded(
flex: 3,
child: Container(
padding: EdgeInsets.symmetric(vertical: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30),
),
),
child: Container(
margin: EdgeInsets.only(
bottom: 15,
left: 15,
right: 15,
top: 30,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
gradient: LinearGradient(
colors: [AppColors.profile_card_gradient1, AppColors.profile_card_gradient2],
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 2,
child: SizedBox(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircleAvatar(
radius: 33,
foregroundImage: NetworkImage(
profile.profileImage,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 10,
height: 10,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.green,
),
),
SizedBox(width: 5),
Text(
"${homescreen.onlineStatus}",
style: TextStyle(
fontSize: 14,
color: Colors.black,
),
),
],
),
],
),
),
),
Expanded(
flex: 3,
child: SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
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(
width: 15,
height: 15,
child: Center(
child: SvgPicture.asset(
"assets/images/next_button.svg",
),
),
),
],
),
),
],
),
),
),
],
),
),
),
),
Expanded(
flex: 8,
child: Container(
padding: EdgeInsets.only(
left: 20,
right: 20,
top: 0,
bottom: 10,
),
child: GridView.builder(
itemCount: 8,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
),
itemBuilder: (context, index) {
var roles = homescreen.roleStatus;
final names = [
"Attendance",
"ERP",
"Gen Tracker",
"Service Engineer",
"Nearby",
"Inventory",
"Whizzdom",
"CRM",
];
return InkResponse(
onTap: () {
switch (names[index]) {
case "Attendance":
// Navigator.push(context,MaterialPageRoute(builder: (context) => AttendanceScreen()));
break;
case "ERP":
Navigator.push(context,MaterialPageRoute(builder: (context) => WebErpScreen(erp_url: homescreen.webPageUrl)));
break;
case "Gen Tracker":
// Navigator.push(context, MaterialPageRoute(builder: (context)=>GenTrackerDashboard()));
break;
case "Service Engineer":
// Navigator.push(context, MaterialPageRoute(builder: (context)=>GenTechnicianDashboard()));
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/images/home_icons_${index + 1}.svg",
),
Text(names[index]),
],
),
),
);
},
),
),
),
],
),
),
);
},
);
}
Future<void> _showProfileBottomSheet(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: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 5.0,
),
child: Row(
children: [
SizedBox(
height: 35,
child: Image.asset(
"assets/images/gen_horiz_logo.png",
),
),
Spacer(),
SizedBox(
height: 25,
width: 25,
child: SvgPicture.asset(
"assets/images/scanner.svg",
),
),
],
),
),
SizedBox(height: 15),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
gradient: LinearGradient(
colors: [AppColors.profile_card_gradient1, AppColors.profile_card_gradient2],
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.all(10),
child: CircleAvatar(
radius: 55,
foregroundImage: NetworkImage(
profile.profileImage,
),
),
),
Text(
"${profile.employeeName}",
style: TextStyle(
color: AppColors.app_blue,
fontSize: 16,
),
),
Text(
"${profile.employeeEmail}",
style: TextStyle(
color: AppColors.semi_black,
fontSize: 14,
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 20),
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: ListView.builder(
shrinkWrap: true,
itemCount: 5,
physics:
NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
final textHeadings = [
"Company",
"Branch",
"Designation",
"Employee ID",
"Mobile Number",
];
return SizedBox(
height: 40,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
"${textHeadings[index]}",
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 14,
color: AppColors.app_blue,
),
),
),
);
},
),
),
Expanded(
flex: 1,
child: ListView.builder(
shrinkWrap: true,
itemCount: 5,
physics:
NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
final textHeadings = [
profile.company,
profile.branch,
profile.designation,
profile.employeeeID,
profile.mobileNUmber,
];
return SizedBox(
height: 40,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
"${textHeadings[index].toString()}",
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 14,
color: AppColors.semi_black,
),
),
),
);
},
),
),
],
),
),
],
),
),
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(
"Logout",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
),
),
),
),
Text(
profile.releaseNotes,
style: TextStyle(
fontSize: 14,
color: AppColors.grey_thick,
),
),
],
),
);
},
),
),
);
},
);
},
);
}
}
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:generp/Notifiers/loginNotifier.dart';
import 'package:provider/provider.dart';
import 'package:share_plus/share_plus.dart';
import 'package:super_tooltip/super_tooltip.dart';
import '../Utils/app_colors.dart';
import '../Utils/commonServices.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
late ScrollController _scrollController;
late SuperTooltipController tooltipcontroller;
final List<String> logos = [
'assets/images/logo_1.png',
'assets/images/logo_2.png',
'assets/images/logo_3.png',
'assets/images/logo_4.png',
'assets/images/logo_5.png',
'assets/images/logo_6.png',
];
TextEditingController password = TextEditingController();
TextEditingController email = TextEditingController();
String platformname = "";
late FocusNode _emailFocusNode;
late FocusNode _passwordFocusNode;
bool _isTextFieldFocused = false;
KeyboardVisibilityController _keyboardVisibilityController =
KeyboardVisibilityController();
@override
void initState() {
super.initState();
Future.microtask(() {
final prov = Provider.of<Loginnotifier>(context, listen: false);
if(Platform.isAndroid){
prov.initAndroidId();
}else if(Platform.isIOS){
prov.getDevId();
}
});
tooltipcontroller = SuperTooltipController();
_scrollController = ScrollController();
_controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 75), // Adjust speed of scroll
)..addListener(() {
_scrollController.jumpTo(_controller.value * 10000);
if (_controller.value == 1.0) {
_controller.repeat();
_scrollController.jumpTo(0);
}
});
_controller.repeat();
_emailFocusNode = FocusNode();
_passwordFocusNode = FocusNode();
if (!mounted) return;
_emailFocusNode.addListener(() {
setState(() {
_isTextFieldFocused =
_emailFocusNode.hasFocus || _passwordFocusNode.hasFocus;
});
});
_passwordFocusNode.addListener(() {
setState(() {
_isTextFieldFocused =
_emailFocusNode.hasFocus || _passwordFocusNode.hasFocus;
});
});
_keyboardVisibilityController.onChange.listen((bool visible) {
if (visible) {
setState(() {
_isTextFieldFocused = true;
});
// print("Keyboard is visible${visibility}");
} else {
setState(() {
_isTextFieldFocused = false;
});
// print("Keyboard is not visible${visibility}");
}
});
}
@override
void dispose() {
_controller.dispose();
_scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
var loginProv = Provider.of<Loginnotifier>(context,listen: true);
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
return Scaffold(
backgroundColor: AppColors.scaffold_bg_color,
body: KeyboardVisibilityProvider(
controller: _keyboardVisibilityController,
child: Stack(
alignment: Alignment.center,
children: [
// Background scrolling logos
ListView.builder(
controller: _scrollController,
itemBuilder: (context, index) {
int logoIndex = index % logos.length;
return Padding(
padding: const EdgeInsets.all(5.0),
child: CustomGridRow(logos: logos, logoIndex: logoIndex),
);
},
),
AnimatedPositioned(
bottom: 0,
left: 0,
right: 0,
duration: Duration(milliseconds: 300),
child: Container(
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment(-0.00, -1.00),
end: Alignment(0, 1),
colors: [
Colors.white.withOpacity(0.0),
// Fully transparent at the very top
Colors.white.withOpacity(0.3),
// Light fade-in
Colors.white.withOpacity(0.6),
// Mid fade
Colors.white,
// Solid white for the rest
],
stops: [0.0, 0.05, 0.1, 0.15],
),
),
child: SingleChildScrollView(
child: Stack(
alignment: Alignment.center,
children: [
Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(
horizontal: 15,
vertical: 10,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
AnimatedContainer(
duration: const Duration(milliseconds: 1200),
curve: Curves.easeInOut,
child:
_isTextFieldFocused
? Row(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: SizedBox(width: 10),
),
Expanded(
flex: 2,
child: Image.asset(
"assets/images/gen_logo.png",
),
),
const SizedBox(width: 10),
Expanded(
flex: 3,
child: Text(
"GEN ERP",
style: TextStyle(
fontFamily: 'LexendSemiBold',
color: AppColors.ERP_text_color,
fontSize: 25,
),
),
),
Expanded(
flex: 1,
child: SizedBox(width: 10),
),
],
)
: Column(
children: [
Container(
width: 180,
height: 120,
child: Image.asset(
"assets/images/gen_logo.png",
),
),
Text(
"GEN ERP",
style: TextStyle(
fontFamily: 'LexendSemiBold',
color: AppColors.ERP_text_color,
fontSize: 25,
),
),
],
),
),
Text(
"Login to enter",
style: TextStyle(
fontSize: 14,
color: AppColors.app_blue,
),
),
Container(
alignment: Alignment.topLeft,
child: Text(
"Enter Email",
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: _emailFocusNode.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: email,
keyboardType: TextInputType.emailAddress,
focusNode: _emailFocusNode,
style: TextStyle(
fontSize: 14
),
onChanged: (value) {
loginProv.updateEmail(email.text);
},
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 Email',
),
),
),
),
if (loginProv.emailError != null) ...[
Container(
alignment: Alignment.topLeft,
margin: EdgeInsets.only(
top: 2.5,
bottom: 2.5,
left: 25,
),
child: Text(
loginProv.emailError,
textAlign: TextAlign.start,
style: TextStyle(color: Colors.red),
),
),
] else ...[
SizedBox(height: 15.0),
],
Container(
alignment: Alignment.topLeft,
child: Text(
"Enter Password",
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: _passwordFocusNode.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,
0,
0,
),
child: TextField(
controller: password,
focusNode: _passwordFocusNode,
obscureText: !loginProv.pwdVisible,
keyboardType: TextInputType.visiblePassword,
style: TextStyle(
fontSize: 14
),
onChanged: (value) {
loginProv.updatePassword(password.text);
},
onEditingComplete: () {
},
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(
0,
10,
0,
0,
),
hintText: "Enter Password",
suffixIcon: IconButton(
icon: Icon(
loginProv.pwdVisible
? CupertinoIcons.eye_solid
: CupertinoIcons.eye_slash_fill,
size: 30,
),
onPressed: () {
loginProv.visibility_ov();
},
),
hintStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
),
isDense: true,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
),
),
),
),
if (loginProv.passwordError != null) ...[
Container(
alignment: Alignment.topLeft,
margin: EdgeInsets.only(
top: 2.5,
bottom: 2.5,
left: 25,
),
child: Text(
loginProv.passwordError,
textAlign: TextAlign.start,
style: TextStyle(color: Colors.red),
),
),
] else ...[
SizedBox(height: 25.0),
],
Container(
child: InkWell(
onTap: () {
// LoginApiFunction();
loginProv.LoginApiFunction(context, email.text, password.text);
var f = FocusScope.of(context);
if (!f.hasPrimaryFocus) {
f.unfocus();
}
// Navigator.push(context,MaterialPageRoute(builder: (context)=>Profile()));
},
child: Container(
alignment: Alignment.center,
height: 45,
width: screenWidth,
margin: EdgeInsets.only(
left: 5.0,
right: 5.0,
),
decoration: BoxDecoration(
color: loginProv.isButtonEnabled?AppColors.app_blue:AppColors.button_disabled, //1487C9
borderRadius: BorderRadius.circular(30.0),
),
child: Center(
child: Text(
"Login",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
),
),
),
),
),
],
),
),
],
),
),
),
),
Positioned(
top: 50,
right: 20,
child: InkResponse(
child: GestureDetector(
onTap: () async {
await tooltipcontroller.showTooltip();
},
child: SuperTooltip(
controller: tooltipcontroller,
popupDirection: TooltipDirection.down,
backgroundColor: Colors.white,
borderColor: Colors.white,
showCloseButton: true,
left: 50,
right: 30,
barrierColor: Colors.transparent,
arrowTipDistance: 20.0,
minimumOutsideMargin: 120,
arrowBaseWidth: 20.0,
arrowLength: 20.0,
borderWidth: 2.0,
constraints: const BoxConstraints(
minHeight: 0.0,
maxHeight: 100,
minWidth: 0.0,
maxWidth: 100,
),
touchThroughAreaShape: ClipAreaShape.rectangle,
touchThroughAreaCornerRadius: 30,
content: Container(
height: 100,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text("Device ID",
style: TextStyle(
fontSize: 16,
color: AppColors.app_blue
),),
SizedBox(height: 15,),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
height: 50,
padding: EdgeInsets.symmetric(horizontal: 10,vertical: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(18),
color: AppColors.text_field_color
),
child: Row(
children: [
Container(
width: 180,
height: 45,
alignment: Alignment.center,
margin: EdgeInsets.only(right: 5.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0)),
child: Text(
'${loginProv.deviceId}',
style: TextStyle(
fontSize: 16,
color: AppColors.semi_black
),
)),
Container(
child: InkWell(
onTap: () async {
Clipboard.setData(ClipboardData(text: loginProv.deviceId.trim()));
toast(context, "Device ID has been copied!");
},
child: Icon(
Icons.copy
),
),
),
],
),
),
Spacer(),
Container(
width: 60,
height: 50,
decoration: BoxDecoration(
color: AppColors.app_blue,
borderRadius: BorderRadius.circular(18)
),
child: InkWell(
onTap: () {
Share.share("${loginProv.deviceId}");
},
child: Icon(
Icons.share_outlined,
color: Colors.white,
),
)),
],
),
],
),
),
child: Align(
alignment: Alignment.topRight,
child: Container(
width: 100,
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: AppColors.overlay_box_color,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColors.app_blue, width: 0.5),
),
child: Center(
child: Text(
"Device ID",
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.app_blue,
fontSize: 14,
),
),
),
),
),
),
),
),
),
],
),
),
);
}
}
class CustomGridRow extends StatelessWidget {
final List<String> logos;
final int logoIndex;
const CustomGridRow({
super.key,
required this.logos,
required this.logoIndex,
});
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
LogoWidget(imagePath: logos[logoIndex % logos.length]),
LogoWidget(imagePath: logos[(logoIndex + 1) % logos.length]),
LogoWidget(imagePath: logos[(logoIndex + 2) % logos.length]),
LogoWidget(imagePath: logos[(logoIndex + 3) % logos.length]),
],
);
}
}
class LogoWidget extends StatelessWidget {
final String imagePath;
const LogoWidget({super.key, required this.imagePath});
@override
Widget build(BuildContext context) {
return Container(
width: 80,
height: 80,
decoration: BoxDecoration(
image: DecorationImage(image: AssetImage(imagePath), fit: BoxFit.cover),
),
);
}
}
import 'package:flutter/cupertino.dart';
class UpdatepasswordScreen extends StatefulWidget {
const UpdatepasswordScreen({super.key});
@override
State<UpdatepasswordScreen> createState() => _UpdatepasswordScreenState();
}
class _UpdatepasswordScreenState extends State<UpdatepasswordScreen> {
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_download_manager/flutter_download_manager.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_svg/svg.dart';
import 'package:generp/Utils/app_colors.dart';
import 'package:generp/services/api_calling.dart';
import 'package:permission_handler/permission_handler.dart';
import 'dart:math';
import 'package:flutter/widgets.dart';
const MAX_PROGRESS = 100;
Future main() async {
await FlutterDownloader.initialize(
debug: true // optional: set false to disable printing logs to console
);
await Permission.storage.request();
}
class WebErpScreen extends StatefulWidget {
final String erp_url;
const WebErpScreen({super.key,required this.erp_url});
@override
State<WebErpScreen> createState() => _WebErpScreenState();
}
class _WebErpScreenState extends State<WebErpScreen> {
final Completer<InAppWebViewController> _controller =
Completer<InAppWebViewController>();
var empId = "";
var sessionId = "";
bool isLoading = true;
InAppWebViewController? webViewController;
PullToRefreshController? pullToRefreshController;
PullToRefreshSettings pullToRefreshSettings = PullToRefreshSettings(
color: AppColors.app_blue,
);
bool pullToRefreshEnabled = true;
final GlobalKey webViewKey = GlobalKey();
var dl = DownloadManager();
@override
void initState() {
// loadData();
pullToRefreshController = kIsWeb
? null
: PullToRefreshController(
settings: pullToRefreshSettings,
onRefresh: () async {
if (defaultTargetPlatform == TargetPlatform.android) {
webViewController?.reload();
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
webViewController?.loadUrl(
urlRequest:
URLRequest(url: await webViewController?.getUrl()));
}
},
);
// print("URL:${widget.url}");
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
if (await webViewController!.canGoBack()) {
webViewController!.goBack();
return false; // Prevent default back button behavior
}
return true; // Allow default back button behavior
},
child: Scaffold(
appBar: AppBar(
elevation: 0,
title: Container(
child: Row(
children: [
SizedBox(width: 10),
Container(
child: InkWell(
onTap: () => Navigator.pop(context, true),
child: Text("ERP",
textAlign: TextAlign.left,
style: TextStyle(
color: AppColors.semi_black,
fontSize: 18,
)),
),
),
],
)),
titleSpacing: 0,
leading: Container(
width: 10,
),
leadingWidth: 20,
),
body: Container(
child: Column(children: <Widget>[
Expanded(
child: Stack(
children: [
InAppWebView(
initialUrlRequest: URLRequest(
url: WebUri(widget.erp_url),
),
androidOnGeolocationPermissionsShowPrompt:
(InAppWebViewController controller, String origin) async {
return GeolocationPermissionShowPromptResponse(
origin: origin, allow: true, retain: true);
},
initialOptions: InAppWebViewGroupOptions(
android: AndroidInAppWebViewOptions(
useWideViewPort: true,
loadWithOverviewMode: true,
allowContentAccess: true,
geolocationEnabled: true,
allowFileAccess: true,
databaseEnabled: true, // Enables the WebView database
domStorageEnabled: true, // Enables DOM storage
builtInZoomControls:
true, // Enables the built-in zoom controls
displayZoomControls:
false, // Disables displaying zoom controls
safeBrowsingEnabled: true, // Enables Safe Browsing
clearSessionCache: true,
),
ios: IOSInAppWebViewOptions(
allowsInlineMediaPlayback: true,
),
),
androidOnPermissionRequest: (InAppWebViewController controller,
String origin, List<String> resources) async {
return PermissionRequestResponse(
resources: resources,
action: PermissionRequestResponseAction.GRANT);
},
onWebViewCreated: (controller) {
webViewController = controller;
_controller.complete(controller);
},
pullToRefreshController: pullToRefreshController,
onLoadStart: (controller, url) {
return setState(() {
isLoading = true;
});
},
onLoadStop: (controller, url) {
pullToRefreshController?.endRefreshing();
return setState(() {
isLoading = false;
});
},
onReceivedError: (controller, request, error) {
pullToRefreshController?.endRefreshing();
},
onProgressChanged: (controller, progress) {
if (progress == 100) {
pullToRefreshController?.endRefreshing();
}
},
onConsoleMessage: (controller, consoleMessage) {
if (kDebugMode) {
debugPrint("consoleMessage${consoleMessage}");
}
debugPrint(
"JavaScript console message: ${consoleMessage.message}");
},
onDownloadStartRequest: (controller, url) async {
await ApiCalling.download_files(
empId, sessionId, "${url.url}", context)
.then((data) => {debugPrint(data)});
},
),
if (isLoading) ...[Container(
color: Colors.white.withOpacity(0.7),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SpinKitRing(
color: AppColors.app_blue,
lineWidth: 4,
// duration: Duration(seconds: 2),
size: 50,
),
const SizedBox(
height: 15,
),
SizedBox(
width: 200,
child: Text(
"Please wait.......",
textAlign: TextAlign.center,
style: TextStyle(
decorationThickness: 0,
fontSize: 15,
fontWeight: FontWeight.normal,
color: AppColors.app_blue),
),
),
// SvgPicture.asset("/assets/images/NutsLoader.gif")
],
),
)]
],
))
])),
),
);
}
}
class SpinKitRing extends StatefulWidget {
const SpinKitRing({
Key? key,
required this.color,
this.lineWidth = 7.0,
this.size = 50.0,
this.duration = const Duration(milliseconds: 1200),
this.controller,
}) : super(key: key);
final Color color;
final double size;
final double lineWidth;
final Duration duration;
final AnimationController? controller;
@override
State<SpinKitRing> createState() => _SpinKitRingState();
}
class _SpinKitRingState extends State<SpinKitRing> with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _animation1;
late Animation<double> _animation2;
late Animation<double> _animation3;
@override
void initState() {
super.initState();
_controller = (widget.controller ?? AnimationController(vsync: this, duration: widget.duration))
..addListener(() {
if (mounted) {
setState(() {});
}
})
..repeat();
_animation1 = Tween(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(0.0, 1.0, curve: Curves.linear),
),
);
_animation2 = Tween(begin: -2 / 3, end: 1 / 2).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(0.5, 1.0, curve: Curves.linear),
),
);
_animation3 = Tween(begin: 0.25, end: 5 / 6).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(0.0, 1.0, curve: SpinKitRingCurve()),
),
);
}
@override
void dispose() {
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}
@override
Widget build(BuildContext context) {
return Center(
child: Transform(
transform: Matrix4.identity()..rotateZ((_animation1.value) * 5 * pi / 6),
alignment: FractionalOffset.center,
child: SizedBox.fromSize(
size: Size.square(widget.size),
child: CustomPaint(
foregroundPainter: RingPainter(
paintWidth: widget.lineWidth,
trackColor: widget.color,
progressPercent: _animation3.value,
startAngle: pi * _animation2.value,
),
),
),
),
);
}
}
class RingPainter extends CustomPainter {
RingPainter({
required this.paintWidth,
this.progressPercent,
this.startAngle,
required this.trackColor,
}) : trackPaint = Paint()
..color = trackColor
..style = PaintingStyle.stroke
..strokeWidth = paintWidth
..strokeCap = StrokeCap.square;
final double paintWidth;
final Paint trackPaint;
final Color trackColor;
final double? progressPercent;
final double? startAngle;
@override
void paint(Canvas canvas, Size size) {
final center = Offset(size.width / 2, size.height / 2);
final radius = (min(size.width, size.height) - paintWidth) / 2;
canvas.drawArc(
Rect.fromCircle(center: center, radius: radius),
startAngle!,
2 * pi * progressPercent!,
false,
trackPaint,
);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => true;
}
class SpinKitRingCurve extends Curve {
const SpinKitRingCurve();
@override
double transform(double t) => (t <= 0.5) ? 2 * t : 2 * (1 - t);
}
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_download_manager/flutter_download_manager.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:generp/Utils/app_colors.dart';
import 'package:permission_handler/permission_handler.dart';
import 'WebERPScreen.dart';
const MAX_PROGRESS = 100;
Future main() async {
await FlutterDownloader.initialize(
debug: true // optional: set false to disable printing logs to console
);
await Permission.storage.request();
}
class WebWhizzdomScreen extends StatefulWidget {
final String whizzdom_url;
const WebWhizzdomScreen({super.key,required this.whizzdom_url});
@override
State<WebWhizzdomScreen> createState() => _WebWhizzdomScreenState();
}
class _WebWhizzdomScreenState extends State<WebWhizzdomScreen> {
final Completer<InAppWebViewController> _controller =
Completer<InAppWebViewController>();
var empId = "";
var sessionId = "";
bool isLoading = true;
InAppWebViewController? webViewController;
PullToRefreshController? pullToRefreshController;
PullToRefreshSettings pullToRefreshSettings = PullToRefreshSettings(
color: AppColors.app_blue,
);
bool pullToRefreshEnabled = true;
final GlobalKey webViewKey = GlobalKey();
var dl = DownloadManager();
@override
void initState() {
// loadData();
pullToRefreshController = kIsWeb
? null
: PullToRefreshController(
settings: pullToRefreshSettings,
onRefresh: () async {
if (defaultTargetPlatform == TargetPlatform.android) {
webViewController?.reload();
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
webViewController?.loadUrl(
urlRequest:
URLRequest(url: await webViewController?.getUrl()));
}
},
);
// print("URL:${widget.url}");
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
if (await webViewController!.canGoBack()) {
webViewController!.goBack();
return false; // Prevent default back button behavior
}
return true; // Allow default back button behavior
},
child: Scaffold(
appBar: AppBar(
elevation: 0,
title: Container(
child: Row(
children: [
SizedBox(width: 10),
Container(
child: InkWell(
onTap: () => Navigator.pop(context, true),
child: Text("Whizzdom",
textAlign: TextAlign.left,
style: TextStyle(
color: AppColors.semi_black,
fontSize: 18,
)),
),
),
],
)),
titleSpacing: 0,
leading: Container(
width: 10,
),
leadingWidth: 20,
),
body: Container(
child: Column(children: <Widget>[
Expanded(
child: Stack(
children: [
InAppWebView(
initialUrlRequest: URLRequest(
url: WebUri(widget.whizzdom_url),
),
androidOnGeolocationPermissionsShowPrompt:
(InAppWebViewController controller, String origin) async {
return GeolocationPermissionShowPromptResponse(
origin: origin, allow: true, retain: true);
},
initialOptions: InAppWebViewGroupOptions(
android: AndroidInAppWebViewOptions(
useWideViewPort: true,
loadWithOverviewMode: true,
allowContentAccess: true,
geolocationEnabled: true,
allowFileAccess: true,
databaseEnabled: true, // Enables the WebView database
domStorageEnabled: true, // Enables DOM storage
builtInZoomControls:
true, // Enables the built-in zoom controls
displayZoomControls:
false, // Disables displaying zoom controls
safeBrowsingEnabled: true, // Enables Safe Browsing
clearSessionCache: true,
),
ios: IOSInAppWebViewOptions(
allowsInlineMediaPlayback: true,
),
),
androidOnPermissionRequest: (InAppWebViewController controller,
String origin, List<String> resources) async {
return PermissionRequestResponse(
resources: resources,
action: PermissionRequestResponseAction.GRANT);
},
onWebViewCreated: (controller) {
webViewController = controller;
_controller.complete(controller);
},
pullToRefreshController: pullToRefreshController,
onLoadStart: (controller, url) {
return setState(() {
isLoading = true;
});
},
onLoadStop: (controller, url) {
pullToRefreshController?.endRefreshing();
return setState(() {
isLoading = false;
});
},
onReceivedError: (controller, request, error) {
pullToRefreshController?.endRefreshing();
},
onProgressChanged: (controller, progress) {
if (progress == 100) {
pullToRefreshController?.endRefreshing();
}
},
),
if (isLoading) ...[Container(
color: Colors.white.withOpacity(0.7),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SpinKitRing(
color: AppColors.app_blue,
lineWidth: 4,
// duration: Duration(seconds: 2),
size: 50,
),
const SizedBox(
height: 15,
),
SizedBox(
width: 200,
child: Text(
"Please wait.......",
textAlign: TextAlign.center,
style: TextStyle(
decorationThickness: 0,
fontSize: 15,
fontWeight: FontWeight.normal,
color: AppColors.app_blue),
),
),
// SvgPicture.asset("/assets/images/NutsLoader.gif")
],
),
)]
],
))
])),
),
);
}
}
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:generp/services/api_calling.dart';
import 'package:provider/provider.dart';
import '../Notifiers/splashVersionNotifier.dart';
class Splash extends StatefulWidget {
const Splash({super.key});
@override
State<Splash> createState() => _SplashState();
}
class _SplashState extends State<Splash> {
late Image splashImage;
@override
void initState() {
// TODO: implement initState
super.initState();
splashImage = Image.asset("assets/images/ic_splash.jpg");
final spalshProvider = Provider.of<SplashVersionNotifier>(context,listen: false);
spalshProvider.initPackageInfo();
spalshProvider.handleVersionCheck(context);
}
@override
void didChangeDependencies() {
// TODO: implement didChangeDependencies
super.didChangeDependencies();
precacheImage(splashImage.image, context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Consumer<SplashVersionNotifier>(builder: (context, value, child) {
return Container(
alignment: Alignment.center,
child: Container(
alignment: Alignment.center,
height: 300,
width: 300,
child: splashImage,
));
}
),
);
}
}
import 'dart:convert';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:generp/services/api_names.dart';
import 'package:generp/services/api_post_request.dart';
import 'package:path_provider/path_provider.dart';
import '../Models/AccountSuggestionResponse.dart';
import '../Models/AddContactResponse.dart';
import '../Models/AttendanceListResponse.dart';
import '../Models/CheckInResponse.dart';
import '../Models/CheckOutResponse.dart';
import '../Models/ComplaintsSelectionResponse.dart';
import '../Models/DashboardResponse.dart';
import '../Models/DayWiseAttendance.dart';
import '../Models/FollowUpResponse.dart';
import '../Models/Inventory_Part_details_response.dart';
import '../Models/LoginQRResponse.dart';
import '../Models/LogoutResponse.dart';
import '../Models/NearbyGeneratorsResponse.dart';
import '../Models/PaymentCollectionResponse.dart';
import '../Models/PaymentCollectionValidateOTPResponse.dart';
import '../Models/PaymentCollectionWalletResponse.dart';
import '../Models/ProfileResponse.dart';
import '../Models/SessionResponse.dart';
import '../Models/StatusResponse.dart';
import '../Models/SubmitComplaintResponse.dart';
import '../Models/TagGeneratorResponse.dart';
import '../Models/TagLocationResponse.dart';
import '../Models/TechnicianAddPaymentCollectionResponse.dart';
import '../Models/TechnicianDashboardResponse.dart';
import '../Models/TechnicianLoadNumbersResponse.dart';
import '../Models/TechniciansPendingComplaintsResponse.dart';
import '../Models/TodayVisitResponse.dart';
import '../Models/UpdateComplaintResponse.dart';
import '../Models/UpdatePasswordResponse.dart';
import '../Models/VersionsResponse.dart';
import '../Models/ViewVisitDetailsResponse.dart';
import '../Models/generatorComplaintResponse.dart';
import '../Models/loadGeneratorDetailsResponse.dart';
import '../Utils/commonServices.dart';
class ApiCalling {
static Future download_files(empId, session, url, cntxt) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, url, {});
if (res != null) {
final bytes = res.bodyBytes;
var directory = "";
if (Platform.isAndroid) {
directory = "/storage/emulated/0/Download";
var _directory = Directory(directory);
if (!_directory.existsSync()) {
// If the directory does not exist, create it
_directory.createSync(recursive: true);
debugPrint('Directory created: $_directory');
} else {
debugPrint('Directory already exists: $_directory');
}
// final androiddirectory = await getDownloadsDirectory();
// directory = androiddirectory!.path;
} else if (Platform.isIOS) {
final iosDirectory = await getApplicationSupportDirectory();
directory = iosDirectory!.path;
}
final contentDisposition = res.headers['content-disposition'];
debugPrint(
"contentDisposition ${contentDisposition?.split('filename=')[1]}");
// final filename = contentDisposition != null
// ? contentDisposition.split('filename=')[1]
// : 'file';
var filename =
(contentDisposition?.split('filename=')[1])?.replaceAll('"', "");
// ignore: unnecessary_brace_in_string_interps
final file = File('${directory}/${filename}');
await file.writeAsBytes(bytes);
toast(
cntxt, "File saved to your downloads as ${filename} to ${directory}, Successfully");
debugPrint('File saved successfully');
return jsonDecode(res.body);
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<VersionsResponse?> checkAppVersionApi() async {
try{
final response = await post( {},getAppVersionUrl, {});
if(response!=null){
return VersionsResponse.fromJson(jsonDecode(response.body));
}else {
return null;
}
}catch (e,s){
return null;
}
}
static Future<SessionResponse?>CheckSessionExistsApi(empId, session) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
print(data);
final res = await post(data, getEmployeeSessionDetailsUrl, {});
if (res != null) {
print("check_session: ${res.body}");
return SessionResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<StatusResponse?> LoginFunctionApi(
email, password, token, deviceID, deviceInfo) async {
try {
Map<String, String> data = {
'email_id': (email).toString(),
'password': (password).toString(),
'token_id': (token).toString(),
'device_id': (deviceID).toString(),
'device_details': (deviceInfo).toString()
};
final res = await post(data, loginUrl, {});
if (res != null) {
debugPrint("Login: ${res.body}");
print(data);
return StatusResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<UpdatePasswordResponse?> UpdatePasswordApi(
empId, session, password, conf_password) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'password': (password).toString(),
'confirm_password': (conf_password).toString()
};
final res = await post(data, updatePasswordUrl, {});
if (res != null) {
debugPrint("update password ${res.body}");
return UpdatePasswordResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<DashboardResponse?> DashboardFunctionApi(empId, session) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, employeeDashboardUrl, {});
if (res != null) {
debugPrint("Dashboard: ${res.body}");
return DashboardResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<ProfileResponse?> ProfileFunctionApi(empId, session) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, employeeProfileUrl, {});
if (res != null) {
debugPrint("profile-details: ${res.body}");
return ProfileResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<LoginQRResponse?> QRLoginRequestAPI(
empId, session, type, token) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'type': (type).toString(),
'token': (token).toString(),
};
final res = await post(data, qrCodeLoginUrl, {});
if (res != null) {
debugPrint(res.body);
return LoginQRResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<LogoutResponse?> LogoutFunctionApi(empId, session) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, logoutAppUrl, {});
if (res != null) {
debugPrint(res.body);
return LogoutResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<CheckInResponse?> CheckInApi(
empId, sessioId, location, latlngs, check_in_pic) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (sessioId).toString(),
'posit': (latlngs).toString(),
'location': (location).toString(),
};
var res;
if (check_in_pic != null) {
res = await postImage(data, employeeChekInUrl, {}, check_in_pic);
res = jsonDecode(res);
} else {
res = await post(data, employeeChekInUrl, {});
res = jsonDecode(res);
}
if (res != null) {
debugPrint(res);
return CheckInResponse.fromJson(res);
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<CheckOutResponse?> CheckOutApi(
empId, sessioId, location, latlngs, image) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (sessioId).toString(),
'location': (location).toString(),
'posit': (latlngs).toString(),
};
var res;
if (image != null) {
res = await postImage2(data, {}, employeeCheckOutUrl, image);
res = jsonDecode(res);
} else {
res = await post(data, employeeCheckOutUrl, {});
res = jsonDecode(res);
}
if (res != null) {
debugPrint(res);
return CheckOutResponse.fromJson(res);
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<AttendanceDashboard?> AttendanceListApi(empId, session) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, employeeAttendanceDashboardUrl, {});
if (res != null) {
debugPrint(res.body);
return AttendanceDashboard.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static LoadAttendanceDetails(empId, session, month, year) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'year': (year).toString(),
'month': month.toString()
};
final res = await post(data, employeeMonthwiseAttendanceUrl, {});
if (res != null) {
debugPrint(res.body);
// return AttendanceHistory.fromJson(jsonDecode(res.body));
return res.body;
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<AttendanceDaywiseResponse?> DateWiseAttendanceApi(
empId, session, date) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'date': (date).toString(),
};
final res = await post(data, employeeDayAttendanceDetailsUrl, {});
if (res != null) {
debugPrint(res.body);
return AttendanceDaywiseResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
///gen tracker
static Future<loadGeneratorDetailsResponse?> LoadGeneratorDetailsAPI(
empId, session, gen_hash_id) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'gen_hash_id': (gen_hash_id).toString(),
};
final res = await post(data, genTrackerGeneratorDetailsUrl, {});
if (res != null) {
debugPrint(res.body);
return loadGeneratorDetailsResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<generatorComplaintResponse?> LoadGeneratorComplaintListAPI(
empId, session, gen_id, open_status) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'gen_id': (gen_id).toString(),
'open_status': (open_status).toString()
};
final res = await post(data, genTrackerGeneratorComplaintsUrl, {});
if (res != null) {
debugPrint(res.body);
return generatorComplaintResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<TagLocationResponse?> TagLocationAPI(
empId, session, gen_hash_id, location) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'gen_hash_id': (gen_hash_id).toString(),
'location': (location).toString()
};
final res = await post(data, genTrackerTagLocationUrl, {});
if (res != null) {
debugPrint(res.body);
return TagLocationResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<TagGeneratorResponse?> TagGeneratorAPI(
empId, session, gen_hash_id, engine_no) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'gen_hash_id': (gen_hash_id).toString(),
'engine_no': (engine_no).toString()
};
final res = await post(data, genTrackerTagGeneratorUrl, {});
if (res != null) {
debugPrint(res.body);
return TagGeneratorResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<SubmitComplaintResponse?> SubmitGeneratorComplaintAPI(
empId,
session,
complaint_type_id,
complaint_category_id,
complaint_desc_id,
running_hrs,
gen_id,
complaint_note) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'complaint_type_id': (complaint_type_id).toString(),
'complaint_category_id': (complaint_category_id).toString(),
'complaint_desc_id': (complaint_desc_id).toString(),
'running_hrs': (running_hrs).toString(),
'gen_id': (gen_id).toString(),
'complaint_note': (complaint_note).toString()
};
final res = await post(data, genTrackerRegisterComplaint, {});
if (res != null) {
debugPrint(res.body);
return SubmitComplaintResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<ComplaintsSelectionResponse?> ComplaintSelectionAPI(
empId, session, gen_hash_id) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'gen_hash_id': (gen_hash_id).toString(),
};
final res = await post(data, complaintsSelectionUrl, {});
if (res != null) {
debugPrint(res.body);
return ComplaintsSelectionResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
///Inventory Module API's
static Future<Inventory_Part_details_response?> LoadPartDetailsAPI(
empId, session, part_id) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'part_id': (part_id).toString(),
};
final res = await post(data, inventoryPartDetailsUrl, {});
if (res != null) {
debugPrint(res.body);
return Inventory_Part_details_response.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<loadGeneratorDetailsResponse?> InventoryUpdateStockAPI(
empId, session, qty, descr, part_id, tran_type) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'qty': (qty).toString(),
'descr': (descr).toString(),
'product_id': (part_id).toString(),
'tran_type': (tran_type).toString(),
};
final res = await post(data, inventoryStockUpdateUrl, {});
if (res != null) {
debugPrint(res.body);
return loadGeneratorDetailsResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
///technician
static Future<loadGeneratorDetailsResponse?>
LoadTechnicianGeneratorDetailsAPI(empId, session, gen_id) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'gen_id': (gen_id).toString(),
};
final res = await post(data, technicianGeneratorDetailsUrl, {});
if (res != null) {
debugPrint(res.body);
return loadGeneratorDetailsResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<TechnicianResponse?> loadTechnicianDashboardApi(
empId, session) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, technicianDashboardUrl, {});
if (res != null) {
debugPrint(res.body);
return TechnicianResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<TodayVisitResponse?> getTodayVisitsListAPI(
empId, session) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, technicianTodayVisitsUrl, {});
if (res != null) {
debugPrint(res.body);
return TodayVisitResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<TodayVisitResponse?> getMonthVisitsListAPI(
empId, session) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, technicianMonthlyVisitsUrl, {});
if (res != null) {
debugPrint(res.body);
return TodayVisitResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<NearbyGeneratorsResponse?> loadNearbyGeneratorsAPI(
empId, session, tech_loc, radius,status) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'tech_loc': (tech_loc).toString(),
'radius': (radius).toString(),
'status': (status).toString(),
};
final res = await post(data, technicianNearbyGeneratorsUrl, {});
if (res != null) {
debugPrint(res.body);
return NearbyGeneratorsResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<AccountSuggestionResonse?> AccountSuggestionAPI(
empId, session, search_string) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'search_string': (search_string).toString(),
};
final res = await post(data, technicianAccountSearchUrl, {});
if (res != null) {
debugPrint(res.body);
return AccountSuggestionResonse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<TechnicianPendingComplaintsResponse?>
LoadTechnicianComplaintsAPI(empId, session) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, technicianPendingComplaintUrl, {});
if (res != null) {
debugPrint(res.body);
return TechnicianPendingComplaintsResponse.fromJson(
jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<TechnicianLoadNumbersResponse?> LoadContactsTechnicianAPI(
empId, session, type, gen_id, account_id) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'type': (type).toString(),
'gen_id': (gen_id).toString(),
'account_id': (account_id).toString(),
};
final res = await post(data, technicianAddPaymentUrl, {});
if (res != null) {
debugPrint(res.body);
return TechnicianLoadNumbersResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<TechnicianAddPaymentCollectionResponse?>
TechnicianUpdatepaymentAPI(
empId,
session,
ref_type,
ref_id,
payment_mode_id,
payment_ref_no,
amount,
otp_validated_name,
otp_validated_mobile_number,
payment_proof) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'ref_type': (ref_type).toString(),
'ref_id': (ref_id).toString(),
'payment_mode_id': (payment_mode_id).toString(),
'payment_ref_no': (payment_ref_no).toString(),
'amount': (amount).toString(),
'otp_validated_name': (otp_validated_name).toString(),
'otp_validated_mobile_number': (otp_validated_mobile_number).toString(),
};
var res;
if (payment_proof != null) {
res = await postImage3(data, {}, technicianAddPaymentCollectionUrl, payment_proof);
res = jsonDecode(res);
} else {
res = await post(data, technicianAddPaymentCollectionUrl, {});
res = jsonDecode(res);
}
if (res != null) {
debugPrint(res);
return TechnicianAddPaymentCollectionResponse.fromJson(res);
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<PaymentCollectionValidateOTPResponse?>
TechnicianPaymentOTPValidateAPI(
empId, session, payment_collection_id, otp) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'payment_collection_id': (payment_collection_id).toString(),
'otp': (otp).toString(),
};
final res = await post(data, technicianPaymentCollectionOtpUrl, {});
if (res != null) {
debugPrint(res.body);
return PaymentCollectionValidateOTPResponse.fromJson(
jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<PaymentCollectionResponse?> paymentCollectionListAPI(
empId,
session,
) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, technicianPaymentCollectionUrl, {});
if (res != null) {
debugPrint(res.body);
return PaymentCollectionResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<PaymentCollectionWalletResponse?> loadTransactionsListAPI(
empId, session) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
};
final res = await post(data, technicianWalletCollectionUrl, {});
if (res != null) {
debugPrint(res.body);
return PaymentCollectionWalletResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<ViewVisitDetailsResponse?> loadVisitDetailsAPI(
empId, session, comp_id) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'comp_id': (comp_id).toString(),
};
final res = await post(data, technicianComplaintDetailsUrl, {});
if (res != null) {
debugPrint(res.body);
return ViewVisitDetailsResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<FollowupListResponse?> loadFollowupListAPI(
empId, session, comp_id) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'comp_id': (comp_id).toString(),
};
final res = await post(data, technicianComplaintFollowUpUrl, {});
if (res != null) {
debugPrint(res.body);
return FollowupListResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<AddContactResponse?> AddContactAPI(empId, session, gen_id, name,
designation, mob1, mob2, tel, mail, type, account_id) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'gen_id': (gen_id).toString(),
'name': (name).toString(),
'designation': (designation).toString(),
'mob1': (mob1).toString(),
'mob2': (mob2).toString(),
'tel': (tel).toString(),
'mail': (mail).toString(),
'type': (type).toString(),
'account_id': (account_id).toString(),
};
final res = await post(data, technicianAddContactUrl, {});
if (res != null) {
debugPrint(res.body);
return AddContactResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
static Future<UpdateComplaintResponse?> UpdateComplaintAPI(
empId,
session,
complaint_id,
in_time,
feedback,
fsr_no,
running_hrs,
complaint_status,
fsr_file) async {
try {
Map<String, String> data = {
'emp_id': (empId).toString(),
'session_id': (session).toString(),
'complaint_id': (complaint_id).toString(),
'in_time': (in_time).toString(),
'feedback': (feedback).toString(),
'fsr_no': (fsr_no).toString(),
'running_hrs': (running_hrs).toString(),
'complaint_status': (complaint_status).toString(),
};
var res;
if (fsr_file != null) {
res = await postImage4(data, {}, technicianUpdateVisitUrl, fsr_file);
res = jsonDecode(res);
} else {
res = await post(data, technicianUpdateVisitUrl, {});
res = jsonDecode(res);
}
if (res != null) {
debugPrint(res);
return UpdateComplaintResponse.fromJson(res);
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint('hello bev=bug $e ');
return null;
}
}
}
\ No newline at end of file
const baseUrl = "https://erp.gengroup.in/ci/app/";
// var WEB_SOCKET_URL = "wss://ws.erp.gengroup.in/?type=user&route=employe_live_location_update&session_id=${Sessionid}";
const getAppVersionUrl = "https://erp.gengroup.in/ci/assets/appversion.json";
///logins
const loginUrl = "${baseUrl}auth/login";
const getEmployeeSessionDetailsUrl ="${baseUrl}home/get_session_det";
const updatePasswordUrl = "${baseUrl}home/update_password";
const qrCodeLoginUrl = "${baseUrl}home/login_qr_code_submit";
const logoutAppUrl = "${baseUrl}home/logout";
///employee
const employeeDashboardUrl = "${baseUrl}home/emp_dashboard";
const employeeProfileUrl = "${baseUrl}home/emp_profile";
const employeeChekInUrl = "${baseUrl}home/attendance_check_in";
const employeeCheckOutUrl = "${baseUrl}home/attendance_check_out";
const employeeAttendanceDashboardUrl = "${baseUrl}home/attendance_dashboard";
const employeeMonthwiseAttendanceUrl = "${baseUrl}home/attendance_monthwise_det";
const employeeDayAttendanceDetailsUrl = "${baseUrl}home/attendance_day_det";
///gentracker
const genTrackerGeneratorDetailsUrl = "${baseUrl}home/gen_tracker_generator_details";
const genTrackerGeneratorComplaintsUrl = "${baseUrl}home/gen_tracker_generator_complaints_list";
const genTrackerTagLocationUrl = "${baseUrl}home/gen_tracker_tag_location";
const genTrackerTagGeneratorUrl = "${baseUrl}home/gen_tracker_tag_generator";
const genTrackerRegisterComplaint = "${baseUrl}home/gen_tracker_register_complaint";
///complaint
const complaintsSelectionUrl = "${baseUrl}home/compliants_select_data";
///inventory
const inventoryPartDetailsUrl = "${baseUrl}home/inventory_part_details";
const inventoryStockUpdateUrl = "${baseUrl}home/inventory_update_stock";
///technician
const technicianDashboardUrl= "${baseUrl}home/technician_dashboard";
const technicianGeneratorDetailsUrl = "${baseUrl}home/technician_generator_details";
const technicianAccountSearchUrl= "${baseUrl}home/technician_search_account_list";
const technicianPendingComplaintUrl= "${baseUrl}home/technician_pending_complaints";
const technicianTodayVisitsUrl= "${baseUrl}home/technician_todays_visits";
const technicianMonthlyVisitsUrl= "${baseUrl}home/technician_monthly_visits";
const technicianNearbyGeneratorsUrl= "${baseUrl}home/technician_nearby_generators";
const technicianAddPaymentUrl= "${baseUrl}home/technician_add_payment_det";
const technicianAddPaymentCollectionUrl= "${baseUrl}home/technician_add_payment_collection";
const technicianPaymentCollectionOtpUrl= "${baseUrl}home/technician_payment_collection_validate_otp";
const technicianPaymentCollectionUrl= "${baseUrl}home/technician_payment_collection_list";
const technicianWalletCollectionUrl= "${baseUrl}home/technician_payment_collection_wallet";
const technicianComplaintDetailsUrl= "${baseUrl}home/technician_complaint_details";
const technicianComplaintFollowUpUrl= "${baseUrl}home/technician_complaint_followup_list";
const technicianAddContactUrl= "${baseUrl}home/technician_add_contact";
const technicianUpdateVisitUrl= "${baseUrl}home/technician_update_visit";
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;
Future<http.Response?> post(Map<String,dynamic> Body,
api_url,Map<String,String> Headers) async{
http.Response? response;
try{
response = await http.post(Uri.parse(api_url),headers: Headers,body: Body);
return response;
}on Exception catch (e,s){
print(e);
print(s);
}
return response;
}
Future<http.Response?> get(api_url,Map<String,String> Headers) async{
http.Response? response;
try{
response = await http.get(Uri.parse(api_url),headers: Headers);
return response;
}on Exception catch (e,s){
print(e);
print(s);
}
return response;
}
Future<String?> postImage(Map<String, String> body, String urlLink,
Map<String, String> headers, File image) async {
try {
var req = http.MultipartRequest('POST', Uri.parse(urlLink));
req.headers.addAll(headers);
req.files.add(await http.MultipartFile.fromPath('check_in_pic', image.path));
req.fields.addAll(body);
var res = await req.send();
final resBody = await res.stream.bytesToString();
if (res.statusCode >= 200 && res.statusCode < 300) {
print("**** $resBody .... $res");
return resBody;
} else {
print("error: ${res.reasonPhrase}");
return null;
}
} catch (e) {
debugPrint(e.toString());
return null;
}
}
Future<String?> postImage2(Map<String, String> body,Map<String, String> headers, String urlLink,
File image) async {
try {
var req = http.MultipartRequest('POST', Uri.parse(urlLink));
req.headers.addAll(headers);
req.files.add(await http.MultipartFile.fromPath('check_out_pic', image.path));
req.fields.addAll(body);
var res = await req.send();
final resBody = await res.stream.bytesToString();
if (res.statusCode >= 200 && res.statusCode < 300) {
print("**** $resBody .... $res");
return resBody;
} else {
print("error: ${res.reasonPhrase}");
return null;
}
} catch (e) {
debugPrint(e.toString());
return null;
}
}
Future<String?> postImage3(Map<String, String> body,Map<String, String> headers, String urlLink,
File image) async {
try {
var req = http.MultipartRequest('POST', Uri.parse(urlLink));
req.headers.addAll(headers);
req.files.add(await http.MultipartFile.fromPath('payment_proof', image.path));
req.fields.addAll(body);
var res = await req.send();
final resBody = await res.stream.bytesToString();
if (res.statusCode >= 200 && res.statusCode < 300) {
print("**** $resBody .... $res");
return resBody;
} else {
print("error: ${res.reasonPhrase}");
return null;
}
} catch (e) {
debugPrint(e.toString());
return null;
}
}
Future<String?> postImage4 (Map<String, String> body,Map<String, String> headers, String urlLink,
File image) async {
try {
var req = http.MultipartRequest('POST', Uri.parse(urlLink));
req.headers.addAll(headers);
req.files.add(await http.MultipartFile.fromPath('fsr_file', image.path));
req.fields.addAll(body);
var res = await req.send();
final resBody = await res.stream.bytesToString();
if (res.statusCode >= 200 && res.statusCode < 300) {
print("**** $resBody .... $res");
return resBody;
} else {
print("error: ${res.reasonPhrase}");
return null;
}
} catch (e) {
debugPrint(e.toString());
return null;
}
}
Future<String?> PostMultipleImages(Map<String, String> body, String urlLink,
Map<String, String> headers, List<http.MultipartFile> newList) async {
try {
var req = http.MultipartRequest('POST', Uri.parse(urlLink));
req.headers.addAll(headers);
req.files.addAll(newList);
req.fields.addAll(body);
var res = await req.send();
final resBody = await res.stream.bytesToString();
if (res.statusCode >= 200 && res.statusCode < 300) {
print("**** $resBody .... $res");
return resBody;
} else {
print("error: ${res.reasonPhrase}");
return null;
}
} catch (e) {
debugPrint(e.toString());
return null;
}
}
\ No newline at end of file
flutter/ephemeral
# Project-level configuration.
cmake_minimum_required(VERSION 3.13)
project(runner LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "generp")
# The unique GTK application identifier for this application. See:
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
set(APPLICATION_ID "in.webgrid.generp")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW)
# Load bundled libraries from the lib/ directory relative to the binary.
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
# Root filesystem for cross-building.
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()
# Define build configuration options.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_14)
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
endfunction()
# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
# Application build; see runner/CMakeLists.txt.
add_subdirectory("runner")
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)
# Only the install-generated bundle's copy of the executable will launch
# correctly, since the resources must in the right relative locations. To avoid
# people trying to run the unbundled copy, put it in a subdirectory instead of
# the default top-level location.
set_target_properties(${BINARY_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
)
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
# === Installation ===
# By default, "installing" just makes a relocatable bundle in the build
# directory.
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
# Start with a clean build bundle directory every time.
install(CODE "
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
" COMPONENT Runtime)
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
install(FILES "${bundled_library}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endforeach(bundled_library)
# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
# Install the AOT library on non-Debug builds only.
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
# This file controls Flutter-level build steps. It should not be edited.
cmake_minimum_required(VERSION 3.10)
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
# Configuration provided via flutter tool.
include(${EPHEMERAL_DIR}/generated_config.cmake)
# TODO: Move the rest of this into files in ephemeral. See
# https://github.com/flutter/flutter/issues/57146.
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
# which isn't available in 3.10.
function(list_prepend LIST_NAME PREFIX)
set(NEW_LIST "")
foreach(element ${${LIST_NAME}})
list(APPEND NEW_LIST "${PREFIX}${element}")
endforeach(element)
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
endfunction()
# === Flutter Library ===
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
# Published to parent scope for install step.
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
list(APPEND FLUTTER_LIBRARY_HEADERS
"fl_basic_message_channel.h"
"fl_binary_codec.h"
"fl_binary_messenger.h"
"fl_dart_project.h"
"fl_engine.h"
"fl_json_message_codec.h"
"fl_json_method_codec.h"
"fl_message_codec.h"
"fl_method_call.h"
"fl_method_channel.h"
"fl_method_codec.h"
"fl_method_response.h"
"fl_plugin_registrar.h"
"fl_plugin_registry.h"
"fl_standard_message_codec.h"
"fl_standard_method_codec.h"
"fl_string_codec.h"
"fl_value.h"
"fl_view.h"
"flutter_linux.h"
)
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
add_library(flutter INTERFACE)
target_include_directories(flutter INTERFACE
"${EPHEMERAL_DIR}"
)
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
target_link_libraries(flutter INTERFACE
PkgConfig::GTK
PkgConfig::GLIB
PkgConfig::GIO
)
add_dependencies(flutter flutter_assemble)
# === Flutter tool backend ===
# _phony_ is a non-existent file to force this command to run every time,
# since currently there's no way to get a full input/output list from the
# flutter tool.
add_custom_command(
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/_phony_
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
"${FLUTTER_LIBRARY}"
${FLUTTER_LIBRARY_HEADERS}
)
//
// Generated file. Do not edit.
//
// clang-format off
#include "generated_plugin_registrant.h"
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
}
//
// Generated file. Do not edit.
//
// clang-format off
#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_
#include <flutter_linux/flutter_linux.h>
// Registers Flutter plugins.
void fl_register_plugins(FlPluginRegistry* registry);
#endif // GENERATED_PLUGIN_REGISTRANT_
#
# Generated file, do not edit.
#
list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_linux
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)
cmake_minimum_required(VERSION 3.13)
project(runner LANGUAGES CXX)
# Define the application target. To change its name, change BINARY_NAME in the
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
# work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME}
"main.cc"
"my_application.cc"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
)
# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})
# Add preprocessor definitions for the application ID.
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
# Add dependency libraries. Add any application-specific dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
#include "my_application.h"
int main(int argc, char** argv) {
g_autoptr(MyApplication) app = my_application_new();
return g_application_run(G_APPLICATION(app), argc, argv);
}
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