93 lines
4.6 KiB
Dart
93 lines
4.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:oc_front/core/models/shared_workspace_local.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/catalog.dart';
|
|
import 'package:oc_front/core/models/workspace_local.dart';
|
|
import 'package:oc_front/pages/shared.dart';
|
|
import 'package:oc_front/widgets/items/item_row.dart';
|
|
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
|
|
|
GlobalKey<EndDrawerWidgetState> endDrawerKey = GlobalKey<EndDrawerWidgetState>();
|
|
class EndDrawerWidget extends StatefulWidget {
|
|
final List<AbstractItem>? items;
|
|
EndDrawerWidget ({ this.items }): super(key: endDrawerKey);
|
|
@override EndDrawerWidgetState createState() => EndDrawerWidgetState();
|
|
}
|
|
class EndDrawerWidgetState extends State<EndDrawerWidget> {
|
|
@override Widget build(BuildContext context) {
|
|
List<ItemRowWidget> itemRows = WorkspaceLocal.items.map(
|
|
(e) => ItemRowWidget(contextWidth: 400, item: e, keys: [endDrawerKey, CatalogFactory.key],)).toList();
|
|
return Stack( children: [
|
|
Container(
|
|
color: Colors.white,
|
|
width: 400,
|
|
height: MediaQuery.of(context).size.height,
|
|
child: Column( children: [
|
|
Container(
|
|
width: 400,
|
|
height: 50,
|
|
decoration: const BoxDecoration(color: Color.fromRGBO(38, 166, 154, 1)),
|
|
child: const Center(
|
|
child: Row( mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Padding(padding: EdgeInsets.only(right: 20), child: Icon(Icons.shopping_cart_outlined, size: 18, color: Colors.white)),
|
|
Text("Workspace", style: TextStyle(fontSize: 18, color: Colors.white, fontWeight: FontWeight.w600))
|
|
])
|
|
|
|
),
|
|
),
|
|
ShallowDropdownInputWidget(
|
|
current: WorkspaceLocal.current,
|
|
width: 400,
|
|
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
|
canRemove: (p0) => p0 != null,
|
|
remove: (p0) async {
|
|
await WorkspaceService().delete(context, p0, {}).then( (e) => WorkspaceLocal.deleteWorkspace(p0));
|
|
},
|
|
type: SharedWorkspaceType.workspace,
|
|
change: (String? change) {
|
|
WorkspaceLocal.changeWorkspace(change.toString());
|
|
}
|
|
),
|
|
Column( children: [
|
|
itemRows.isEmpty ? Container( height: MediaQuery.of(context).size.height - 100,
|
|
color: Colors.grey.shade300,
|
|
child: const Center(child: Text("WORKSPACE IS EMPTY",
|
|
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600, color: Colors.white))))
|
|
: Container( height: MediaQuery.of(context).size.height - 100, child: SingleChildScrollView(
|
|
scrollDirection: Axis.vertical,
|
|
child: Column( children: [ ...itemRows, Container(height: 50)])
|
|
)),
|
|
])
|
|
])
|
|
),
|
|
itemRows.isEmpty ? Container() : Positioned( bottom: 0, left: 0,
|
|
child: ShallowDropdownInputWidget(
|
|
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: 400,
|
|
filled: Colors.grey.shade300,
|
|
hintColor: Colors.grey,
|
|
color: Colors.black,
|
|
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 ?? "");
|
|
SharedWorkspaceLocal.init(context, false);
|
|
},
|
|
remove: (String val) async {
|
|
await SharedService().removeWorkspace(context, val, WorkspaceLocal.current ?? "");
|
|
SharedWorkspaceLocal.init(context, false);
|
|
})
|
|
)
|
|
]
|
|
);
|
|
}
|
|
} |