Skip to content

Commit

Permalink
rfac: full refactor; removed flutter hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
JideGuru committed Aug 15, 2024
1 parent 9763635 commit 4c40d93
Show file tree
Hide file tree
Showing 47 changed files with 2,494 additions and 1,342 deletions.
19 changes: 2 additions & 17 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_drawing_board/view/drawing_page.dart';
import 'package:flutter_drawing_board/src/src.dart';

void main() {
runApp(const MyApp());
runApp(const LetsDrawApp());
}

const Color kCanvasColor = Color(0xfff2f3f7);
const String kGithubRepo = 'https://github.com/JideGuru/flutter_drawing_board';

class MyApp extends StatelessWidget {
const MyApp({super.key});

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Let\'s Draw',
theme: ThemeData(primarySwatch: Colors.blue, useMaterial3: false),
debugShowCheckedModeBanner: false,
home: const DrawingPage(),
);
}
}
1 change: 1 addition & 0 deletions lib/src/constants/constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'values.dart';
2 changes: 2 additions & 0 deletions lib/src/constants/values.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
double markerDefaultOpacity = 0.7;
double markerDefaultSize = 25;
1 change: 1 addition & 0 deletions lib/src/domain/domain.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'models/models.dart';
46 changes: 46 additions & 0 deletions lib/src/domain/models/drawing_canvas_options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'package:flutter/material.dart';
import 'package:flutter_drawing_board/src/src.dart';

class DrawingCanvasOptions {
final Color strokeColor;
final double size;
final double opacity;
final DrawingTool currentTool;
final Color backgroundColor;
final bool showGrid;
final int polygonSides;
final bool fillShape;

const DrawingCanvasOptions({
this.strokeColor = blackAccent,
this.size = 10,
this.opacity = 1,
this.currentTool = DrawingTool.pencil,
this.backgroundColor = lightAccent,
this.showGrid = false,
this.polygonSides = 3,
this.fillShape = false,
});

DrawingCanvasOptions copyWith({
Color? strokeColor,
double? size,
double? opacity,
DrawingTool? currentTool,
Color? backgroundColor,
bool? showGrid,
int? polygonSides,
bool? fillShape,
}) {
return DrawingCanvasOptions(
strokeColor: strokeColor ?? this.strokeColor,
size: size ?? this.size,
opacity: opacity ?? this.opacity,
currentTool: currentTool ?? this.currentTool,
backgroundColor: backgroundColor ?? this.backgroundColor,
showGrid: showGrid ?? this.showGrid,
polygonSides: polygonSides ?? this.polygonSides,
fillShape: fillShape ?? this.fillShape,
);
}
}
19 changes: 19 additions & 0 deletions lib/src/domain/models/drawing_tool.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
enum DrawingTool {
pencil,
marker,
fill,
line,
eraser,
polygon,
square,
circle;

bool get isEraser => this == DrawingTool.eraser;
bool get isLine => this == DrawingTool.line;
bool get isFill => this == DrawingTool.fill;
bool get isMarker => this == DrawingTool.marker;
bool get isPencil => this == DrawingTool.pencil;
bool get isPolygon => this == DrawingTool.polygon;
bool get isSquare => this == DrawingTool.square;
bool get isCircle => this == DrawingTool.circle;
}
5 changes: 5 additions & 0 deletions lib/src/domain/models/models.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export 'drawing_canvas_options.dart';
export 'drawing_tool.dart';
export 'stroke.dart';
export 'tool_type.dart';
export 'undo_redo_stack.dart';
Loading

0 comments on commit 4c40d93

Please sign in to comment.