import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:oc_front/core/sections/header/header.dart'; import 'package:oc_front/core/services/specialized_services/resource_service.dart'; import 'package:oc_front/main.dart'; import 'package:oc_front/models/search.dart'; import 'package:oc_front/widgets/catalog.dart'; import 'package:oc_front/pages/abstract_page.dart'; class CatalogFactory implements AbstractFactory { @override GlobalKey getKey() { return key; } static GlobalKey key = GlobalKey(); @override void clear() { mainKey?.currentState?.setState(() { HeaderConstants.headerKey.currentState?.setState(() {}); HeaderConstants.headerWidget?.setState(() {}); key.currentState?.widget.items = []; }); } @override bool searchFill() { return key.currentState?.widget.items.isEmpty ?? true; } @override Widget factory(GoRouterState state, List args) { return CatalogPageWidget(); } @override void search(BuildContext context, bool special) { if (special) { return; } CatalogFactory.key.currentState?.widget.search.search(context, [ SearchConstants.get()! ], {}).then((value) { if (value.data == null) { return; } key.currentState?.widget.items = [ ...value.data!.workflows, ...value.data!.processings, ...value.data!.datas, ...value.data!.storages, ...value.data!.computes,]; HeaderConstants.headerKey.currentState?.setState(() {}); HeaderConstants.headerWidget?.setState(() {}); CatalogFactory.key.currentState?.setState(() {}); // ignore: invalid_use_of_protected_member }); } } // ignore: must_be_immutable class CatalogPageWidget extends StatefulWidget { double? itemWidth; List items = []; final ResourceService search = ResourceService(); CatalogPageWidget ({ this.itemWidth, }): super(key: CatalogFactory.key); @override CatalogPageWidgetState createState() => CatalogPageWidgetState(); } class CatalogPageWidgetState extends State { @override Widget build(BuildContext context) { if (widget.items.isEmpty) { return Container(); } return Column( children : [ SizedBox( width: getMainWidth(context), height: getMainHeight(context), child: SingleChildScrollView( child: CatalogWidget(items: CatalogFactory.key.currentState?.widget.items, itemWidth: widget.itemWidth) )), ] ); } } /* PermsService.getPerm(Perms.WORKSPACE_SHARE) ? ShallowDropdownInputWidget( iconLoad: Icons.share_rounded, tooltipLoad: 'share', tooltipRemove: 'unshare', color: Colors.white, filled: const Color.fromRGBO(38, 166, 154, 1), hintColor: midColor, type: CollaborativeAreaType.workspace, all: () async => CollaborativeAreaLocal.workspaces.values.map( (e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList(), current: WorkspaceLocal.workspaces[WorkspaceLocal.current]?.shared, width: (getMainWidth(context) / 3), canLoad: (String? change) => CollaborativeAreaLocal.workspaces[change] == null || !CollaborativeAreaLocal.workspaces[change]!.workspaces.map( (e) => e.id ).contains(WorkspaceLocal.current), canRemove: (String? change) => CollaborativeAreaLocal.workspaces[change] == null || CollaborativeAreaLocal.workspaces[change]!.workspaces.map( (e) => e.id ).contains(WorkspaceLocal.current), load: (String val) async { await SharedService().addWorkspace(context, val, WorkspaceLocal.current ?? ""); // ignore: use_build_context_synchronously CollaborativeAreaLocal.init(context, false); }, remove: (String val) async { await SharedService().removeWorkspace(context, val, WorkspaceLocal.current ?? ""); // ignore: use_build_context_synchronously CollaborativeAreaLocal.init(context, false); }) : Container(width: (getMainWidth(context) / 3), height: 50, color: const Color.fromRGBO(38, 166, 154, 1)), */