Dashboard API's 1.2
parent
596ac1a875
commit
b6670289b1
@ -0,0 +1,39 @@
|
|||||||
|
class ListMenu {
|
||||||
|
ListMenu({
|
||||||
|
this.menuId,
|
||||||
|
this.menuName,
|
||||||
|
this.menuType,
|
||||||
|
this.requestGroupId,
|
||||||
|
this.requestGroupName,
|
||||||
|
this.respId,
|
||||||
|
this.subMenuName,
|
||||||
|
});
|
||||||
|
|
||||||
|
int? menuId;
|
||||||
|
String? menuName;
|
||||||
|
String? menuType;
|
||||||
|
int? requestGroupId;
|
||||||
|
String? requestGroupName;
|
||||||
|
dynamic? respId;
|
||||||
|
String? subMenuName;
|
||||||
|
|
||||||
|
factory ListMenu.fromJson(Map<String, dynamic> json) => ListMenu(
|
||||||
|
menuId: json["MENU_ID"] == null ? null : json["MENU_ID"],
|
||||||
|
menuName: json["MENU_NAME"] == null ? null : json["MENU_NAME"],
|
||||||
|
menuType: json["MENU_TYPE"] == null ? null : json["MENU_TYPE"],
|
||||||
|
requestGroupId: json["REQUEST_GROUP_ID"] == null ? null : json["REQUEST_GROUP_ID"],
|
||||||
|
requestGroupName: json["REQUEST_GROUP_NAME"] == null ? null : json["REQUEST_GROUP_NAME"],
|
||||||
|
respId: json["RESP_ID"],
|
||||||
|
subMenuName: json["SUB_MENU_NAME"] == null ? null : json["SUB_MENU_NAME"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"MENU_ID": menuId == null ? null : menuId,
|
||||||
|
"MENU_NAME": menuName == null ? null : menuName,
|
||||||
|
"MENU_TYPE": menuType == null ? null : menuType,
|
||||||
|
"REQUEST_GROUP_ID": requestGroupId == null ? null : requestGroupId,
|
||||||
|
"REQUEST_GROUP_NAME": requestGroupName == null ? null : requestGroupName,
|
||||||
|
"RESP_ID": respId,
|
||||||
|
"SUB_MENU_NAME": subMenuName == null ? null : subMenuName,
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
class GetMenuEntriesList {
|
||||||
|
GetMenuEntriesList({
|
||||||
|
this.addButton,
|
||||||
|
this.deleteButton,
|
||||||
|
this.entrySequence,
|
||||||
|
this.functionName,
|
||||||
|
this.icon,
|
||||||
|
this.lvl,
|
||||||
|
this.menuEntryType,
|
||||||
|
this.menuName,
|
||||||
|
this.parentMenuName,
|
||||||
|
this.prompt,
|
||||||
|
this.requestType,
|
||||||
|
this.updateButton,
|
||||||
|
});
|
||||||
|
|
||||||
|
String? addButton;
|
||||||
|
String? deleteButton;
|
||||||
|
int? entrySequence;
|
||||||
|
String? functionName;
|
||||||
|
String? icon;
|
||||||
|
int? lvl;
|
||||||
|
String? menuEntryType;
|
||||||
|
String? menuName;
|
||||||
|
String? parentMenuName;
|
||||||
|
String? prompt;
|
||||||
|
String? requestType;
|
||||||
|
String? updateButton;
|
||||||
|
|
||||||
|
factory GetMenuEntriesList.fromJson(Map<String, dynamic> json) => GetMenuEntriesList(
|
||||||
|
addButton: json["ADD_BUTTON"] == null ? null : json["ADD_BUTTON"],
|
||||||
|
deleteButton: json["DELETE_BUTTON"] == null ? null : json["DELETE_BUTTON"],
|
||||||
|
entrySequence: json["ENTRY_SEQUENCE"] == null ? null : json["ENTRY_SEQUENCE"],
|
||||||
|
functionName: json["FUNCTION_NAME"] == null ? null : json["FUNCTION_NAME"],
|
||||||
|
icon: json["ICON"] == null ? null : json["ICON"],
|
||||||
|
lvl: json["LVL"] == null ? null : json["LVL"],
|
||||||
|
menuEntryType: json["MENU_ENTRY_TYPE"] == null ? null : json["MENU_ENTRY_TYPE"],
|
||||||
|
menuName: json["MENU_NAME"] == null ? null : json["MENU_NAME"],
|
||||||
|
parentMenuName: json["PARENT_MENU_NAME"] == null ? null : json["PARENT_MENU_NAME"],
|
||||||
|
prompt: json["PROMPT"] == null ? null : json["PROMPT"],
|
||||||
|
requestType: json["REQUEST_TYPE"] == null ? null : json["REQUEST_TYPE"],
|
||||||
|
updateButton: json["UPDATE_BUTTON"] == null ? null :json["UPDATE_BUTTON"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"ADD_BUTTON": addButton == null ? null :addButton,
|
||||||
|
"DELETE_BUTTON": deleteButton == null ? null : deleteButton,
|
||||||
|
"ENTRY_SEQUENCE": entrySequence == null ? null : entrySequence,
|
||||||
|
"FUNCTION_NAME": functionName == null ? null : functionName,
|
||||||
|
"ICON": icon == null ? null : icon,
|
||||||
|
"LVL": lvl == null ? null : lvl,
|
||||||
|
"MENU_ENTRY_TYPE": menuEntryType == null ? null : menuEntryType,
|
||||||
|
"MENU_NAME": menuName == null ? null : menuName,
|
||||||
|
"PARENT_MENU_NAME": parentMenuName == null ? null : parentMenuName,
|
||||||
|
"PROMPT": prompt == null ? null : prompt,
|
||||||
|
"REQUEST_TYPE": requestType == null ? null : requestType,
|
||||||
|
"UPDATE_BUTTON": updateButton == null ? null : updateButton,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart';
|
||||||
|
|
||||||
|
class Menus {
|
||||||
|
GetMenuEntriesList menuEntry;
|
||||||
|
List<GetMenuEntriesList> menuEntiesList;
|
||||||
|
|
||||||
|
Menus(this.menuEntry, this.menuEntiesList);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,138 @@
|
|||||||
|
import 'package:easy_localization/src/public_ext.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
import 'package:mohem_flutter_app/config/routes.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/string_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/provider/dashboard_provider_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class MenusWidget extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
List<int> namesColor = [0xff125765, 0xff239D8F, 0xff2BB8A8, 0xff1D92AA];
|
||||||
|
|
||||||
|
return Consumer<DashboardProviderModel>(builder: (context, data, child) {
|
||||||
|
return GridView(
|
||||||
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 2 / 2, crossAxisSpacing: 9, mainAxisSpacing: 9),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
shrinkWrap: true,
|
||||||
|
primary: false,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
children: [
|
||||||
|
data.isWorkListLoading
|
||||||
|
? MenuShimmer().onPress(() {
|
||||||
|
data.fetchWorkListCounter();
|
||||||
|
})
|
||||||
|
: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(namesColor[0]),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
LocaleKeys.workList.tr().toText12(color: Colors.white),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: data.workListCounter.toString().toText16(color: Colors.white, isBold: true),
|
||||||
|
),
|
||||||
|
SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
).paddingOnly(left: 10, right: 10, bottom: 6, top: 6),
|
||||||
|
).onPress(() {
|
||||||
|
// Navigator.pushNamed(context, AppRoutes.workList);
|
||||||
|
data.fetchWorkListCounter();
|
||||||
|
}),
|
||||||
|
data.isMissingSwipeLoading
|
||||||
|
? MenuShimmer().onPress(() {
|
||||||
|
data.fetchWorkListCounter();
|
||||||
|
})
|
||||||
|
: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(namesColor[1]),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
LocaleKeys.missingSwipes.tr().toText12(color: Colors.white),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: data.missingSwipeCounter.toString().toText16(color: Colors.white, isBold: true),
|
||||||
|
),
|
||||||
|
SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
).paddingOnly(left: 10, right: 10, bottom: 6, top: 6),
|
||||||
|
).onPress(() {
|
||||||
|
Navigator.pushNamed(context, AppRoutes.workList);
|
||||||
|
}),
|
||||||
|
data.isLeaveTicketBalanceLoading
|
||||||
|
? MenuShimmer().onPress(() {
|
||||||
|
data.fetchWorkListCounter();
|
||||||
|
})
|
||||||
|
: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(namesColor[2]),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
LocaleKeys.leaveBalance.tr().toText12(color: Colors.white),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: data.leaveBalance.toString().toText16(color: Colors.white, isBold: true),
|
||||||
|
),
|
||||||
|
SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
).paddingOnly(left: 10, right: 10, bottom: 6, top: 6),
|
||||||
|
).onPress(() {
|
||||||
|
Navigator.pushNamed(context, AppRoutes.workList);
|
||||||
|
}),
|
||||||
|
data.isLeaveTicketBalanceLoading
|
||||||
|
? MenuShimmer().onPress(() {
|
||||||
|
data.fetchWorkListCounter();
|
||||||
|
})
|
||||||
|
: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(namesColor[3]),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
LocaleKeys.ticketBalance.tr().toText12(color: Colors.white),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: data.ticketBalance.toString().toText16(color: Colors.white, isBold: true),
|
||||||
|
),
|
||||||
|
SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
).paddingOnly(left: 10, right: 10, bottom: 6, top: 6),
|
||||||
|
).onPress(() {
|
||||||
|
Navigator.pushNamed(context, AppRoutes.workList);
|
||||||
|
})
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,147 @@
|
|||||||
|
import 'package:easy_localization/src/public_ext.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/svg.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/widget_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ServicesWidget extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
List<String> namesT = [LocaleKeys.monthlyAttendance.tr(), LocaleKeys.workFromHome.tr(), LocaleKeys.ticketRequest.tr(), LocaleKeys.monthlyAttendance.tr()];
|
||||||
|
List<String> iconT = [
|
||||||
|
"assets/images/monthly_attendance.svg",
|
||||||
|
"assets/images/work_from_home.svg",
|
||||||
|
"assets/images/ticket_request.svg",
|
||||||
|
"assets/images/work_from_home.svg",
|
||||||
|
"assets/images/work_from_home.svg",
|
||||||
|
"assets/images/work_from_home.svg",
|
||||||
|
"assets/images/work_from_home.svg",
|
||||||
|
"assets/images/work_from_home.svg"
|
||||||
|
];
|
||||||
|
|
||||||
|
return Consumer<DashboardProviderModel>(
|
||||||
|
builder: (context, data, child) {
|
||||||
|
return data.isServicesMenusLoading
|
||||||
|
? whileLoading()
|
||||||
|
: ListView.separated(
|
||||||
|
itemBuilder: (context, parentIndex) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
firstWord(data.homeMenus![parentIndex].menuEntry.prompt!).toText12(),
|
||||||
|
lastWord(data.homeMenus![parentIndex].menuEntry.prompt!).toText24(isBold: true),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
LocaleKeys.viewAllServices.tr().toText12(isUnderLine: true),
|
||||||
|
],
|
||||||
|
).paddingOnly(left: 21, right: 21),
|
||||||
|
SizedBox(
|
||||||
|
height: 105 + 26,
|
||||||
|
child: ListView.separated(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13),
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemBuilder: (cxt, index) {
|
||||||
|
return AspectRatio(
|
||||||
|
aspectRatio: 105 / 105,
|
||||||
|
child: data.isServicesMenusLoading
|
||||||
|
? ServicesMenuShimmer()
|
||||||
|
: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: const Color(0xff000000).withOpacity(.05),
|
||||||
|
blurRadius: 26,
|
||||||
|
offset: const Offset(0, -3),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SvgPicture.asset(iconT[index]),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText11(isBold: true),
|
||||||
|
),
|
||||||
|
SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
).paddingOnly(left: 10, right: 10, bottom: 10, top: 12),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (cxt, index) => 9.width,
|
||||||
|
itemCount: data.homeMenus![parentIndex].menuEntiesList.length),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (context, index) {
|
||||||
|
return 12.height;
|
||||||
|
},
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: NeverScrollableScrollPhysics(),
|
||||||
|
itemCount: data.homeMenus!.length);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String firstWord(String value) {
|
||||||
|
return value.split(" ").length > 1 ? value.split(" ")[0] : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
String lastWord(String value) {
|
||||||
|
var parts = value.split(" ");
|
||||||
|
if (parts.length == 1) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
int i = value.indexOf(" ");
|
||||||
|
return value.substring(i + 1).toCamelCase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget whileLoading() {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
ServicesHeaderShimmer().paddingOnly(left: 21, right: 21),
|
||||||
|
SizedBox(
|
||||||
|
height: 105 + 26,
|
||||||
|
child: ListView.separated(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13),
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemBuilder: (cxt, index) {
|
||||||
|
return AspectRatio(
|
||||||
|
aspectRatio: 105 / 105,
|
||||||
|
child: ServicesMenuShimmer(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (cxt, index) => 9.width,
|
||||||
|
itemCount: 4),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
/* ZiK */
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
|
typedef ChildProvider<E> = Widget Function(BuildContext context, E? data);
|
||||||
|
|
||||||
|
class Updater<T> extends StatelessWidget{
|
||||||
|
final ChildProvider<T> childProvider;
|
||||||
|
StreamController<T?>? sink;
|
||||||
|
T? initialData;
|
||||||
|
List<T?> _history = [];
|
||||||
|
|
||||||
|
Stream<T?>? _stream;
|
||||||
|
Updater({T? initialData, required this.childProvider}){
|
||||||
|
this.sink = StreamController<T?>();
|
||||||
|
this.initialData = initialData;
|
||||||
|
_stream = this.sink?.stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return StreamBuilder<T?>(
|
||||||
|
initialData: this.initialData,
|
||||||
|
stream: _stream,
|
||||||
|
builder: (ctx, snapshot){
|
||||||
|
return childProvider(context, snapshot.data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pushData(T? data) {
|
||||||
|
_history.add(data);
|
||||||
|
sink?.sink.add(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<T?> getDataHistory() => _history;
|
||||||
|
T? getLatestData() => _history.last;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue