From d1f61200fcb3d581856fd5014c3b4492a8a1a794 Mon Sep 17 00:00:00 2001 From: yaso-meth Date: Sat, 24 Aug 2024 05:10:38 +0200 Subject: [PATCH] remove multi layer list with list of homeTile grids --- .../lib/components/homeTileGrid.dart | 552 ++++++++++++------ 1 file changed, 363 insertions(+), 189 deletions(-) diff --git a/Frontend/patient_manager/lib/components/homeTileGrid.dart b/Frontend/patient_manager/lib/components/homeTileGrid.dart index a4db665e..c47d4b5c 100644 --- a/Frontend/patient_manager/lib/components/homeTileGrid.dart +++ b/Frontend/patient_manager/lib/components/homeTileGrid.dart @@ -30,196 +30,346 @@ class HomeTileGrid extends StatefulWidget { } class _HomeTileGridState extends State { - late List> personalTileList = []; - late List> businessTileList = []; - late List> devTileList = []; - late List>> pbswitch; + late List persHTList = []; + late List busHTList = []; + late List> pbswitch; late bool businessUserSwitch; int _selectedIndex = 0; final baseAPI = AppEnviroment.baseApiUrl; - void setAppsNewPersonal(List> tileList) { + void setAppsNewPersonal(List tileList) { if (widget.signedInUser.fname == "") { - tileList.add( - [ - Icons.perm_identity, - "Setup Profie", - () { - Navigator.of(context) - .popAndPushNamed('/profile', arguments: widget.signedInUser); - // Navigator.popAndPushNamed(context, '/patient-manager', - // arguments: widget.userEmail); - } - ], - ); + tileList.add(HomeTile( + onTap: () { + Navigator.of(context) + .popAndPushNamed('/profile', arguments: widget.signedInUser); + }, + tileName: "Setup Profie", + tileIcon: Icons.perm_identity, + p: getPrim(), + s: getSec(), + )); + // tileList.add( + // [ + // home + // Icons.perm_identity, + // "Setup Profie", + // () { + // Navigator.of(context) + // .popAndPushNamed('/profile', arguments: widget.signedInUser); + // // Navigator.popAndPushNamed(context, '/patient-manager', + // // arguments: widget.userEmail); + // } + // ], + // ); } } - void setAppsNewBusiness(List> tileList) { - tileList.add( - [ - Icons.add_business_outlined, - "Setup Business", - () { + void setAppsNewBusiness(List tileList) { + tileList.add(HomeTile( + onTap: () { + Navigator.of(context).popAndPushNamed( + '/business/add', + arguments: widget.signedInUser, + ); + }, + tileName: "Setup Business", + tileIcon: Icons.add_business_outlined, + p: getPrim(), + s: getSec(), + )); + // tileList.add( + // [ + // Icons.add_business_outlined, + // "Setup Business", + // () { + // Navigator.of(context).popAndPushNamed( + // '/business/add', + // arguments: widget.signedInUser, + // ); + // } + // ], + // ); + } + + void setAppsPersonal(List tileList) { + tileList.add(HomeTile( + onTap: () { + Navigator.of(context).popAndPushNamed('/patient-profile', + arguments: PatientViewArguments( + widget.signedInUser, null, null, null, "personal")); + }, + tileName: "Patient Profile", + tileIcon: Icons.medication, + p: getPrim(), + s: getSec(), + )); + tileList.add(HomeTile( + onTap: () { + Navigator.of(context).popAndPushNamed( + '/patient-access-review', + arguments: widget.signedInUser, + ); + }, + tileName: "Access Review", + tileIcon: Icons.check_box_outlined, + p: getPrim(), + s: getSec(), + )); + // tileList.add( + // [ + // Icons.medication, + // "Patient Profile", + // () { + // //comeback here + // Navigator.of(context).popAndPushNamed('/patient-profile', + // arguments: PatientViewArguments( + // widget.signedInUser, null, null, null, "personal")); + // // Navigator.popAndPushNamed(context, '/patient-manager', + // // arguments: widget.userEmail); + // } + // ], + // ); + // tileList.add( + // [ + // Icons.check_box_outlined, + // "Access Review", + // () { + // Navigator.of(context).popAndPushNamed( + // '/patient-access-review', + // arguments: widget.signedInUser, + // ); + // // Navigator.popAndPushNamed(context, '/patient-manager', + // // arguments: widget.userEmail); + // } + // ], + // ); + } + + void setAppsBusiness(List tileList) { + if (widget.businessUser!.access == "Full") { + tileList.add(HomeTile( + onTap: () { + Navigator.of(context).popAndPushNamed( + '/business-profile', + arguments: BusinessArguments( + widget.signedInUser, + widget.businessUser, + widget.business, + ), + ); + }, + tileName: "Business Profile", + tileIcon: Icons.business, + p: getPrim(), + s: getSec(), + )); + + // tileList.add( + // [ + // Icons.business, + // "Business Profile", + // () { + // Navigator.of(context).popAndPushNamed( + // '/business-profile', + // arguments: BusinessArguments( + // widget.signedInUser, + // widget.businessUser, + // widget.business, + // ), + // ); + // // Navigator.popAndPushNamed(context, '/patient-manager', + // // arguments: widget.userEmail); + // } + // ], + // ); + } + if (widget.business!.type == "Doctors Office") { + tileList.add(HomeTile( + onTap: () { + Navigator.of(context).popAndPushNamed( + '/patient-manager', + arguments: BusinessArguments( + widget.signedInUser, + widget.businessUser, + widget.business, + ), + ); + }, + tileName: "Manage Patient", + tileIcon: Icons.medication, + p: getPrim(), + s: getSec(), + )); + // tileList.add( + // [ + // Icons.medication, + // "Manage Patient", + // () { + // Navigator.of(context).popAndPushNamed( + // '/patient-manager', + // arguments: BusinessArguments( + // widget.signedInUser, + // widget.businessUser, + // widget.business, + // ), + // ); + // // Navigator.popAndPushNamed(context, '/patient-manager', + // // arguments: widget.userEmail); + // } + // ], + // ); + } + } + + void setAppsDev(List tileList) { + if (AppEnviroment.getEnv() == "Dev") { + tileList.add(HomeTile( + onTap: () { + showDialog( + context: context, + builder: (context) { + return const Mihloadingcircle(); + }, + ); + }, + tileName: "Loading - Dev", + tileIcon: Icons.change_circle, + p: getPrim(), + s: getSec(), + )); + // tileList.add( + // [ + // Icons.change_circle, + // "Loading - Dev", + // () { + // showDialog( + // context: context, + // builder: (context) { + // return const Mihloadingcircle(); + // }, + // ); + // } + // ], + // ); + tileList.add(HomeTile( + onTap: () { Navigator.of(context).popAndPushNamed( '/business/add', arguments: widget.signedInUser, ); - } - ], - ); - } - - void setAppsPersonal(List> tileList) { - tileList.add( - [ - Icons.medication, - "Patient Profile", - () { - //comeback here - Navigator.of(context).popAndPushNamed('/patient-profile', - arguments: PatientViewArguments( - widget.signedInUser, null, null, null, "personal")); - // Navigator.popAndPushNamed(context, '/patient-manager', - // arguments: widget.userEmail); - } - ], - ); - tileList.add( - [ - Icons.check_box_outlined, - "Access Review", - () { - Navigator.of(context).popAndPushNamed( - '/patient-access-review', - arguments: widget.signedInUser, - ); - // Navigator.popAndPushNamed(context, '/patient-manager', - // arguments: widget.userEmail); - } - ], - ); - } - - void setAppsBusiness(List> tileList) { - if (widget.businessUser!.access == "Full") { - tileList.add( - [ - Icons.business, - "Business Profile", - () { - Navigator.of(context).popAndPushNamed( - '/business-profile', - arguments: BusinessArguments( - widget.signedInUser, - widget.businessUser, - widget.business, - ), - ); - // Navigator.popAndPushNamed(context, '/patient-manager', - // arguments: widget.userEmail); - } - ], - ); - } - if (widget.business!.type == "Doctors Office") { - tileList.add( - [ - Icons.medication, - "Manage Patient", - () { - Navigator.of(context).popAndPushNamed( - '/patient-manager', - arguments: BusinessArguments( - widget.signedInUser, - widget.businessUser, - widget.business, - ), - ); - // Navigator.popAndPushNamed(context, '/patient-manager', - // arguments: widget.userEmail); - } - ], - ); - } - } - - void setAppsDev(List> tileList) { - if (AppEnviroment.getEnv() == "Dev") { - tileList.add( - [ - Icons.change_circle, - "Loading - Dev", - () { - showDialog( - context: context, - builder: (context) { - return const Mihloadingcircle(); - }, - ); - } - ], - ); - tileList.add( - [ - Icons.add_business_outlined, - "Setup Bus - Dev", - () { - Navigator.of(context).popAndPushNamed( - '/business/add', - arguments: widget.signedInUser, - ); - } - ], - ); - tileList.add([ - Icons.add_circle_outline, - "Add Pat - Dev", - () { + }, + tileName: "Setup Bus - Dev", + tileIcon: Icons.add_business_outlined, + p: getPrim(), + s: getSec(), + )); + // tileList.add( + // [ + // Icons.add_business_outlined, + // "Setup Bus - Dev", + // () { + // Navigator.of(context).popAndPushNamed( + // '/business/add', + // arguments: widget.signedInUser, + // ); + // } + // ], + // ); + tileList.add(HomeTile( + onTap: () { Navigator.of(context).popAndPushNamed('/patient-manager/add', arguments: widget.signedInUser); - } - ]); - tileList.add( - [ - Icons.perm_identity, - "Upd Prof - Dev", - () { - Navigator.of(context) - .popAndPushNamed('/profile', arguments: widget.signedInUser); - // Navigator.popAndPushNamed(context, '/patient-manager', - // arguments: widget.userEmail); - } - ], - ); - tileList.add([ - Icons.warning_amber_rounded, - "Warn - Dev", - () { + }, + tileName: "Add Pat - Dev", + tileIcon: Icons.add_circle_outline, + p: getPrim(), + s: getSec(), + )); + // tileList.add([ + // Icons.add_circle_outline, + // "Add Pat - Dev", + // () { + // Navigator.of(context).popAndPushNamed('/patient-manager/add', + // arguments: widget.signedInUser); + // } + // ]); + tileList.add(HomeTile( + onTap: () { + Navigator.of(context) + .popAndPushNamed('/profile', arguments: widget.signedInUser); + }, + tileName: "Upd Prof - Dev", + tileIcon: Icons.perm_identity, + p: getPrim(), + s: getSec(), + )); + // tileList.add( + // [ + // Icons.perm_identity, + // "Upd Prof - Dev", + // () { + // Navigator.of(context) + // .popAndPushNamed('/profile', arguments: widget.signedInUser); + // // Navigator.popAndPushNamed(context, '/patient-manager', + // // arguments: widget.userEmail); + // } + // ], + // ); + tileList.add(HomeTile( + onTap: () { showDialog( context: context, builder: (context) { return const MIHWarningMessage(warningType: "No Access"); }, ); - } - ]); - tileList.add([ - Icons.error_outline_outlined, - "Error - Dev", - () { + }, + tileName: "Warn - Dev", + tileIcon: Icons.warning_amber_rounded, + p: getPrim(), + s: getSec(), + )); + // tileList.add([ + // Icons.warning_amber_rounded, + // "Warn - Dev", + // () { + // showDialog( + // context: context, + // builder: (context) { + // return const MIHWarningMessage(warningType: "No Access"); + // }, + // ); + // } + // ]); + tileList.add(HomeTile( + onTap: () { showDialog( context: context, builder: (context) { return const MIHErrorMessage(errorType: "Invalid Username"); }, ); - } - ]); - tileList.add([ - Icons.check_circle_outline_outlined, - "Success - Dev", - () { + }, + tileName: "Error - Dev", + tileIcon: Icons.error_outline_outlined, + p: getPrim(), + s: getSec(), + )); + // tileList.add([ + // Icons.error_outline_outlined, + // "Error - Dev", + // () { + // showDialog( + // context: context, + // builder: (context) { + // return const MIHErrorMessage(errorType: "Invalid Username"); + // }, + // ); + // } + // ]); + tileList.add(HomeTile( + onTap: () { showDialog( context: context, builder: (context) { @@ -229,50 +379,74 @@ class _HomeTileGridState extends State { "Congratulations! Your account has been created successfully. You are log in and can start exploring.\n\nPlease note: more apps will appear once you update your profile."); }, ); - } - ]); - tileList.add([ - Icons.delete_forever_outlined, - "Delete - Dev", - () { + }, + tileName: "Success - Dev", + tileIcon: Icons.check_circle_outline_outlined, + p: getPrim(), + s: getSec(), + )); + // tileList.add([ + // Icons.check_circle_outline_outlined, + // "Success - Dev", + // () { + // showDialog( + // context: context, + // builder: (context) { + // return const MIHSuccessMessage( + // successType: "Success", + // successMessage: + // "Congratulations! Your account has been created successfully. You are log in and can start exploring.\n\nPlease note: more apps will appear once you update your profile."); + // }, + // ); + // } + // ]); + tileList.add(HomeTile( + onTap: () { showDialog( context: context, builder: (context) { return MIHDeleteMessage(deleteType: "File", onTap: () {}); }, ); - } - ]); + }, + tileName: "Delete - Dev", + tileIcon: Icons.delete_forever_outlined, + p: getPrim(), + s: getSec(), + )); + // tileList.add([ + // Icons.delete_forever_outlined, + // "Delete - Dev", + // () { + // showDialog( + // context: context, + // builder: (context) { + // return MIHDeleteMessage(deleteType: "File", onTap: () {}); + // }, + // ); + // } + // ]); } } - List>> setApps(List> personalTileList, - List> businessTileList) { - //print(widget.businessUser); + List> setApps( + List personalTileList, List businessTileList) { if (widget.signedInUser.fname == "") { - //print("New personal user"); setAppsNewPersonal(personalTileList); } else if (widget.signedInUser.type == "personal") { - //print("existing personal user"); setAppsPersonal(personalTileList); } else if (widget.businessUser == null) { - //print("new business user"); setAppsPersonal(personalTileList); setAppsNewBusiness(businessTileList); } else { - //business - //print("existing business user"); setAppsPersonal(personalTileList); setAppsBusiness(businessTileList); } if (AppEnviroment.getEnv() == "Dev") { - //print("Dev Enviroment"); setAppsDev(personalTileList); setAppsDev(businessTileList); } return [personalTileList, businessTileList]; - // pbswitch.add(personalTileList); - // pbswitch.add(businessTileList); } Color getPrim() { @@ -321,8 +495,11 @@ class _HomeTileGridState extends State { @override void initState() { - pbswitch = setApps(personalTileList, businessTileList); - businessUserSwitch = false; + setState(() { + pbswitch = setApps(persHTList, busHTList); + businessUserSwitch = false; + }); + super.initState(); } @@ -375,11 +552,8 @@ class _HomeTileGridState extends State { itemCount: pbswitch[_selectedIndex].length, gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 200), - //const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), itemBuilder: (context, index) { - var tile = pbswitch[_selectedIndex][index]; - //setState(() {}); - return buildtile(tile); + return pbswitch[_selectedIndex][index]; }, ), ),