Latest Front with debug
This commit is contained in:
@@ -1,12 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/models/shared_workspace_local.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.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/core/services/specialized_services/shared_service.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/workspace_service.dart';
|
||||
import 'package:oc_front/models/response.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/pages/shared.dart';
|
||||
import 'package:oc_front/widgets/catalog.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/core/sections/header/search.dart';
|
||||
import 'package:oc_front/widgets/menu_clipper/workspace_menu.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
||||
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
||||
|
||||
class CatalogFactory implements AbstractFactory {
|
||||
static List<AbstractItem> items = [];
|
||||
@@ -25,18 +32,84 @@ class CatalogFactory implements AbstractFactory {
|
||||
}
|
||||
|
||||
class CatalogPageWidget extends StatefulWidget {
|
||||
double? itemWidth;
|
||||
final ResourceService search = ResourceService();
|
||||
CatalogPageWidget (): super(key: CatalogFactory.key);
|
||||
CatalogPageWidget ({
|
||||
this.itemWidth,
|
||||
}): super(key: CatalogFactory.key);
|
||||
@override CatalogPageWidgetState createState() => CatalogPageWidgetState();
|
||||
}
|
||||
class CatalogPageWidgetState extends State<CatalogPageWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children : [
|
||||
CatalogFactory.items.isEmpty ? Container() : MenuWorkspaceWidget(),
|
||||
CatalogFactory.items.isEmpty ? Container() :
|
||||
Row( children: [
|
||||
ShallowDropdownInputWidget(
|
||||
current: WorkspaceLocal.current,
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
||||
type: SharedWorkspaceType.workspace,
|
||||
change: (String? change) {
|
||||
WorkspaceLocal.changeWorkspace(change.toString());
|
||||
},
|
||||
color: Colors.white,
|
||||
filled: const Color.fromRGBO(38, 166, 154, 1),
|
||||
hintColor: Colors.grey.shade300,
|
||||
canRemove: (String? remove) => remove != null,
|
||||
remove: (String? remove) async {
|
||||
if (remove == null) { return; }
|
||||
WorkspaceLocal.deleteWorkspace(remove);
|
||||
},
|
||||
),
|
||||
ShallowTextInputWidget(
|
||||
width: MediaQuery.of(context).size.width / 3,
|
||||
type: SharedWorkspaceType.workspace,
|
||||
color: Colors.white,
|
||||
filled: const Color.fromRGBO(38, 166, 154, 1),
|
||||
hintColor: Colors.grey.shade300,
|
||||
canRemove: (p0) => p0 != null,
|
||||
remove: (p0) async {
|
||||
await WorkspaceService().delete(context, p0, {}).then( (e) => WorkspaceLocal.deleteWorkspace(p0));
|
||||
},
|
||||
canLoad: (String? remove) => remove != null,
|
||||
load: (Map<String?, dynamic> add) async {
|
||||
if (add["name"] == null) { return; }
|
||||
WorkspaceLocal.createWorkspace(add["name"], context);
|
||||
},
|
||||
),
|
||||
ShallowDropdownInputWidget(
|
||||
iconLoad: Icons.share_rounded,
|
||||
tooltipLoad: 'share',
|
||||
tooltipRemove: 'unshare',
|
||||
color: Colors.white,
|
||||
filled: const Color.fromRGBO(38, 166, 154, 1),
|
||||
hintColor: Colors.grey.shade300,
|
||||
type: SharedWorkspaceType.workspace,
|
||||
all: () async => SharedWorkspaceLocal.workspaces.values.map(
|
||||
(e) => Shallow(id: e.id ?? "", name: e.name ?? "") ).toList(),
|
||||
current: WorkspaceLocal.workspaces[WorkspaceLocal.current]?.shared,
|
||||
width: (MediaQuery.of(context).size.width / 3),
|
||||
canLoad: (String? change) => SharedWorkspaceLocal.workspaces[change] == null
|
||||
|| !SharedWorkspaceLocal.workspaces[change]!.workspaces.map(
|
||||
(e) => e.id ).contains(WorkspaceLocal.current),
|
||||
canRemove: (String? change) => SharedWorkspaceLocal.workspaces[change] == null
|
||||
|| SharedWorkspaceLocal.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
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
},
|
||||
remove: (String val) async {
|
||||
await SharedService().removeWorkspace(context, val, WorkspaceLocal.current ?? "");
|
||||
// ignore: use_build_context_synchronously
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
})
|
||||
]),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: CatalogFactory.items.isEmpty ? 0 : MediaQuery.of(context).size.height - HeaderConstants.height - 50,
|
||||
child: CatalogWidget(items: CatalogFactory.items) )
|
||||
child: SingleChildScrollView( child: CatalogWidget(items: CatalogFactory.items, itemWidth: widget.itemWidth) )),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user