getDatePicker method

dynamic getDatePicker(
  1. dynamic aDate,
  2. dynamic backcolor,
  3. dynamic context,
  4. dynamic formname,
  5. dynamic id,
  6. dynamic actions,
)

Implementation

getDatePicker(aDate, backcolor, context, formname, id, actions) {
  myLogAll('getDatePicker');
  if (isNull(aDate)) {
    aDate = getTodayStr();
  }
  setDplistYear();
  List selectedIndex = [-1, -1, -1];

  List sList = [gYear, gMonth, gDay];
  List widths = [80.0, 40.0, 40.0];

  List sListValue = aDate.split('-');
  if (sListValue.length < 2) {
    sListValue.add('');
  }
  if (sListValue.length < 3) {
    sListValue.add('');
  }
  if (!isNull(actions[0][gItem])) {
    dynamic item = actions[0][gItem];
    if (item[gType] == gDatetime) {
      selectedIndex.add(-1);
      //selectedIndex.add(-1);
      //selectedIndex.add(-1);

      sList.add(gHour);
      //sList.add(gSecond);
      //sList.add(gSecond);
      widths.add(40.0);
      //widths.add(40.0);
      //widths.add(40.0);
      if (sListValue.length < 4) {
        sListValue.add('');
      }
      /*if (sListValue.length < 5) {
        sListValue.add('');
      }
      if (sListValue.length < 6) {
        sListValue.add('');
      }*/
    }
  }
  double width = MediaQuery.of(context).size.width - 70.0;

  if ((actions[0][gId] ?? '') == gAdvanceSearch) {
    width -= 30.0;
    //sList.removeAt(0);
    //selectedIndex.removeAt(0);
    //widths.removeAt(0);
    //sListValue.removeAt(0);

    int length = sList.length;
    selectedIndex.add(0);
    sList.add(gDash);
    widths.add(10.0);
    sListValue.add('-');
    for (int i = 0; i < length; i++) {
      selectedIndex.add(-1);
      sList.add('${sList.elementAt(i)}1');
      widths.add(widths.elementAt(i));
      if (i == length - 1) {
        sListValue.add('23');
      } else {
        sListValue.add(sListValue.elementAt(i));
      }
    }
  }

  for (int j = 0; j < sList.length; j++) {
    for (int i = 0; i < _dpList[sList[j]].length; i++) {
      if (_dpList[sList[j]][i].toString().contains(sListValue[j])) {
        selectedIndex[j] = i;
        _dpListDefaultIndex[sList[j]] = i;
        break;
      }
    }
  }
  List widesList = [];
  double widthTotal = 0.0;
  for (int i = 0; i < widths.length; i++) {
    widthTotal += widths[i];
  }
  double widthRate = width / widthTotal;
  for (int i = 0; i < widths.length; i++) {
    widesList.add(widths[i] * widthRate);
  }

  Map param = {
    gAction: gLocalAction,
    gAction1: gDroplist,
    gHeight: null,
    gSelectedList: selectedIndex,
    gData: sList,
    gWidth: widesList,
    gFormName: formname,
    gId: id,
    gType: gDate
  };
  Widget result = MyListPicker(param, backcolor);
  return result;
}