-
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.
Merge pull request #5 from CopyPaste-Orbital2022/toolbar
added basic drawing features
- Loading branch information
Showing
13 changed files
with
94 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "plugins/scribble"] | ||
path = plugins/scribble | ||
url = https://github.com/CopyPaste-Orbital2022/scribble.git |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'package:injectable/injectable.dart'; | ||
import 'package:scribble/scribble.dart'; | ||
|
||
@module | ||
abstract class ScribbleInjectionModule { | ||
@lazySingleton | ||
ScribbleNotifier get notifier => ScribbleNotifier(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
import 'package:bloc/bloc.dart'; | ||
import 'package:copypaste/features/drawing/domain/entities/pen_state.dart'; | ||
import 'package:copypaste/features/drawing/domain/entities/selectable_tools.dart'; | ||
import 'package:copypaste/features/drawing/domain/repositories/i_drawing_toolbar_repository.dart'; | ||
import 'package:copypaste/features/drawing/presentation/bloc/index.dart'; | ||
import 'package:injectable/injectable.dart'; | ||
import 'package:scribble/scribble.dart'; | ||
|
||
@LazySingleton() | ||
class DrawingBloc extends Bloc<DrawingEvent, DrawingState> { | ||
final IDrawingToolBarRepository _repository; | ||
DrawingBloc(this._repository) : super(DrawingStateX.initialState()) { | ||
final ScribbleNotifier _notifier; | ||
DrawingBloc(this._repository, this._notifier) | ||
: super(DrawingStateX.initialState()) { | ||
on<ChangeSelectedDrawingButtonEvent>((event, emit) { | ||
_repository.saveCurrentTool(event.tool); | ||
emit( | ||
state.copyWith(currentTool: event.tool), | ||
); | ||
if (event.tool == DrawingTool.eraser) { | ||
_notifier.setEraser(); | ||
} else if (event.tool == DrawingTool.pen) { | ||
_notifier.setPen(); | ||
} else if (event.tool == DrawingTool.hand) {} | ||
}); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:copypaste/core/injections/injection.dart'; | ||
import 'package:copypaste/features/drawing/domain/entities/selectable_tools.dart'; | ||
import 'package:copypaste/features/drawing/presentation/bloc/index.dart'; | ||
import 'package:copypaste/features/drawing/presentation/widgets/drawing_button_menu.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:scribble/scribble.dart'; | ||
|
||
class DrawingPage extends StatelessWidget { | ||
const DrawingPage({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
actions: const [ | ||
DrawingButtonMenu(), | ||
], | ||
), | ||
body: BlocProvider( | ||
create: (context) => getIt<DrawingBloc>(), | ||
child: BlocConsumer<DrawingBloc, DrawingState>( | ||
builder: (context, state) { | ||
return Scribble( | ||
notifier: getIt<ScribbleNotifier>(), | ||
drawPen: state.currentTool == DrawingTool.pen, | ||
drawEraser: state.currentTool == DrawingTool.eraser, | ||
); | ||
}, | ||
listener: (context, state) {}, | ||
), | ||
), | ||
); | ||
} | ||
} |
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