Skip to content

Commit

Permalink
add exact slider to label, remove unused controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Feb 22, 2022
1 parent 21c70f5 commit e29477e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 130 deletions.
13 changes: 0 additions & 13 deletions app/lib/dialogs/color_pick.dart
Original file line number Diff line number Diff line change
Expand Up @@ -520,32 +520,19 @@ class CustomColorPicker extends StatefulWidget {

class _CustomColorPickerState extends State<CustomColorPicker> {
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();
}

void _changeColor({int? red, int? green, int? blue, int? alpha}) =>
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(
Expand Down
3 changes: 0 additions & 3 deletions app/lib/dialogs/elements/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class ImageElementDialog extends StatefulWidget {
}

class _ImageElementDialogState extends State<ImageElementDialog> {
final TextEditingController _scaleController = TextEditingController();
late ImageElement element;

@override
Expand All @@ -36,7 +35,6 @@ class _ImageElementDialogState extends State<ImageElementDialog> {
var bloc = context.read<DocumentBloc>();
element = (bloc.state as DocumentLoadSuccess).document.content[widget.index]
as ImageElement;
_scaleController.text = (element.scale * 100).toStringAsFixed(2);
}

void _changeElement() {
Expand All @@ -58,7 +56,6 @@ class _ImageElementDialogState extends State<ImageElementDialog> {
max: 5,
defaultValue: 1,
onChanged: (value) {
_scaleController.text = (value * 100).toStringAsFixed(2);
setState(() => element = element.copyWith(scale: value));
},
onChangeEnd: (value) => _changeElement(),
Expand Down
6 changes: 0 additions & 6 deletions app/lib/dialogs/image_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class _ImageExportDialogState extends State<ImageExportDialog> {
final TextEditingController _xController = TextEditingController(text: '0');

final TextEditingController _yController = TextEditingController(text: '0');
final TextEditingController _scaleController =
TextEditingController(text: '100');

final TextEditingController _widthController =
TextEditingController(text: '1000');
Expand Down Expand Up @@ -70,7 +68,6 @@ class _ImageExportDialogState extends State<ImageExportDialog> {
_yController.text = y.toString();
_widthController.text = width.toString();
_heightController.text = height.toString();
_scaleController.text = scale.toStringAsFixed(2);

super.initState();
}
Expand Down Expand Up @@ -104,9 +101,6 @@ class _ImageExportDialogState extends State<ImageExportDialog> {

@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) {
Expand Down
13 changes: 0 additions & 13 deletions app/lib/dialogs/painters/eraser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ class EraserPainterDialog extends StatefulWidget {

class _EraserPainterDialogState extends State<EraserPainterDialog> {
final TextEditingController _nameController = TextEditingController();
final TextEditingController _strokeWidthController = TextEditingController();
final TextEditingController _strokeMultiplierController =
TextEditingController();
@override
Widget build(BuildContext context) {
return BlocProvider.value(
Expand All @@ -39,16 +36,6 @@ class _EraserPainterDialogState extends State<EraserPainterDialog> {
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(
Expand Down
94 changes: 26 additions & 68 deletions app/lib/dialogs/painters/label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -156,9 +158,6 @@ class LabelPropertyView extends StatefulWidget {

class _LabelPropertyViewState extends State<LabelPropertyView> {
late LabelProperty _value;
final TextEditingController _sizeController = TextEditingController();
final TextEditingController _thicknessController = TextEditingController();
final TextEditingController _spacingController = TextEditingController();
bool _decorationExpanded = false;

@override
Expand All @@ -171,16 +170,6 @@ class _LabelPropertyViewState extends State<LabelPropertyView> {
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);
}
Expand All @@ -189,41 +178,22 @@ class _LabelPropertyViewState extends State<LabelPropertyView> {
@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<FontWeight>(
Expand Down Expand Up @@ -328,26 +298,14 @@ class _LabelPropertyViewState extends State<LabelPropertyView> {
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))),
),
]))
],
Expand Down
6 changes: 0 additions & 6 deletions app/lib/dialogs/painters/path_eraser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class PathEraserPainterDialog extends StatefulWidget {

class _PathEraserPainterDialogState extends State<PathEraserPainterDialog> {
final TextEditingController _nameController = TextEditingController();
final TextEditingController _strokeWidthController = TextEditingController();
@override
Widget build(BuildContext context) {
return BlocProvider.value(
Expand All @@ -38,11 +37,6 @@ class _PathEraserPainterDialogState extends State<PathEraserPainterDialog> {
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(
Expand Down
13 changes: 0 additions & 13 deletions app/lib/dialogs/painters/pen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ class PenPainterDialog extends StatefulWidget {

class _PenPainterDialogState extends State<PenPainterDialog> {
final TextEditingController _nameController = TextEditingController();
final TextEditingController _strokeWidthController = TextEditingController();
final TextEditingController _strokeMultiplierController =
TextEditingController();

@override
Widget build(BuildContext context) {
Expand All @@ -42,16 +39,6 @@ class _PenPainterDialogState extends State<PenPainterDialog> {
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(
Expand Down
8 changes: 0 additions & 8 deletions app/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -18,8 +15,3 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
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)

1 comment on commit e29477e

@vercel
Copy link

@vercel vercel bot commented on e29477e Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.