Shared WS
This commit is contained in:
142
lib/widgets/menu_clipper/shared_workspace_menu.dart
Normal file
142
lib/widgets/menu_clipper/shared_workspace_menu.dart
Normal file
@@ -0,0 +1,142 @@
|
||||
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/models/shared.dart';
|
||||
import 'package:oc_front/pages/catalog.dart';
|
||||
import 'package:oc_front/pages/catalog_item.dart';
|
||||
import 'package:oc_front/pages/workflow.dart';
|
||||
|
||||
enum SharedMenuWorkspaceType { workspace, workflow, peer }
|
||||
|
||||
class SharedMenuWorkspaceWidget extends StatefulWidget {
|
||||
List<dynamic> excluded = [];
|
||||
SharedMenuWorkspaceType type = SharedMenuWorkspaceType.workspace;
|
||||
double? width;
|
||||
String contextID;
|
||||
SharedService service = SharedService();
|
||||
String? selected;
|
||||
bool inner = false;
|
||||
bool reverse = false;
|
||||
double? topMargin;
|
||||
String? before;
|
||||
TextEditingController ctrl = TextEditingController();
|
||||
SharedMenuWorkspaceWidget ({ Key? key, this.width, required this.contextID, this.selected,
|
||||
this.type = SharedMenuWorkspaceType.workspace, this.topMargin, this.excluded = const [],
|
||||
this.inner = false, this.reverse = false, this.before}): super(key: key);
|
||||
@override SharedMenuWorkspaceWidgetState createState() => SharedMenuWorkspaceWidgetState();
|
||||
}
|
||||
class SharedMenuWorkspaceWidgetState extends State<SharedMenuWorkspaceWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Row( children: [
|
||||
Tooltip( message: "current workspace", child:
|
||||
Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
canvasColor: Colors.grey,
|
||||
),
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: widget.topMargin ?? (widget.inner ? 0 : 10)),
|
||||
height: 50, width: (widget.width ?? MediaQuery.of(context).size.width) - 100,
|
||||
decoration: BoxDecoration(
|
||||
color: widget.reverse ? Colors.white : ( widget.inner ? Color.fromRGBO(38, 166, 154, 1) : Colors.grey.shade300 ),
|
||||
border: const Border(bottom: BorderSide(color: Colors.transparent, width: 1))
|
||||
),
|
||||
padding: EdgeInsets.only(left: (widget.width ?? 400) < 400 ? 20 : 50, right: (widget.width ?? 400) < 400 ? 20 : 0),
|
||||
child: DropdownButtonFormField(
|
||||
value: widget.selected,
|
||||
isExpanded: true,
|
||||
style: const TextStyle(color:Colors.black, fontSize: 15),
|
||||
hint: Text("choose shared workspace...", style: TextStyle(color: widget.inner ? Colors.grey.shade300 : Colors.grey, fontSize: 15)),
|
||||
icon: Icon( // Add this
|
||||
Icons.arrow_drop_down, // Add this
|
||||
color: widget.inner ? Colors.white : Colors.grey, // Add this
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
suffixIconColor: widget.inner ? Colors.grey.shade300 : Colors.grey,
|
||||
focusedBorder: const OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Colors.transparent, width: 0),
|
||||
),
|
||||
fillColor: widget.reverse ? Colors.white : (widget.inner ? const Color.fromRGBO(38, 166, 154, 1) : Colors.grey.shade300),
|
||||
contentPadding: EdgeInsets.only(left: 0 , right: (widget.width ?? 400) < 400 ? 0 : 30, top: 10, bottom: 30),
|
||||
enabledBorder: const OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Colors.transparent, width: 0),
|
||||
),
|
||||
border: const OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Colors.transparent, width: 0)),
|
||||
),
|
||||
items: SharedWorkspaceLocal.workspaces.values.where((element) => !widget.excluded.contains(element.id)
|
||||
).map((e) => DropdownMenuItem(
|
||||
value: e.id ,child: Text(e.name ?? ""),)).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
widget.before = widget.selected;
|
||||
widget.selected = value.toString();
|
||||
});
|
||||
})))),
|
||||
Tooltip(
|
||||
message: 'share',
|
||||
child:InkWell(
|
||||
mouseCursor: widget.selected == null || widget.selected == widget.before ? MouseCursor.defer : SystemMouseCursors.click,
|
||||
onTap: () async {
|
||||
if (widget.selected != null && widget.contextID != "" && widget.selected != widget.before) {
|
||||
if (widget.type == SharedMenuWorkspaceType.peer) {
|
||||
await widget.service.addPeer(context, widget.selected!, widget.contextID);
|
||||
} else if (widget.type == SharedMenuWorkspaceType.workflow) {
|
||||
await widget.service.addWorkflow(context, widget.selected!, widget.contextID);
|
||||
} else {
|
||||
await widget.service.addWorkspace(context, widget.selected!, widget.contextID);
|
||||
}
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
setState(() {});
|
||||
dash.selectedLeftMenuKey.currentState?.setState(() { });
|
||||
CatalogFactory.key.currentState?.setState(() {});
|
||||
CatalogItemFactory.key.currentState?.setState(() {});
|
||||
WorkflowFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: widget.topMargin ?? (widget.inner ? 0 : 10)),
|
||||
width: 50,
|
||||
height: 50,
|
||||
color: Colors.black,
|
||||
child: Icon(Icons.share_rounded,
|
||||
color: widget.selected == null || widget.selected == widget.before ? Colors.grey : Colors.white)
|
||||
)
|
||||
)
|
||||
),
|
||||
Tooltip(
|
||||
message: 'unshare',
|
||||
child:InkWell(
|
||||
mouseCursor: widget.selected == null || widget.selected == widget.before ? MouseCursor.defer : SystemMouseCursors.click,
|
||||
onTap: () async {
|
||||
if (widget.selected != null && widget.contextID != "" && widget.selected != widget.before) {
|
||||
if (widget.type == SharedMenuWorkspaceType.peer) {
|
||||
await widget.service.removePeer(context, widget.selected!, widget.contextID);
|
||||
} else if (widget.type == SharedMenuWorkspaceType.workflow) {
|
||||
await widget.service.removeWorkflow(context, widget.selected!, widget.contextID);
|
||||
} else {
|
||||
await widget.service.removeWorkspace(context, widget.selected!, widget.contextID);
|
||||
}
|
||||
SharedWorkspaceLocal.init(context, false);
|
||||
setState(() {});
|
||||
dash.selectedLeftMenuKey.currentState?.setState(() { });
|
||||
CatalogFactory.key.currentState?.setState(() {});
|
||||
CatalogItemFactory.key.currentState?.setState(() {});
|
||||
WorkflowFactory.key.currentState?.setState(() {});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.black,
|
||||
border: Border(left: BorderSide(color: Colors.white, width: 1))
|
||||
),
|
||||
margin: EdgeInsets.only( top: widget.topMargin ?? (widget.inner ? 0 : 10 )),
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: Icon(Icons.delete, color: widget.selected == null || widget.selected == widget.before ? Colors.grey : Colors.white)
|
||||
)
|
||||
)
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/models/shared_workspace_local.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/widgets/menu_clipper/shared_workspace_menu.dart';
|
||||
class MenuWorkspaceWidget extends StatefulWidget {
|
||||
bool simpliest = false;
|
||||
double? width;
|
||||
@@ -17,7 +19,7 @@ class MenuWorkspaceWidgetState extends State<MenuWorkspaceWidget> {
|
||||
data: Theme.of(context).copyWith(
|
||||
canvasColor: widget.simpliest ? Colors.grey.shade300 : Colors.grey,
|
||||
),
|
||||
child: Container( height: 50, width: widget.width ?? MediaQuery.of(context).size.width / ( widget.simpliest ? 1 : 2),
|
||||
child: Container( height: 50, width: widget.width ?? MediaQuery.of(context).size.width / ( widget.simpliest ? 1 : 3),
|
||||
decoration: BoxDecoration(
|
||||
color: widget.simpliest ? Colors.white : const Color.fromRGBO(38, 166, 154, 1),
|
||||
border: Border(bottom: BorderSide(color: widget.simpliest ? Colors.grey.shade300 : Colors.transparent, width: 1))
|
||||
@@ -58,12 +60,13 @@ class MenuWorkspaceWidgetState extends State<MenuWorkspaceWidget> {
|
||||
}
|
||||
});
|
||||
})))),
|
||||
|
||||
widget.simpliest ? Container() : Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: (MediaQuery.of(context).size.width / 2) - 50,
|
||||
width: (MediaQuery.of(context).size.width / 3) - 50,
|
||||
height: 50,
|
||||
decoration: const BoxDecoration(border: Border(left: BorderSide(color: Colors.white))),
|
||||
child: TextFormField(
|
||||
@@ -106,7 +109,12 @@ class MenuWorkspaceWidgetState extends State<MenuWorkspaceWidget> {
|
||||
)
|
||||
)
|
||||
)
|
||||
])
|
||||
]),
|
||||
widget.simpliest ? Container() : SharedMenuWorkspaceWidget( inner: true,
|
||||
excluded: const[],
|
||||
before: WorkspaceLocal.workspaces[WorkspaceLocal.current]!.shared,
|
||||
selected: WorkspaceLocal.workspaces[WorkspaceLocal.current]!.shared,
|
||||
contextID: WorkspaceLocal.current ?? "", width: (MediaQuery.of(context).size.width / 3))
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user