Widget build()

in ui/lib/modules/catalog/widgets/catalog_list.dart [62:140]


  Widget build(BuildContext context) {
    final templatesList = ref.watch(templatesProvider);

    return templatesList.when(
        loading: () => Text('Loading...'),
        error: (err, stack) => Text('Error: $err'),
        data: (listOfTemplates) {
          List<Template> templates = [];

          if (widget.showDrafts) {
            templates = listOfTemplates
                .where((template) => widget.categories.contains(template.category))
                .toList();
          } else {
            templates = listOfTemplates
                .where((template) => widget.categories.contains(template.category) && template.draft == widget.showDrafts)
                .toList();
          }

          return SingleChildScrollView(
            child: Container(
              padding: EdgeInsets.all(24),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    "Cloud Provision Catalog",
                    style: GoogleFonts.openSans(
                      fontSize: 32,
                      color: Color(0xFF1b3a57),
                      fontWeight: FontWeight.w600,
                    ),
                  ),
                  Divider(),
                  Row(
                    children: [
                      CatalogSwitch(
                        Category.application.name,
                        Category.application.code,
                        switchCallback,
                            widget.categories.contains(Category.application.code),
                      ),
                      SizedBox(
                        width: 5,
                      ),
                      CatalogSwitch(
                          Category.infra.name, Category.infra.code, switchCallback,
                              widget.categories.contains(Category.infra.code)),
                      SizedBox(
                        width: 5,
                      ),
                      CatalogSwitch(
                          Category.solution.name, Category.solution.code, switchCallback,
                              widget.categories.contains(Category.solution.code)),
                      SizedBox(
                        width: 5,
                      ),
                      CatalogSwitch("Drafts", "draft", switchDraftCallback,
                          widget.showDrafts),
                    ],
                  ),
                  Divider(),
                  Text(
                    templates.isEmpty ? "No entries found" : "",
                    style: GoogleFonts.openSans(
                      fontSize: 14,
                      color: Color(0xFF1b3a57),
                      fontWeight: FontWeight.w600,
                    ),
                  ),
                  templates.isNotEmpty
                      ? _templates(context, templates)
                      : Container(),
                ],
              ),
            ),
          );
        });
  }