Skip to content

Commit

Permalink
Fix selection alpha and add pen options
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 15, 2024
1 parent 4ed9201 commit 591f55d
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 31 deletions.
19 changes: 9 additions & 10 deletions app/lib/selections/elements/pen.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
part of '../selection.dart';

class PenElementSelection extends ElementSelection<PenElement> {
final _propertySelection = PenPropertySelection();

PenElementSelection(super.selected);

@override
List<Widget> buildProperties(BuildContext context) {
final element = selected.first.element;
void updateProperty(PenProperty property) => updateElements(
context, elements.map((e) => e.copyWith(property: property)).toList());
return [
...super.buildProperties(context),
ColorField(
title: Text(AppLocalizations.of(context).color),
value: Color(element.property.color),
onChanged: (color) => updateElements(
context,
elements
.map((e) => e.copyWith(
// ignore: deprecated_member_use
property: e.property.copyWith(color: color.value)))
.toList()),
SizedBox(height: 16),
..._propertySelection.build(
context,
element.property,
updateProperty,
),
];
}
Expand Down
9 changes: 6 additions & 3 deletions app/lib/selections/elements/shape.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ class ShapeElementSelection extends ElementSelection<ShapeElement> {
...super.buildProperties(context),
ColorField(
title: Text(AppLocalizations.of(context).color),
value: Color(element.property.color),
value: Color(element.property.color).withAlpha(255),
onChanged: (color) => updateElements(
context,
elements
.map((e) => e.copyWith(
// ignore: deprecated_member_use
property: e.property.copyWith(color: color.value)))
property: e.property.copyWith(
color: convertOldColor(
// ignore: deprecated_member_use
color.value,
element.property.color))))
.toList()),
),
ExactSlider(
Expand Down
6 changes: 3 additions & 3 deletions app/lib/selections/properties/pen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class PenPropertySelection extends PropertySelection<PenProperty>
...super.build(context, property, onChanged),
const SizedBox(height: 4),
ColorField(
value: Color(property.color),
onChanged: (value) =>
value: Color(property.color).withAlpha(255),
onChanged: (value) => onChanged(property.copyWith(
// ignore: deprecated_member_use
onChanged(property.copyWith(color: value.value)),
color: convertOldColor(value.value, property.color))),
title: Text(AppLocalizations.of(context).color),
),
ExactSlider(
Expand Down
9 changes: 7 additions & 2 deletions app/lib/selections/tools/label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ class LabelToolSelection extends ToolSelection<LabelTool> {
value: Color(selected.first.foreground),
onChanged: (value) => update(
context,
// ignore: deprecated_member_use
selected.map((e) => e.copyWith(foreground: value.value)).toList()),
selected
.map((e) => e.copyWith(
foreground: convertOldColor(
// ignore: deprecated_member_use
value.value,
selected.first.foreground)))
.toList()),
title: Text(AppLocalizations.of(context).foreground),
),
ExactSlider(
Expand Down
26 changes: 15 additions & 11 deletions app/lib/selections/tools/shape.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ShapeToolSelection extends ToolSelection<ShapeTool> {
.toList())),
ExactSlider(
header: Text(AppLocalizations.of(context).strokeWidth),
value: tool.property.strokeWidth,
value: property.strokeWidth,
min: 0,
max: 70,
defaultValue: 5,
Expand All @@ -83,13 +83,14 @@ class ShapeToolSelection extends ToolSelection<ShapeTool> {
.toList())),
const SizedBox(height: 50),
ColorField(
value: Color(tool.property.color),
value: Color(property.color),
onChanged: (color) => update(
context,
selected
.map((e) => e.copyWith(
// ignore: deprecated_member_use
property: e.property.copyWith(color: color.value)))
property: e.property.copyWith(
// ignore: deprecated_member_use
color: convertOldColor(color.value, property.color))))
.toList()),
title: Text(AppLocalizations.of(context).color),
),
Expand Down Expand Up @@ -240,8 +241,9 @@ class _CircleShapeView extends StatelessWidget {
title: Text(AppLocalizations.of(context).fill),
leading: const PhosphorIcon(PhosphorIconsLight.paintBucket),
defaultColor: Colors.transparent,
// ignore: deprecated_member_use
onChanged: (color) => onChanged(shape.copyWith(fillColor: color.value)),
onChanged: (color) => onChanged(shape.copyWith(
// ignore: deprecated_member_use
fillColor: convertOldColor(color.value, shape.fillColor))),
),
ExactSlider(
// ignore: deprecated_member_use
Expand Down Expand Up @@ -271,8 +273,9 @@ class _TriangleShapeView extends StatelessWidget {
title: Text(AppLocalizations.of(context).fill),
leading: const PhosphorIcon(PhosphorIconsLight.paintBucket),
defaultColor: Colors.transparent,
// ignore: deprecated_member_use
onChanged: (color) => onChanged(shape.copyWith(fillColor: color.value)),
onChanged: (color) => onChanged(shape.copyWith(
// ignore: deprecated_member_use
fillColor: convertOldColor(color.value, shape.fillColor))),
),
ExactSlider(
// ignore: deprecated_member_use
Expand Down Expand Up @@ -309,9 +312,10 @@ class _RectangleShapeViewState extends State<_RectangleShapeView> {
leading: const PhosphorIcon(PhosphorIconsLight.paintBucket),
value: Color(widget.shape.fillColor),
defaultColor: Colors.transparent,
onChanged: (color) =>
// ignore: deprecated_member_use
widget.onChanged(widget.shape.copyWith(fillColor: color.value)),
onChanged: (color) => widget.onChanged(widget.shape.copyWith(
fillColor:
// ignore: deprecated_member_use
convertOldColor(color.value, widget.shape.fillColor))),
),
ExactSlider(
// ignore: deprecated_member_use
Expand Down
7 changes: 5 additions & 2 deletions app/lib/selections/utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,11 @@ class _UtilitiesViewState extends State<_UtilitiesView>
title: Text(AppLocalizations.of(context).color),
value: Color(widget.option.gridColor),
onChanged: (value) => widget.onToolChanged(
// ignore: deprecated_member_use
widget.option.copyWith(gridColor: value.value),
widget.option.copyWith(
gridColor: convertOldColor(
// ignore: deprecated_member_use
value.value,
widget.option.gridColor)),
),
),
const SizedBox(height: 8),
Expand Down
2 changes: 2 additions & 0 deletions metadata/en-US/changelogs/124.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Change zoom dependent to false by default
* Use material blue and red as default colors
* Improve sliders for background dialog
* Add additional selection ui options to the pen element
* Fix export on web
* Fix shape detection always enabled in pen tool
* Fix ruler not working correctly in pen tool
Expand All @@ -23,6 +24,7 @@
* Fix document isn't saved when clicking home
* Fix stamp don't use unique element ids
* Fix render order when creating multiple elements when baking
* Fix some color fields don't keep alpha value
* Show git hash instead of version in web version
* Upgrade to flutter 3.27

Expand Down

0 comments on commit 591f55d

Please sign in to comment.