Skip to content

Commit 194805f

Browse files
committed
feat: draw-canvas-feature-to-display-on-badge.
1 parent 926d55b commit 194805f

22 files changed

Lines changed: 1032 additions & 0 deletions

assets/fonts/Lato-Regular.ttf

73.4 KB
Binary file not shown.
323 KB
Binary file not shown.

assets/fonts/OpenSans-Regular.ttf

128 KB
Binary file not shown.

assets/fonts/Oswald-Regular.ttf

85.2 KB
Binary file not shown.
142 KB
Binary file not shown.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:magic_epaper_app/draw_canvas/models/overlay_item.dart';
3+
4+
Widget buildTextOverlayDialog({
5+
required BuildContext context,
6+
required Color selectedColor,
7+
required void Function(OverlayItem) onItemCreated,
8+
}) {
9+
TextEditingController controller = TextEditingController();
10+
double selectedFontSize = 24;
11+
String selectedFont = 'Roboto';
12+
List<String> fontOptions = [
13+
'Roboto',
14+
'Open Sans',
15+
'Lato',
16+
'Montserrat',
17+
'Oswald'
18+
];
19+
20+
return StatefulBuilder(
21+
builder: (context, setDialogState) => AlertDialog(
22+
title: Text("Enter Text"),
23+
content: Column(
24+
mainAxisSize: MainAxisSize.min,
25+
children: [
26+
TextField(controller: controller),
27+
const SizedBox(height: 10),
28+
DropdownButton<String>(
29+
value: selectedFont,
30+
onChanged: (value) => setDialogState(() => selectedFont = value!),
31+
items: fontOptions.map((font) {
32+
return DropdownMenuItem(
33+
value: font,
34+
child: Text(font, style: TextStyle(fontFamily: font)),
35+
);
36+
}).toList(),
37+
),
38+
const SizedBox(height: 10),
39+
Row(
40+
children: [
41+
Text("Font size: ${selectedFontSize.toInt()}"),
42+
Expanded(
43+
child: Slider(
44+
value: selectedFontSize,
45+
min: 12,
46+
max: 48,
47+
divisions: 12,
48+
onChanged: (value) =>
49+
setDialogState(() => selectedFontSize = value),
50+
),
51+
),
52+
],
53+
),
54+
],
55+
),
56+
actions: [
57+
TextButton(
58+
onPressed: () {
59+
final text = controller.text;
60+
Navigator.pop(context);
61+
if (text.isNotEmpty) {
62+
onItemCreated(
63+
OverlayItem.text(
64+
text: text,
65+
color: selectedColor,
66+
font: selectedFont,
67+
fontSize: selectedFontSize,
68+
),
69+
);
70+
}
71+
},
72+
child: Text("Add"),
73+
),
74+
],
75+
),
76+
);
77+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'dart:typed_data';
2+
import 'package:flutter/material.dart';
3+
4+
Widget buildImagePreviewDialog({
5+
required BuildContext context,
6+
required Uint8List image,
7+
required VoidCallback onSubmit,
8+
}) {
9+
return AlertDialog(
10+
title: const Text("Preview Captured Image"),
11+
content: SingleChildScrollView(child: Image.memory(image)),
12+
actions: [
13+
TextButton(
14+
onPressed: () => Navigator.pop(context),
15+
child: const Text("Close"),
16+
),
17+
TextButton(
18+
onPressed: () {
19+
Navigator.pop(context);
20+
onSubmit();
21+
},
22+
child: const Text("Submit"),
23+
),
24+
],
25+
);
26+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
3+
4+
Widget buildColorPickerDialog(BuildContext context, Color selectedColor,
5+
ValueChanged<Color> onColorPicked) {
6+
return AlertDialog(
7+
title: const Text("Pick a color"),
8+
content: BlockPicker(
9+
availableColors: [Colors.black, Colors.white, Colors.red],
10+
pickerColor: selectedColor,
11+
onColorChanged: (color) {
12+
onColorPicked(color);
13+
Navigator.of(context).pop();
14+
},
15+
),
16+
);
17+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:magic_epaper_app/draw_canvas/models/overlay_item.dart';
3+
4+
Widget buildLayerManagerDialog({
5+
required List<OverlayItem> items,
6+
required void Function(int oldIndex, int newIndex) onReorder,
7+
required void Function(void Function()) setModalState,
8+
}) {
9+
return ReorderableListView(
10+
onReorder: (oldIndex, newIndex) {
11+
onReorder(oldIndex, newIndex);
12+
setModalState(() {});
13+
},
14+
children: [
15+
for (int i = 0; i < items.length; i++)
16+
ListTile(
17+
key: ValueKey(items[i].id),
18+
title: Text(
19+
items[i].type == 'text'
20+
? items[i].text ?? 'Text Layer'
21+
: items[i].label ?? 'Image Layer',
22+
),
23+
leading: Icon(
24+
items[i].type == 'text' ? Icons.text_fields : Icons.image,
25+
),
26+
trailing: const Icon(Icons.drag_handle),
27+
),
28+
],
29+
);
30+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import 'package:image/image.dart' as img;
2+
3+
class ImageAdjustParams {
4+
final img.Image image;
5+
final double brightness;
6+
final double contrast;
7+
8+
ImageAdjustParams(this.image, this.brightness, this.contrast);
9+
}

0 commit comments

Comments
 (0)