|
|
|
@ -1,20 +1,55 @@
|
|
|
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:easy_localization/src/public_ext.dart';
|
|
|
|
import 'package:easy_localization/src/public_ext.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
|
|
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/classes/inAppWebView.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
|
|
import 'package:mohem_flutter_app/config/routes.dart';
|
|
|
|
import 'package:mohem_flutter_app/config/routes.dart';
|
|
|
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
|
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/main.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/models/generic_response_model.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/models/sso_auth_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/my_attendance/services_menu_list_screen.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/my_attendance/services_menu_list_screen.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class ServicesWidget extends StatelessWidget {
|
|
|
|
class ServicesWidget extends StatelessWidget {
|
|
|
|
|
|
|
|
MyInAppBrowser? myInAppBrowser;
|
|
|
|
|
|
|
|
var inAppBrowserOptions = InAppBrowserClassSettings(
|
|
|
|
|
|
|
|
webViewSettings: InAppWebViewSettings(
|
|
|
|
|
|
|
|
useShouldOverrideUrlLoading: false,
|
|
|
|
|
|
|
|
transparentBackground: false,
|
|
|
|
|
|
|
|
isInspectable: false,
|
|
|
|
|
|
|
|
applePayAPIEnabled: true,
|
|
|
|
|
|
|
|
cacheEnabled: false,
|
|
|
|
|
|
|
|
allowsBackForwardNavigationGestures: false,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
browserSettings: InAppBrowserSettings(
|
|
|
|
|
|
|
|
hideUrlBar: true,
|
|
|
|
|
|
|
|
hideTitleBar: true,
|
|
|
|
|
|
|
|
hideDefaultMenuItems: true,
|
|
|
|
|
|
|
|
hideToolbarBottom: true,
|
|
|
|
|
|
|
|
hideToolbarTop: false,
|
|
|
|
|
|
|
|
hideCloseButton: false,
|
|
|
|
|
|
|
|
allowGoBackWithBackButton: false,
|
|
|
|
|
|
|
|
toolbarBottomBackgroundColor: Colors.black,
|
|
|
|
|
|
|
|
closeButtonColor: Colors.white,
|
|
|
|
|
|
|
|
presentationStyle: ModalPresentationStyle.FULL_SCREEN,
|
|
|
|
|
|
|
|
// toolbarTopBackgroundColor: Colors.black
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
List<String> namesT = [LocaleKeys.monthlyAttendance.tr(), LocaleKeys.workFromHome.tr(), LocaleKeys.ticketRequest.tr(), LocaleKeys.monthlyAttendance.tr()];
|
|
|
|
List<String> namesT = [LocaleKeys.monthlyAttendance.tr(), LocaleKeys.workFromHome.tr(), LocaleKeys.ticketRequest.tr(), LocaleKeys.monthlyAttendance.tr()];
|
|
|
|
@ -26,7 +61,7 @@ class ServicesWidget extends StatelessWidget {
|
|
|
|
"assets/images/vacation_rule.svg",
|
|
|
|
"assets/images/vacation_rule.svg",
|
|
|
|
"assets/images/ticket_request.svg",
|
|
|
|
"assets/images/ticket_request.svg",
|
|
|
|
"assets/images/ticket_request.svg",
|
|
|
|
"assets/images/ticket_request.svg",
|
|
|
|
"assets/images/ticket_request.svg"
|
|
|
|
"assets/images/ticket_request.svg",
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
return Consumer<DashboardProviderModel>(
|
|
|
|
return Consumer<DashboardProviderModel>(
|
|
|
|
@ -51,36 +86,31 @@ class ServicesWidget extends StatelessWidget {
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
return AspectRatio(
|
|
|
|
return AspectRatio(
|
|
|
|
aspectRatio: 105 / 105,
|
|
|
|
aspectRatio: 105 / 105,
|
|
|
|
child: data.isServicesMenusLoading
|
|
|
|
child:
|
|
|
|
|
|
|
|
data.isServicesMenusLoading
|
|
|
|
? ServicesMenuShimmer()
|
|
|
|
? ServicesMenuShimmer()
|
|
|
|
: Container(
|
|
|
|
: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
color: Colors.white,
|
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
|
boxShadow: [
|
|
|
|
boxShadow: [BoxShadow(color: const Color(0xff000000).withOpacity(.05), blurRadius: 26, offset: const Offset(0, -3))],
|
|
|
|
BoxShadow(
|
|
|
|
|
|
|
|
color: const Color(0xff000000).withOpacity(.05),
|
|
|
|
|
|
|
|
blurRadius: 26,
|
|
|
|
|
|
|
|
offset: const Offset(0, -3),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
SvgPicture.asset(AppState().isArabic(context)
|
|
|
|
SvgPicture.asset(
|
|
|
|
|
|
|
|
AppState().isArabic(context)
|
|
|
|
? getMenuIconAr(data.homeMenus![parentIndex].menuEntiesList[index].prompt!)
|
|
|
|
? getMenuIconAr(data.homeMenus![parentIndex].menuEntiesList[index].prompt!)
|
|
|
|
: getMenuIconEn(data.homeMenus![parentIndex].menuEntiesList[index].prompt!)),
|
|
|
|
: getMenuIconEn(data.homeMenus![parentIndex].menuEntiesList[index].prompt!),
|
|
|
|
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
Expanded(child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText11(isBold: true)),
|
|
|
|
child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText11(isBold: true),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)),
|
|
|
|
RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
)
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
).paddingOnly(left: 10, right: 10, bottom: 10, top: 12),
|
|
|
|
).paddingOnly(left: 10, right: 10, bottom: 10, top: 12),
|
|
|
|
).onPress(() {
|
|
|
|
).onPress(() {
|
|
|
|
@ -89,7 +119,8 @@ class ServicesWidget extends StatelessWidget {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
separatorBuilder: (cxt, index) => 9.width,
|
|
|
|
separatorBuilder: (cxt, index) => 9.width,
|
|
|
|
itemCount: data.homeMenus![parentIndex].menuEntiesList.length),
|
|
|
|
itemCount: data.homeMenus![parentIndex].menuEntiesList.length,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -99,7 +130,8 @@ class ServicesWidget extends StatelessWidget {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
shrinkWrap: true,
|
|
|
|
shrinkWrap: true,
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
itemCount: data.homeMenus!.length);
|
|
|
|
itemCount: data.homeMenus!.length,
|
|
|
|
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -196,7 +228,7 @@ class ServicesWidget extends StatelessWidget {
|
|
|
|
return returnImage;
|
|
|
|
return returnImage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void handleOnPress(context, GetMenuEntriesList menuEntry) {
|
|
|
|
Future<void> handleOnPress(context, GetMenuEntriesList menuEntry) async {
|
|
|
|
var pro = Provider.of<DashboardProviderModel>(context, listen: false);
|
|
|
|
var pro = Provider.of<DashboardProviderModel>(context, listen: false);
|
|
|
|
if (menuEntry.requestType == "MONTHLY_ATTENDANCE") {
|
|
|
|
if (menuEntry.requestType == "MONTHLY_ATTENDANCE") {
|
|
|
|
Navigator.pushNamed(context, AppRoutes.monthlyAttendance);
|
|
|
|
Navigator.pushNamed(context, AppRoutes.monthlyAttendance);
|
|
|
|
@ -219,11 +251,89 @@ class ServicesWidget extends StatelessWidget {
|
|
|
|
} else if (menuEntry.requestType == "PAYSLIP") {
|
|
|
|
} else if (menuEntry.requestType == "PAYSLIP") {
|
|
|
|
Navigator.pushNamed(context, AppRoutes.monthlyPaySlip);
|
|
|
|
Navigator.pushNamed(context, AppRoutes.monthlyPaySlip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (menuEntry.menuName == "HMG_TICKET_REQUESTS") {
|
|
|
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
|
|
|
print("=========");
|
|
|
|
|
|
|
|
TicketBookingResult response = await pro.fetchTicketBooking();
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
|
|
|
if (response.success) {
|
|
|
|
|
|
|
|
print("============ Allowed ============");
|
|
|
|
|
|
|
|
SSOAuthModel? ssoToken = await pro.fetchSSOAuthRedirection(clientID: response.clientId);
|
|
|
|
|
|
|
|
if (ssoToken != null) {
|
|
|
|
|
|
|
|
logger.d(ssoToken.data!.toJson());
|
|
|
|
|
|
|
|
logger.d(ssoToken.data!.accessToken);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dynamic valu = await pro.fetchURLRedirection(token: ssoToken.data!.accessToken!);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
myInAppBrowser = MyInAppBrowser(
|
|
|
|
|
|
|
|
onExitCallback: () {
|
|
|
|
|
|
|
|
log("Browser Exited");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onLoadStartCallback: (String url) {
|
|
|
|
|
|
|
|
log("Browser LoadStart for : $url");
|
|
|
|
|
|
|
|
if (url.contains("https://ek.techmaster.in/")) {
|
|
|
|
|
|
|
|
// Handle the URL as needed
|
|
|
|
|
|
|
|
log("SSO URL Loaded: $url");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await myInAppBrowser!.openUrlRequest(
|
|
|
|
|
|
|
|
urlRequest: URLRequest(
|
|
|
|
|
|
|
|
url: WebUri(valu, forceToStringRawValue: true),
|
|
|
|
|
|
|
|
allowsCellularAccess: true,
|
|
|
|
|
|
|
|
allowsConstrainedNetworkAccess: true,
|
|
|
|
|
|
|
|
allowsExpensiveNetworkAccess: true,
|
|
|
|
|
|
|
|
// headers: {'Authorization': 'Bearer ${ssoToken.data!.accessToken}'},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
settings: inAppBrowserOptions,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Navigator.of(context).push(
|
|
|
|
|
|
|
|
// MaterialPageRoute(
|
|
|
|
|
|
|
|
// builder:
|
|
|
|
|
|
|
|
// (context) => WebViewWidget(
|
|
|
|
|
|
|
|
// controller:
|
|
|
|
|
|
|
|
// WebViewController()
|
|
|
|
|
|
|
|
// ..setJavaScriptMode(JavaScriptMode.unrestricted)
|
|
|
|
|
|
|
|
// ..setNavigationDelegate(
|
|
|
|
|
|
|
|
// NavigationDelegate(
|
|
|
|
|
|
|
|
// onNavigationRequest: (NavigationRequest request) {
|
|
|
|
|
|
|
|
// return NavigationDecision.navigate;
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// onHttpError: (HttpResponseError response) {
|
|
|
|
|
|
|
|
// print(response.response!.statusCode);
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// onProgress: (int value) {
|
|
|
|
|
|
|
|
// print(value);
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// onWebResourceError: (WebResourceError error) {
|
|
|
|
|
|
|
|
// print(error.errorCode);
|
|
|
|
|
|
|
|
// print(error.description);
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// )
|
|
|
|
|
|
|
|
// ..loadRequest(Uri.parse("https://ek.techmaster.in/SSO/HMG"), headers: {'Authorization': 'Bearer ${ssoToken.data!.accessToken}'}),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// launchUrl(Uri.parse("https://ek.techmaster.in/SSO/HMG"),headers: {'Authorization': 'Bearer ${ssoToken.data!.accessToken}'}, mode: LaunchMode.inAppBrowserView);
|
|
|
|
|
|
|
|
// ddv
|
|
|
|
|
|
|
|
print("============ Token Fetched ============");
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
List<GetMenuEntriesList> _menuList =
|
|
|
|
List<GetMenuEntriesList> _menuList =
|
|
|
|
pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? [];
|
|
|
|
pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? [];
|
|
|
|
Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, _menuList.isEmpty ? menuList : _menuList));
|
|
|
|
Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, _menuList.isEmpty ? menuList : _menuList));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
List<GetMenuEntriesList> _menuList =
|
|
|
|
|
|
|
|
pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? [];
|
|
|
|
|
|
|
|
Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, _menuList.isEmpty ? menuList : _menuList));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -253,10 +363,7 @@ class ServicesWidget extends StatelessWidget {
|
|
|
|
padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13),
|
|
|
|
padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13),
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
return AspectRatio(
|
|
|
|
return AspectRatio(aspectRatio: 105 / 105, child: ServicesMenuShimmer());
|
|
|
|
aspectRatio: 105 / 105,
|
|
|
|
|
|
|
|
child: ServicesMenuShimmer(),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
separatorBuilder: (cxt, index) => 9.width,
|
|
|
|
separatorBuilder: (cxt, index) => 9.width,
|
|
|
|
itemCount: 4,
|
|
|
|
itemCount: 4,
|
|
|
|
|