getButtonsList method
dynamic
getButtonsList(
- dynamic context,
- dynamic detail,
- dynamic data,
- dynamic params,
- dynamic backcolor,
Implementation
getButtonsList(context, detail, data, params, backcolor) {
myLogAll('getButtonsList');
myLog('getButtonsList data:$data');
List<Widget> list = [];
if (isNull(data)) {
return list;
}
double realWidth = 0;
double realHeight = 0;
if (data is Map && !isNull(data[gParam])) {
dynamic dataParam = data[gParam];
if (!isNull(dataParam[gType])) {
if (dataParam[gType] == '$gRow$gCnt') {
int cnt = dataParam[gValue];
realWidth =
MediaQuery.of(context).size.width / cnt - gVerticalspace * 9;
realHeight = realWidth / 2;
if (realHeight > 80.0) {
realHeight = 80.0;
}
}
}
}
int colorIndex = 0;
if (data is Map && !isNull(data[gColorIndex])) {
colorIndex = data[gColorIndex];
}
if (isNull(detail)) {
return list;
}
for (Map element in detail) {
if (isAfterEmptyCurrent(element)) {
continue;
}
//detail.forEach((element) {
dynamic x, xShow;
dynamic y, yShow;
if (isNull(element[gX])) {
x = -1;
} else {
x = element[gX] ?? -1;
}
if (isNull(element[gY])) {
y = -1;
} else {
y = element[gY] ?? -1;
}
if (!isNull(element[gWidth] ?? '')) {
//element[gWidth] = getDouble(element[gWidth]);
element[gWidth] = element[gWidth];
}
if (realWidth > 0) {
element[gWidth] = realWidth;
element[gHeight] = realHeight;
}
if (!isNull(element[gParam] ?? '')) {
Map items =
getMap(isSS() ? getJsonDecode(element[gParam]) : element[gParam]);
for (int i = 0; i < items.entries.length; i++) {
dynamic item = items.entries.elementAt(i).value;
dynamic key = items.entries.elementAt(i).key;
if (key == gWhere) {
item = getWhereFilter(item);
}
if (isNull(element[key])) {
element[key] = item;
}
//element.putIfAbsent(key, () => item);
}
}
if (colorIndex >= _colorList.length) {
colorIndex = 0;
}
bool isInstant = false;
if (!isNull(_globalParam[gGlobalCompanyid]) &&
!isNull(element[gInstantrule])) {
if (isSqlTrue(element[gInstantrule], context)) {
isInstant = true;
element[gInstantrule] = '';
}
}
if (isNull(element[gColor])) {
element[gColor] = _colorList[colorIndex].value.toString();
}
//element.putIfAbsent(gColor, () => _colorList[colorIndex]);
if (x == -1 && y == -1) {
colorIndex += 1;
}
if (!isNull(element[gShowrule])) {
if (isNull(_globalParam[gGlobalCompanyid]) ||
!isSqlTrue(element[gShowrule], context)) {
continue;
}
}
if (!isNull(element[gActiverule])) {
if (isNull(_globalParam[gGlobalCompanyid])) {
if (isNull(element[gIsactive])) {
element[gIsactive] = true;
}
//element.putIfAbsent(gIsactive, () => true);
} else if (!isSqlTrue(element[gActiverule], context)) {
if (isNull(element[gIsactive])) {
element[gIsactive] = false;
}
//element.putIfAbsent(gIsactive, () => false);
}
}
/*if (!isNull(element[gMsg])) {
if (isNull(element[gMsg])) {
element[gMsg] = element[gMsg];
}
//element.putIfAbsent(gMsg, () => element[gMsg]);
}*/
if (isNull(element[gWidth])) {
element[gWidth] = '60.0';
}
//element.putIfAbsent(gWidth, () => 140.0);
if (isNull(element[gName])) {
element[gName] = params[gName] ?? '';
}
//element.putIfAbsent(gName, () => params[gName] ?? '');
if (isNull(element[gType])) {
element[gType] = params[gType] ?? '';
}
//element.putIfAbsent(gType, () => params[gType] ?? '');
if (x != -1 && y != -1) {
element[gIconSize] = '40.0';
}
Widget w;
if (x != -1 && y != -1) {
xShow = element[gXshow];
yShow = element[gYshow];
if (element[gType] == gLabel) {
xShow = xShow + 20.0;
w = MyLabel({
gLabel: element[gLabel],
}, backcolor);
/*Widget wDividor = const Divider();
double right = getDouble(params[gData][gWidth]) -
getDouble(x.toString()) -
30.0 -
getCharLength(element);
wDividor =
Positioned(top: getDouble(y.toString()), right: right, child: w);*/
if ((element[gActionid] ?? '') == gDivider) {
list.add(Positioned(
top: getDouble(yShow.toString()) - 5.0,
left: 20.0,
child: SizedBox(
width: getDouble(params[gData][gWidth]),
height: 0.0,
child: const Divider(thickness: 2.5))));
}
} else if (element[gType] == gLine) {
element[gFontSize] = 10.0;
double x0 = element[gXshow];
double y0 = element[gYshow];
double x1 = element['{$gXshow}0'];
double y1 = element['{$gYshow}0'];
dynamic d0 = element['d0'];
double width0 = getDouble(getCharLength(element).toString());
double height0 = width0 > 0 ? 20.0 : 0.0;
double segSmall = width0 > 0 ? 5.0 : 0.0;
double left = x0 + segSmall, top = y0 - height0 / 2; // right
if (d0 == gLeft) {
left = x0 - segSmall;
} else if (d0.toString().startsWith(gTop) ||
d0.toString().startsWith(gBottom)) {
top = y0 - segSmall - height0;
if (d0.toString().startsWith(gBottom)) {
top = y0 + segSmall;
}
left = x0 - width0 / 2;
if (d0 == 'gTopgLeft' || d0 == 'gBottomgLeft') {
left = x0 - width0 / 3;
} else if (d0 == 'gTopRight' || d0 == 'gBottomgRight') {
left = x0 - width0 * 2 / 3;
}
}
dynamic paint0 = Paint()
..color = colorList[0]
..strokeWidth = 3;
dynamic paint1 = Paint()
..color = Colors.red
..strokeWidth = 3;
//myLog('top is $top');
List param = [
{
// double left = 20.0, top = 0.0;
'x0': x0,
'y0': y0,
'x1': x1,
'y1': y1,
'left': left,
'top': top,
'width': width0,
'height': height0,
'horizen': true,
'type': 'line',
'paint': {'paint0': paint0, 'paint1': paint1},
}
];
xShow = 0.0;
yShow = 0.0;
w = drawWidget(param);
/*w = Positioned(
top: 0.0,
left: 0.0,
child: SizedBox(
width: x1 + width0 + seg,
height: y1 + height0 + seg,
child: w));*/
/*w = Positioned(
top: top,
left: left,
child: SizedBox(
width: x1 + width0 + seg,
height: y1 + height0 + seg,
child: MyLabel(element, backcolor)));*/
if (width0 > 0) {
Widget wLabel = Positioned(
top: top, left: left, child: MyLabel(element, backcolor));
list.add(wLabel);
}
/*drawLine(element[gLabel] ?? '', element[gXshow], element[gYshow],
element['{$gXshow}0'], element['{$gYshow}0']);*/
} else {
element[gIconSize] = 50.0;
element[gPattern] = gRow;
if (!isNull(params) && !isNull(params[gParam])) {
addParams(element, params[gParam]);
}
w = MyButton(element);
}
/*double right = getDouble(params[gData][gWidth]) -
getDouble(xShow.toString()) -
30.0 -
getCharLength(element);*/
w = Positioned(
top: getDouble(yShow.toString()),
left: getDouble(xShow.toString()),
child: w);
} else {
if (!isNull(params) && !isNull(params[gParam])) {
addParams(element, params[gParam]);
}
w = MyButton(element);
}
list.add(w);
if (isInstant) {
_futureTask = {
gAction: 'onTabMyButton',
gValue: element,
gContext: context
};
showFutureTask();
}
}
return list;
}