2024-07-05 09:24:40 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:go_router/go_router.dart';
|
2024-07-17 13:28:02 +02:00
|
|
|
import 'package:oc_front/core/sections/header/header.dart';
|
2024-08-08 08:42:32 +02:00
|
|
|
import 'package:oc_front/core/services/specialized_services/resource_service.dart';
|
2024-11-08 13:59:22 +01:00
|
|
|
import 'package:oc_front/main.dart';
|
2024-07-05 09:24:40 +02:00
|
|
|
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 {
|
2024-11-08 13:59:22 +01:00
|
|
|
@override GlobalKey getKey() { return key; }
|
2024-07-05 09:24:40 +02:00
|
|
|
static GlobalKey<CatalogPageWidgetState> key = GlobalKey<CatalogPageWidgetState>();
|
2024-11-08 13:59:22 +01:00
|
|
|
@override bool searchFill() { return key.currentState?.widget.items.isEmpty ?? true; }
|
2024-07-05 09:24:40 +02:00
|
|
|
@override Widget factory(GoRouterState state, List<String> args) { return CatalogPageWidget(); }
|
2024-11-08 13:59:22 +01:00
|
|
|
@override void search(BuildContext context, bool special) {
|
|
|
|
if (special) { return; }
|
2024-08-08 08:42:32 +02:00
|
|
|
CatalogFactory.key.currentState?.widget.search.search(context, [ SearchConstants.get()! ], {}).then((value) {
|
2024-07-05 09:24:40 +02:00
|
|
|
if (value.data == null) { return; }
|
2024-11-08 13:59:22 +01:00
|
|
|
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
|
2024-07-05 09:24:40 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-08 13:59:22 +01:00
|
|
|
// ignore: must_be_immutable
|
2024-07-05 09:24:40 +02:00
|
|
|
class CatalogPageWidget extends StatefulWidget {
|
2024-08-30 12:52:32 +02:00
|
|
|
double? itemWidth;
|
2024-11-08 13:59:22 +01:00
|
|
|
List<AbstractItem> items = [];
|
2024-08-08 08:42:32 +02:00
|
|
|
final ResourceService search = ResourceService();
|
2024-08-30 12:52:32 +02:00
|
|
|
CatalogPageWidget ({
|
|
|
|
this.itemWidth,
|
|
|
|
}): super(key: CatalogFactory.key);
|
2024-07-05 09:24:40 +02:00
|
|
|
@override CatalogPageWidgetState createState() => CatalogPageWidgetState();
|
|
|
|
}
|
|
|
|
class CatalogPageWidgetState extends State<CatalogPageWidget> {
|
|
|
|
@override Widget build(BuildContext context) {
|
2024-11-08 13:59:22 +01:00
|
|
|
if (widget.items.isEmpty) { return Container(); }
|
2024-07-05 09:24:40 +02:00
|
|
|
return Column( children : [
|
2024-11-19 15:06:22 +01:00
|
|
|
SizedBox( width: getMainWidth(context),
|
|
|
|
height: getMainHeight(context) - 50,
|
2024-11-08 13:59:22 +01:00
|
|
|
child: SingleChildScrollView( child: CatalogWidget(items: CatalogFactory.key.currentState?.widget.items, itemWidth: widget.itemWidth) )),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
|
|
|
|
PermsService.getPerm(Perms.WORKSPACE_SHARE) ? ShallowDropdownInputWidget(
|
2024-08-30 12:52:32 +02:00
|
|
|
iconLoad: Icons.share_rounded,
|
2024-11-08 13:59:22 +01:00
|
|
|
tooltipLoad: 'share',
|
2024-08-30 12:52:32 +02:00
|
|
|
tooltipRemove: 'unshare',
|
|
|
|
color: Colors.white,
|
|
|
|
filled: const Color.fromRGBO(38, 166, 154, 1),
|
2024-11-08 13:59:22 +01:00
|
|
|
hintColor: midColor,
|
|
|
|
type: CollaborativeAreaType.workspace,
|
|
|
|
all: () async => CollaborativeAreaLocal.workspaces.values.map(
|
2024-08-30 12:52:32 +02:00
|
|
|
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList(),
|
|
|
|
current: WorkspaceLocal.workspaces[WorkspaceLocal.current]?.shared,
|
2024-11-08 13:59:22 +01:00
|
|
|
width: (getMainWidth(context) / 3),
|
|
|
|
canLoad: (String? change) => CollaborativeAreaLocal.workspaces[change] == null
|
|
|
|
|| !CollaborativeAreaLocal.workspaces[change]!.workspaces.map(
|
2024-08-30 12:52:32 +02:00
|
|
|
(e) => e.id ).contains(WorkspaceLocal.current),
|
2024-11-08 13:59:22 +01:00
|
|
|
canRemove: (String? change) => CollaborativeAreaLocal.workspaces[change] == null
|
|
|
|
|| CollaborativeAreaLocal.workspaces[change]!.workspaces.map(
|
2024-08-30 12:52:32 +02:00
|
|
|
(e) => e.id ).contains(WorkspaceLocal.current),
|
|
|
|
load: (String val) async {
|
|
|
|
await SharedService().addWorkspace(context, val, WorkspaceLocal.current ?? "");
|
|
|
|
// ignore: use_build_context_synchronously
|
2024-11-08 13:59:22 +01:00
|
|
|
CollaborativeAreaLocal.init(context, false);
|
2024-08-30 12:52:32 +02:00
|
|
|
},
|
|
|
|
remove: (String val) async {
|
|
|
|
await SharedService().removeWorkspace(context, val, WorkspaceLocal.current ?? "");
|
|
|
|
// ignore: use_build_context_synchronously
|
2024-11-08 13:59:22 +01:00
|
|
|
CollaborativeAreaLocal.init(context, false);
|
|
|
|
}) : Container(width: (getMainWidth(context) / 3), height: 50,
|
|
|
|
color: const Color.fromRGBO(38, 166, 154, 1)),
|
|
|
|
*/
|