builderXEditDialog_BTNs function

XBtnbase builderXEditDialog_BTNs(
  1. TextEditingController controller,
  2. BuildContext context,
  3. String valueAndLabel,
  4. bool isSconto,
  5. void parentSetState(
    1. void ()
    ), {
  6. XCol? xCol,
})

Implementation

XBtnbase builderXEditDialog_BTNs(TextEditingController controller, BuildContext context, String valueAndLabel, bool isSconto, void Function(void Function()) parentSetState, {XCol? xCol}) {
  return XBtnbase(
      padding: EdgeInsets.all(1),
      width: 45 * XUtils.kforScale,
      label_Style: XStyles.xStyTextForSubLabel(
          textColor: valueAndLabel.contains("+")
              ? Colors.green
              : valueAndLabel.contains("-") || valueAndLabel == ("C")
                  ? Colors.red
                  : Colors.green),
      label: valueAndLabel,
      backGroundColor: Colors.grey[700],
      onPressed: () {
        if (valueAndLabel == "C") {
          controller.text = "";
          FocusScope.of(context).unfocus();
        } else {
          if (isSconto) {
            parentSetState(() {
              controller.text += calcSconto(controller, valueAndLabel);
            });
          } else {
            if (valueAndLabel.contains("-")) {
              calcCell_Negative(xCol!, controller, int.parse(valueAndLabel.replaceFirst("-", "")));
            } else {
              calcCell_Positive(xCol!, controller, int.parse(valueAndLabel.replaceFirst("+", "")));
            }
          }
          controller.selection = TextSelection(baseOffset: controller.text.length, extentOffset: controller.text.length);
        }
      });
}