|
|
|
@ -1,4 +1,4 @@
|
|
|
|
import 'package:easy_localization/src/public_ext.dart';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/gestures.dart';
|
|
|
|
import 'package:flutter/gestures.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:mohem_flutter_app/api/profile_api_client.dart';
|
|
|
|
import 'package:mohem_flutter_app/api/profile_api_client.dart';
|
|
|
|
@ -13,7 +13,6 @@ import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/get_employee_contacts.model.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/get_employee_contacts.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/profile/add_update_family_member.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/profile/add_update_family_member.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/profile/profile_screen.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
@ -28,22 +27,11 @@ class FamilyMembers extends StatefulWidget {
|
|
|
|
class _FamilyMembersState extends State<FamilyMembers> {
|
|
|
|
class _FamilyMembersState extends State<FamilyMembers> {
|
|
|
|
List<GetEmployeeContactsList> getEmployeeContactsList = [];
|
|
|
|
List<GetEmployeeContactsList> getEmployeeContactsList = [];
|
|
|
|
|
|
|
|
|
|
|
|
dynamic? relationId;
|
|
|
|
int? relationId;
|
|
|
|
int? flag;
|
|
|
|
|
|
|
|
GetMenuEntriesList menuEntries = GetMenuEntriesList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
List<GetMenuEntriesList> menuData = Provider.of<DashboardProviderModel>(context, listen: false).getMenuEntriesList!;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<GetMenuEntriesList> arr = menuData.where((GetMenuEntriesList e) => e.requestType == 'CONTACT').toList();
|
|
|
|
|
|
|
|
if (arr.isNotEmpty) {
|
|
|
|
|
|
|
|
menuEntries = arr[0];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
menuEntries = new GetMenuEntriesList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getEmployeeContacts();
|
|
|
|
getEmployeeContacts();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -59,7 +47,19 @@ class _FamilyMembersState extends State<FamilyMembers> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetMenuEntriesList _getContactMenuEntries(BuildContext context) {
|
|
|
|
|
|
|
|
List<GetMenuEntriesList> menuData = context.watch<DashboardProviderModel>().getMenuEntriesList ?? <GetMenuEntriesList>[];
|
|
|
|
|
|
|
|
List<GetMenuEntriesList> arr = menuData.where((GetMenuEntriesList e) => e.requestType == 'CONTACT').toList();
|
|
|
|
|
|
|
|
return arr.isNotEmpty ? arr.first : GetMenuEntriesList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
GetMenuEntriesList menuEntries = _getContactMenuEntries(context);
|
|
|
|
|
|
|
|
bool canAddFamilyMember = menuEntries.addButton == 'Y';
|
|
|
|
|
|
|
|
bool canUpdateFamilyMember = menuEntries.updateButton == 'Y';
|
|
|
|
|
|
|
|
bool canDeleteFamilyMember = menuEntries.deleteButton == 'Y';
|
|
|
|
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBarWidget(
|
|
|
|
appBar: AppBarWidget(
|
|
|
|
context,
|
|
|
|
context,
|
|
|
|
@ -95,16 +95,18 @@ class _FamilyMembersState extends State<FamilyMembers> {
|
|
|
|
child: Icon(
|
|
|
|
child: Icon(
|
|
|
|
Icons.edit,
|
|
|
|
Icons.edit,
|
|
|
|
size: 14,
|
|
|
|
size: 14,
|
|
|
|
color: menuEntries.updateButton == 'Y' ? MyColors.grey67Color : MyColors.lightGreyColor,
|
|
|
|
color: canUpdateFamilyMember ? MyColors.grey67Color : MyColors.lightGreyColor,
|
|
|
|
)),
|
|
|
|
)),
|
|
|
|
TextSpan(
|
|
|
|
TextSpan(
|
|
|
|
text: LocaleKeys.update.tr(),
|
|
|
|
text: LocaleKeys.update.tr(),
|
|
|
|
style: TextStyle(
|
|
|
|
style: TextStyle(
|
|
|
|
color: menuEntries.updateButton == 'Y' ? MyColors.grey67Color : MyColors.lightGreyColor, fontSize: 12, letterSpacing: -0.36, fontWeight: FontWeight.w600),
|
|
|
|
color: canUpdateFamilyMember ? MyColors.grey67Color : MyColors.lightGreyColor, fontSize: 12, letterSpacing: -0.36, fontWeight: FontWeight.w600),
|
|
|
|
recognizer: TapGestureRecognizer()
|
|
|
|
recognizer: TapGestureRecognizer()
|
|
|
|
..onTap = () async {
|
|
|
|
..onTap = () async {
|
|
|
|
relationId = getEmployeeContactsList[index]!.cONTACTRELATIONSHIPID;
|
|
|
|
relationId = getEmployeeContactsList[index].cONTACTRELATIONSHIPID;
|
|
|
|
menuEntries.updateButton == 'Y' ? showUpdateAlertDialog(context, relationId, 2, "UPDATE") : null;
|
|
|
|
if (canUpdateFamilyMember && relationId != null) {
|
|
|
|
|
|
|
|
showUpdateAlertDialog(context, relationId, 2, "UPDATE");
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -117,19 +119,21 @@ class _FamilyMembersState extends State<FamilyMembers> {
|
|
|
|
child: Icon(
|
|
|
|
child: Icon(
|
|
|
|
Icons.delete,
|
|
|
|
Icons.delete,
|
|
|
|
size: 15,
|
|
|
|
size: 15,
|
|
|
|
color: menuEntries.updateButton == 'Y' ? MyColors.redColor : MyColors.lightGreyColor,
|
|
|
|
color: canDeleteFamilyMember ? MyColors.redColor : MyColors.lightGreyColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
TextSpan(
|
|
|
|
TextSpan(
|
|
|
|
text: LocaleKeys.remove.tr(),
|
|
|
|
text: LocaleKeys.remove.tr(),
|
|
|
|
style: TextStyle(
|
|
|
|
style: TextStyle(
|
|
|
|
color: menuEntries.updateButton == 'Y' ? MyColors.redColor : MyColors.lightGreyColor, fontSize: 12, letterSpacing: -0.36, fontWeight: FontWeight.w600),
|
|
|
|
color: canDeleteFamilyMember ? MyColors.redColor : MyColors.lightGreyColor, fontSize: 12, letterSpacing: -0.36, fontWeight: FontWeight.w600),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
).onPress(() {
|
|
|
|
).onPress(() {
|
|
|
|
relationId = getEmployeeContactsList[index]!.cONTACTRELATIONSHIPID;
|
|
|
|
relationId = getEmployeeContactsList[index].cONTACTRELATIONSHIPID;
|
|
|
|
menuEntries.updateButton == 'Y' ? showRemoveAlertDialog(context, relationId) : null;
|
|
|
|
if (canDeleteFamilyMember && relationId != null) {
|
|
|
|
|
|
|
|
showRemoveAlertDialog(context, relationId);
|
|
|
|
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -139,10 +143,13 @@ class _FamilyMembersState extends State<FamilyMembers> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
DefaultButton(
|
|
|
|
DefaultButton(
|
|
|
|
LocaleKeys.addNewFamilyMember.tr(),
|
|
|
|
LocaleKeys.addNewFamilyMember.tr(),
|
|
|
|
menuEntries.updateButton == 'Y'
|
|
|
|
canAddFamilyMember
|
|
|
|
? () async {
|
|
|
|
? () async {
|
|
|
|
Navigator.pushNamed(context, AppRoutes.addUpdateFamilyMember, arguments: FamilyMemberScreenParams( relationId, flag: 1, actionType: "ADD"));
|
|
|
|
Navigator.pushNamed(
|
|
|
|
// ProfileScreen();
|
|
|
|
context,
|
|
|
|
|
|
|
|
AppRoutes.addUpdateFamilyMember,
|
|
|
|
|
|
|
|
arguments: FamilyMemberScreenParams(null, flag: 1, actionType: "ADD"),
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
: null)
|
|
|
|
: null)
|
|
|
|
.insideContainer,
|
|
|
|
.insideContainer,
|
|
|
|
@ -164,6 +171,7 @@ class _FamilyMembersState extends State<FamilyMembers> {
|
|
|
|
LocaleKeys.ok.tr(),
|
|
|
|
LocaleKeys.ok.tr(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
Navigator.pushNamed(
|
|
|
|
Navigator.pushNamed(
|
|
|
|
context,
|
|
|
|
context,
|
|
|
|
AppRoutes.addUpdateFamilyMember,
|
|
|
|
AppRoutes.addUpdateFamilyMember,
|
|
|
|
@ -203,7 +211,7 @@ class _FamilyMembersState extends State<FamilyMembers> {
|
|
|
|
LocaleKeys.ok.tr(),
|
|
|
|
LocaleKeys.ok.tr(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.pushNamed(context, AppRoutes.deleteFamilyMember, arguments: FamilyMemberScreenParams(relationId));
|
|
|
|
Navigator.pushNamed(context, AppRoutes.deleteFamilyMember, arguments: relationId);
|
|
|
|
// continueDynamicForms();
|
|
|
|
// continueDynamicForms();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|