Skip to content

Commit

Permalink
fix: fix restoring current pen to shape pen
Browse files Browse the repository at this point in the history
When the user restarts the app and their last used tool was the ShapePen, the last tool is successfully restored but `Pen.currentPen` isn't updated.
  • Loading branch information
adil192 committed Oct 22, 2023
1 parent 765ae43 commit 2bcdd98
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion lib/components/home/preview_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import 'package:saber/data/extensions/color_extensions.dart';
import 'package:saber/data/file_manager/file_manager.dart';
import 'package:saber/data/prefs.dart';
import 'package:saber/data/routes.dart';
import 'package:saber/i18n/strings.g.dart';
import 'package:saber/pages/editor/editor.dart';

class PreviewCard extends StatefulWidget {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/toolbar/pen_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class _PenModalState extends State<PenModal> {
),
IconButton(
onPressed: () => setState(() {
widget.setTool(ShapePen.currentShapePen);
widget.setTool(ShapePen());
}),
style: TextButton.styleFrom(
foregroundColor: Pen.currentPen.icon == ShapePen.shapePenIcon
Expand Down
2 changes: 0 additions & 2 deletions lib/data/tools/shape_pen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class ShapePen extends Pen {
strokeProperties = Prefs.lastShapePenProperties.value;
}

static Pen currentShapePen = ShapePen();

static final log = Logger('ShapePen');

static const IconData shapePenIcon = FontAwesomeIcons.shapes;
Expand Down
7 changes: 5 additions & 2 deletions lib/pages/editor/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,13 @@ class EditorState extends State<Editor> {
Pen.currentPen = Pen.ballpointPen();
}
return Pen.currentPen;
case ToolId.shapePen:
if (Pen.currentPen.toolId != Prefs.lastTool.value) {
Pen.currentPen = ShapePen();
}
return Pen.currentPen;
case ToolId.highlighter:
return Highlighter.currentHighlighter;
case ToolId.shapePen:
return ShapePen.currentShapePen;
case ToolId.eraser:
return Eraser();
case ToolId.select:
Expand Down

0 comments on commit 2bcdd98

Please sign in to comment.