diff --git a/lib/models/resources/resources.dart b/lib/models/resources/resources.dart index 70c717b..2b094d5 100644 --- a/lib/models/resources/resources.dart +++ b/lib/models/resources/resources.dart @@ -160,7 +160,7 @@ abstract class AbstractItem> instances = []; @@ -178,7 +178,7 @@ abstract class AbstractItem infos) { @@ -263,7 +263,7 @@ abstract class AbstractItem { ))); childrenReadOnly.add(Padding(padding: EdgeInsets.only(bottom: 15), child: SubDropdownInputWidget( dropdownMenuEntries: dpItems, subkey: "", width: 180, empty: false, - initialValue: "${widget.instanceID}", change: (value) { - if (value != null) { setState(() { widget.instanceID = int.parse(value); }); } + initialValue: "${widget.item.selectedInstance}", change: (value) { + if (value != null) { setState(() { widget.item.selectedInstance = int.parse(value); }); } }, )) ); - if (widget.item.instances.length > widget.instanceID) { - childrenReadOnly.addAll(getWidgets(widget.item.instances[widget.instanceID].infos())); + if (widget.item.instances.length > (widget.item.selectedInstance)) { + childrenReadOnly.addAll(getWidgets(widget.item.instances[(widget.item.selectedInstance)].infos())); } } instancesCat.add(ContainerFormsWidget(dash: widget.dash, item: widget.item, elementID: widget.elementID)); diff --git a/lib/widgets/inputs/shallow_dropdown_input.dart b/lib/widgets/inputs/shallow_dropdown_input.dart index 4cbcf3c..637177a 100644 --- a/lib/widgets/inputs/shallow_dropdown_input.dart +++ b/lib/widgets/inputs/shallow_dropdown_input.dart @@ -5,6 +5,7 @@ import 'package:oc_front/pages/shared.dart'; class ShallowDropdownInputWidget extends StatefulWidget { double? width; + double? height; CollaborativeAreaType type = CollaborativeAreaType.workspace; Future> Function()? all; Future Function(String)? load; @@ -17,7 +18,7 @@ class ShallowDropdownInputWidget extends StatefulWidget { Widget? prefixIcon; IconData? iconLoad; IconData? iconRemove; - + String? label; String? hint; String? tooltipLoad; @@ -30,8 +31,8 @@ class ShallowDropdownInputWidget extends StatefulWidget { bool deletion = false; ShallowDropdownInputWidget ({ Key? key, this.width, this.current, required this.all, this.prefixIcon, - this.iconLoad, this.iconRemove, this.hint, this.filled, this.hintColor, this.color, - this.tooltipLoad, this.tooltipRemove, this.deletion = false, this.maptoDropdown, + this.iconLoad, this.iconRemove, this.hint, this.filled, this.hintColor, this.color, this.height, + this.tooltipLoad, this.tooltipRemove, this.deletion = false, this.maptoDropdown, this.label, required this.type, this.canLoad, this.canRemove, this.load, this.remove, this.change }): super(key: key); @override ShallowDropdownInputWidgetState createState() => ShallowDropdownInputWidgetState(); } @@ -54,11 +55,12 @@ class ShallowDropdownInputWidgetState extends State data: Theme.of(context).copyWith( canvasColor: widget.filled ??Colors.white, ), - child: Container( height: 50, width: (widget.width ?? getMainWidth(context)) - (widget.load == null ? 0 : 50) - (widget.remove == null ? 0 : 50), + child: Container( height: widget.height ?? 50, + width: (widget.width ?? getMainWidth(context)) - (widget.load == null ? 0 : 50) - (widget.remove == null ? 0 : 50), decoration: const BoxDecoration( color: Colors.white, ), - child: DropdownButtonFormField( + child: Center(child: DropdownButtonFormField( onChanged: (value) { setState(() { widget.current = value; @@ -78,6 +80,8 @@ class ShallowDropdownInputWidgetState extends State ), decoration: InputDecoration( filled: true, + label: widget.label == null ? null : Text(widget.label!), + alignLabelWithHint: false, prefixIconColor: Colors.grey, prefixIcon: widget.prefixIcon, suffixIconColor: widget.hintColor ?? Colors.grey , @@ -88,7 +92,7 @@ class ShallowDropdownInputWidgetState extends State contentPadding: EdgeInsets.only(left: (widget.width ?? 400) < 200 ? 0 : 30, right: (widget.width ?? 400) < 200 ? 0 : 30, top: 18, bottom: 18), ), items: items, - )))), + ))))), widget.load == null ? Container() : Tooltip( message: widget.tooltipLoad ?? "load $t", child:InkWell( diff --git a/lib/widgets/items/item.dart b/lib/widgets/items/item.dart index ffbcdf0..90da22a 100644 --- a/lib/widgets/items/item.dart +++ b/lib/widgets/items/item.dart @@ -1,6 +1,10 @@ import 'package:oc_front/main.dart'; import 'package:flutter/material.dart'; import 'package:oc_front/models/resources/resources.dart'; +import 'package:oc_front/models/response.dart'; +import 'package:oc_front/pages/shared.dart'; +import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart'; +import 'package:oc_front/widgets/inputs/sub_dropdown_input%20.dart'; // ignore: must_be_immutable class ItemWidget extends StatefulWidget { @@ -10,21 +14,86 @@ class ItemWidget extends StatefulWidget { } class ItemWidgetState extends State { @override Widget build(BuildContext context) { - Widget w = Container(); + List widgets = [ + Container( margin: EdgeInsets.only(bottom: 20), + decoration: BoxDecoration(border: Border(bottom: BorderSide(color: midColor))), + width: getMainWidth(context) / 2, + child: Center(child: Padding( padding: EdgeInsets.only(bottom: 20), + child: Text("RESOURCE INFORMATIONS", style: TextStyle(fontSize: 18, color: Colors.grey, fontWeight: FontWeight.w500))))) + ]; + var infos = widget.item.infos(); + var count = 0; + for (var info in infos.keys) { + count++; + widgets.add(Padding( padding: EdgeInsets.symmetric(vertical: 5), child : Row(children: [ + Padding( padding: EdgeInsets.only(left: 50, right: 10), child : Text("${info.toUpperCase().replaceAll("_", " ")} :", style: TextStyle(fontSize: 15, color: Colors.grey))), + Text("${infos[info] is bool ? (infos[info] == true ? "yes" : "no") : infos[info] ?? "unknown"}", + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.w500)) + ]))); + } + if (count == 0 ) { + widgets.add(Center(child: Padding( padding: EdgeInsets.symmetric(vertical: 5), child : Row(children: [ + Padding( padding: EdgeInsets.only(left: 50, right: 10), child : Text("NO INFORMATION", style: TextStyle(fontSize: 15, color: Colors.grey))), + ])))); + } + List widgetsInstance = []; + List dpItems = []; + for (var (i, instance) in widget.item.instances.indexed) { + dpItems.add(Shallow(id: "$i", name: instance.name ?? "")); + } + if (dpItems.isNotEmpty) { + widgetsInstance.add(Center( child: Padding(padding: EdgeInsets.only(bottom: 15), child: + ShallowDropdownInputWidget( all: () async => dpItems, width: (getWidth(context) / 2) - 25, + label: "instances", type: CollaborativeAreaType.resource, height: 65, + current: "${widget.item.selectedInstance}", change: (value) { + if (value != null) { setState(() { widget.item.selectedInstance = int.parse(value); }); } + }, + )) + )); + } + if (widget.item.instances.length > widget.item.selectedInstance) { + var instance = widget.item.instances[widget.item.selectedInstance]; + widgetsInstance.add(Container(height: 20, width: getWidth(context) / 2,)); + var count = 0; + for (var info in instance.infos().keys) { + if (instance.infos()[info] == null || instance.infos()[info] is List) { continue; } + count++; + widgetsInstance.add(Center(child: Padding( padding: EdgeInsets.symmetric(vertical: 5), child : Row(children: [ + Padding( padding: EdgeInsets.only(left: 50, right: 10), child : Text("${info.toUpperCase().replaceAll("_", " ")} :", style: TextStyle(fontSize: 15, color: Colors.grey))), + Text("${instance.infos()[info] is bool ? (instance.infos()[info] == true ? "yes" : "no") : instance.infos()[info] ?? "unknown"}", + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.w500)) + ])))); + } + if (count == 0 ) { + widgetsInstance.add(Padding( padding: EdgeInsets.symmetric(vertical: 5), child : Row(children: [ + Padding( padding: EdgeInsets.only(left: 50, right: 10), child : Text("NO INSTANCE INFORMATION", style: TextStyle(fontSize: 15, color: Colors.grey))), + ]))); + } + } + Widget w = Column( mainAxisSize: MainAxisSize.max, children: widgets ); + Widget w2 = Column( mainAxisSize: MainAxisSize.max, children: widgetsInstance ); return SizedBox( - height: getHeight(context) - 300, + height: getHeight(context) - 200, child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ widget.item.description == null ? Container() : Container( width: getMainWidth(context), alignment: Alignment.center, + height: 100, decoration: BoxDecoration(border: Border(bottom: BorderSide(color: midColor))), - padding: const EdgeInsets.all(30), - child: Text(widget.item.description!, + padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 50), + child: Text(widget.item.description!.length > 350 ? "${widget.item.description!.substring(0, 347)}..." : widget.item.description!, style: TextStyle(fontSize: 15, color: Colors.grey, fontWeight: FontWeight.w500))), - Container(padding: const EdgeInsets.all(30), - alignment: Alignment.topLeft, - color: midColor, width: getMainWidth(context) / 2, child: w) + Row( children: [ + Container(padding: const EdgeInsets.symmetric(vertical: 20), + height: getHeight(context) - 300, + decoration: BoxDecoration(border: Border(right: BorderSide(color: midColor))), + alignment: Alignment.topLeft, width: getMainWidth(context) / 2, child: w), + Container(height: getHeight(context) - 300, + alignment: Alignment.topRight, width: getMainWidth(context) / 2, child: w2) + ]) ] ) )