getRowItemOneAll method

dynamic getRowItemOneAll(
  1. dynamic paramAll,
  2. dynamic id,
  3. dynamic item,
  4. dynamic context,
  5. dynamic backColorValue,
  6. dynamic type,
)

Implementation

getRowItemOneAll(paramAll, id, item, context, backColorValue, type) {
  myLogAll('getRowItemOneAll');
  dynamic name = paramAll[gTableID] ?? paramAll[gValue];
  Map info;
  var typeOwner = gForm;
  if (_tableList[name] != null) {
    typeOwner = gTable;
  }
  if (typeOwner == gForm) {
    info = formLists[name]!;
  } else {
    info = tableList[name]!;
  }
  if (isNull(info)) {
    return MyLabel(
        {gLabel: gNotavailable, gFontSize: _defaultFontSize}, backColorValue);
  }
  bool isEmpty = isempty(item, name, id, type);
  bool isAdvanceSearch = false;
  if (paramAll[gAdvanceSearch] ?? false) {
    isAdvanceSearch = true;
  }
  /*if ((item[gIsHidden] ?? "false") == gTrue) {
    isEmpty = true;
  }
  else if ((item[gInputType] ?? item[gType]) == gHidden) {
    isEmpty = true;
  }
  else if (isAfterEmpty(item, name, id)) {
    isEmpty = true;
  }
  else if (!isNull(item[gShowrange]) && item[gShowrange] != type) {
    isEmpty = true;
  }*/
  /*if (!isNull(item[gAfter])) {
    List afterList = item[gAfter].toString().split(',');
    for (int i = 0; i < afterList.length; i++) {
      String afterListI = afterList[i];
      if (isNull(afterListI)) {
        continue;
      }
      dynamic afterValue = getValue(name, afterListI, id);
      if (isNull(afterValue)) {
        isEmpty = true;
        break;
      }
      /*if (afterValue[gType] ?? '' == gOriginalValue) {
        isEmpty = true;
        break;
      }*/
      if (isNull(afterValue[gValue] ?? '')) {
        isEmpty = true;
        break;
      }
    }
  }*/

  if (isEmpty) {
    Widget w = getEmptyWidget();
    return {
      gWidget: w,
      gParam: {gIsempty: true},
      gContext: context
    };
  }
  if (!isAdvanceSearch && (item[gInputType] ?? "") == gCode) {
    Widget w = MyPinCode(item, name);
    return {gWidget: w, gParam: {}, gContext: context};
  }
  if (!isAdvanceSearch && (item[gInputType] ?? "") == gBtn) {
    Widget w = MyButton(item);
    return w;
  }
  var originalValue = '';
  bool isModified = false;
  bool needi10n = false;
  var droplist = '';
  bool isFocus = false;
  bool isReadonly = isreadonly(item, name);
  if (!isReadonly &&
      (_mFocusNode[gIsLabel] ?? false) &&
      ((_mFocusNode[gName] ?? '') == name) &&
      (_mFocusNode[gCol] == item[gId]) &&
      ((id ?? '') == (_mFocusNode[gId] ?? ''))) {
    isReadonly = true;
  }

  Map param = {
    gItem: item,
    gName: name,
    //gRow: row,
    gTypeOwner: (type == gForm) ? gForm : typeOwner,
    gBackgroundColor: backColorValue,
    gParam0: paramAll
  };
  //droplist = item[gDroplist] ?? "";
  droplist = getDPidfromItem(item) ?? '';

  if (type == gForm) {
    //var colname = item[gId];
    id = id ?? getValueOriginal(name, gId, id);
    param[gId] = id;
    originalValue = getValueOriginal(name, item[gId], id);

    if ( //_mFocusNode[gType] == typeOwner &&
        _mFocusNode[gName] == name && _mFocusNode[gCol] == item[gId]) {
      isFocus = true;
    }
  } else {
    var colname = item[gId];
    Map dataRow = getTableRowByID(name, id);
    originalValue = getValueOriginal(name, colname, id).toString();

    if ( //_mFocusNode[gType] == type &&
        _mFocusNode[gName] == name &&
            _mFocusNode[gCol] == colname &&
            (_mFocusNode[gId] ?? '') == id) {
      /*if (!isNull(info[gTableItemRow]) && dataRow[gId] == id
        //&&          colname == info[gTableItemColName]
        ) {*/
      Map<dynamic, dynamic> formDefine = formLists[name]!;
      Map<dynamic, dynamic> formItems = formDefine[gItems];
      item = getFormOneItem(formItems, colname, dataRow, name, param[gValue],
          isModified, originalValue);
      isFocus = true;
    }
  }

  param[gFocus] = isFocus;
  param[gId] = id;
  dynamic aValue = getRowItemOneValue(param, context) ?? {gValue: ''};
  param[gValue] = aValue[gValue] ?? '';
  param[gType] = aValue[gType];

  isModified = param[gValue] != originalValue;
  if (!isNull(droplist)) {
    needi10n = true;
  }
  Widget w;
  /*
      如果是非点中项
        显示label,退出

      如果不可编辑,显示label,加上按钮,退出
          (
            如果是电话,加上电话按钮
            如果是URL,加上URL按钮
            如果是邮件,加上邮件按钮
            如果是密码,用星号显示
            ...
          )

      如果不是下拉框(日期、地址、下拉),用编辑框,退出

      如果是地址,用编辑框加地址按钮,退出


      加上下拉框按钮,退出


  */
  bool isRequired = false;
  param[gAlert] = isItemValueValidStr(item, param[gValue]);
  if (param[gAlert] == gRequired) {
    isRequired = true;
    param[gAlert] = '';
  }
  if (item[gType] == gDate || item[gType] == gDatetime) {
    //droplist = item[gType];
    isReadonly = true;
  }
  var showTxt = getValueGUI(param[gValue], item);
  bool isAdvancedSearch = paramAll[gAdvanceSearch] ?? false;
  if (isAdvancedSearch) {
    showTxt = '';
  }

  if ((item[gInputType] ?? "") == gBool) {
    bool isTrue = ((showTxt ?? '') == "true");

    Widget w = IconButton(
        icon: Icon(isTrue
            ? Icons.check_box_outlined
            : Icons.check_box_outline_blank_outlined),
        onPressed: () {
          if (isReadonly) {
            return;
          }
          setFocusOne(
              name, item[gId], id, (param[gTypeOwner] == gForm), context, -1);
          textChange(isTrue ? "false" : "true", item, context,
              param[gTypeOwner], name, id);

          myNotifyListeners();
          //phonecallItem();
        });
    return {gWidget: w, gParam: param, gContext: context};
  }
  if ((item[gInputType] ?? "") == gIcon ||
      (item[gInputType] ?? "") == gPhoto ||
      (item[gInputType] ?? "") == gSelfie ||
      (item[gInputType] ?? "") == gMoney ||
      (item[gInputType] ?? "") == gBarcode) {
    //选择icon
    isReadonly = true;
  }
  if (!isFocus || isReadonly) {
    if (item[gType] == gPassword || item[gHash]) {
      showTxt = getStrMask(showTxt, '*');
    }

    if (isNull(showTxt) && param[gTypeOwner] == gForm) {
      //var aMsg = gTouch;
      var aMsg = item[gLabel];
      needi10n = true;

      if (isReadonly) {
        if ((item[gInputType] ?? "") == gIcon) {
          //showTxt = getSCurrent('Please select icon');
          showTxt = aMsg;
        } else if ((item[gInputType] ?? "") == gPhoto) {
          //showTxt = getSCurrent('Please ') + getSCurrent('take picture');
          showTxt = aMsg;
        } else if ((item[gInputType] ?? "") == gBarcode) {
          showTxt = '******';
        } else if ((item[gInputType] ?? "") == gSelfie) {
          //showTxt = getSCurrent('Please ') + getSCurrent('take selfie');
          showTxt = aMsg;
        }
      } else {
        showTxt = aMsg;
        if (isRequired) {
          showTxt = '* $showTxt';
        }
      }
    }
    Map labelParam = {
      gLabel: showTxt,
      gOriginalValue: (isModified && item[gType] != gPassword)
          ? getValueGUI(originalValue, item)
          : null,
      gNeedi10n: needi10n,
      gSearch: (type == gForm) ? '' : (info[gSearch] ?? '')
    };
    if (param[gType] == gDataModifiedInvalid || item[gType] == gLabel) {
      labelParam[gColorLabel] = warningColor;
    }
    if (isModified && isNull(labelParam[gOriginalValue])) {
      labelParam[gIsBold] = true;
    }
    if (param[gTypeOwner] == gForm) {
      labelParam[gAlign] = TextAlign.left;
      if (!isReadonly) {
        labelParam[gTextDecoration] = TextDecoration.underline;
      }
    }
    if ((item[gType] == gIcon ||
            item[gType] == gSelfie ||
            item[gType] == gPhoto) &&
        !isNull(param[gValue])) {
      param[gIsIcon] = true;
      double height = 32.0;
      if (item[gType] != gIcon) {
        height = 96.0;
      }
      param[gHeight] = height;
      param[gWidth] = height;

      if (originalValue == param[gValue]) {
        Widget wIcon = getImg(param, backColorValue);
        w = (type == gTreeView)
            ? wIcon
            : Row(
                children: [
                  Expanded(child: getEmptyWidget()),
                  IgnorePointer(
                    child: wIcon,
                  ),
                ],
              );
      } else {
        param[gColor] = Colors.red;
        Widget wIcon = getImg(param, backColorValue);
        Widget wIconOriginal =
            getImg({gValue: originalValue}, backColorValue);
        w = (type == gTreeView)
            ? Row(
                children: [
                  wIconOriginal,
                  MyLabel(const {gLabel: '->'}, backColorValue),
                  wIcon,
                ],
              )
            : Row(
                children: [
                  const Expanded(child: SizedBox(height: 5.0)),
                  IgnorePointer(
                    child: wIconOriginal,
                  ),
                  MyLabel(const {gLabel: '->'}, backColorValue),
                  IgnorePointer(
                    child: wIcon,
                  ),
                ],
              );
      }
    } else {
      w = MyLabel(labelParam, backColorValue);
      if (type == gForm) {
        //myLog('getrowvalue item type is ${item[gType]}');
        w = Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            isNull(item[gPreFixIcon])
                ? MyLabel({gLabel: '${item[gLabel]}:  '}, backColorValue)
                : MyIcon({
                    gValue: item[gPreFixIcon],
                    gColor: (fromBdckcolor(defaultBackGroundColor))
                  }),
            w,
          ],
        );
      }
      if (!isNull(droplist)) {
        List listDp = _dpList[droplist] ?? [];
        if (listDp.isNotEmpty && listDp.length < 4) {
          for (int i = 0; i < listDp.length; i++) {
            if (listDp[i] is! Map) {
              break;
            }
            Map li = listDp[i];

            if (li[gLabel] == param[gValue]) {
              w = Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  w,
                  MyIcon({
                    gValue: li[gValue],
                    gColor: (param[gValue] == originalValue)
                        ? Colors.green
                        : Colors.red
                  }),
                  /*Icon(
                      IconData(
                        getInt(li[gValue]),
                        fontFamily: 'MaterialIcons',
                      ),
                      color: (param[gValue] == originalValue)
                          ? Colors.green
                          : Colors.red),*/
                ],
              );
              break;
            }
          }
        }
      }

      param[gIsLabel] = true;
    }
    param[gWidget] = w;

    w = addValidCheckWidget(param, context);

    return {gWidget: w, gParam: param, gContext: context};
  }
  if (isNull(droplist)) {
    item[gFocus] = isFocus;

    item[gFontSize] = _defaultFontSize;
    item[gFontStyle] = FontStyle.italic;
    if (param[gTypeOwner] != gForm) {
      item[gLength] = null;
    }
    w = TextFieldWidget(
      item: item,
      backcolor: backColorValue,
      typeOwner: typeOwner,
      name: name,
      id: id,
    );
    //param[gWidget] = Expanded(child: w);
    param[gWidget] = w;
    param[gIsLabel] = false;

    w = addValidCheckWidget(param, context);

    return {gWidget: w, gParam: param, gContext: context};
  }

  if (!isNull(param[gValue])) {
    /*getItemIconDroplist(
        item, typeOwner, name, param[gValue], id, backColorValue, context);*/
    w = MyLabel({
      gLabel: param[gValue],
      gOriginalValue: isModified ? originalValue : null,
      gNeedi10n: needi10n
    }, backColorValue);
    param[gWidget] = w;
    param[gIsLabel] = true;

    w = addValidCheckWidget(param, context);

    return {gWidget: w, gParam: param, gContext: context};
  }
  showPopupItem(item, typeOwner, name, param[gValue], id, backColorValue,
      context, true);
  return const Text("");
}