From 3094da5c70ca6eb2fb6cd8c262b8601a7a183760 Mon Sep 17 00:00:00 2001 From: otsmr Date: Tue, 8 Apr 2025 13:04:59 +0200 Subject: [PATCH] fix #96 --- .../image_editor/layers/draw_layer.dart | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/lib/src/components/image_editor/layers/draw_layer.dart b/lib/src/components/image_editor/layers/draw_layer.dart index 2095c98..0409b70 100644 --- a/lib/src/components/image_editor/layers/draw_layer.dart +++ b/lib/src/components/image_editor/layers/draw_layer.dart @@ -20,12 +20,13 @@ class DrawLayer extends StatefulWidget { } class _DrawLayerState extends State { - Color pickerColor = Colors.white, currentColor = Colors.white; + Color currentColor = Colors.red; var screenshotController = ScreenshotController(); List undoList = []; bool skipNextEvent = false; + bool showMagnifyingGlass = false; @override void initState() { @@ -45,7 +46,7 @@ class _DrawLayerState extends State { super.initState(); } - double _sliderValue = 0.0; + double _sliderValue = 0.125; final colors = [ Colors.white, @@ -189,6 +190,16 @@ class _DrawLayerState extends State { activeColor: Colors.transparent, inactiveColor: Colors.transparent, onChanged: _onSliderChanged, + onChangeStart: (value) => { + setState(() { + showMagnifyingGlass = true; + }) + }, + onChangeEnd: (value) => { + setState(() { + showMagnifyingGlass = false; + }) + }, min: 0.0, max: 1.0, divisions: 100, @@ -198,6 +209,12 @@ class _DrawLayerState extends State { ], ), ), + if (showMagnifyingGlass) + Positioned( + right: 80, + top: 50 + (185 * _sliderValue), + child: MagnifyingGlass(color: currentColor), + ), if (!widget.layerData.isEditing) Positioned.fill( child: Container( @@ -207,3 +224,27 @@ class _DrawLayerState extends State { ); } } + +class MagnifyingGlass extends StatelessWidget { + final Color color; + + const MagnifyingGlass({super.key, required this.color}); + + @override + Widget build(BuildContext context) { + return SizedBox( + width: 50, + height: 50, + child: Container( + decoration: BoxDecoration( + color: color, + shape: BoxShape.circle, + border: Border.all( + color: Colors.white, + width: 2, + ), + ), + ), + ); + } +}