Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHeitmann committed Oct 7, 2022
2 parents 2ecd4b8 + b941d8f commit bafa001
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/widgets/EditorLayout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class EditorLayout extends StatelessWidget {
return LayoutBuilder(builder: (context, constraints) {
return ResizableWidget(
axis: Axis.horizontal,
percentages: [0.18, 0.60, 0.22],
percentages: [0.22, 0.53, 0.25],
draggableThickness: 4,
lineThickness: 4,
children: [
Expand Down
75 changes: 75 additions & 0 deletions lib/widgets/propEditors/customXmlProps/conditionEditor.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

import 'package:flutter/material.dart';

import '../../../customTheme.dart';
import '../../../stateManagement/ChangeNotifierWidget.dart';
import '../../../stateManagement/xmlProps/xmlProp.dart';
import '../simpleProps/XmlPropEditorFactory.dart';
import '../simpleProps/propEditorFactory.dart';
import 'puidReferenceEditor.dart';

class ConditionEditor extends ChangeNotifierWidget {
final XmlProp prop;
final bool showDetails;

ConditionEditor({super.key, required this.prop, required this.showDetails}) : super(notifier: prop);

@override
State<ConditionEditor> createState() => _ConditionEditorState();
}

class _ConditionEditorState extends ChangeNotifierState<ConditionEditor> {
@override
Widget build(BuildContext context) {
var label = widget.prop.get("condition")?.get("state")?.get("label")?.value;
var value = widget.prop.get("condition")?.get("state")?.get("value");
var args = widget.prop.get("args");

return Padding(
padding: const EdgeInsets.all(4.0),
child: Row(
children: [
// Icon(Icons.help),
Text(
"?",
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
SizedBox(width: 12),
Expanded(
child: Container(
decoration: BoxDecoration(
color: getTheme(context).formElementBgColor,
borderRadius: BorderRadius.circular(5),
),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
PuidReferenceEditor(prop: widget.prop.get("puid")!, showDetails: widget.showDetails),
Divider(color: getTheme(context).textColor!.withOpacity(0.75), thickness: 2,),
if (label != null)
makePropEditor(label)
else
Text("No label"),
if (value != null)
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: makeXmlPropEditor(value, widget.showDetails),
),
if (args != null)
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: makeXmlPropEditor(args, widget.showDetails),
),
],
),
),
)
]
),
);
}
}


5 changes: 5 additions & 0 deletions lib/widgets/propEditors/simpleProps/XmlPropEditorFactory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import '../../../stateManagement/Property.dart';
import '../../../stateManagement/xmlProps/xmlProp.dart';
import '../../../utils.dart';
import '../customXmlProps/areaEditor.dart';
import '../customXmlProps/conditionEditor.dart';
import '../customXmlProps/entityEditor.dart';
import '../customXmlProps/layoutsEditor.dart';
import '../customXmlProps/paramEditor.dart';
Expand All @@ -31,6 +32,10 @@ Widget makeXmlPropEditor<T extends PropTextField>(XmlProp prop, bool showDetails
if (prop.length == 3 && prop[0].tagName == "name" && prop[1].tagName == "code" && prop[2].tagName == "body") {
return ParamsEditor(prop: prop, showDetails: showDetails);
}
// condition
if (prop.get("puid") != null && prop.get("condition") != null) {
return ConditionEditor(prop: prop, showDetails: showDetails);
}
// fallback
return XmlPropEditor<T>(prop: prop, showDetails: showDetails,);
}
Expand Down

0 comments on commit bafa001

Please sign in to comment.