Skip to content

Commit c1f78c6

Browse files
authored
Merge branch 'main' into side_nav
2 parents 536e842 + e4aa8fe commit c1f78c6

2 files changed

Lines changed: 59 additions & 5 deletions

File tree

lib/constants/string_constants.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class StringConstants {
22
static const String appName = 'Magic epaper';
3+
34
static const String aboutUsDescription =
45
'Magic ePaper is an app designed to control and update ePaper displays.'
56
'The goal is to provide tools for customizing and transferring images, text, and patterns to ePaper screens using NFC.'
@@ -21,4 +22,12 @@ class StringConstants {
2122
static const String buyBadge = 'Buy Badge';
2223
static const String feedbackBugReports = 'Feedback/Bug Reports';
2324
static const String continueButton = 'Continue';
25+
static const String noImageSelectedFeedback = 'Import an image first!';
26+
static const String adjustButtonLabel = 'Adjust';
27+
static const String importImageButtonLabel = 'Import New';
28+
static const String openEditor = 'Open Editor';
29+
static const String importStartingImageFeedback = "Import an image to begin";
30+
static const String transferButtonLabel = 'Transfer';
31+
static const String filterScreenTitle = 'Select a Filter';
32+
2433
}

lib/view/image_editor.dart

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import 'package:flutter/material.dart';
33
import 'package:magic_epaper_app/pro_image_editor/features/movable_background_image.dart';
44
import 'package:magic_epaper_app/util/image_editor_utils.dart';
55
import 'package:magic_epaper_app/view/widget/image_list.dart';
6+
import 'package:pro_image_editor/pro_image_editor.dart';
67
import 'package:provider/provider.dart';
78
import 'package:image/image.dart' as img;
89

910
import 'package:magic_epaper_app/provider/image_loader.dart';
1011
import 'package:magic_epaper_app/util/epd/epd.dart';
1112
import 'package:magic_epaper_app/constants/color_constants.dart';
13+
import 'package:magic_epaper_app/constants/string_constants.dart';
1214
import 'package:magic_epaper_app/util/protocol.dart';
1315

1416
class ImageEditor extends StatefulWidget {
@@ -109,7 +111,7 @@ class _ImageEditorState extends State<ImageEditor> {
109111
backgroundColor: colorAccent,
110112
elevation: 0,
111113
title: const Text(
112-
'Select a Filter',
114+
StringConstants.filterScreenTitle,
113115
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
114116
),
115117
actions: <Widget>[
@@ -136,7 +138,7 @@ class _ImageEditorState extends State<ImageEditor> {
136138
side: const BorderSide(color: Colors.white, width: 1),
137139
),
138140
),
139-
child: const Text('Transfer'),
141+
child: const Text(StringConstants.transferButtonLabel),
140142
),
141143
),
142144
],
@@ -197,7 +199,7 @@ class BottomActionMenu extends StatelessWidget {
197199
color: Colors.white,
198200
boxShadow: [
199201
BoxShadow(
200-
color: colorBlack.withOpacity(0.1),
202+
color: colorBlack.withValues(alpha: .1),
201203
spreadRadius: 0,
202204
blurRadius: 10,
203205
offset: const Offset(0, -5),
@@ -213,7 +215,7 @@ class BottomActionMenu extends StatelessWidget {
213215
_buildActionButton(
214216
context: context,
215217
icon: Icons.add_photo_alternate_outlined,
216-
label: 'Import New',
218+
label: StringConstants.importImageButtonLabel,
217219
onTap: () async {
218220
final success = await imgLoader.pickImage(
219221
width: epd.width, height: epd.height);
@@ -227,7 +229,7 @@ class BottomActionMenu extends StatelessWidget {
227229
_buildActionButton(
228230
context: context,
229231
icon: Icons.edit_outlined,
230-
label: 'Open Editor',
232+
label: StringConstants.openEditor,
231233
onTap: () async {
232234
final canvasBytes =
233235
await Navigator.of(context).push<Uint8List>(
@@ -246,6 +248,49 @@ class BottomActionMenu extends StatelessWidget {
246248
}
247249
},
248250
),
251+
_buildActionButton(
252+
context: context,
253+
icon: Icons.tune_rounded,
254+
label: StringConstants.adjustButtonLabel,
255+
onTap: () async {
256+
if (imgLoader.image != null) {
257+
final canvasBytes = await Navigator.of(context)
258+
.push<Uint8List>(MaterialPageRoute(
259+
builder: (context) => ProImageEditor.memory(
260+
img.encodeJpg(imgLoader.image!),
261+
callbacks: ProImageEditorCallbacks(
262+
onImageEditingComplete: (Uint8List bytes) async {
263+
Navigator.pop(context, bytes);
264+
},
265+
),
266+
configs: const ProImageEditorConfigs(
267+
paintEditor: PaintEditorConfigs(enabled: false),
268+
textEditor: TextEditorConfigs(enabled: false),
269+
cropRotateEditor: CropRotateEditorConfigs(
270+
enabled: false,
271+
),
272+
emojiEditor: EmojiEditorConfigs(enabled: false),
273+
),
274+
),
275+
));
276+
if (canvasBytes != null) {
277+
imgLoader.updateImage(
278+
bytes: canvasBytes,
279+
width: epd.width,
280+
height: epd.height,
281+
);
282+
}
283+
} else {
284+
ScaffoldMessenger.of(context).showSnackBar(
285+
const SnackBar(
286+
duration: Durations.medium4,
287+
content:
288+
Text(StringConstants.noImageSelectedFeedback),
289+
backgroundColor: colorPrimary),
290+
);
291+
}
292+
},
293+
),
249294
],
250295
),
251296
),

0 commit comments

Comments
 (0)