KforScale_UI_edit method

dynamic KforScale_UI_edit()

Implementation

KforScale_UI_edit() async {
  double _currentValue = (widget.xApp.KforScale * 100).round().toDouble();
  double _minValue = 70;
  double _maxValue = 200;
  double _firstMarkerSize = 10;
  // String _annotationValue = '100';
  var res = await showDialog<bool?>(
      context: context,
      builder: (context) {
        return StatefulBuilder(builder: (context, setState) {
          double width = MediaQuery.of(context).size.width;

          //Da modificare per fare i font
          void handlePointerValueChanged(double value) {
            setState(() {
              _currentValue = value.round().toDouble();
            });
          }

          /// Pointer dragging is canceled when dragging pointer value is less than 7.
          // void handlePointerValueChanging(ValueChangingArgs args) {
          //   if (args.value < _minValue || args.value > _maxValue) {
          //     args.cancel = true;
          //   }
          // }

          return Container(
              margin: EdgeInsets.symmetric(horizontal: 20),
              child: XAlertDialog(
                  colorBackGround: Colors.grey[900],
                  height: MediaQuery.of(context).size.height / 2,
                  title_Text: "Scegli la tua grandezza del testo:",
                  title_Style: XStyles.xStyleText(fontSize: 18 * (_currentValue / 100) / widget.xApp.KforScale),
                  content_insetPadding: EdgeInsets.all(0),
                  btnYES_label: "Salva",
                  btnNO_label: "Annulla",
                  child: Column(children: <Widget>[
                    // Expanded(
                    //   flex: 7,
                    //   child: SfRadialGauge(axes: <RadialAxis>[
                    //     RadialAxis(
                    //       minimum: _minValue, maximum: _maxValue,
                    //       axisLineStyle: const AxisLineStyle(thickness: 0.2, thicknessUnit: GaugeSizeUnit.factor),
                    //       showTicks: false,
                    //       showLastLabel: true,
                    //       //style delle tacchette interne
                    //       axisLabelStyle: GaugeTextStyle(color: XColors.foregroundLight, fontSize: 18),
                    //       onAxisTapped: handlePointerValueChanged,
                    //       pointers: <GaugePointer>[
                    //         //streiscia da tappare e fare lo slide
                    //         RangePointer(
                    //           value: _currentValue,
                    //           onValueChanged: handlePointerValueChanged,
                    //           onValueChangeEnd: handlePointerValueChanged,
                    //           onValueChanging: handlePointerValueChanging,
                    //           enableDragging: true,
                    //           width: 0.2,
                    //           sizeUnit: GaugeSizeUnit.factor,
                    //         ),
                    //         //Pallino bianco dentro la striscia da tappare
                    //         MarkerPointer(
                    //           value: _currentValue,
                    //           color: Colors.white,
                    //           markerHeight: _firstMarkerSize,
                    //           markerWidth: _firstMarkerSize,
                    //           markerType: MarkerType.circle,
                    //         ),
                    //       ],
                    //       //Percentuale interna allo slider
                    //       annotations: <GaugeAnnotation>[
                    //         GaugeAnnotation(
                    //             widget: Row(
                    //               mainAxisSize: MainAxisSize.min,
                    //               children: <Widget>[Text('${_currentValue.toInt()} %', style: XStyles.xStyTextForSubDescr())],
                    //             ),
                    //             positionFactor: 0.13,
                    //             angle: 0)
                    //       ],
                    //     )
                    //   ]),
                    // ),
                    //Slider orizzontale sotto alla chart
                    Expanded(
                        flex: 3,
                        child: SizedBox(
                          width: width - 50,
                          child: Slider(
                            min: _minValue,
                            max: _maxValue,
                            activeColor: const Color(0xFF02AAB0),
                            inactiveColor: const Color(0xFF00CDAC),
                            onChanged: handlePointerValueChanged,
                            value: _currentValue,
                          ),
                        )),
                  ]),
                  btnYES_OnPressed: () {
                    Navigator.pop(context, true);
                  },
                  btnNO_OnPressed: () {
                    Navigator.pop(context, false);
                  }));
        });
      });
  if (res != null && res) {
    setState(() {
      widget.xApp.KforScale = _currentValue / 100;
    });
    var prefs = await SharedPreferences.getInstance();
    prefs.setString("fontSize", widget.xApp.KforScale.toString());
  }
}