forked from Catrobat/Paintroid-Flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
26 changed files
with
895 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/command/lib/src/command_implementation/graphic/line_path_command.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'dart:ui'; | ||
|
||
import 'package:command/command.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:tools/tools.dart'; | ||
|
||
class LinePathCommand extends GraphicCommand { | ||
LinePathCommand(this.path, super.paint, this.startPoint, this.endPoint); | ||
|
||
PathWithActionHistory path; | ||
Offset startPoint; | ||
Offset endPoint; | ||
bool isSourcePath = false; | ||
|
||
@override | ||
void call(Canvas canvas) { | ||
canvas.drawPath(path, paint); | ||
} | ||
|
||
@override | ||
List<Object?> get props => [paint, path]; | ||
|
||
void drawVertices(Canvas canvas, VertexStack vertexStack) { | ||
for (var vertex in vertexStack) { | ||
canvas.drawCircle( | ||
vertex.vertexCenter, Vertex.VERTEX_RADIUS, Vertex.getVertexPaint()); | ||
} | ||
} | ||
|
||
void setAsSourcePath() { | ||
isSourcePath = true; | ||
} | ||
|
||
void updatePath(PathWithActionHistory newPath) { | ||
path = newPath; | ||
} | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
// TODO: implement toJson | ||
throw UnimplementedError(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 23 additions & 2 deletions
25
packages/features/workspace_screen/lib/src/components/command_painter.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 80 additions & 8 deletions
88
packages/features/workspace_screen/lib/src/components/top_app_bar.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,84 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:tools/tools.dart'; | ||
import 'package:workspace_screen/workspace_screen.dart'; | ||
|
||
class TopAppBar extends AppBar { | ||
TopAppBar({Key? key, required String title}) | ||
: super( | ||
key: key, | ||
title: Text(title), | ||
centerTitle: false, | ||
actions: [const OverflowMenu()], | ||
); | ||
class TopAppBar extends ConsumerWidget implements PreferredSizeWidget { | ||
final String title; | ||
|
||
const TopAppBar({Key? key, required this.title}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final currentTool = ref.watch(toolBoxStateProvider).currentTool; | ||
|
||
List<Widget> actions = [ | ||
if (currentTool.type == ToolType.LINE) ...[ | ||
PlusButton(onPressed: () { | ||
_onPlusPressed(currentTool); | ||
}), | ||
CheckMarkButton(onPressed: () { | ||
onCheckmarkPressed(currentTool); | ||
}), | ||
], | ||
const OverflowMenu(), | ||
]; | ||
|
||
return AppBar( | ||
title: Text(title), | ||
centerTitle: false, | ||
actions: actions, | ||
); | ||
} | ||
|
||
@override | ||
Size get preferredSize => const Size.fromHeight(kToolbarHeight); | ||
|
||
void _onPlusPressed(Tool currentTool) { | ||
switch (currentTool.type) { | ||
case ToolType.LINE: | ||
(currentTool as LineTool).onPlus(); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
void onCheckmarkPressed(Tool currentTool) { | ||
switch (currentTool.type) { | ||
case ToolType.LINE: | ||
(currentTool as LineTool).onCheckMark(); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
|
||
class PlusButton extends StatelessWidget { | ||
final VoidCallback onPressed; | ||
|
||
const PlusButton({Key? key, required this.onPressed}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return IconButton( | ||
icon: const Icon(Icons.add), | ||
onPressed: onPressed, | ||
); | ||
} | ||
} | ||
|
||
class CheckMarkButton extends StatelessWidget { | ||
final VoidCallback onPressed; | ||
|
||
const CheckMarkButton({Key? key, required this.onPressed}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return IconButton( | ||
icon: const Icon(Icons.check), | ||
onPressed: onPressed, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/features/workspace_screen/lib/src/states/canvas_state_provider.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.