openFontScaleBottomSheet method
void
openFontScaleBottomSheet()
Displays a range slider for adjusting the line width of the painting tool.
This method shows a range slider in a modal bottom sheet for adjusting the line width of the painting tool.
Implementation
void openFontScaleBottomSheet() {
final presetFontScale = _fontScale;
showModalBottomSheet(
context: context,
backgroundColor:
imageEditorTheme.paintingEditor.lineWidthBottomSheetColor,
builder: (BuildContext context) {
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: StatefulBuilder(builder: (context, setState) {
void updateFontScaleScale(double value) {
fontScale = value;
setState(() {});
}
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
BottomSheetHeaderRow(
title: '${i18n.textEditor.fontScale} ${_fontScale}x',
theme: widget.theme,
textStyle:
imageEditorTheme.textEditor.fontSizeBottomSheetTitle,
closeButton:
customWidgets.textEditor.fontSizeCloseButton != null
? (fn) => customWidgets
.textEditor.fontSizeCloseButton!(this, fn)
: null,
),
customWidgets.textEditor.sliderFontSize?.call(
this,
_rebuildController.stream,
_fontScale,
updateFontScaleScale,
(onChangedEnd) {},
) ??
Row(
children: [
Expanded(
child: Slider.adaptive(
max: textEditorConfigs.maxFontScale,
min: textEditorConfigs.minFontScale,
divisions: (textEditorConfigs.maxFontScale -
textEditorConfigs.minFontScale) ~/
0.1,
value: _fontScale,
onChanged: updateFontScaleScale,
),
),
const SizedBox(width: 8),
IconTheme(
data: Theme.of(context).primaryIconTheme,
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 150),
child: _fontScale != presetFontScale
? IconButton(
onPressed: () {
updateFontScaleScale(presetFontScale);
},
icon: Icon(
icons.textEditor.resetFontScale),
)
: IconButton(
key: UniqueKey(),
color: Colors.transparent,
onPressed: null,
icon: Icon(
icons.textEditor.resetFontScale),
),
),
),
const SizedBox(width: 2),
],
),
],
);
}),
),
),
);
},
);
}