102 lines
4.7 KiB
Dart
102 lines
4.7 KiB
Dart
import 'package:oc_front/main.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:oc_front/pages/shared.dart';
|
|
import 'package:oc_front/pages/catalog.dart';
|
|
import 'package:oc_front/widgets/items/item_row.dart';
|
|
import 'package:oc_front/models/resources/resources.dart';
|
|
import 'package:oc_front/core/models/workspace_local.dart';
|
|
import 'package:oc_front/widgets/inputs/shallow_text_input.dart';
|
|
import 'package:oc_front/core/models/shared_workspace_local.dart';
|
|
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
|
|
import 'package:oc_front/core/services/specialized_services/workspace_service.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: getHeight(context),
|
|
child: Column( children: [
|
|
Container(
|
|
width: 400,
|
|
height: 50,
|
|
decoration: BoxDecoration(color: lightColor ),
|
|
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,
|
|
filled: Colors.white,
|
|
width: 400,
|
|
all: () async => WorkspaceLocal.getWorkspacesShallow(),
|
|
canRemove: (p0) => p0 != null,
|
|
remove: (p0) async {
|
|
await WorkspaceService().delete(context, p0, {}).then( (e) => WorkspaceLocal.deleteWorkspace(p0));
|
|
},
|
|
type: CollaborativeAreaType.workspace,
|
|
change: (String? change) {
|
|
WorkspaceLocal.changeWorkspace(change.toString());
|
|
}
|
|
),
|
|
Container(
|
|
width: 400,
|
|
height: 40,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
border: Border(bottom: BorderSide(color: midColor), top: BorderSide(color: midColor)),
|
|
),
|
|
child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [
|
|
Padding(padding: EdgeInsets.only(right: 5), child: Icon(Icons.share, size: 12, color: Colors.grey)),
|
|
Text( (WorkspaceLocal.workspaces[WorkspaceLocal.current]?.shared) == null ?
|
|
"actually not shared" : "share with ${CollaborativeAreaLocal.workspaces[WorkspaceLocal.workspaces[WorkspaceLocal.current]!.shared!]}",
|
|
style: TextStyle( fontSize: 14, color: Colors.grey ),),
|
|
]),
|
|
),
|
|
Column( children: [
|
|
itemRows.isEmpty ? Container( height: getHeight(context) - 140,
|
|
color: Colors.white,
|
|
child: Center(child: Text("WORKSPACE IS EMPTY",
|
|
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600, color: midColor))))
|
|
: Container( height: getHeight(context) - 140, child: SingleChildScrollView(
|
|
scrollDirection: Axis.vertical,
|
|
child: Column( children: [ ...itemRows, Container(height: 50)])
|
|
)),
|
|
])
|
|
])
|
|
),
|
|
Positioned( bottom: 0, left: 0,
|
|
child: Tooltip( message: "create workspace", child: ShallowTextInputWidget(
|
|
width: 400,
|
|
tooltipLoad: "create workspace",
|
|
iconLoad: Icons.create_new_folder_sharp,
|
|
type: CollaborativeAreaType.workspace,
|
|
color: Colors.white,
|
|
filled: midColor,
|
|
hint: "enter workspace name",
|
|
hintColor: Colors.grey,
|
|
canLoad: (String? remove) => remove != null,
|
|
load: (Map<String?, dynamic> add) async {
|
|
if (add["name"] == null) { return; }
|
|
WorkspaceLocal.createWorkspace(add["name"], context);
|
|
},
|
|
),
|
|
))
|
|
]
|
|
);
|
|
}
|
|
} |