import 'dart:async'; import 'dart:io'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:generp/Utils/commonWidgets.dart'; import '../Utils/commonServices.dart'; import 'genTracker/ScanEnterGeneratorIDScreen.dart'; import 'hrm/HrmDashboardScreen.dart'; import 'notifierExports.dart'; import 'screensExports.dart'; import 'package:geolocator/geolocator.dart'; import 'package:provider/provider.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:location/location.dart' as loc; import '../Utils/app_colors.dart'; import 'inventory/InventoryScreen.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_html/flutter_html.dart' as html; class MyHomePage extends StatefulWidget { const MyHomePage({super.key}); @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { Timer? timer; Map _source = {ConnectivityResult.mobile: true}; final MyConnectivity _connectivity = MyConnectivity.instance; @override void initState() { // TODO: implement initState _connectivity.initialise(); _connectivity.myStream.listen((source) { setState(() => _source = source); }); var prov = Provider.of(context, listen: false); var prof_prov = Provider.of(context, listen: false); // var jobDisc_prov = Provider.of(context, listen: false); Future.microtask(() { prov.DashboardApiFunction(context); }); Future.delayed(Duration(milliseconds: 600), () { prof_prov.ProfileApiFunction(prov, context); prof_prov.VersionApiFunction(); }); super.initState(); } Future onBackPressed() async { return await showDialog( context: context, builder: (context) => AlertDialog( title: const Text('Are you sure?'), content: const Text('Do you want to exit the App'), actions: [ TextButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.white), overlayColor: MaterialStateProperty.all(Colors.white), ), onPressed: () => Navigator.of(context).pop(false), child: Text( "NO", style: TextStyle(fontWeight: FontWeight.w500), ), ), const SizedBox(height: 16), TextButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.white), overlayColor: MaterialStateProperty.all(Colors.white70), ), onPressed: () => SystemChannels.platform.invokeMethod( 'SystemNavigator.pop', ), child: Text( "YES", style: TextStyle(fontWeight: FontWeight.w500), ), ), ], elevation: 30.0, ), barrierDismissible: false, ) ?? false; } Future requestGpsPermission() async { bool isLocationEnabled = false; bool hasLocationPermission = false; 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 loc.Location location = loc.Location(); bool serviceEnabled; serviceEnabled = await location.serviceEnabled(); if (!serviceEnabled) { serviceEnabled = await location.requestService(); if (!serviceEnabled) { return; } } } @override void dispose() { // TODO: implement dispose super.dispose(); _connectivity.disposeStream(); } @override Widget build(BuildContext context) { double screenWidth = MediaQuery.of(context).size.width; double screenHeight = MediaQuery.of(context).size.height; switch (_source.keys.toList()[0]) { case ConnectivityResult.mobile: connection = 'Online'; break; case ConnectivityResult.wifi: connection = 'Online'; break; case ConnectivityResult.none: default: connection = 'Offline'; } return (connection == 'Online') ? Consumer2( builder: (context, homescreen, profile, child) { final coreRequiredRoles = ["12", "540","433", "434", "430"]; final requiredRoles = ["430", "430", "431", "431"]; final coreNames = ["CRM", "Orders","Service", "Gen Tracker","HRM" ]; final names = ["Attendance", "Finance", "ERP", "Whizzdom"]; final subtitles = [ "Check-in,Check-out", "Payment Requests, Transactions", "Centralized data and reports", "Page guidance, Learn to use", ]; final coreIcons = [ "assets/svg/home/home_crm_ic.svg", "assets/svg/home/home_order_ic.svg", "assets/svg/home/home_service_ic.svg", "assets/svg/home/home_gentracker_ic.svg", "assets/svg/hrm/pie-chart.svg", ]; final icons = [ "assets/svg/home/home_attendance_ic.svg", "assets/svg/home/home_finance_ic.svg", "assets/svg/home/home_erp_ic.svg", "assets/svg/home/home_whizzdom_ic.svg", ]; final coreSubtitles = [ "Leads, Followups", "Orders, TPC, Dispatch", "Visits, P.C. Wallet", "Generator Details", "Tour Bills, Live Attendance", ]; final coreFilteredItems = >[]; final filteredItems = >[]; for (int j = 0; j < names.length; j++) { if (homescreen.roleStatus.contains(requiredRoles[j])) { filteredItems.add({ 'name': names[j], 'icon': icons[j], 'subtitle': subtitles[j], }); } } for (int i = 0; i < coreNames.length; i++) { if (homescreen.roleStatus.contains(coreRequiredRoles[i])) { coreFilteredItems.add({ 'name': coreNames[i], 'icon': coreIcons[i], 'subtitle': coreSubtitles[i], }); } } return WillPopScope( onWillPop: onBackPressed, child: RefreshIndicator.adaptive( color: AppColors.app_blue, onRefresh: () async { await Future.delayed(const Duration(milliseconds: 600)); homescreen.DashboardApiFunction(context); }, child: SafeArea( top: false, bottom: Platform.isIOS ? false : true, child: Scaffold( resizeToAvoidBottomInset: true, backgroundColor: AppColors.scaffold_bg_color, appBar: AppBar( automaticallyImplyLeading: false, toolbarHeight: 0, backgroundColor: Colors.white, ), body: SingleChildScrollView( child: Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [ AppColors.scaffold_bg_color, AppColors.scaffold_bg_color, Color(0xFFCEEDFF), ], begin: Alignment.topCenter, end: Alignment.bottomCenter, ), ), child: Column( mainAxisSize: MainAxisSize.min, children: [ InkResponse( onTap: () { HapticFeedback.selectionClick(); _showProfileBottomSheet( context, ); }, child: Container( // padding: EdgeInsets.symmetric(vertical: 5), 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, ), padding: EdgeInsets.only(bottom: 1, right: 10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), gradient: LinearGradient( colors: [ AppColors.profile_card, AppColors.profile_card, ], ), ), child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( flex: 8, child: Padding( padding: EdgeInsets.only( left: 25, top: 15, bottom: 15 ), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ // Text( // "${profile.employeeName}", // maxLines: 1, // style: TextStyle( // color: AppColors.app_blue, // fontFamily: "JakartaSemiBold", // fontSize: 18, // ), // ), AutoSizeText( '${profile.employeeName}', maxFontSize: 16, minFontSize: 12, style: TextStyle( fontSize: 16, color: AppColors.app_blue, fontFamily: "JakartaSemiBold", ), maxLines: 2, ), AutoSizeText( '(${profile.designation})', maxFontSize: 14, minFontSize: 10, style: TextStyle( fontSize: 14, color: AppColors.semi_black, fontFamily: "JakartaRegular", ), maxLines: 1, ), // Text( // "${profile.designation}", // maxLines: 1, // style: TextStyle( // color: AppColors.semi_black, // fontFamily: "JakartaRegular", // fontSize: 14, // ), // ), Text( "${profile.employeeeID}", style: TextStyle( color: AppColors.semi_black, fontFamily: "JakartaRegular", fontSize: 14, ), ), SizedBox(height: 12,), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( width: 12, height: 12, decoration: BoxDecoration( shape: BoxShape.circle, color: homescreen.onlineStatus == "Online" ? AppColors.approved_text_color : AppColors.rejected_text_color, ), ), SizedBox(width: 6), Text( "${homescreen.onlineStatus}", style: TextStyle( fontSize: 14, fontFamily: "JakartaRegular", color: Color(0xFF2D2D2D), ), ), ], ), ], ), ), ), Spacer(), Expanded( flex: 2, child: Container( padding: EdgeInsets.symmetric( vertical: 15, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( width: 60, height: 60, 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), ), ), ), ], ), ), ), ], ), ), ), ), SizedBox( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // if (coreFilteredItems.isNotEmpty) ...[ // Container( // padding: const EdgeInsets.only( // top: 10, // bottom: 5, // ), // margin: EdgeInsets.symmetric( // horizontal: 10, // ), // child: Text( // "Core Functionalities", // style: TextStyle( // color: AppColors.grey_thick, // fontSize: 14, // fontFamily: "JakartaMedium", // ), // ), // ), // Container( // padding: EdgeInsets.symmetric( // vertical: 10, // horizontal: 15, // ), // margin: EdgeInsets.symmetric( // horizontal: 10, // ), // decoration: BoxDecoration( // color: Colors.white, // borderRadius: BorderRadius.circular(14), // ), // child: Row( // mainAxisAlignment: // MainAxisAlignment.center, // children: List.generate(4, (ic) { // return Expanded( // child: InkResponse( // onTap: () async { // var res; // switch (coreFilteredItems[ic]['name']) { // case "Gen Tracker": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // Gentrackerdashboard(), // settings: RouteSettings( // arguments: // 'Gentrackerdashboard', // ), // ), // ); // break; // case "Service": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // Serviceengineerdashboard(), // ), // ); // break; // case "Orders": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // Ordermoduledashboard(), // ), // ); // case "CRM": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // CrmdashboardScreen(), // settings: RouteSettings( // name: // 'CrmdashboardScreen', // ), // ), // ); // default: // print("111"); // break; // } // if (res == true) { // homescreen.DashboardApiFunction( // context, // ); // } // }, // child: SizedBox( // child: Column( // crossAxisAlignment: // CrossAxisAlignment.center, // mainAxisAlignment: // MainAxisAlignment.center, // children: [ // SvgPicture.asset( // coreFilteredItems[ic]['icon'] ?? // "-", // ), // SizedBox(height: 10), // Text( // coreFilteredItems[ic]['name'] ?? // "-", // maxLines: 2, // textAlign: // TextAlign.center, // style: TextStyle( // fontSize: 12, // fontFamily: // "JakartaMedium", // ), // ), // ], // ), // ), // ), // ); // }), // ), // ), // ], if (homescreen.roleStatus.contains( "432", )) ...[ if (filteredItems.isNotEmpty) ...[ Container( padding: const EdgeInsets.only( top: 10, bottom: 5, ), margin: EdgeInsets.only( left: 10, bottom: 5, top: 10 ), child: Text( "Workforce & Operations", style: TextStyle( color: AppColors.grey_thick, fontSize: 14, fontFamily: "JakartaMedium", ), ), ), Container( padding: EdgeInsets.symmetric( vertical: 15, horizontal: 15, ), margin: EdgeInsets.symmetric( horizontal: 10, ), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(14), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: List.generate(4, (ic) { return Expanded( child: InkResponse( onTap: () async { HapticFeedback.selectionClick(); var res; switch (filteredItems[ic]['name']) { case "Attendance": res = await Navigator.push( context, MaterialPageRoute( builder: (context) => AttendanceScreen(), settings: RouteSettings( arguments: 'AttendanceScreen', ), ), ); break; case "ERP": bool isGpsEnabled = await Geolocator.isLocationServiceEnabled(); if (isGpsEnabled) { if (Platform.isAndroid) { res = await Navigator.push( context, MaterialPageRoute( builder: ( context, ) => WebErpScreen( erp_url: homescreen .webPageUrl, ), ), ); } else { res = await Navigator.push( context, MaterialPageRoute( builder: ( context, ) => WebERPIOS( url: homescreen .webPageUrl, ), ), ); } } else { requestGpsPermission(); } break; case "Whizzdom": bool isGpsEnabled = await Geolocator.isLocationServiceEnabled(); if (isGpsEnabled) { res = await Navigator.push( context, MaterialPageRoute( builder: ( context, ) => WebWhizzdomScreen( whizzdom_url: homescreen .whizzdomPageUrl, ), ), ); } else { requestGpsPermission(); } break; case "Finance": res = await Navigator.push( context, MaterialPageRoute( builder: (context) => Financedashboard(), settings: RouteSettings( arguments: 'Financedashboard', ), ), ); break; default: print("111"); break; } if (res == true) { homescreen.DashboardApiFunction( context, ); } }, child: SizedBox( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ SvgPicture.asset( filteredItems[ic]['icon'] ?? "-", ), SizedBox(height: 10), Text( filteredItems[ic]['name'] ?? "-", maxLines: 2, textAlign: TextAlign.center, style: TextStyle( fontSize: 12, fontFamily: "JakartaMedium", ), ), ], ), ), ), ); }), ), ), ], Container( margin: EdgeInsets.only( left: 10, bottom: 5, top: 10 ), padding: const EdgeInsets.only( top: 10, bottom: 5, ), child: Text( "Inventory Management", style: TextStyle( color: AppColors.grey_thick, fontSize: 14, fontFamily: "JakartaMedium", ), ), ), InkResponse( onTap: () async { HapticFeedback.selectionClick(); var res = await Navigator.push( context, MaterialPageRoute( builder: (context) => InventoryScreen(), ), ); if (res == true) { homescreen.DashboardApiFunction( context, ); } }, child: Container( margin: EdgeInsets.symmetric( horizontal: 10, ), padding: EdgeInsets.symmetric( vertical: 15, horizontal: 15, ), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular( 14, ), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( flex: 1, child: SvgPicture.asset( "assets/svg/home/home_inventory_ic.svg", ), ), SizedBox(width: 10), Expanded( flex: 5, child: SizedBox( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Inventory", style: TextStyle( fontSize: 14, color: AppColors.app_blue, fontFamily: "JakartaMedium", ), ), Text( "Stock Management, Evaluations", style: TextStyle( fontSize: 14, color: AppColors.grey_semi, fontFamily: "JakartaMedium", ), ), ], ), ), ), ], ), ), ), ] else...[ if (filteredItems.isNotEmpty) ...[ Container( margin: EdgeInsets.only( left: 10, bottom: 5, top: 10 ), padding: const EdgeInsets.only( top: 10, bottom: 5, ), child: Text( "Workforce & Operations", style: TextStyle( color: AppColors.grey_thick, fontSize: 14, fontFamily: "JakartaMedium", ), ), ), Container( margin: EdgeInsets.symmetric( horizontal: 5, ), child: GridView.builder( shrinkWrap: true, itemCount: filteredItems.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 2 / 1.1, ), itemBuilder: (context, ci) { return InkResponse( onTap: () async { HapticFeedback.selectionClick(); var res; switch (filteredItems[ci]['name']) { case "Attendance": res = await Navigator.push( context, MaterialPageRoute( builder: (context) => AttendanceScreen(), settings: RouteSettings( arguments: 'AttendanceScreen', ), ), ); break; case "ERP": bool isGpsEnabled = await Geolocator.isLocationServiceEnabled(); if (isGpsEnabled) { if (Platform.isAndroid) { res = await Navigator.push( context, MaterialPageRoute( builder: ( context, ) => WebErpScreen( erp_url: homescreen .webPageUrl, ), ), ); } else { res = await Navigator.push( context, MaterialPageRoute( builder: ( context, ) => WebERPIOS( url: homescreen .webPageUrl, ), ), ); } } else { requestGpsPermission(); } break; case "Whizzdom": bool isGpsEnabled = await Geolocator.isLocationServiceEnabled(); if (isGpsEnabled) { res = await Navigator.push( context, MaterialPageRoute( builder: ( context, ) => WebWhizzdomScreen( whizzdom_url: homescreen .whizzdomPageUrl, ), ), ); } else { requestGpsPermission(); } break; case "Finance": res = await Navigator.push( context, MaterialPageRoute( builder: (context) => Financedashboard(), settings: RouteSettings( arguments: 'Financedashboard', ), ), ); break; default: print("111"); break; } if (res == true) { homescreen.DashboardApiFunction( context, ); } }, child: Container( padding: EdgeInsets.symmetric( vertical: 5, horizontal: 15, ), margin: EdgeInsets.symmetric( vertical: 7, horizontal: 5, ), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(14), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( flex: 2, child: SizedBox( child: Column( crossAxisAlignment: CrossAxisAlignment .start, mainAxisAlignment: MainAxisAlignment .center, children: [ Text( filteredItems[ci]['name'] ?? "-", style: TextStyle( fontSize: 14, color: AppColors .app_blue, fontFamily: "JakartaMedium", ), ), Text( filteredItems[ci]['subtitle'] ?? "-", style: TextStyle( fontSize: 12, color: AppColors .grey_semi, fontFamily: "JakartaMedium", ), ), ], ), ), ), SizedBox(width: 10), Expanded( flex: 1, child: SvgPicture.asset( filteredItems[ci]['icon'] ?? "-", ), ), ], ), ), ); }, ), ), ], ], // if (filteredItems.isNotEmpty) ...[ // Container( // margin: EdgeInsets.symmetric( // horizontal: 10, // ), // padding: const EdgeInsets.only( // top: 10, // bottom: 5, // ), // child: Text( // "Workforce & Operations", // style: TextStyle( // color: AppColors.grey_thick, // fontSize: 14, // fontFamily: "JakartaMedium", // ), // ), // ), // Container( // margin: EdgeInsets.symmetric( // horizontal: 5, // ), // child: GridView.builder( // shrinkWrap: true, // itemCount: filteredItems.length, // gridDelegate: // SliverGridDelegateWithFixedCrossAxisCount( // crossAxisCount: 2, // childAspectRatio: 2 / 1.1, // ), // itemBuilder: (context, ci) { // return InkResponse( // onTap: () async { // var res; // switch (filteredItems[ci]['name']) { // case "Attendance": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // AttendanceScreen(), // settings: RouteSettings( // arguments: // 'AttendanceScreen', // ), // ), // ); // break; // case "ERP": // bool isGpsEnabled = // await Geolocator.isLocationServiceEnabled(); // if (isGpsEnabled) { // if (Platform.isAndroid) { // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // ( // context, // ) => WebErpScreen( // erp_url: // homescreen // .webPageUrl, // ), // ), // ); // } else { // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // ( // context, // ) => WebERPIOS( // url: // homescreen // .webPageUrl, // ), // ), // ); // } // } else { // requestGpsPermission(); // } // break; // case "Whizzdom": // bool isGpsEnabled = // await Geolocator.isLocationServiceEnabled(); // if (isGpsEnabled) { // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // ( // context, // ) => WebWhizzdomScreen( // whizzdom_url: // homescreen // .whizzdomPageUrl, // ), // ), // ); // } else { // requestGpsPermission(); // } // break; // case "Finance": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // Financedashboard(), // settings: RouteSettings( // arguments: // 'Financedashboard', // ), // ), // ); // break; // default: // print("111"); // break; // } // if (res == true) { // homescreen.DashboardApiFunction( // context, // ); // } // }, // // child: Container( // padding: EdgeInsets.symmetric( // vertical: 5, // horizontal: 15, // ), // margin: EdgeInsets.symmetric( // vertical: 7, // horizontal: 5, // ), // decoration: BoxDecoration( // color: Colors.white, // borderRadius: // BorderRadius.circular(14), // ), // child: Row( // mainAxisAlignment: // MainAxisAlignment.center, // crossAxisAlignment: // CrossAxisAlignment.center, // children: [ // Expanded( // flex: 2, // child: SizedBox( // child: Column( // crossAxisAlignment: // CrossAxisAlignment // .start, // mainAxisAlignment: // MainAxisAlignment // .center, // children: [ // Text( // filteredItems[ci]['name'] ?? // "-", // style: TextStyle( // fontSize: 14, // color: // AppColors // .app_blue, // fontFamily: // "JakartaMedium", // ), // ), // Text( // filteredItems[ci]['subtitle'] ?? // "-", // style: TextStyle( // fontSize: 12, // color: // AppColors // .grey_semi, // fontFamily: // "JakartaMedium", // ), // ), // ], // ), // ), // ), // SizedBox(width: 10), // Expanded( // flex: 1, // child: SvgPicture.asset( // filteredItems[ci]['icon'] ?? // "-", // ), // ), // ], // ), // ), // ); // }, // ), // ), // ], if (coreFilteredItems.isNotEmpty) ...[ Container( margin: EdgeInsets.only( left: 10, bottom: 5, top: 10 ), padding: const EdgeInsets.only( top: 10, bottom: 5, ), child: Text( "Core Functionalities", style: TextStyle( color: AppColors.grey_thick, fontSize: 14, fontFamily: "JakartaMedium", ), ), ), Container( margin: EdgeInsets.symmetric( horizontal: 5, ), child: GridView.builder( shrinkWrap: true, itemCount: coreFilteredItems.length, physics: NeverScrollableScrollPhysics(), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 2 / 1.1, ), itemBuilder: (context, ci) { return InkResponse( onTap: () async { HapticFeedback.selectionClick(); var res; switch (coreFilteredItems[ci]['name']) { case "Gen Tracker": res = await Navigator.push( context, MaterialPageRoute( builder: (context) => Gentrackerdashboard(), settings: RouteSettings( arguments: 'Gentrackerdashboard', ), ), ); // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => Scanentergeneratoridscreen( // from: "Generator Details", // ), // settings: RouteSettings( // name: 'Scanentergeneratoridscreen' // ) // ), // ); break; case "Service": res = await Navigator.push( context, MaterialPageRoute( builder: (context) => Serviceengineerdashboard(), ), ); break; case "Orders": res = await Navigator.push( context, MaterialPageRoute( builder: (context) => Ordermoduledashboard(), ), ); case "CRM": res = await Navigator.push( context, MaterialPageRoute( builder: (context) => CrmdashboardScreen(), settings: RouteSettings( name: 'CrmdashboardScreen', ), ), ); case "HRM": res = await Navigator.push( context, MaterialPageRoute( builder: (context) => HrmdashboardScreen(), settings: RouteSettings( name: 'CrmdashboardScreen', ), ), ); default: print("111"); break; } if (res == true) { homescreen.DashboardApiFunction( context, ); } }, child: Container( padding: EdgeInsets.symmetric( vertical: 5, horizontal: 15, ), margin: EdgeInsets.symmetric( vertical: 7, horizontal: 5, ), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(14), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( flex: 2, child: SizedBox( child: Column( crossAxisAlignment: CrossAxisAlignment .start, mainAxisAlignment: MainAxisAlignment .center, children: [ Text( coreFilteredItems[ci]['name'] ?? "-", style: TextStyle( fontSize: 14, color: AppColors .app_blue, fontFamily: "JakartaMedium", ), ), Text( coreFilteredItems[ci]['subtitle'] ?? "-", style: TextStyle( fontSize: 12, color: AppColors .grey_semi, fontFamily: "JakartaMedium", ), ), ], ), ), ), SizedBox(width: 10), Expanded( flex: 1, child: SvgPicture.asset( coreFilteredItems[ci]['icon'] ?? "-", ), ), ], ), ), ); }, ), ), ], ], ), ), Align( alignment: Alignment.bottomCenter, child: Container( height: 40, alignment: Alignment.bottomCenter, margin: EdgeInsets.only(bottom: 20), child: Image.asset( fit: BoxFit.scaleDown, "assets/images/horizontal_logo.png", ), ), ), // Expanded( // flex: 10, // child: Container( // padding: EdgeInsets.only( // left: 20, // right: 20, // top: 0, // bottom: 10, // ), // margin: EdgeInsets.only(top: 10), // child: GridView.builder( // itemCount: filteredItems.length, // gridDelegate: // SliverGridDelegateWithFixedCrossAxisCount( // crossAxisCount: 2, // crossAxisSpacing: 10, // mainAxisSpacing: 10, // ), // itemBuilder: (context, index) { // final item = filteredItems[index]; // return InkResponse( // onTap: () async { // var res; // switch (item['name']) { // case "Attendance": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // AttendanceScreen(), // settings: RouteSettings( // arguments: 'AttendanceScreen', // ), // ), // ); // break; // case "ERP": // bool isGpsEnabled = // await Geolocator.isLocationServiceEnabled(); // if (isGpsEnabled) { // if (Platform.isAndroid) { // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => WebErpScreen( // erp_url: // homescreen // .webPageUrl, // ), // ), // ); // } else { // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => WebERPIOS( // url: // homescreen // .webPageUrl, // ), // ), // ); // } // } else { // requestGpsPermission(); // } // // break; // case "Gen Tracker": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // Gentrackerdashboard(), // settings: RouteSettings( // arguments: // 'Gentrackerdashboard', // ), // ), // ); // break; // case "Service Engineer": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // Serviceengineerdashboard(), // ), // ); // break; // case "Nearby": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // Nearbygenerators(), // ), // ); // // break; // case "Inventory": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // InventoryScreen(), // ), // ); // break; // case "Whizzdom": // bool isGpsEnabled = // await Geolocator.isLocationServiceEnabled(); // if (isGpsEnabled) { // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // ( // context, // ) => WebWhizzdomScreen( // whizzdom_url: // homescreen // .whizzdomPageUrl, // ), // ), // ); // } else { // requestGpsPermission(); // } // break; // case "Common": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // Commondashboard(), // ), // ); // break; // case "Finance": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // Financedashboard(), // settings: RouteSettings( // arguments: 'Financedashboard', // ), // ), // ); // break; // case "Orders": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // Ordermoduledashboard(), // ), // ); // case "CRM": // res = await Navigator.push( // context, // MaterialPageRoute( // builder: // (context) => // CrmdashboardScreen(), // settings: RouteSettings( // name: 'CrmdashboardScreen', // ), // ), // ); // default: // print("111"); // break; // } // if (res == true) { // homescreen.DashboardApiFunction( // context, // ); // } // }, // child: Container( // decoration: BoxDecoration( // color: Colors.white, // borderRadius: BorderRadius.circular(30), // ), // child: Column( // crossAxisAlignment: // CrossAxisAlignment.center, // mainAxisAlignment: // MainAxisAlignment.center, // children: [ // SvgPicture.asset( // item['icon']!, // height: 45, // ), // SizedBox(height: 10), // Text(item['name']!), // ], // ), // ), // ); // }, // ), // ), // ), ], ), ), ), // floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, // floatingActionButton: ), ), ), ); }, ) : NoNetwork(context); } Future _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, ), padding: EdgeInsets.only( bottom: MediaQuery.of(context).viewInsets.bottom, ), 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(), InkResponse( onTap: () { HapticFeedback.selectionClick(); Navigator.push( context, MaterialPageRoute( builder: (context) => Scannerlogin(), ), ); }, child: SizedBox( height: 25, width: 25, child: SvgPicture.asset( "assets/svg/scanner.svg", ), ), ), ], ), ), SizedBox(height: 15), Container( padding: EdgeInsets.symmetric( horizontal: 5, vertical: 10, ), 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: 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), ), ), ), ), Text( "${profile.employeeName}", textAlign: TextAlign.center, style: TextStyle( color: AppColors.app_blue, fontFamily: "JakartaSemiBold", fontSize: 18, ), ), Text( "${profile.employeeEmail}", textAlign: TextAlign.center, 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, fontFamily: "JakartaMedium", 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, ]; final itemText = textHeadings[index]?.toString() ?? "-"; return SizedBox( height: 40, child: Align( alignment: Alignment.centerLeft, child: InkWell( onTap: () async { final profileNotifier = Provider.of(context, listen: false); // Call API await profileNotifier.fetchJobDescription( Provider.of(context, listen: false), context, ); // fetching, check response if (profileNotifier.response != null && profileNotifier.response!.jobDescription != null) { if (profileNotifier.response!.jobDescription!.jobDescription != null && profileNotifier.response!.jobDescription!.jobDescription != "") { showJobDescriptionSheet( context: context, htmlData: profileNotifier.response!.jobDescription!.jobDescription ?? "

