fix: remove template button when there are templates available

This commit is contained in:
Freek van de Ven 2024-08-05 14:56:51 +02:00 committed by Freek van de Ven
parent beef725364
commit 1671c90a78

View file

@ -48,7 +48,6 @@ class _TemplateLegendState extends State<TemplateLegend> {
false; false;
var templatesVisible = templatesAvailable && _templateDrawerOpen; var templatesVisible = templatesAvailable && _templateDrawerOpen;
if (!templatesAvailable && if (!templatesAvailable &&
!featureSet.require(AvailabilityFeature.templates)) { !featureSet.require(AvailabilityFeature.templates)) {
return const SizedBox.shrink(); return const SizedBox.shrink();
@ -86,7 +85,7 @@ class _TemplateLegendState extends State<TemplateLegend> {
thickness: 1, thickness: 1,
); );
if (_templateDrawerOpen && !templatesLoading) { if (_templateDrawerOpen && templatesAvailable) {
body = Container( body = Container(
constraints: const BoxConstraints(maxHeight: 152), constraints: const BoxConstraints(maxHeight: 152),
child: SingleChildScrollView( child: SingleChildScrollView(
@ -161,8 +160,8 @@ class _TemplateLegendState extends State<TemplateLegend> {
translations.templateLegendTitle, translations.templateLegendTitle,
style: textTheme.titleMedium, style: textTheme.titleMedium,
), ),
if ((templatesAvailable && !templatesLoading) || if (templatesAvailable ||
_templateDrawerOpen) ...[ (_templateDrawerOpen && templatesLoading)) ...[
Icon( Icon(
_templateDrawerOpen _templateDrawerOpen
? Icons.arrow_drop_up ? Icons.arrow_drop_up
@ -195,7 +194,9 @@ class _TemplateLegendState extends State<TemplateLegend> {
if (templatesLoading) ...[ if (templatesLoading) ...[
options.loadingIndicatorBuilder(context), options.loadingIndicatorBuilder(context),
] else ...[ ] else ...[
createNewTemplateButton, if (templates.isEmpty) ...[
createNewTemplateButton,
],
], ],
], ],
], ],