openOpacityBottomSheet method

void openOpacityBottomSheet()

Opens a bottom sheet to adjust the opacity when drawing.

Implementation

void openOpacityBottomSheet() {
  showModalBottomSheet(
    context: context,
    backgroundColor: imageEditorTheme.paintingEditor.opacityBottomSheetColor,
    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.changeOpacity,
                    theme: initConfigs.theme,
                    textStyle: imageEditorTheme
                        .paintingEditor.opacityBottomSheetTitle,
                    closeButton:
                        customWidgets.paintEditor.changeOpacityCloseButton !=
                                null
                            ? (fn) => customWidgets.paintEditor
                                .changeOpacityCloseButton!(this, fn)
                            : null,
                  ),
                  StatefulBuilder(builder: (context, setState) {
                    if (customWidgets.paintEditor.sliderChangeOpacity !=
                        null) {
                      return customWidgets.paintEditor.sliderChangeOpacity!(
                        this,
                        rebuildController.stream,
                        paintCtrl.opacity,
                        (value) {
                          setOpacity(value);
                          setState(() {});
                        },
                        (onChangedEnd) {},
                      );
                    }

                    return Slider.adaptive(
                      max: 1,
                      min: 0,
                      divisions: 100,
                      value: paintCtrl.opacity,
                      onChanged: (value) {
                        setOpacity(value);
                        setState(() {});
                      },
                    );
                  }),
                ],
              ),
            ),
          ),
        );
      });
    },
  );
}