No description

", title: "Job Description",//profileNotifier.response!.jobDescription!.name ?? ); } } else { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text(profileNotifier.errorMessage ?? "Failed to fetch job description"), ), ); } }, // no click for others child: Text( itemText, textAlign: TextAlign.left, style: TextStyle( fontSize: 14, color: index == 2 ? AppColors.semi_black : AppColors.semi_black, decoration: index == 2 ? TextDecoration.underline : null, decorationStyle: TextDecorationStyle.dotted, ), ), ), ), ); }, ), ), ], ), ), ], ), ), SizedBox(height: 10), InkWell( onTap: () { HapticFeedback.selectionClick(); // LoginApiFunction(); var f = FocusScope.of(context); if (!f.hasPrimaryFocus) { f.unfocus(); } _showLogoutBottomSheet(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(15.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, ), ), ], ), ); }, ), ), ); }, ); }, ); } // Job Descriptions Future showJobDescriptionSheet({ required BuildContext context, required String htmlData, // pass details_articles!.description String title = "Job Description", }) { return showModalBottomSheet( useSafeArea: true, isDismissible: true, isScrollControlled: true, showDragHandle: true, enableDrag: true, backgroundColor: Colors.white, context: context, builder: (context) { return SafeArea( child: Container( margin: const EdgeInsets.only( bottom: 15, left: 15, right: 15, top: 15, ), padding: EdgeInsets.only( bottom: MediaQuery.of(context).viewInsets.bottom, ), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ /// Heading Text( title, style: TextStyle( fontFamily: "JakartaMedium", fontSize: 18, color: AppColors.app_blue, fontWeight: FontWeight.w600, ), ), const SizedBox(height: 5), /// HTML description Html( data: htmlData, style: { "h2": Style( wordSpacing: 0, letterSpacing: 0, fontSize: FontSize(16), fontFamily: "JakartaMedium", color: AppColors.semi_black, ), "h3": Style( wordSpacing: 0, letterSpacing: 0, fontSize: FontSize(12), fontFamily: "JakartaMedium", color: AppColors.semi_black, ), "p": Style( wordSpacing: 0, letterSpacing: 0, fontSize: FontSize(12), fontFamily: "JakartaMedium", color: AppColors.grey_semi, lineHeight: LineHeight.number(2.4), ), "ul": Style( wordSpacing: 0, letterSpacing: 0, fontSize: FontSize(15), fontFamily: "JakartaMedium", color: AppColors.grey_semi, padding: HtmlPaddings.only(left: 10, right: 8), // fixed for v3.0.0 lineHeight: LineHeight.number(1.4), ), "li": Style( wordSpacing: 0, letterSpacing: 0, fontSize: FontSize(14), fontFamily: "JakartaMedium", color: Colors.black, padding: HtmlPaddings.only(left: 4), lineHeight: LineHeight.number(1.4), // bullet text line height margin: Margins.only(bottom: 10), ), "a": Style( color: Colors.blue, textDecoration: TextDecoration.underline, ), }, onLinkTap: (url, _, __) { debugPrint("Link tapped: $url"); if (url != null) { // launchUrl(Uri.parse(url)); // needs url_launcher } }, ), const SizedBox(height: 6), /// Close button InkWell( onTap: () => Navigator.pop(context), child: Container( alignment: Alignment.center, height: 45, margin: const EdgeInsets.symmetric( horizontal: 5.0, vertical: 5.0, ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15.0), ), child: Center( child: Text( "Close", textAlign: TextAlign.center, style: TextStyle( color: AppColors.app_blue, fontFamily: "JakartaMedium", fontSize: 15, ), ), ), ), ), ], ), ), ), ); }, ); } // Future showJobDescriptionSheet( // BuildContext context, // List jobPoints, // ) { // return showModalBottomSheet( // useSafeArea: true, // isDismissible: true, // isScrollControlled: true, // showDragHandle: true, // enableDrag: true, // backgroundColor: Colors.white, // context: context, // builder: (context) { // return SafeArea( // child: Container( // margin: const EdgeInsets.only( // bottom: 15, // left: 15, // right: 15, // top: 30, // ), // padding: EdgeInsets.only( // bottom: MediaQuery.of(context).viewInsets.bottom, // ), // child: SingleChildScrollView( // child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisSize: MainAxisSize.min, // children: [ // /// Heading // Text( // "Job Description", // style: TextStyle( // fontFamily: "JakartaMedium", // fontSize: 16, // color: AppColors.app_blue, // same as Logout "Yes, Logout" button // fontWeight: FontWeight.w600, // ), // ), // const SizedBox(height: 15), // // /// Bullet points list // ...jobPoints.map( // (point) => Padding( // padding: const EdgeInsets.symmetric(vertical: 6), // child: Row( // crossAxisAlignment: CrossAxisAlignment.start, // children: [ // Text( // "• ", // style: TextStyle( // fontSize: 14, // color: AppColors.semi_black, // ), // ), // Expanded( // child: Text( // point, // style: TextStyle( // fontSize: 14, // color: AppColors.semi_black, // fontFamily: "JakartaRegular", // height: 1.4, // line spacing // ), // ), // ), // ], // ), // ), // ), // // const SizedBox(height: 20), // // /// Close button // InkWell( // onTap: () => Navigator.pop(context), // child: Container( // alignment: Alignment.center, // height: 45, // margin: const EdgeInsets.symmetric( // horizontal: 5.0, // vertical: 5.0, // ), // decoration: BoxDecoration( // borderRadius: BorderRadius.circular(15.0), // ), // child: Center( // child: Text( // "Close", // textAlign: TextAlign.center, // style: TextStyle( // color: AppColors.app_blue, // fontFamily: "JakartaMedium", // fontSize: 15, // ), // ), // ), // ), // ), // ], // ), // ), // ), // ); // }, // ); // } Future _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, ), padding: EdgeInsets.only( bottom: MediaQuery.of(context).viewInsets.bottom, ), 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( fontFamily: "JakartaMedium", color: AppColors.semi_black, fontSize: 18, ), ), ], ), SizedBox(height: 20), InkWell( onTap:logout.logoutButtonClicked?null: () { HapticFeedback.selectionClick(); // LoginApiFunction(); logout.logoutButtonClicked = true; 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(15.0), ), child: Center( child: Text( "Yes, Logout", textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontFamily: "JakartaMedium", ), ), ), ), ), InkWell( onTap: () { HapticFeedback.selectionClick(); // 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, fontFamily: "JakartaMedium", ), ), ), ), ), ], ), ); }, ), ), ); }, ); }, ); } }