From fd9522200d8e584a993c326278826cb41a10ecd5 Mon Sep 17 00:00:00 2001 From: helderbetiol <37706737+helderbetiol@users.noreply.github.com> Date: Tue, 17 Sep 2024 18:20:54 +0200 Subject: [PATCH 1/2] refactor(app) appbar --- APP/lib/common/appbar.dart | 314 +++++++++++++++++++++++-------------- APP/lib/common/csv.dart | 2 +- 2 files changed, 193 insertions(+), 123 deletions(-) diff --git a/APP/lib/common/appbar.dart b/APP/lib/common/appbar.dart index d84f6022..97816336 100644 --- a/APP/lib/common/appbar.dart +++ b/APP/lib/common/appbar.dart @@ -11,57 +11,20 @@ import 'package:ogree_app/widgets/login/change_password_popup.dart'; import 'package:ogree_app/widgets/tenants/popups/create_server_popup.dart'; import 'package:ogree_app/widgets/tools/download_tool_popup.dart'; -AppBar myAppBar(context, userEmail, {isTenantMode = false}) { - final localeMsg = AppLocalizations.of(context)!; - Future logout() => Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const LoginPage(), - ), - ); - - final List> entries = >[ - PopupMenuItem( - value: "change", - child: Text(AppLocalizations.of(context)!.changePassword), - ), - const PopupMenuItem( - value: "logout", - child: Text("Logout"), - ), - ]; - if (isTenantMode) { - entries.insert( - 0, - PopupMenuItem( - value: "new", - child: Text(backendType == BackendType.kubernetes - ? localeMsg.addKube - : localeMsg.addServer,), - ),); - } else { - entries.insert( - 0, - PopupMenuItem( - value: Tools.unity.name, - child: Text(localeMsg.downloadUnity), - ),); - entries.insert( - 0, - PopupMenuItem( - value: Tools.cli.name, - child: Text(localeMsg.downloadCli), - ),); - if (isTenantAdmin) { - entries.insert( - 0, - PopupMenuItem( - value: "tenant", - child: Text(localeMsg.tenantParameters), - ),); - } - } +enum PopupMenuEntries { + passwordChange, + logout, + createNewServer, + tenantParams, + downloadUnity, + downloadCli +} +AppBar myAppBar(BuildContext context, String userEmail, + {bool isTenantMode = false}) { + final localeMsg = AppLocalizations.of(context)!; final bool isSmallDisplay = MediaQuery.of(context).size.width < 600; + return AppBar( backgroundColor: Colors.grey.shade900, leadingWidth: 160, @@ -73,15 +36,17 @@ AppBar myAppBar(context, userEmail, {isTenantMode = false}) { child: const Text( 'OGrEE', style: TextStyle( - fontSize: 21, - fontWeight: FontWeight.w700, - color: Colors.white,), + fontSize: 21, + fontWeight: FontWeight.w700, + color: Colors.white, + ), ), onPressed: () => Navigator.of(context).push( MaterialPageRoute( builder: (context) => ProjectsPage( - userEmail: isTenantMode ? "admin" : userEmail, - isTenantMode: isTenantMode,), + userEmail: isTenantMode ? "admin" : userEmail, + isTenantMode: isTenantMode, + ), ), ), ), @@ -93,80 +58,185 @@ AppBar myAppBar(context, userEmail, {isTenantMode = false}) { ), ), actions: [ - if (isSmallDisplay) Container() else Padding( - padding: const EdgeInsets.only(right: 20), - child: Row( - children: [ - if (backendType == BackendType.kubernetes) Padding( - padding: const EdgeInsets.only(right: 8), - child: Container( - decoration: BoxDecoration( - borderRadius: - const BorderRadius.all(Radius.circular(8)), - border: Border.all(color: Colors.white), - ), - child: Badge( - backgroundColor: Colors.grey.shade900, - label: const Text("KUBE"), - ), - ), - ) else Container(), - Text(isTenantMode ? apiUrl : tenantName, - style: const TextStyle(color: Colors.white),), - ], - ), - ), + getInfoBadge(isTenantMode, isSmallDisplay), const Padding( padding: EdgeInsets.symmetric(vertical: 15), child: LanguageToggle(), ), const SizedBox(width: 17), - PopupMenuButton( - onSelected: (value) { - if (value == "logout") { - logout(); - } else if (value == "new") { - showCustomPopup( - context, CreateServerPopup(parentCallback: () {}),); - } else if (value == "tenant") { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => const TenantPage(userEmail: "admin"), - ),); - } else if (value == Tools.unity.name) { - showCustomPopup(context, const DownloadToolPopup(tool: Tools.unity), - isDismissible: true,); - } else if (value == Tools.cli.name) { - showCustomPopup(context, const DownloadToolPopup(tool: Tools.cli), - isDismissible: true,); - } else { - showCustomPopup(context, const ChangePasswordPopup()); - } - }, - itemBuilder: (_) => entries, - child: Row( - children: [ - const Icon( - Icons.account_circle, - color: Colors.white, - ), - const SizedBox(width: 10), - if (isSmallDisplay) Tooltip( - message: isTenantMode - ? (backendType == BackendType.kubernetes - ? "(KUBE) $apiUrl" - : apiUrl) - : tenantName, - triggerMode: TooltipTriggerMode.tap, - child: const Icon( - Icons.info_outline_rounded, - color: Colors.white, - ),) else Text( - isTenantMode ? "admin" : userEmail, - style: const TextStyle(color: Colors.white), - ), - ], - ),), + getPopupMenuButton( + isTenantMode, isSmallDisplay, userEmail, localeMsg, context), const SizedBox(width: 40), ], ); } + +// KUBE + API URL + TenantName +Widget getInfoBadge(bool isTenantMode, bool isSmallDisplay) { + if (isSmallDisplay) { + return Container(); + } else { + return Padding( + padding: const EdgeInsets.only(right: 20), + child: Row( + children: [ + if (backendType == BackendType.kubernetes) + Padding( + padding: const EdgeInsets.only(right: 8), + child: Container( + decoration: BoxDecoration( + borderRadius: const BorderRadius.all(Radius.circular(8)), + border: Border.all(color: Colors.white), + ), + child: Badge( + backgroundColor: Colors.grey.shade900, + label: const Text("KUBE"), + ), + ), + ) + else + Container(), + Text( + isTenantMode ? apiUrl : tenantName, + style: const TextStyle(color: Colors.white), + ), + ], + ), + ); + } +} + +// POPUP MENU +PopupMenuButton getPopupMenuButton( + bool isTenantMode, + bool isSmallDisplay, + String userEmail, + AppLocalizations localeMsg, + BuildContext context) { + return PopupMenuButton( + onSelected: (value) => onMenuEntrySelected(value, context), + itemBuilder: (_) => getPopupMenuEntries(isTenantMode, localeMsg), + child: Row( + children: [ + const Icon( + Icons.account_circle, + color: Colors.white, + ), + const SizedBox(width: 10), + if (isSmallDisplay) + Tooltip( + message: isTenantMode + ? (backendType == BackendType.kubernetes + ? "(KUBE) $apiUrl" + : apiUrl) + : tenantName, + triggerMode: TooltipTriggerMode.tap, + child: const Icon( + Icons.info_outline_rounded, + color: Colors.white, + ), + ) + else + Text( + isTenantMode ? "admin" : userEmail, + style: const TextStyle(color: Colors.white), + ), + ], + ), + ); +} + +List> getPopupMenuEntries( + bool isTenantMode, AppLocalizations localeMsg) { + final List> entries = + >[ + PopupMenuItem( + value: PopupMenuEntries.passwordChange, + child: Text(localeMsg.changePassword), + ), + const PopupMenuItem( + value: PopupMenuEntries.logout, + child: Text("Logout"), + ), + ]; + if (isTenantMode) { + entries.insert( + 0, + PopupMenuItem( + value: PopupMenuEntries.createNewServer, + child: Text( + backendType == BackendType.kubernetes + ? localeMsg.addKube + : localeMsg.addServer, + ), + ), + ); + } else { + entries.insert( + 0, + PopupMenuItem( + value: PopupMenuEntries.downloadUnity, + child: Text(localeMsg.downloadUnity), + ), + ); + entries.insert( + 0, + PopupMenuItem( + value: PopupMenuEntries.downloadCli, + child: Text(localeMsg.downloadCli), + ), + ); + if (isTenantAdmin) { + entries.insert( + 0, + PopupMenuItem( + value: PopupMenuEntries.tenantParams, + child: Text(localeMsg.tenantParameters), + ), + ); + } + } + return entries; +} + +onMenuEntrySelected(PopupMenuEntries selectedEntry, BuildContext context) { + switch (selectedEntry) { + case PopupMenuEntries.logout: + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const LoginPage(), + ), + ); + break; + case PopupMenuEntries.tenantParams: + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const TenantPage(userEmail: "admin"), + ), + ); + break; + case PopupMenuEntries.downloadUnity: + showCustomPopup( + context, + const DownloadToolPopup(tool: Tools.unity), + isDismissible: true, + ); + break; + case PopupMenuEntries.downloadCli: + showCustomPopup( + context, + const DownloadToolPopup(tool: Tools.cli), + isDismissible: true, + ); + break; + case PopupMenuEntries.passwordChange: + showCustomPopup(context, const ChangePasswordPopup()); + break; + case PopupMenuEntries.createNewServer: + showCustomPopup( + context, + CreateServerPopup(parentCallback: () {}), + ); + break; + } +} diff --git a/APP/lib/common/csv.dart b/APP/lib/common/csv.dart index edfed41e..949d4f9f 100644 --- a/APP/lib/common/csv.dart +++ b/APP/lib/common/csv.dart @@ -18,7 +18,7 @@ saveCSV(String desiredFileName, List> rows, html.AnchorElement( href: 'data:application/octet-stream;base64,${base64Encode(bytes)}', ) - ..setAttribute("download", "report.csv") + ..setAttribute("download", "$desiredFileName.csv") ..click(); } else { // Save to local filesystem From e9840c01ed8cdcde997ce3f0fa7fac481dbbeed6 Mon Sep 17 00:00:00 2001 From: helderbetiol <37706737+helderbetiol@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:06:00 +0200 Subject: [PATCH 2/2] refactor(app) projects page --- APP/lib/pages/projects_page.dart | 536 ++++++++++++++++++------------- 1 file changed, 320 insertions(+), 216 deletions(-) diff --git a/APP/lib/pages/projects_page.dart b/APP/lib/pages/projects_page.dart index 9d342cb6..0849a8ca 100644 --- a/APP/lib/pages/projects_page.dart +++ b/APP/lib/pages/projects_page.dart @@ -25,8 +25,11 @@ import 'package:ogree_app/widgets/tools/tool_card.dart'; class ProjectsPage extends StatefulWidget { final String userEmail; final bool isTenantMode; - const ProjectsPage( - {super.key, required this.userEmail, required this.isTenantMode,}); + const ProjectsPage({ + super.key, + required this.userEmail, + required this.isTenantMode, + }); @override State createState() => _ProjectsPageState(); @@ -49,58 +52,39 @@ class _ProjectsPageState extends State { _isSmallDisplay = MediaQuery.of(context).size.width < 720; final localeMsg = AppLocalizations.of(context)!; return Scaffold( - appBar: myAppBar(context, widget.userEmail, - isTenantMode: widget.isTenantMode,), + appBar: myAppBar( + context, + widget.userEmail, + isTenantMode: widget.isTenantMode, + ), body: Padding( padding: EdgeInsets.symmetric( - horizontal: _isSmallDisplay ? 40 : 80.0, vertical: 20,), + horizontal: _isSmallDisplay ? 40 : 80.0, + vertical: 20, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ ...getAlertWidgets(localeMsg), - // SizedBox(height: 30), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - if (widget.isTenantMode) Row( - children: [ - Text(localeMsg.applications, - style: Theme.of(context).textTheme.headlineLarge,), - IconButton( - onPressed: () => setState(() { - _gotData = false; - }), - icon: const Icon(Icons.refresh),), - ], - ) else Text(localeMsg.myprojects, - style: Theme.of(context).textTheme.headlineLarge,), - Row( - children: [ - if (!widget.isTenantMode) Padding( - padding: - const EdgeInsets.only(right: 10.0, bottom: 10), - child: impactViewButton(), - ) else Container(), - Padding( - padding: const EdgeInsets.only(right: 10.0, bottom: 10), - child: createProjectButton(), - ), - if (widget.isTenantMode) Padding( - padding: - const EdgeInsets.only(right: 10.0, bottom: 10), - child: createToolsButton(), - ) else Container(), - ], - ), - ], - ), + projectsPageTitleRow(), const SizedBox(height: 3), FutureBuilder( - future: _gotData ? null : getProjectData(), - builder: (context, _) { - if (!_gotData) { - return const Center(child: CircularProgressIndicator()); - } else if (!widget.isTenantMode) { + future: _gotData ? null : getProjectData(), + builder: (context, _) { + if (!_gotData) { + return const Center(child: CircularProgressIndicator()); + } else if (!widget.isTenantMode) { + return Expanded( + child: SingleChildScrollView( + child: Wrap( + spacing: 5, + children: getCards(context), + ), + ), + ); + } else { + if ((_tenants != null && _tenants!.isNotEmpty) || + (_tools != null && _tools!.isNotEmpty)) { return Expanded( child: SingleChildScrollView( child: Wrap( @@ -110,22 +94,12 @@ class _ProjectsPageState extends State { ), ); } else { - if ((_tenants != null && _tenants!.isNotEmpty) || - (_tools != null && _tools!.isNotEmpty)) { - return Expanded( - child: SingleChildScrollView( - child: Wrap( - spacing: 5, - children: getCards(context), - ), - ), - ); - } else { - // Empty messages - return Text(localeMsg.noProjects); - } + // Empty messages + return Text(localeMsg.noProjects); } - },), + } + }, + ), ], ), ), @@ -139,58 +113,71 @@ class _ProjectsPageState extends State { } getProjectData() async { - final messenger = ScaffoldMessenger.of(context); if (widget.isTenantMode) { - final result = await fetchApplications(); + await getApplications(); + } else { + await getProjects(); + } + } + + getProjects() async { + final messenger = ScaffoldMessenger.of(context); + final result = await fetchProjects(widget.userEmail); + switch (result) { + case Success(value: final value): + _projects = value; + setState(() { + _gotData = true; + }); + case Failure(exception: final exception): + showSnackBar(messenger, exception.toString(), isError: true); + _projects = []; + } + } + + getApplications() async { + final messenger = ScaffoldMessenger.of(context); + final result = await fetchApplications(); + switch (result) { + case Success(value: final value): + final (tenants, tools) = value; + _tenants = tenants; + await getTenantDockerInfo(tenants); + _tools = tools; + setState(() { + _gotData = true; + }); + case Failure(exception: final exception): + showSnackBar(messenger, exception.toString(), isError: true); + _tenants = []; + } + } + + getTenantDockerInfo(List tenants) async { + for (final tenant in tenants) { + final result = await fetchTenantDockerInfo(tenant.name); switch (result) { case Success(value: final value): - final (tenants, tools) = value; - _tenants = tenants; - for (final tenant in tenants) { - final result = await fetchTenantDockerInfo(tenant.name); - switch (result) { - case Success(value: final value): - final List dockerInfo = value; - if (dockerInfo.isEmpty) { - tenant.status = TenantStatus.unavailable; - } else { - int runCount = 0; - for (final container in dockerInfo) { - if (container.status.contains("run")) { - runCount++; - } - } - if (runCount == dockerInfo.length) { - tenant.status = TenantStatus.running; - } else if (runCount > 0) { - tenant.status = TenantStatus.partialRun; - } else { - tenant.status = TenantStatus.notRunning; - } - } - case Failure(): - tenant.status = TenantStatus.unavailable; + final List dockerInfo = value; + if (dockerInfo.isEmpty) { + tenant.status = TenantStatus.unavailable; + } else { + int runCount = 0; + for (final container in dockerInfo) { + if (container.status.contains("run")) { + runCount++; + } + } + if (runCount == dockerInfo.length) { + tenant.status = TenantStatus.running; + } else if (runCount > 0) { + tenant.status = TenantStatus.partialRun; + } else { + tenant.status = TenantStatus.notRunning; } } - _tools = tools; - setState(() { - _gotData = true; - }); - case Failure(exception: final exception): - showSnackBar(messenger, exception.toString(), isError: true); - _tenants = []; - } - } else { - final result = await fetchProjects(widget.userEmail); - switch (result) { - case Success(value: final value): - _projects = value; - setState(() { - _gotData = true; - }); - case Failure(exception: final exception): - showSnackBar(messenger, exception.toString(), isError: true); - _projects = []; + case Failure(): + tenant.status = TenantStatus.unavailable; } } } @@ -210,13 +197,74 @@ class _ProjectsPageState extends State { } } + Row projectsPageTitleRow() { + final localeMsg = AppLocalizations.of(context)!; + if (widget.isTenantMode) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Text( + localeMsg.applications, + style: Theme.of(context).textTheme.headlineLarge, + ), + IconButton( + onPressed: () => setState(() { + _gotData = false; + }), + icon: const Icon(Icons.refresh), + ), + ], + ), + Row( + children: [ + Padding( + padding: const EdgeInsets.only(right: 10.0, bottom: 10), + child: createProjectButton(), + ), + Padding( + padding: const EdgeInsets.only(right: 10.0, bottom: 10), + child: createToolsButton(), + ), + ], + ), + ], + ); + } else { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + localeMsg.myprojects, + style: Theme.of(context).textTheme.headlineLarge, + ), + Row( + children: [ + Padding( + padding: const EdgeInsets.only(right: 10.0, bottom: 10), + child: impactViewButton(), + ), + Padding( + padding: const EdgeInsets.only(right: 10.0, bottom: 10), + child: createProjectButton(), + ), + ], + ), + ], + ); + } + } + ElevatedButton createProjectButton() { final localeMsg = AppLocalizations.of(context)!; return ElevatedButton( onPressed: () { if (widget.isTenantMode) { showCustomPopup( - context, CreateTenantPopup(parentCallback: refreshFromChildren),); + context, + CreateTenantPopup(parentCallback: refreshFromChildren), + ); } else { Navigator.of(context).push( MaterialPageRoute( @@ -230,12 +278,20 @@ class _ProjectsPageState extends State { children: [ Padding( padding: EdgeInsets.only( - top: 8, bottom: 8, right: _isSmallDisplay ? 0 : 10,), + top: 8, + bottom: 8, + right: _isSmallDisplay ? 0 : 10, + ), child: const Icon(Icons.add_to_photos), ), - if (_isSmallDisplay) Container() else Text(widget.isTenantMode + if (_isSmallDisplay) + Container() + else + Text( + widget.isTenantMode ? "${localeMsg.create} tenant" - : localeMsg.newProject,), + : localeMsg.newProject, + ), ], ), ); @@ -278,40 +334,58 @@ class _ProjectsPageState extends State { switch (value) { case Tools.netbox: if (_hasNetbox) { - showSnackBar(ScaffoldMessenger.of(context), - localeMsg.onlyOneTool("Netbox"),); + showSnackBar( + ScaffoldMessenger.of(context), + localeMsg.onlyOneTool("Netbox"), + ); } else { showCustomPopup( - context, - CreateNboxPopup( - parentCallback: refreshFromChildren, - tool: Tools.netbox,),); + context, + CreateNboxPopup( + parentCallback: refreshFromChildren, + tool: Tools.netbox, + ), + ); } case Tools.nautobot: if (_hasNautobot) { - showSnackBar(ScaffoldMessenger.of(context), - localeMsg.onlyOneTool("Nautobot"),); + showSnackBar( + ScaffoldMessenger.of(context), + localeMsg.onlyOneTool("Nautobot"), + ); } else { showCustomPopup( - context, - CreateNboxPopup( - parentCallback: refreshFromChildren, - tool: Tools.nautobot,),); + context, + CreateNboxPopup( + parentCallback: refreshFromChildren, + tool: Tools.nautobot, + ), + ); } case Tools.opendcim: if (_hasOpenDcim) { - showSnackBar(ScaffoldMessenger.of(context), - localeMsg.onlyOneTool("OpenDCIM"),); + showSnackBar( + ScaffoldMessenger.of(context), + localeMsg.onlyOneTool("OpenDCIM"), + ); } else { - showCustomPopup(context, - CreateOpenDcimPopup(parentCallback: refreshFromChildren),); + showCustomPopup( + context, + CreateOpenDcimPopup(parentCallback: refreshFromChildren), + ); } case Tools.cli: - showCustomPopup(context, const DownloadToolPopup(tool: Tools.cli), - isDismissible: true,); + showCustomPopup( + context, + const DownloadToolPopup(tool: Tools.cli), + isDismissible: true, + ); case Tools.unity: - showCustomPopup(context, const DownloadToolPopup(tool: Tools.unity), - isDismissible: true,); + showCustomPopup( + context, + const DownloadToolPopup(tool: Tools.unity), + isDismissible: true, + ); } }, itemBuilder: (_) => entries, @@ -320,7 +394,10 @@ class _ProjectsPageState extends State { children: [ Padding( padding: EdgeInsets.only( - top: 8, bottom: 8, right: _isSmallDisplay ? 0 : 10,), + top: 8, + bottom: 8, + right: _isSmallDisplay ? 0 : 10, + ), child: const Icon(Icons.timeline), ), if (_isSmallDisplay) Container() else Text(localeMsg.tools), @@ -331,59 +408,75 @@ class _ProjectsPageState extends State { } List getCards(context) { - final List cards = []; if (widget.isTenantMode) { - if (_tenants != null && _tenants!.isNotEmpty) { - for (final tenant in _tenants!) { - cards.add(TenantCard( - tenant: tenant, - parentCallback: refreshFromChildren, - ),); - } - } - if (_tools != null && _tools!.isNotEmpty) { - _hasOpenDcim = false; - _hasNetbox = false; - _hasNautobot = false; - for (final tool in _tools!) { - var type = Tools.netbox; - if (tool.name.contains(Tools.opendcim.name)) { - type = Tools.opendcim; - _hasOpenDcim = true; - } else if (tool.name.contains(Tools.nautobot.name)) { - type = Tools.nautobot; - _hasNautobot = true; - } else { - _hasNetbox = true; - } - cards.add(ToolCard( - type: type, - container: tool, - parentCallback: refreshFromChildren, - ),); - } - } + return getTenantModeCards(); } else { + final List cards = []; if (isDemo) { - cards.add(AutoUnityProjectCard( - userEmail: widget.userEmail, - ),); + cards.add( + AutoUnityProjectCard( + userEmail: widget.userEmail, + ), + ); } for (final namespace in Namespace.values) { if (namespace != Namespace.Test) { - cards.add(AutoProjectCard( - namespace: namespace, - userEmail: widget.userEmail, - parentCallback: refreshFromChildren, - ),); + cards.add( + AutoProjectCard( + namespace: namespace, + userEmail: widget.userEmail, + parentCallback: refreshFromChildren, + ), + ); } } for (final project in _projects!) { - cards.add(ProjectCard( - project: project, - userEmail: widget.userEmail, - parentCallback: refreshFromChildren, - ),); + cards.add( + ProjectCard( + project: project, + userEmail: widget.userEmail, + parentCallback: refreshFromChildren, + ), + ); + } + return cards; + } + } + + List getTenantModeCards() { + final List cards = []; + if (_tenants != null && _tenants!.isNotEmpty) { + for (final tenant in _tenants!) { + cards.add( + TenantCard( + tenant: tenant, + parentCallback: refreshFromChildren, + ), + ); + } + } + if (_tools != null && _tools!.isNotEmpty) { + _hasOpenDcim = false; + _hasNetbox = false; + _hasNautobot = false; + for (final tool in _tools!) { + var type = Tools.netbox; + if (tool.name.contains(Tools.opendcim.name)) { + type = Tools.opendcim; + _hasOpenDcim = true; + } else if (tool.name.contains(Tools.nautobot.name)) { + type = Tools.nautobot; + _hasNautobot = true; + } else { + _hasNetbox = true; + } + cards.add( + ToolCard( + type: type, + container: tool, + parentCallback: refreshFromChildren, + ), + ); } } return cards; @@ -409,7 +502,10 @@ class _ProjectsPageState extends State { children: [ Padding( padding: EdgeInsets.only( - top: 8, bottom: 8, right: _isSmallDisplay ? 0 : 10,), + top: 8, + bottom: 8, + right: _isSmallDisplay ? 0 : 10, + ), child: const Icon(Icons.settings_suggest), ), if (_isSmallDisplay) Container() else Text(localeMsg.impactAnalysis), @@ -426,8 +522,10 @@ class _ProjectsPageState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(localeMsg.myAlerts, - style: Theme.of(context).textTheme.headlineLarge,), + Text( + localeMsg.myAlerts, + style: Theme.of(context).textTheme.headlineLarge, + ), Padding( padding: const EdgeInsets.only(right: 10.0, bottom: 10), child: alertViewButton(), @@ -438,42 +536,43 @@ class _ProjectsPageState extends State { Padding( padding: const EdgeInsets.only(right: 20.0), child: FutureBuilder( - future: _gotAlerts ? null : getAlerts(), - builder: (context, _) { - if (!_gotAlerts) { - return const Center(child: CircularProgressIndicator()); - } - return InkWell( - onTap: () => Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => AlertPage( - userEmail: widget.userEmail, - alerts: _alerts, - ), + future: _gotAlerts ? null : getAlerts(), + builder: (context, _) { + if (!_gotAlerts) { + return const Center(child: CircularProgressIndicator()); + } + return InkWell( + onTap: () => Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => AlertPage( + userEmail: widget.userEmail, + alerts: _alerts, ), ), - child: MaterialBanner( - padding: - const EdgeInsets.symmetric(horizontal: 20, vertical: 5), - content: _isSmallDisplay - ? Text(localeMsg.oneAlert) - : (_alerts.isEmpty - ? Text("${localeMsg.noAlerts} :)") - : Text(alertsToString(localeMsg))), - leading: const Icon(Icons.info), - backgroundColor: _alerts.isEmpty - ? Colors.grey.shade200 - : Colors.amber.shade100, - dividerColor: Colors.transparent, - actions: const [ - TextButton( - onPressed: null, - child: Text(''), - ), - ], - ), - ); - },), + ), + child: MaterialBanner( + padding: + const EdgeInsets.symmetric(horizontal: 20, vertical: 5), + content: _isSmallDisplay + ? Text(localeMsg.oneAlert) + : (_alerts.isEmpty + ? Text("${localeMsg.noAlerts} :)") + : Text(alertsToString(localeMsg))), + leading: const Icon(Icons.info), + backgroundColor: _alerts.isEmpty + ? Colors.grey.shade200 + : Colors.amber.shade100, + dividerColor: Colors.transparent, + actions: const [ + TextButton( + onPressed: null, + child: Text(''), + ), + ], + ), + ); + }, + ), ), const SizedBox(height: 30), ]; @@ -505,7 +604,9 @@ class _ProjectsPageState extends State { onPressed: () { if (widget.isTenantMode) { showCustomPopup( - context, CreateTenantPopup(parentCallback: refreshFromChildren),); + context, + CreateTenantPopup(parentCallback: refreshFromChildren), + ); } else { Navigator.of(context).push( MaterialPageRoute( @@ -522,7 +623,10 @@ class _ProjectsPageState extends State { children: [ Padding( padding: EdgeInsets.only( - top: 8, bottom: 8, right: _isSmallDisplay ? 0 : 10,), + top: 8, + bottom: 8, + right: _isSmallDisplay ? 0 : 10, + ), child: const Icon(Icons.analytics), ), if (_isSmallDisplay) Container() else Text(localeMsg.viewAlerts),