openLineWeightBottomSheet method

void openLineWeightBottomSheet()

Opens a bottom sheet to adjust the line weight when drawing.

Implementation

void openLineWeightBottomSheet() {
  showModalBottomSheet(
    context: context,
    backgroundColor:
        imageEditorTheme.paintingEditor.lineWidthBottomSheetColor,
    builder: (BuildContext context) {
      return StatefulBuilder(builder: (context, setState) {
        return Material(
          color: Colors.transparent,
          textStyle: platformTextStyle(context, designMode),
          child: SingleChildScrollView(
            physics: const ClampingScrollPhysics(),
            child: Padding(
              padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  BottomSheetHeaderRow(
                    title: i18n.paintEditor.lineWidth,
                    theme: initConfigs.theme,
                    textStyle: imageEditorTheme
                        .paintingEditor.lineWidthBottomSheetTitle,
                    closeButton:
                        customWidgets.paintEditor.lineWidthCloseButton != null
                            ? (fn) => customWidgets
                                .paintEditor.lineWidthCloseButton!(this, fn)
                            : null,
                  ),
                  StatefulBuilder(builder: (context, setState) {
                    if (customWidgets.paintEditor.sliderLineWidth != null) {
                      return customWidgets.paintEditor.sliderLineWidth!(
                        this,
                        rebuildController.stream,
                        paintCtrl.strokeWidth,
                        (value) {
                          setStrokeWidth(value);
                          setState(() {});
                        },
                        (onChangedEnd) {},
                      );
                    }

                    return Slider.adaptive(
                      max: 40,
                      min: 2,
                      divisions: 19,
                      value: paintCtrl.strokeWidth,
                      onChanged: (value) {
                        setStrokeWidth(value);
                        setState(() {});
                      },
                    );
                  }),
                ],
              ),
            ),
          ),
        );
      });
    },
  );
}