intermediate
This commit is contained in:
116
lib/widgets/menu_clipper/workspace_menu.dart
Normal file
116
lib/widgets/menu_clipper/workspace_menu.dart
Normal file
@@ -0,0 +1,116 @@
|
||||
|
||||
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
class MenuWorkspaceWidget extends StatefulWidget {
|
||||
bool simpliest = false;
|
||||
double? width;
|
||||
void Function()? onWorkspaceChange;
|
||||
TextEditingController ctrl = TextEditingController();
|
||||
MenuWorkspaceWidget ({ Key? key, this.simpliest = false, this.width, this.onWorkspaceChange }): super(key: key);
|
||||
@override MenuWorkspaceWidgetState createState() => MenuWorkspaceWidgetState();
|
||||
}
|
||||
class MenuWorkspaceWidgetState extends State<MenuWorkspaceWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
|
||||
return Row( children: [
|
||||
Tooltip( message: "current workspace", child:
|
||||
Theme(
|
||||
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),
|
||||
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))
|
||||
),
|
||||
padding: EdgeInsets.only(left: (widget.width ?? 400) < 400 ? 20 : 50, right: (widget.width ?? 400) < 400 ? 20 : 0),
|
||||
child: DropdownButtonFormField(
|
||||
value: WorkspaceLocal.getCurrentWorkspace()?.id,
|
||||
isExpanded: true,
|
||||
style: TextStyle(color: widget.simpliest ? Colors.black : Colors.white, fontSize: 15),
|
||||
hint: Text("load workspace...", style: TextStyle(color: Colors.grey.shade300, fontSize: 15)),
|
||||
icon: Icon( // Add this
|
||||
Icons.arrow_drop_down, // Add this
|
||||
color: widget.simpliest ? Colors.grey : Colors.white, // Add this
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
prefixIconColor: widget.simpliest ? Colors.grey : Colors.white,
|
||||
icon: Icon(Icons.shopping_cart, color: Colors.grey.shade300),
|
||||
suffixIconColor: widget.simpliest ? Colors.grey : Colors.white,
|
||||
focusedBorder: const OutlineInputBorder( borderRadius: BorderRadius.zero,
|
||||
borderSide: BorderSide(color: Colors.transparent, width: 0),
|
||||
),
|
||||
fillColor: widget.simpliest ? Colors.white : const Color.fromRGBO(38, 166, 154, 1),
|
||||
contentPadding: EdgeInsets.only(left: (widget.width ?? 400) < 400 ? 0 : 30, 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: WorkspaceLocal.getWorkspacesIDS().map((e) => DropdownMenuItem(
|
||||
value: e.id,child: Text(e.name ?? ""),)).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
WorkspaceLocal.changeWorkspace(value.toString());
|
||||
if (widget.onWorkspaceChange != null) {
|
||||
widget.onWorkspaceChange!();
|
||||
}
|
||||
});
|
||||
})))),
|
||||
widget.simpliest ? Container() : Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: (MediaQuery.of(context).size.width / 2) - 50,
|
||||
height: 50,
|
||||
decoration: const BoxDecoration(border: Border(left: BorderSide(color: Colors.white))),
|
||||
child: TextFormField(
|
||||
expands: true,
|
||||
maxLines: null,
|
||||
minLines: null,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 15),
|
||||
cursorColor: const Color.fromARGB(38, 166, 154, 1),
|
||||
controller: widget.ctrl,
|
||||
onChanged: (value) { setState(() { }); },
|
||||
validator: (value) => value == null || value.isEmpty ? "name is required" : null,
|
||||
decoration: InputDecoration(
|
||||
hintText: "name a new workspace...",
|
||||
fillColor: const Color.fromRGBO(38, 166, 154, 1),
|
||||
filled: true,
|
||||
contentPadding: const EdgeInsets.only(left: 30, right: 30, top: 15, bottom: 5),
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.grey.shade300,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w400
|
||||
),
|
||||
border: InputBorder.none
|
||||
)
|
||||
)
|
||||
),
|
||||
Tooltip(
|
||||
message: 'add',
|
||||
child:InkWell(
|
||||
mouseCursor: widget.ctrl.value.text.isEmpty ? MouseCursor.defer : SystemMouseCursors.click,
|
||||
onTap: () async {
|
||||
if (widget.ctrl.value.text.isNotEmpty) {
|
||||
WorkspaceLocal.createWorkspace(widget.ctrl.value.text, context);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
color: Colors.black,
|
||||
child: Icon(Icons.add, color: widget.ctrl.value.text.isEmpty ? Colors.grey : Colors.white)
|
||||
)
|
||||
)
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user