@@ -3,12 +3,14 @@ import 'package:flutter/material.dart';
33import 'package:magic_epaper_app/pro_image_editor/features/movable_background_image.dart' ;
44import 'package:magic_epaper_app/util/image_editor_utils.dart' ;
55import 'package:magic_epaper_app/view/widget/image_list.dart' ;
6+ import 'package:pro_image_editor/pro_image_editor.dart' ;
67import 'package:provider/provider.dart' ;
78import 'package:image/image.dart' as img;
89
910import 'package:magic_epaper_app/provider/image_loader.dart' ;
1011import 'package:magic_epaper_app/util/epd/epd.dart' ;
1112import 'package:magic_epaper_app/constants/color_constants.dart' ;
13+ import 'package:magic_epaper_app/constants/string_constants.dart' ;
1214import 'package:magic_epaper_app/util/protocol.dart' ;
1315
1416class 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