480 lines
26 KiB
Dart
480 lines
26 KiB
Dart
|
import 'package:auto_size_text/auto_size_text.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
|
||
|
import 'package:fluttericon/font_awesome5_icons.dart';
|
||
|
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/dashboard_icon_generator.dart';
|
||
|
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/superadmin_expanded_menu.dart';
|
||
|
import 'package:unit2/screens/unit2/homepage.dart/module-screen.dart';
|
||
|
import 'package:unit2/theme-data.dart/colors.dart';
|
||
|
import './shared_card_label.dart';
|
||
|
|
||
|
class DashBoard extends StatefulWidget {
|
||
|
final List<DisplayCard> cards;
|
||
|
final int userId;
|
||
|
const DashBoard({super.key, required this.cards, required this.userId});
|
||
|
|
||
|
@override
|
||
|
State<DashBoard> createState() => _DashBoardState();
|
||
|
}
|
||
|
|
||
|
List<String> finishRoles = [];
|
||
|
List<DisplayCard> unit2Cards = [];
|
||
|
List<DisplayCard> superadminCards = [];
|
||
|
List<DisplayCard> rpassCards = [];
|
||
|
List<DisplayCard> docSmsCards = [];
|
||
|
List<DisplayCard> tempSuperAdminCards = [];
|
||
|
List<DisplayCard> tempUnit2Cards = [];
|
||
|
|
||
|
class _DashBoardState extends State<DashBoard> {
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
setState(() {
|
||
|
finishRoles.clear();
|
||
|
unit2Cards.clear();
|
||
|
superadminCards.clear();
|
||
|
rpassCards.clear();
|
||
|
docSmsCards.clear();
|
||
|
tempSuperAdminCards.clear();
|
||
|
});
|
||
|
widget.cards.forEach((e) {
|
||
|
if (e.moduleName == "unit2") {
|
||
|
if (!finishRoles.contains(e.object.name)) {
|
||
|
unit2Cards.add(e);
|
||
|
}
|
||
|
finishRoles.add(e.object.name!);
|
||
|
}
|
||
|
if (e.moduleName == 'superadmin') {
|
||
|
superadminCards.add(e);
|
||
|
}
|
||
|
if (e.moduleName == 'rpass') {
|
||
|
rpassCards.add(e);
|
||
|
}
|
||
|
if (e.moduleName == 'document management') {
|
||
|
docSmsCards.add(e);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
if (superadminCards.length > 3) {
|
||
|
tempSuperAdminCards = superadminCards.sublist(0, 4);
|
||
|
}
|
||
|
if (unit2Cards.length > 3) {
|
||
|
tempUnit2Cards = unit2Cards.sublist(0, 4);
|
||
|
}
|
||
|
|
||
|
return Container(
|
||
|
padding:
|
||
|
const EdgeInsetsDirectional.symmetric(vertical: 24, horizontal: 24),
|
||
|
child: ListView(
|
||
|
children: [
|
||
|
Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
////unit2 module operations
|
||
|
Container(child: unit2Cards.isEmpty?const SizedBox():Text(
|
||
|
"Unit2 module operations",
|
||
|
style: Theme.of(context).textTheme.displaySmall!.copyWith(
|
||
|
fontSize: 16, color: primary, fontWeight: FontWeight.w300),
|
||
|
),),
|
||
|
SizedBox(
|
||
|
height: unit2Cards.isEmpty?0: 8,
|
||
|
),
|
||
|
Container(child: unit2Cards.isEmpty?const SizedBox():GridView.count(
|
||
|
shrinkWrap: true,
|
||
|
crossAxisCount: 4,
|
||
|
crossAxisSpacing: 8,
|
||
|
mainAxisSpacing: 10,
|
||
|
physics: const BouncingScrollPhysics(),
|
||
|
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 5),
|
||
|
children: unit2Cards.length > 3
|
||
|
? tempUnit2Cards.map((
|
||
|
e,
|
||
|
) {
|
||
|
int index = tempUnit2Cards.indexOf(e);
|
||
|
//// if unit2 cards is less then 3
|
||
|
return Container(
|
||
|
child: index == 3
|
||
|
? CardLabel(
|
||
|
icon: FontAwesome5.chevron_circle_right,
|
||
|
title: "See More",
|
||
|
ontap: () {
|
||
|
showDialog(
|
||
|
context: context,
|
||
|
builder: (BuildContext context) {
|
||
|
return AlertDialog(
|
||
|
title: const Text(
|
||
|
"Unit2 Admin Module Operations",
|
||
|
textAlign: TextAlign.center,
|
||
|
),
|
||
|
content: Column(
|
||
|
mainAxisSize: MainAxisSize.min,
|
||
|
children: [
|
||
|
SizedBox(
|
||
|
height: 200,
|
||
|
width: double.maxFinite,
|
||
|
child: GridView.count(
|
||
|
shrinkWrap: true,
|
||
|
crossAxisCount: 3,
|
||
|
crossAxisSpacing: 8,
|
||
|
mainAxisSpacing: 10,
|
||
|
physics:
|
||
|
const BouncingScrollPhysics(),
|
||
|
padding:
|
||
|
const EdgeInsets
|
||
|
.symmetric(
|
||
|
vertical: 5,
|
||
|
horizontal: 5),
|
||
|
children:
|
||
|
unit2Cards.map((
|
||
|
e,
|
||
|
) {
|
||
|
int index = unit2Cards
|
||
|
.indexOf(e);
|
||
|
//// if unit2 cards is less then 3
|
||
|
return AnimationConfiguration
|
||
|
.staggeredGrid(
|
||
|
position: index,
|
||
|
columnCount: 3,
|
||
|
child:
|
||
|
ScaleAnimation(
|
||
|
child:
|
||
|
FadeInAnimation(
|
||
|
child: Container(
|
||
|
child: (e.roleName == 'superadmin' || e.roleName == 'qr code scanner' || e.roleName == 'security guard' || e.roleName == 'establishment point-person' || e.roleName == 'registration in-charge') && e.moduleName == 'unit2'
|
||
|
? CardLabel(
|
||
|
icon: iconGenerator(name: e.object.name!),
|
||
|
title: e.object.name!.toLowerCase() == 'role based access control'
|
||
|
? "RBAC"
|
||
|
: e.object.name!.toLowerCase() == "person basic information"
|
||
|
? "Basic Info"
|
||
|
: e.object.name!,
|
||
|
ontap: () {
|
||
|
if (e.object.name!.toLowerCase() == 'pass check') {
|
||
|
PassCheckArguments passCheckArguments = PassCheckArguments(roleId: 10, userId: widget.userId);
|
||
|
Navigator.pushNamed(context, '/pass-check', arguments: passCheckArguments);
|
||
|
}
|
||
|
if (e.object.name!.toLowerCase() == 'role based access control') {
|
||
|
Navigator.pushNamed(context, '/rbac');
|
||
|
}
|
||
|
})
|
||
|
: Container(
|
||
|
color:
|
||
|
Colors.black,
|
||
|
)),
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}).toList()),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
});
|
||
|
})
|
||
|
: (e.roleName == 'superadmin' ||
|
||
|
e.roleName == 'qr code scanner' ||
|
||
|
e.roleName == 'security guard' ||
|
||
|
e.roleName ==
|
||
|
'establishment point-person' ||
|
||
|
e.roleName ==
|
||
|
'registration in-charge') &&
|
||
|
e.moduleName == 'unit2'
|
||
|
? CardLabel(
|
||
|
icon:
|
||
|
iconGenerator(name: e.object.name!),
|
||
|
title: e.object.name!.toLowerCase() ==
|
||
|
'role based access control'
|
||
|
? "RBAC"
|
||
|
: e.object.name!.toLowerCase() ==
|
||
|
"person basic information"
|
||
|
? "Basic Info"
|
||
|
: e.object.name!,
|
||
|
ontap: () {
|
||
|
if (e.object.name!.toLowerCase() ==
|
||
|
'pass check') {
|
||
|
PassCheckArguments
|
||
|
passCheckArguments =
|
||
|
PassCheckArguments(
|
||
|
roleId: 10,
|
||
|
userId: widget.userId);
|
||
|
Navigator.pushNamed(
|
||
|
context, '/pass-check',
|
||
|
arguments: passCheckArguments);
|
||
|
}
|
||
|
if (e.object.name!.toLowerCase() ==
|
||
|
'role based access control') {
|
||
|
Navigator.pushNamed(
|
||
|
context, '/rbac');
|
||
|
}
|
||
|
})
|
||
|
: Container(
|
||
|
color: Colors.black,
|
||
|
));
|
||
|
}).toList()
|
||
|
: unit2Cards.map((
|
||
|
e,
|
||
|
) {
|
||
|
////if unit2 cards is greater than 3
|
||
|
return Container(
|
||
|
child: (e.roleName == 'superadmin' ||
|
||
|
e.roleName == 'qr code scanner' ||
|
||
|
e.roleName == 'security guard' ||
|
||
|
e.roleName ==
|
||
|
'establishment point-person' ||
|
||
|
e.roleName ==
|
||
|
'registration in-charge') &&
|
||
|
e.moduleName == 'unit2'
|
||
|
? CardLabel(
|
||
|
icon: iconGenerator(name: e.object.name!),
|
||
|
title: e.object.name!.toLowerCase() ==
|
||
|
'role based access control'
|
||
|
? "RBAC"
|
||
|
: e.object.name!.toLowerCase() ==
|
||
|
"person basic information"
|
||
|
? "Basic Info"
|
||
|
: e.object.name!,
|
||
|
ontap: () {
|
||
|
if (e.object.name!.toLowerCase() ==
|
||
|
'pass check') {
|
||
|
PassCheckArguments passCheckArguments =
|
||
|
PassCheckArguments(
|
||
|
roleId: 10,
|
||
|
userId: widget.userId);
|
||
|
Navigator.pushNamed(
|
||
|
context, '/pass-check',
|
||
|
arguments: passCheckArguments);
|
||
|
}
|
||
|
if (e.object.name!.toLowerCase() ==
|
||
|
'role based access control') {
|
||
|
Navigator.pushNamed(context, '/rbac');
|
||
|
}
|
||
|
})
|
||
|
: Container(
|
||
|
color: Colors.black,
|
||
|
));
|
||
|
}).toList(),
|
||
|
),),
|
||
|
SizedBox(
|
||
|
height: unit2Cards.isEmpty?0:24,
|
||
|
),
|
||
|
Container(child: superadminCards.isEmpty?const SizedBox(): Text(
|
||
|
"Superadmin module operations",
|
||
|
style: Theme.of(context).textTheme.displaySmall!.copyWith(
|
||
|
fontSize: 16, color: primary, fontWeight: FontWeight.w300),
|
||
|
),),
|
||
|
SizedBox(
|
||
|
height: superadminCards.isEmpty? 0: 8,
|
||
|
),
|
||
|
Container(child: superadminCards.isEmpty?const SizedBox():GridView.count(
|
||
|
shrinkWrap: true,
|
||
|
crossAxisCount: 4,
|
||
|
crossAxisSpacing: 8,
|
||
|
mainAxisSpacing: 10,
|
||
|
physics: const BouncingScrollPhysics(),
|
||
|
padding:
|
||
|
const EdgeInsets.symmetric(vertical: 5, horizontal: 5),
|
||
|
children: superadminCards.length > 3
|
||
|
//// in superadmincards lenght is greaterthan 3
|
||
|
? tempSuperAdminCards.map((e) {
|
||
|
int index = tempSuperAdminCards.indexOf(e);
|
||
|
return Container(
|
||
|
child: index == 3
|
||
|
? CardLabel(
|
||
|
icon: FontAwesome5.chevron_circle_right,
|
||
|
title: "See More",
|
||
|
ontap: () {
|
||
|
showDialog(
|
||
|
context: context,
|
||
|
builder: (BuildContext context) {
|
||
|
return AlertDialog(
|
||
|
title: const Text(
|
||
|
"Super Admin Module Operations",
|
||
|
textAlign: TextAlign.center,
|
||
|
),
|
||
|
content: Column(
|
||
|
mainAxisSize:
|
||
|
MainAxisSize.min,
|
||
|
children: [
|
||
|
SizedBox(
|
||
|
height: 480,
|
||
|
width: double.maxFinite,
|
||
|
child: GridView.count(
|
||
|
shrinkWrap: true,
|
||
|
crossAxisCount: 3,
|
||
|
crossAxisSpacing: 8,
|
||
|
mainAxisSpacing: 10,
|
||
|
physics:
|
||
|
const BouncingScrollPhysics(),
|
||
|
padding:
|
||
|
const EdgeInsets
|
||
|
.symmetric(
|
||
|
vertical: 5,
|
||
|
horizontal: 5),
|
||
|
children:
|
||
|
superadminCards
|
||
|
.map((e) {
|
||
|
int index =
|
||
|
superadminCards
|
||
|
.indexOf(e);
|
||
|
return SuperAdminMenu(
|
||
|
id: widget.userId,
|
||
|
columnCount: 3,
|
||
|
index: index,
|
||
|
object: e,
|
||
|
);
|
||
|
}).toList(),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
});
|
||
|
})
|
||
|
: SuperAdminMenu(
|
||
|
id: widget.userId,
|
||
|
object: e,
|
||
|
index: index,
|
||
|
columnCount: 3,
|
||
|
));
|
||
|
}).toList()
|
||
|
//// in superadmincards lenght is lessthan 3
|
||
|
: superadminCards.map((e) {
|
||
|
int index = tempSuperAdminCards.indexOf(e);
|
||
|
return Container(
|
||
|
child: index == 3
|
||
|
? CardLabel(
|
||
|
icon: FontAwesome5.chevron_circle_right,
|
||
|
title: "See More",
|
||
|
ontap: () {
|
||
|
showDialog(
|
||
|
context: context,
|
||
|
builder: (BuildContext context) {
|
||
|
return AlertDialog(
|
||
|
title: const Text(
|
||
|
"Super Admin Module Operations",
|
||
|
textAlign: TextAlign.center,
|
||
|
),
|
||
|
content: Column(
|
||
|
mainAxisSize:
|
||
|
MainAxisSize.min,
|
||
|
children: [
|
||
|
SizedBox(
|
||
|
height: 480,
|
||
|
width: double.maxFinite,
|
||
|
child: GridView.count(
|
||
|
shrinkWrap: true,
|
||
|
crossAxisCount: 3,
|
||
|
crossAxisSpacing: 8,
|
||
|
mainAxisSpacing: 10,
|
||
|
physics:
|
||
|
const BouncingScrollPhysics(),
|
||
|
padding:
|
||
|
const EdgeInsets
|
||
|
.symmetric(
|
||
|
vertical: 5,
|
||
|
horizontal: 5),
|
||
|
children:
|
||
|
superadminCards
|
||
|
.map((e) {
|
||
|
return SuperAdminMenu(
|
||
|
id: widget.userId,
|
||
|
columnCount: 4,
|
||
|
index: index,
|
||
|
object: e,
|
||
|
);
|
||
|
}).toList(),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
});
|
||
|
})
|
||
|
: SuperAdminMenu(
|
||
|
id: widget.userId,
|
||
|
object: e,
|
||
|
index: index,
|
||
|
columnCount: 4,
|
||
|
));
|
||
|
}).toList())),
|
||
|
const SizedBox(
|
||
|
height: 24,
|
||
|
),
|
||
|
Container(child: rpassCards.isEmpty?const SizedBox(): Text(
|
||
|
"RPAss module operations",
|
||
|
style: Theme.of(context).textTheme.displaySmall!.copyWith(
|
||
|
fontSize: 16, color: primary, fontWeight: FontWeight.w300),
|
||
|
),)
|
||
|
, SizedBox(
|
||
|
height:rpassCards.isEmpty?0: 8,
|
||
|
),
|
||
|
Container(child: rpassCards.isEmpty?const SizedBox():GridView.count(
|
||
|
shrinkWrap: true,
|
||
|
crossAxisCount: 4,
|
||
|
crossAxisSpacing: 8,
|
||
|
mainAxisSpacing: 10,
|
||
|
physics: const BouncingScrollPhysics(),
|
||
|
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 5),
|
||
|
children: rpassCards.map((e) {
|
||
|
return Container(
|
||
|
child: (e.roleName == 'field surveyor') &&
|
||
|
e.moduleName == 'rpass'
|
||
|
? CardLabel(
|
||
|
icon: iconGenerator(name: e.object.name!),
|
||
|
title: e.object.name == 'Real Property'
|
||
|
? "Field Surveyor"
|
||
|
: e.object.name!,
|
||
|
ontap: () {})
|
||
|
: Container(
|
||
|
color: Colors.black,
|
||
|
));
|
||
|
}).toList(),
|
||
|
),),
|
||
|
const SizedBox(
|
||
|
height: 24,
|
||
|
),
|
||
|
Container(child: docSmsCards.isEmpty?const SizedBox(): Text(
|
||
|
"DocSMS module operations",
|
||
|
style: Theme.of(context).textTheme.displaySmall!.copyWith(
|
||
|
fontSize: 16, color: primary, fontWeight: FontWeight.w300),
|
||
|
),),
|
||
|
const SizedBox(
|
||
|
height: 8,
|
||
|
),
|
||
|
GridView.count(
|
||
|
shrinkWrap: true,
|
||
|
crossAxisCount: 4,
|
||
|
crossAxisSpacing: 8,
|
||
|
mainAxisSpacing: 10,
|
||
|
physics: const BouncingScrollPhysics(),
|
||
|
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 5),
|
||
|
children: docSmsCards.map((e) {
|
||
|
return Container(
|
||
|
child: (e.roleName == 'process server') &&
|
||
|
e.moduleName == 'document management'
|
||
|
? CardLabel(
|
||
|
icon: iconGenerator(name: e.object.name!),
|
||
|
title: e.object.name == "Document"
|
||
|
? "Process Server"
|
||
|
: e.object.name!,
|
||
|
ontap: () {
|
||
|
|
||
|
})
|
||
|
: Container(
|
||
|
color: Colors.black,
|
||
|
));
|
||
|
}).toList(),
|
||
|
)
|
||
|
],
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class PassCheckArguments {
|
||
|
final int roleId;
|
||
|
final int userId;
|
||
|
const PassCheckArguments({required this.roleId, required this.userId});
|
||
|
}
|