From e29477e2377ce0f570f39b17cf0f1f783296b672 Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Tue, 22 Feb 2022 14:51:29 +0100 Subject: [PATCH] add exact slider to label, remove unused controllers --- app/lib/dialogs/color_pick.dart | 13 ---- app/lib/dialogs/elements/image.dart | 3 - app/lib/dialogs/image_export.dart | 6 -- app/lib/dialogs/painters/eraser.dart | 13 ---- app/lib/dialogs/painters/label.dart | 94 +++++++---------------- app/lib/dialogs/painters/path_eraser.dart | 6 -- app/lib/dialogs/painters/pen.dart | 13 ---- app/linux/flutter/generated_plugins.cmake | 8 -- 8 files changed, 26 insertions(+), 130 deletions(-) diff --git a/app/lib/dialogs/color_pick.dart b/app/lib/dialogs/color_pick.dart index 4156dff8edc8..f0c800f9884f 100644 --- a/app/lib/dialogs/color_pick.dart +++ b/app/lib/dialogs/color_pick.dart @@ -520,15 +520,10 @@ class CustomColorPicker extends StatefulWidget { class _CustomColorPickerState extends State { late Color color; - final TextEditingController _redController = TextEditingController(); - final TextEditingController _greenController = TextEditingController(); - final TextEditingController _blueController = TextEditingController(); - final TextEditingController _alphaController = TextEditingController(); @override void initState() { color = widget.defaultColor; - _updateController(); super.initState(); } @@ -536,16 +531,8 @@ class _CustomColorPickerState extends State { setState(() { color = Color.fromARGB(alpha ?? color.alpha, red ?? color.red, green ?? color.green, blue ?? color.blue); - _updateController(); }); - void _updateController() { - _redController.text = color.red.toString(); - _greenController.text = color.green.toString(); - _blueController.text = color.blue.toString(); - _alphaController.text = color.alpha.toString(); - } - @override Widget build(BuildContext context) { return Dialog( diff --git a/app/lib/dialogs/elements/image.dart b/app/lib/dialogs/elements/image.dart index b76f1e6b83d8..098b70425b97 100644 --- a/app/lib/dialogs/elements/image.dart +++ b/app/lib/dialogs/elements/image.dart @@ -27,7 +27,6 @@ class ImageElementDialog extends StatefulWidget { } class _ImageElementDialogState extends State { - final TextEditingController _scaleController = TextEditingController(); late ImageElement element; @override @@ -36,7 +35,6 @@ class _ImageElementDialogState extends State { var bloc = context.read(); element = (bloc.state as DocumentLoadSuccess).document.content[widget.index] as ImageElement; - _scaleController.text = (element.scale * 100).toStringAsFixed(2); } void _changeElement() { @@ -58,7 +56,6 @@ class _ImageElementDialogState extends State { max: 5, defaultValue: 1, onChanged: (value) { - _scaleController.text = (value * 100).toStringAsFixed(2); setState(() => element = element.copyWith(scale: value)); }, onChangeEnd: (value) => _changeElement(), diff --git a/app/lib/dialogs/image_export.dart b/app/lib/dialogs/image_export.dart index f0e11c7abf5c..2d5c18f61ae7 100644 --- a/app/lib/dialogs/image_export.dart +++ b/app/lib/dialogs/image_export.dart @@ -41,8 +41,6 @@ class _ImageExportDialogState extends State { final TextEditingController _xController = TextEditingController(text: '0'); final TextEditingController _yController = TextEditingController(text: '0'); - final TextEditingController _scaleController = - TextEditingController(text: '100'); final TextEditingController _widthController = TextEditingController(text: '1000'); @@ -70,7 +68,6 @@ class _ImageExportDialogState extends State { _yController.text = y.toString(); _widthController.text = width.toString(); _heightController.text = height.toString(); - _scaleController.text = scale.toStringAsFixed(2); super.initState(); } @@ -104,9 +101,6 @@ class _ImageExportDialogState extends State { @override Widget build(BuildContext context) { - if (scale.toStringAsFixed(2) != _scaleController.text) { - _scaleController.text = (scale * 100).toStringAsFixed(2); - } return BlocProvider.value( value: widget.bloc, child: Builder(builder: (context) { diff --git a/app/lib/dialogs/painters/eraser.dart b/app/lib/dialogs/painters/eraser.dart index 6389cd0e87e3..233fb50a1b2d 100644 --- a/app/lib/dialogs/painters/eraser.dart +++ b/app/lib/dialogs/painters/eraser.dart @@ -21,9 +21,6 @@ class EraserPainterDialog extends StatefulWidget { class _EraserPainterDialogState extends State { final TextEditingController _nameController = TextEditingController(); - final TextEditingController _strokeWidthController = TextEditingController(); - final TextEditingController _strokeMultiplierController = - TextEditingController(); @override Widget build(BuildContext context) { return BlocProvider.value( @@ -39,16 +36,6 @@ class _EraserPainterDialogState extends State { if (_nameController.text != painter.name) { _nameController.text = painter.name; } - if (double.tryParse(_strokeWidthController.text) != - painter.property.strokeWidth) { - _strokeWidthController.text = - painter.property.strokeWidth.toStringAsFixed(2); - } - if (double.tryParse(_strokeMultiplierController.text) != - painter.property.strokeMultiplier) { - _strokeMultiplierController.text = - painter.property.strokeMultiplier.toStringAsFixed(2); - } return Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( diff --git a/app/lib/dialogs/painters/label.dart b/app/lib/dialogs/painters/label.dart index 3c6f64421332..8b15fc1dde16 100644 --- a/app/lib/dialogs/painters/label.dart +++ b/app/lib/dialogs/painters/label.dart @@ -8,6 +8,8 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:phosphor_flutter/phosphor_flutter.dart'; +import '../../widgets/exact_slider.dart'; + class LabelPainterDialog extends StatefulWidget { final DocumentBloc bloc; final int painterIndex; @@ -156,9 +158,6 @@ class LabelPropertyView extends StatefulWidget { class _LabelPropertyViewState extends State { late LabelProperty _value; - final TextEditingController _sizeController = TextEditingController(); - final TextEditingController _thicknessController = TextEditingController(); - final TextEditingController _spacingController = TextEditingController(); bool _decorationExpanded = false; @override @@ -171,16 +170,6 @@ class _LabelPropertyViewState extends State { setState(() { _value = newValue; }); - if (double.tryParse(_sizeController.text) != _value.size) { - _sizeController.text = _value.size.toStringAsFixed(2); - } - if (double.tryParse(_spacingController.text) != _value.letterSpacing) { - _spacingController.text = _value.letterSpacing.toStringAsFixed(2); - } - if (double.tryParse(_thicknessController.text) != - _value.decorationThickness) { - _thicknessController.text = _value.decorationThickness.toStringAsFixed(2); - } if (notify) { widget.onChanged(newValue); } @@ -189,41 +178,22 @@ class _LabelPropertyViewState extends State { @override Widget build(BuildContext context) { return Column(children: [ - Row(children: [ - ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 100), - child: TextField( - decoration: InputDecoration( - labelText: AppLocalizations.of(context)!.size), - controller: _sizeController, - onChanged: (value) => - change(_value.copyWith(size: double.tryParse(value))), - )), - Expanded( - child: Slider( - value: _value.size.clamp(6, 512), - min: 6, - max: 512, - onChanged: (value) => change(_value.copyWith(size: value)))), - ]), - Row(children: [ - ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 100), - child: TextField( - decoration: InputDecoration( - labelText: AppLocalizations.of(context)!.spacing), - controller: _spacingController, - onChanged: (value) => change( - _value.copyWith(letterSpacing: double.tryParse(value)))), - ), - Expanded( - child: Slider( - value: _value.letterSpacing.clamp(0, 20), - min: 0, - max: 20, - onChanged: (value) => - change(_value.copyWith(letterSpacing: value)))), - ]), + ExactSlider( + label: AppLocalizations.of(context)!.size, + value: _value.size, + defaultValue: 12, + min: 6, + max: 512, + onChanged: (value) => + change(_value.copyWith(size: value), value != _value.size)), + ExactSlider( + label: AppLocalizations.of(context)!.spacing, + value: _value.letterSpacing, + defaultValue: 0, + min: 0, + max: 20, + onChanged: (value) => change(_value.copyWith(letterSpacing: value), + value != _value.letterSpacing)), ListTile( title: Text(AppLocalizations.of(context)!.fontWeight), trailing: DropdownButton( @@ -328,26 +298,14 @@ class _LabelPropertyViewState extends State { title: Text(AppLocalizations.of(context)!.color)), Padding( padding: const EdgeInsets.all(16.0), - child: Row(children: [ - ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 100), - child: TextField( - decoration: InputDecoration( - labelText: - AppLocalizations.of(context)!.thickness), - controller: _thicknessController, - onChanged: (value) => change(_value.copyWith( - decorationThickness: double.tryParse(value))), - )), - Expanded( - child: Slider( - value: _value.decorationThickness.clamp(0.1, 4), - min: 0.1, - max: 4, - onChanged: (value) => change( - _value.copyWith(decorationThickness: value))), - ) - ]), + child: ExactSlider( + header: Text(AppLocalizations.of(context)!.thickness), + defaultValue: 1, + value: _value.decorationThickness.clamp(0.1, 4), + min: 0.1, + max: 4, + onChanged: (value) => + change(_value.copyWith(decorationThickness: value))), ), ])) ], diff --git a/app/lib/dialogs/painters/path_eraser.dart b/app/lib/dialogs/painters/path_eraser.dart index 506533e579fb..bafeba504e10 100644 --- a/app/lib/dialogs/painters/path_eraser.dart +++ b/app/lib/dialogs/painters/path_eraser.dart @@ -22,7 +22,6 @@ class PathEraserPainterDialog extends StatefulWidget { class _PathEraserPainterDialogState extends State { final TextEditingController _nameController = TextEditingController(); - final TextEditingController _strokeWidthController = TextEditingController(); @override Widget build(BuildContext context) { return BlocProvider.value( @@ -38,11 +37,6 @@ class _PathEraserPainterDialogState extends State { if (_nameController.text != painter.name) { _nameController.text = painter.name; } - if (double.tryParse(_strokeWidthController.text) != - painter.strokeWidth) { - _strokeWidthController.text = - painter.strokeWidth.toStringAsFixed(2); - } return Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( diff --git a/app/lib/dialogs/painters/pen.dart b/app/lib/dialogs/painters/pen.dart index 1a0a3b1157e7..bc8c50195ed1 100644 --- a/app/lib/dialogs/painters/pen.dart +++ b/app/lib/dialogs/painters/pen.dart @@ -23,9 +23,6 @@ class PenPainterDialog extends StatefulWidget { class _PenPainterDialogState extends State { final TextEditingController _nameController = TextEditingController(); - final TextEditingController _strokeWidthController = TextEditingController(); - final TextEditingController _strokeMultiplierController = - TextEditingController(); @override Widget build(BuildContext context) { @@ -42,16 +39,6 @@ class _PenPainterDialogState extends State { if (_nameController.text != painter.name) { _nameController.text = painter.name; } - if (double.tryParse(_strokeWidthController.text) != - painter.property.strokeWidth) { - _strokeWidthController.text = - painter.property.strokeWidth.toStringAsFixed(2); - } - if (double.tryParse(_strokeMultiplierController.text) != - painter.property.strokeMultiplier) { - _strokeMultiplierController.text = - painter.property.strokeMultiplier.toStringAsFixed(2); - } return Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( diff --git a/app/linux/flutter/generated_plugins.cmake b/app/linux/flutter/generated_plugins.cmake index 9674f4f01a88..1d233e7384a2 100644 --- a/app/linux/flutter/generated_plugins.cmake +++ b/app/linux/flutter/generated_plugins.cmake @@ -7,9 +7,6 @@ list(APPEND FLUTTER_PLUGIN_LIST url_launcher_linux ) -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -18,8 +15,3 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin)