Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mobile][photos] Refine text editor interactions and layout

r4khul6443d2c9f4e2
diff --git a/mobile/apps/photos/changes/image-editor-text.md b/mobile/apps/photos/changes/image-editor-text.md
index 92e1981b5e..d96dd952b9 100644
--- a/mobile/apps/photos/changes/image-editor-text.md
+++ b/mobile/apps/photos/changes/image-editor-text.md
@@ -1 +1,3 @@
- Add text to photos with a choice of fonts, colors, backgrounds, and alignment.
+- Select text, stickers, and drawings to duplicate or delete them; edit text and drawings from the selection menu.
+- Remove drag-to-delete for stickers and drawings.
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart
index ed9bfe9bec..6fd0ce5db9 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart
@@ -11,7 +11,6 @@ class CircularIconButton extends StatelessWidget {
final IconData? icon;
final Widget? child;
final double size;
- final double width;
final bool isSelected;
const CircularIconButton({
@@ -23,7 +22,6 @@ class CircularIconButton extends StatelessWidget {
this.icon,
this.child,
this.size = 60,
- this.width = 90,
this.isSelected = false,
}) : assert(
hugeIcon != null || svgPath != null || icon != null || child != null,
@@ -64,7 +62,7 @@ class CircularIconButton extends StatelessWidget {
onTap: onTap,
behavior: HitTestBehavior.opaque,
child: SizedBox(
- width: width,
+ width: 90,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_color_picker.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_color_picker.dart
index 0b62ba14ce..64de987444 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_color_picker.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_color_picker.dart
@@ -6,6 +6,7 @@ class ImageEditorColorPicker extends StatefulWidget {
final ValueChanged<double> onChanged;
final ValueChanged<double>? onChangeStart;
final String? semanticLabel;
+ final EdgeInsetsGeometry padding;
const ImageEditorColorPicker({
super.key,
@@ -13,6 +14,7 @@ class ImageEditorColorPicker extends StatefulWidget {
required this.onChanged,
this.onChangeStart,
this.semanticLabel,
+ this.padding = const EdgeInsets.symmetric(horizontal: 20.0),
});
@override
@@ -29,7 +31,7 @@ class ColorSliderState extends State<ImageEditorColorPicker> {
Widget build(BuildContext context) {
final colors = context.componentColors;
return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 20.0),
+ padding: widget.padding,
child: SizedBox(
height: 40,
child: Stack(
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_layer_selection.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_layer_selection.dart
new file mode 100644
index 0000000000..43c3615054
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_layer_selection.dart
@@ -0,0 +1,478 @@
+import "dart:math";
+
+import "package:ente_components/ente_components.dart";
+import "package:ente_strings/ente_strings.dart";
+import "package:flutter/gestures.dart";
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/ui/tools/editor/image_editor/image_editor_constants.dart";
+import "package:pro_image_editor/features/main_editor/services/layer_copy_manager.dart";
+import "package:pro_image_editor/pro_image_editor.dart";
+
+const _layerPadding = 24.0;
+const _frameGap = 6.0;
+const _handleRadius = 5.0;
+const _handleTapSize = 32.0;
+const _actionSize = 44.0;
+
+LayerInteractionConfigs imageEditorLayerInteractionConfigs(
+ BuildContext context,
+ ValueGetter<ProImageEditorState?> editor,
+) {
+ final colors = context.componentColors;
+ final strings = context.strings;
+ return LayerInteractionConfigs(
+ selectable: LayerInteractionSelectable.enabled,
+ initialSelected: true,
+ hideToolbarOnInteraction: false,
+ enableKeyboardMultiSelection: false,
+ enableLongPressMultiSelection: false,
+ enableLayerDragSelection: false,
+ style: const LayerInteractionStyle(
+ overlayPadding: EdgeInsets.all(_layerPadding),
+ ),
+ widgets: LayerInteractionWidgets(
+ overlayChildBuilder: (rebuildStream, info, layer, interactions) =>
+ ReactiveWidget(
+ stream: rebuildStream,
+ builder: (_) => _LayerSelection(
+ info: info,
+ colors: colors,
+ onScaleRotateDown: interactions.scaleRotateDown,
+ onScaleRotateUp: interactions.scaleRotateUp,
+ actions: [
+ if (layer.isTextLayer ||
+ (layer is PaintLayer && !layer.item.isCensorArea))
+ _LayerAction(
+ label: strings.edit,
+ icon: HugeIcons.strokeRoundedPencilEdit02,
+ color: colors.iconColor,
+ onTap: () {
+ final state = editor();
+ if (state != null &&
+ !state.isSubEditorOpen &&
+ layer.isTextLayer) {
+ _editTextLayer(state, layer as TextLayer);
+ } else if (layer.isPaintLayer) {
+ interactions.edit();
+ }
+ },
+ ),
+ _LayerAction(
+ label: strings.imageEditorDuplicate,
+ icon: HugeIcons.strokeRoundedCopy01,
+ color: colors.iconColor,
+ onTap: interactions.duplicated,
+ ),
+ _LayerAction(
+ label: strings.delete,
+ icon: HugeIcons.strokeRoundedDelete02,
+ color: colors.warning,
+ onTap: () {
+ interactions.remove();
+ editor()?.layerInteractionManager.clearSelectedLayers();
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+}
+
+class ImageEditorLayerDoubleTap {
+ ImageEditorLayerDoubleTap(this.editor, {DateTime Function()? now})
+ : now = now ?? DateTime.now;
+
+ final ValueGetter<ProImageEditorState?> editor;
+ final DateTime Function() now;
+ final Map<int, Offset> _pointers = {};
+ String? _downLayerId;
+ Offset? _downOffset;
+ double? _downScale;
+ double? _downRotation;
+ String? _upLayerId;
+ bool _moved = false;
+ bool _multiTouch = false;
+ String? _lastLayerId;
+ DateTime? _lastTap;
+
+ void onLayerDown(Layer layer) {
+ _downLayerId = layer.id;
+ _downOffset = layer.offset;
+ _downScale = layer.scale;
+ _downRotation = layer.rotation;
+ _moved = false;
+ }
+
+ void onLayerUp(Layer layer) => _upLayerId = layer.id;
+
+ void onPointerDown(PointerDownEvent event) {
+ _pointers[event.pointer] = event.position;
+ if (_pointers.length > 1) {
+ _multiTouch = true;
+ _lastLayerId = null;
+ }
+ }
+
+ void onPointerMove(PointerMoveEvent event) {
+ final start = _pointers[event.pointer];
+ if (start != null && (event.position - start).distance > kTouchSlop) {
+ _moved = true;
+ _lastLayerId = null;
+ }
+ }
+
+ void onPointerUp(PointerUpEvent event) {
+ final layerId = _upLayerId;
+ final state = editor();
+ final layer = state?.activeLayers
+ .whereType<TextLayer>()
+ .where((layer) => layer.id == layerId)
+ .firstOrNull;
+ final start = _pointers.remove(event.pointer);
+ final isTap =
+ start != null &&
+ (event.position - start).distance <= kTouchSlop &&
+ !_moved &&
+ !_multiTouch &&
+ _pointers.isEmpty &&
+ layer != null &&
+ layer.id == _downLayerId &&
+ layer.offset == _downOffset &&
+ layer.scale == _downScale &&
+ layer.rotation == _downRotation &&
+ state != null &&
+ !state.isSubEditorOpen;
+ _upLayerId = null;
+ if (_pointers.isEmpty) {
+ _downLayerId = null;
+ _multiTouch = false;
+ _moved = false;
+ }
+ if (!isTap) {
+ _lastLayerId = null;
+ return;
+ }
+ final tapTime = now();
+ if (_lastLayerId == layerId &&
+ _lastTap != null &&
+ tapTime.difference(_lastTap!) < kDoubleTapTimeout) {
+ _lastLayerId = null;
+ _editTextLayer(state, layer);
+ } else {
+ _lastLayerId = layerId;
+ _lastTap = tapTime;
+ }
+ }
+
+ void onPointerCancel(PointerCancelEvent event) {
+ _pointers.remove(event.pointer);
+ _upLayerId = null;
+ _lastLayerId = null;
+ if (_pointers.isEmpty) _multiTouch = false;
+ }
+}
+
+Future<TextLayer?> imageEditorCreateTextLayer(
+ ValueGetter<ProImageEditorState?> editor,
+) async {
+ final state = editor();
+ if (state == null || state.isSubEditorOpen) return null;
+ final id = UniqueKey().toString();
+ final layer = await state.openPage<TextLayer>(
+ TextEditor(
+ key: state.textEditor,
+ heroTag: id,
+ configs: state.configs,
+ theme: state.configs.theme ?? Theme.of(state.context),
+ callbacks: state.callbacks,
+ imageSize: state.sizesManager.decodedImageSize,
+ ),
+ duration: const Duration(milliseconds: 150),
+ );
+ if (layer == null) return null;
+ layer.id = id;
+ _selectLayerAfterClose(state, id);
+ return layer;
+}
+
+void _selectLayerAfterClose(ProImageEditorState state, String id) {
+ void selectWhenReady(Duration _) {
+ if (!state.mounted) return;
+ if (state.isSubEditorOpen) {
+ WidgetsBinding.instance.addPostFrameCallback(selectWhenReady);
+ return;
+ }
+ if (!state.activeLayers.any((active) => active.id == id)) return;
+ state.unselectAllLayers();
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (!state.mounted) return;
+ state.selectLayerById(id);
+ });
+ }
+
+ WidgetsBinding.instance.addPostFrameCallback(selectWhenReady);
+}
+
+Future<void> _editTextLayer(ProImageEditorState editor, TextLayer layer) async {
+ if (editor.isSubEditorOpen) return;
+ final layerWidth = layer.keyInternalSize.currentContext?.size?.width;
+ final availableWidth = editor.sizesManager.bodySize.width - 34;
+ final displayScale = min(
+ layer.scale,
+ layerWidth == null || layerWidth <= 0
+ ? layer.scale
+ : layer.scale * availableWidth / layerWidth,
+ );
+ final updated = await editor.openPage<TextLayer>(
+ TextEditor(
+ key: editor.textEditor,
+ layer: (LayerCopyManager().copyLayer(layer) as TextLayer)
+ ..fontScale = layer.fontScale * displayScale,
+ heroTag: layer.rotation == 0 ? layer.id : null,
+ configs: editor.configs,
+ theme: editor.configs.theme ?? Theme.of(editor.context),
+ callbacks: editor.callbacks,
+ imageSize: editor.sizesManager.decodedImageSize,
+ ),
+ duration: const Duration(milliseconds: 250),
+ );
+ if (!editor.mounted || updated == null) return;
+ if (updated.text.isEmpty) {
+ editor.removeLayer(layer);
+ return;
+ }
+ final color = updated.color;
+ final background = updated.background;
+ // The text flies back to wherever this layer is laid out. A layer with a
+ // new key is measured at its new size, but it is also painted for one frame
+ // before the flight hides it, so it stays clear for that frame.
+ updated
+ ..id = layer.id
+ ..flipX = layer.flipX
+ ..flipY = layer.flipY
+ ..offset = layer.offset
+ ..scale = layer.scale
+ ..rotation = layer.rotation
+ ..boxConstraints = layer.boxConstraints
+ ..fontScale = updated.fontScale / displayScale
+ ..maxTextWidth = updated.maxTextWidth == null
+ ? null
+ : updated.maxTextWidth! / displayScale
+ ..groupId = layer.groupId
+ ..interaction = layer.interaction
+ ..meta = layer.meta
+ ..color = Colors.transparent
+ ..background = Colors.transparent;
+ editor.replaceLayer(
+ index: editor.activeLayers.indexWhere((other) => other.id == layer.id),
+ layer: updated,
+ );
+ _selectLayerAfterClose(editor, layer.id);
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ updated
+ ..color = color
+ ..background = background;
+ if (editor.mounted) editor.setState(() {});
+ });
+}
+
+class _LayerSelection extends StatelessWidget {
+ const _LayerSelection({
+ required this.info,
+ required this.colors,
+ required this.onScaleRotateDown,
+ required this.onScaleRotateUp,
+ required this.actions,
+ });
+
+ final OverlayChildLayoutInfo info;
+ final ColorTokens colors;
+ final ValueChanged<PointerDownEvent> onScaleRotateDown;
+ final ValueChanged<PointerUpEvent> onScaleRotateUp;
+ final List<Widget> actions;
+
+ @override
+ Widget build(BuildContext context) {
+ Offset point(double x, double y) =>
+ MatrixUtils.transformPoint(info.childPaintTransform, Offset(x, y));
+ final topLeft = point(_layerPadding, _layerPadding);
+ final topRight = point(info.childSize.width - _layerPadding, _layerPadding);
+ final bottomLeft = point(
+ _layerPadding,
+ info.childSize.height - _layerPadding,
+ );
+ final center = (topRight + bottomLeft) / 2;
+ final angle = (topRight - topLeft).direction;
+ final frame = Size(
+ (topRight - topLeft).distance + _frameGap * 2,
+ (bottomLeft - topLeft).distance + _frameGap * 2,
+ );
+ final corners = [
+ for (final (dx, dy) in const [(-1, -1), (1, -1), (-1, 1), (1, 1)])
+ center +
+ Offset.fromDirection(angle, dx * frame.width / 2) +
+ Offset.fromDirection(angle + pi / 2, dy * frame.height / 2),
+ ];
+ final top = corners.map((corner) => corner.dy).reduce(min);
+ final bottom = corners.map((corner) => corner.dy).reduce(max);
+ final actionsWidth = actions.length * _actionSize;
+ final visibleTop = MediaQuery.viewPaddingOf(context).top + kToolbarHeight;
+ final visibleBottom =
+ info.overlaySize.height -
+ editorBottomBarHeight -
+ MediaQuery.viewPaddingOf(context).bottom;
+ final belowFits = bottom + Spacing.md + _actionSize <= visibleBottom;
+ final actionTop =
+ (belowFits ? bottom + Spacing.md : top - Spacing.md - _actionSize)
+ .clamp(visibleTop, max(visibleTop, visibleBottom - _actionSize))
+ .toDouble();
+ return Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Positioned.fill(
+ child: IgnorePointer(
+ child: CustomPaint(
+ painter: _LayerFramePainter(
+ center: center,
+ angle: angle,
+ size: frame,
+ color: colors.specialWhite,
+ outline: colors.specialScrim,
+ ),
+ ),
+ ),
+ ),
+ for (final corner in corners)
+ Positioned(
+ left: corner.dx - _handleTapSize / 2,
+ top: corner.dy - _handleTapSize / 2,
+ width: _handleTapSize,
+ height: _handleTapSize,
+ child: Listener(
+ behavior: HitTestBehavior.translucent,
+ onPointerDown: onScaleRotateDown,
+ onPointerUp: onScaleRotateUp,
+ child: const IgnorePointer(child: SizedBox.expand()),
+ ),
+ ),
+ Positioned(
+ left: (center.dx - actionsWidth / 2).clamp(
+ Spacing.sm,
+ max(Spacing.sm, info.overlaySize.width - actionsWidth - Spacing.sm),
+ ),
+ top: actionTop,
+ child: Container(
+ height: _actionSize,
+ decoration: BoxDecoration(
+ color: colors.fillLight,
+ borderRadius: BorderRadius.circular(_actionSize / 2),
+ boxShadow: Shadows.soft,
+ ),
+ child: Row(mainAxisSize: MainAxisSize.min, children: actions),
+ ),
+ ),
+ ],
+ );
+ }
+}
+
+class _LayerFramePainter extends CustomPainter {
+ const _LayerFramePainter({
+ required this.center,
+ required this.angle,
+ required this.size,
+ required this.color,
+ required this.outline,
+ });
+
+ final Offset center;
+ final double angle;
+ final Size size;
+ final Color color;
+ final Color outline;
+
+ @override
+ void paint(Canvas canvas, Size canvasSize) {
+ final frame = RRect.fromRectAndRadius(
+ Rect.fromCenter(
+ center: Offset.zero,
+ width: size.width,
+ height: size.height,
+ ),
+ const Radius.circular(Radii.sm),
+ );
+ final outlinePaint = Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 3
+ ..color = outline;
+ final framePaint = Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 1.5
+ ..color = color;
+ canvas
+ ..save()
+ ..translate(center.dx, center.dy)
+ ..rotate(angle)
+ ..drawRRect(frame, outlinePaint)
+ ..drawRRect(frame, framePaint);
+ for (final corner in [
+ frame.outerRect.topLeft,
+ frame.outerRect.topRight,
+ frame.outerRect.bottomLeft,
+ frame.outerRect.bottomRight,
+ ]) {
+ canvas
+ ..drawCircle(corner, _handleRadius + 0.75, Paint()..color = outline)
+ ..drawCircle(corner, _handleRadius, Paint()..color = color);
+ }
+ canvas.restore();
+ }
+
+ @override
+ bool shouldRepaint(_LayerFramePainter oldDelegate) =>
+ center != oldDelegate.center ||
+ angle != oldDelegate.angle ||
+ size != oldDelegate.size ||
+ color != oldDelegate.color ||
+ outline != oldDelegate.outline;
+}
+
+class _LayerAction extends StatelessWidget {
+ const _LayerAction({
+ required this.label,
+ required this.icon,
+ required this.color,
+ required this.onTap,
+ });
+
+ final String label;
+ final List<List<dynamic>> icon;
+ final Color color;
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ return Semantics(
+ button: true,
+ label: label,
+ excludeSemantics: true,
+ onTap: onTap,
+ child: Tooltip(
+ message: label,
+ excludeFromSemantics: true,
+ child: GestureDetector(
+ onTap: onTap,
+ behavior: HitTestBehavior.opaque,
+ child: SizedBox.square(
+ dimension: _actionSize,
+ child: Center(
+ child: HugeIcon(icon: icon, size: IconSizes.medium, color: color),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
index 0220f5fa6d..4256ca9c7f 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
@@ -9,7 +9,6 @@ import "package:ente_strings/ente_strings.dart";
import 'package:flutter/material.dart';
import "package:flutter/services.dart";
import "package:flutter_image_compress/flutter_image_compress.dart";
-import "package:hugeicons/hugeicons.dart";
import 'package:image/image.dart' as img;
import "package:logging/logging.dart";
import 'package:path/path.dart' as path;
@@ -30,6 +29,7 @@ import "package:photos/ui/tools/editor/image_editor/image_editor_app_bar.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_constants.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_crop_rotate.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_filter_bar.dart";
+import "package:photos/ui/tools/editor/image_editor/image_editor_layer_selection.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_main_bottom_bar.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_paint_bar.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_text_bar.dart";
@@ -59,6 +59,9 @@ class ImageEditorPage extends StatefulWidget {
class _ImageEditorPageState extends State<ImageEditorPage> {
final _mainEditorBarKey = GlobalKey<ImageEditorMainBottomBarState>();
final editorKey = GlobalKey<ProImageEditorState>();
+ late final _layerDoubleTap = ImageEditorLayerDoubleTap(
+ () => editorKey.currentState,
+ );
SubEditor? _activeSubEditor;
final _logger = Logger("ImageEditor");
@@ -236,362 +239,333 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
extendBodyBehindAppBar: true,
resizeToAvoidBottomInset: false,
backgroundColor: colors.backgroundBase,
- body: ProImageEditor.file(
- key: editorKey,
- widget.file,
- callbacks: ProImageEditorCallbacks(
- onCloseEditor: (_) {
- editorKey.currentState?.isPopScopeDisabled = true;
- _showExitConfirmationDialog(context);
- },
- mainEditorCallbacks: MainEditorCallbacks(
- onOpenSubEditor: (editor) => _activeSubEditor = editor,
- onStartCloseSubEditor: (value) {
- _mainEditorBarKey.currentState?.setState(() {});
+ body: Listener(
+ onPointerDown: _layerDoubleTap.onPointerDown,
+ onPointerMove: _layerDoubleTap.onPointerMove,
+ onPointerUp: _layerDoubleTap.onPointerUp,
+ onPointerCancel: _layerDoubleTap.onPointerCancel,
+ child: ProImageEditor.file(
+ key: editorKey,
+ widget.file,
+ callbacks: ProImageEditorCallbacks(
+ onCloseEditor: (_) {
+ editorKey.currentState?.isPopScopeDisabled = true;
+ _showExitConfirmationDialog(context);
},
- onPopInvoked: (didPop, result) {
- editorKey.currentState?.isPopScopeDisabled = false;
- },
- ),
- ),
- configs: ProImageEditorConfigs(
- i18n: I18n(
- textEditor: I18nTextEditor(
- inputHintText: context.strings.imageEditorEnterText,
- bottomNavigationBarText: context.strings.imageEditorText,
- back: context.strings.cancel,
- done: context.strings.done,
- textAlign: context.strings.align,
- backgroundMode: context.strings.background,
- ),
- tuneEditor: I18nTuneEditor(
- brightness: context.strings.imageEditorBrightness,
- contrast: context.strings.imageEditorContrast,
- saturation: context.strings.imageEditorSaturation,
- exposure: context.strings.imageEditorExposure,
- hue: context.strings.imageEditorHue,
- temperature: context.strings.imageEditorTemperature,
- sharpness: context.strings.imageEditorSharpness,
- fade: context.strings.imageEditorFade,
- luminance: context.strings.imageEditorLuminance,
+ mainEditorCallbacks: MainEditorCallbacks(
+ onOpenSubEditor: (editor) => _activeSubEditor = editor,
+ onLayerTapDown: _layerDoubleTap.onLayerDown,
+ onLayerTapUp: _layerDoubleTap.onLayerUp,
+ onCreateTextLayer: () =>
+ imageEditorCreateTextLayer(() => editorKey.currentState),
+ onEndCloseSubEditor: (editor) {
+ if (editor == SubEditor.paint) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ editorKey.currentState?.unselectAllLayers();
+ });
+ }
+ },
+ onStartCloseSubEditor: (value) {
+ _mainEditorBarKey.currentState?.setState(() {});
+ },
+ onPopInvoked: (didPop, result) {
+ editorKey.currentState?.isPopScopeDisabled = false;
+ },
),
),
- imageGeneration: const ImageGenerationConfigs(
- jpegQuality: 100,
- enableIsolateGeneration: true,
- captureImageByteFormat: ui.ImageByteFormat.rawStraightRgba,
- outputFormat: OutputFormat.png,
- pngLevel: 0,
- ),
- layerInteraction: const LayerInteractionConfigs(
- hideToolbarOnInteraction: false,
- ),
- theme: ThemeData(
- scaffoldBackgroundColor: colors.backgroundBase,
- appBarTheme: AppBarTheme(
- titleTextStyle: actionTextStyle,
- backgroundColor: colors.backgroundBase,
+ configs: ProImageEditorConfigs(
+ i18n: I18n(
+ textEditor: I18nTextEditor(
+ inputHintText: context.strings.imageEditorEnterText,
+ bottomNavigationBarText: context.strings.imageEditorText,
+ back: context.strings.cancel,
+ done: context.strings.done,
+ textAlign: context.strings.align,
+ backgroundMode: context.strings.background,
+ ),
+ tuneEditor: I18nTuneEditor(
+ brightness: context.strings.imageEditorBrightness,
+ contrast: context.strings.imageEditorContrast,
+ saturation: context.strings.imageEditorSaturation,
+ exposure: context.strings.imageEditorExposure,
+ hue: context.strings.imageEditorHue,
+ temperature: context.strings.imageEditorTemperature,
+ sharpness: context.strings.imageEditorSharpness,
+ fade: context.strings.imageEditorFade,
+ luminance: context.strings.imageEditorLuminance,
+ ),
),
- bottomAppBarTheme: BottomAppBarThemeData(
- color: colors.backgroundBase,
+ imageGeneration: const ImageGenerationConfigs(
+ jpegQuality: 100,
+ enableIsolateGeneration: true,
+ captureImageByteFormat: ui.ImageByteFormat.rawStraightRgba,
+ outputFormat: OutputFormat.png,
+ pngLevel: 0,
),
- brightness: isLightMode ? Brightness.light : Brightness.dark,
- ),
- mainEditor: MainEditorConfigs(
- enableZoom: true,
- tools: const [
- SubEditorMode.cropRotate,
- SubEditorMode.filter,
- SubEditorMode.tune,
- SubEditorMode.paint,
- SubEditorMode.text,
- SubEditorMode.emoji,
- ],
- style: MainEditorStyle(
- subEditorPage: imageEditorSubEditorPageStyle(
- () => _activeSubEditor,
+ layerInteraction: imageEditorLayerInteractionConfigs(
+ context,
+ () => editorKey.currentState,
+ ),
+ theme: ThemeData(
+ scaffoldBackgroundColor: colors.backgroundBase,
+ appBarTheme: AppBarTheme(
+ titleTextStyle: actionTextStyle,
+ backgroundColor: colors.backgroundBase,
),
- uiOverlayStyle: SystemUiOverlayStyle(
- systemNavigationBarContrastEnforced: true,
- systemNavigationBarColor: Colors.transparent,
- statusBarBrightness: isLightMode
- ? Brightness.dark
- : Brightness.light,
- statusBarIconBrightness: isLightMode
- ? Brightness.dark
- : Brightness.light,
+ bottomAppBarTheme: BottomAppBarThemeData(
+ color: colors.backgroundBase,
),
- appBarBackground: colors.backgroundBase,
- background: colors.backgroundBase,
- bottomBarBackground: colors.backgroundBase,
+ brightness: isLightMode ? Brightness.light : Brightness.dark,
),
- widgets: MainEditorWidgets(
- removeLayerArea:
- (removeAreaKey, _, rebuildStream, isLayerBeingTransformed) {
- return Align(
- alignment: Alignment.bottomCenter,
- child: StreamBuilder(
- stream: rebuildStream,
- builder: (context, snapshot) {
- final isHovered = editorKey
- .currentState!
- .layerInteractionManager
- .hoverRemoveBtn;
-
- return AnimatedSwitcher(
- duration: const Duration(milliseconds: 150),
- child: isLayerBeingTransformed
- ? Container(
- key: removeAreaKey,
- height: 56,
- width: 56,
- margin: const EdgeInsets.only(bottom: 24),
- decoration: BoxDecoration(
- color: isHovered
- ? colors.warning.withValues(
- alpha: 0.8,
- )
- : Colors.white,
- shape: BoxShape.circle,
- ),
- padding: const EdgeInsets.all(12),
- child: Center(
- child: HugeIcon(
- icon: HugeIcons.strokeRoundedDelete02,
- color: isHovered
- ? Colors.white
- : colors.warning.withValues(
- alpha: 0.8,
- ),
- ),
- ),
- )
- : SizedBox.shrink(
- // When hidden, key still needed for hit
- // detection to work (returns empty bounds)
- key: removeAreaKey,
- ),
- );
+ mainEditor: MainEditorConfigs(
+ enableZoom: true,
+ tools: const [
+ SubEditorMode.cropRotate,
+ SubEditorMode.filter,
+ SubEditorMode.tune,
+ SubEditorMode.paint,
+ SubEditorMode.text,
+ SubEditorMode.emoji,
+ ],
+ style: MainEditorStyle(
+ subEditorPage: imageEditorSubEditorPageStyle(
+ () => _activeSubEditor,
+ ),
+ uiOverlayStyle: SystemUiOverlayStyle(
+ systemNavigationBarContrastEnforced: true,
+ systemNavigationBarColor: Colors.transparent,
+ statusBarBrightness: isLightMode
+ ? Brightness.dark
+ : Brightness.light,
+ statusBarIconBrightness: isLightMode
+ ? Brightness.dark
+ : Brightness.light,
+ ),
+ appBarBackground: colors.backgroundBase,
+ background: colors.backgroundBase,
+ bottomBarBackground: colors.backgroundBase,
+ ),
+ widgets: MainEditorWidgets(
+ removeLayerArea: (removeAreaKey, _, _, _) =>
+ SizedBox.shrink(key: removeAreaKey),
+ appBar: (editor, rebuildStream) {
+ return ReactiveAppbar(
+ builder: (context) {
+ return ImageEditorAppBar(
+ enableRedo: editor.canRedo,
+ enableUndo: editor.canUndo,
+ key: const Key('image_editor_app_bar'),
+ redo: () => editor.redoAction(),
+ undo: () => editor.undoAction(),
+ configs: editor.configs,
+ done: () async {
+ await saveImage(editorKey.currentState!);
},
- ),
- );
- },
- appBar: (editor, rebuildStream) {
- return ReactiveAppbar(
- builder: (context) {
- return ImageEditorAppBar(
- enableRedo: editor.canRedo,
- enableUndo: editor.canUndo,
- key: const Key('image_editor_app_bar'),
- redo: () => editor.redoAction(),
- undo: () => editor.undoAction(),
- configs: editor.configs,
- done: () async {
- await saveImage(editorKey.currentState!);
- },
- close: () {
- _showExitConfirmationDialog(context);
- },
- isMainEditor: true,
- );
- },
- stream: rebuildStream,
- );
- },
- bottomBar: (editor, rebuildStream, key) => ReactiveWidget(
- key: key,
- builder: (context) {
- return ImageEditorMainBottomBar(
- key: _mainEditorBarKey,
- editor: editor,
- configs: editor.configs,
- callbacks: editor.callbacks,
+ close: () {
+ _showExitConfirmationDialog(context);
+ },
+ isMainEditor: true,
+ );
+ },
+ stream: rebuildStream,
);
},
- stream: rebuildStream,
- ),
- ),
- ),
- paintEditor: PaintEditorConfigs(
- style: PaintEditorStyle(
- initialColor: const Color(0xFF00FFFF),
- background: colors.backgroundBase,
- ),
- widgets: PaintEditorWidgets(
- appBar: (editor, rebuildStream) {
- return ReactiveAppbar(
+ bottomBar: (editor, rebuildStream, key) => ReactiveWidget(
+ key: key,
builder: (context) {
- return ImageEditorAppBar(
- enableRedo: editor.canRedo,
- enableUndo: editor.canUndo,
- key: const Key('image_editor_app_bar'),
- redo: () => editor.redoAction(),
- undo: () => editor.undoAction(),
+ return ImageEditorMainBottomBar(
+ key: _mainEditorBarKey,
+ editor: editor,
configs: editor.configs,
- done: () => editor.done(),
- close: () => editor.close(),
+ callbacks: editor.callbacks,
);
},
stream: rebuildStream,
- );
- },
- colorPicker:
- (paintEditor, rebuildStream, currentColor, setColor) =>
- null,
- bottomBar: (editorState, rebuildStream) {
- return ReactiveWidget(
- builder: (context) {
- return ImageEditorPaintBar(
- configs: editorState.configs,
- callbacks: editorState.callbacks,
- editor: editorState,
- i18nColor: 'Color',
- );
- },
- stream: rebuildStream,
- );
- },
- ),
- ),
- textEditor: imageEditorTextConfigs(context),
- cropRotateEditor: CropRotateEditorConfigs(
- style: CropRotateEditorStyle(
- background: colors.backgroundBase,
- cropCornerColor: colors.primary,
- ),
- widgets: CropRotateEditorWidgets(
- appBar: (editor, rebuildStream) {
- return ReactiveAppbar(
- builder: (context) {
- return ImageEditorAppBar(
- key: const Key('image_editor_app_bar'),
- configs: editor.configs,
- done: () => editor.done(),
- close: () => editor.close(),
- enableRedo: editor.canRedo,
- enableUndo: editor.canUndo,
- redo: () => editor.redoAction(),
- undo: () => editor.undoAction(),
- );
- },
- stream: rebuildStream,
- );
- },
- bottomBar: (cropRotateEditor, rebuildStream) => ReactiveWidget(
- stream: rebuildStream,
- builder: (_) => ImageEditorCropRotateBar(
- configs: cropRotateEditor.configs,
- callbacks: cropRotateEditor.callbacks,
- editor: cropRotateEditor,
),
),
),
- ),
- filterEditor: FilterEditorConfigs(
- fadeInUpDuration: fadeInDuration,
- fadeInUpStaggerDelayDuration: fadeInDelay,
- filterList: filterList,
- style: FilterEditorStyle(background: colors.backgroundBase),
- widgets: FilterEditorWidgets(
- slider:
- (
- editorState,
- rebuildStream,
- value,
- onChanged,
- onChangeEnd,
- ) => ReactiveWidget(
+ paintEditor: PaintEditorConfigs(
+ style: PaintEditorStyle(
+ initialColor: const Color(0xFF00FFFF),
+ background: colors.backgroundBase,
+ ),
+ widgets: PaintEditorWidgets(
+ appBar: (editor, rebuildStream) {
+ return ReactiveAppbar(
+ builder: (context) {
+ return ImageEditorAppBar(
+ enableRedo: editor.canRedo,
+ enableUndo: editor.canUndo,
+ key: const Key('image_editor_app_bar'),
+ redo: () => editor.redoAction(),
+ undo: () => editor.undoAction(),
+ configs: editor.configs,
+ done: () => editor.done(),
+ close: () => editor.close(),
+ );
+ },
+ stream: rebuildStream,
+ );
+ },
+ colorPicker:
+ (paintEditor, rebuildStream, currentColor, setColor) =>
+ null,
+ bottomBar: (editorState, rebuildStream) {
+ return ReactiveWidget(
builder: (context) {
- return const SizedBox.shrink();
+ return ImageEditorPaintBar(
+ configs: editorState.configs,
+ callbacks: editorState.callbacks,
+ editor: editorState,
+ i18nColor: 'Color',
+ );
},
stream: rebuildStream,
- ),
- filterButton:
- (
- filter,
- isSelected,
- scaleFactor,
- onSelectFilter,
- editorImage,
- filterKey,
- ) {
- return ImageEditorFilterBar(
- filterModel: filter,
- isSelected: isSelected,
- onSelectFilter: () {
- onSelectFilter.call();
- editorKey.currentState?.setState(() {});
+ );
+ },
+ ),
+ ),
+ textEditor: imageEditorTextConfigs(context),
+ cropRotateEditor: CropRotateEditorConfigs(
+ style: CropRotateEditorStyle(
+ background: colors.backgroundBase,
+ cropCornerColor: colors.primary,
+ ),
+ widgets: CropRotateEditorWidgets(
+ appBar: (editor, rebuildStream) {
+ return ReactiveAppbar(
+ builder: (context) {
+ return ImageEditorAppBar(
+ key: const Key('image_editor_app_bar'),
+ configs: editor.configs,
+ done: () => editor.done(),
+ close: () => editor.close(),
+ enableRedo: editor.canRedo,
+ enableUndo: editor.canUndo,
+ redo: () => editor.redoAction(),
+ undo: () => editor.undoAction(),
+ );
+ },
+ stream: rebuildStream,
+ );
+ },
+ bottomBar: (cropRotateEditor, rebuildStream) =>
+ ReactiveWidget(
+ stream: rebuildStream,
+ builder: (_) => ImageEditorCropRotateBar(
+ configs: cropRotateEditor.configs,
+ callbacks: cropRotateEditor.callbacks,
+ editor: cropRotateEditor,
+ ),
+ ),
+ ),
+ ),
+ filterEditor: FilterEditorConfigs(
+ fadeInUpDuration: fadeInDuration,
+ fadeInUpStaggerDelayDuration: fadeInDelay,
+ filterList: filterList,
+ style: FilterEditorStyle(background: colors.backgroundBase),
+ widgets: FilterEditorWidgets(
+ slider:
+ (
+ editorState,
+ rebuildStream,
+ value,
+ onChanged,
+ onChangeEnd,
+ ) => ReactiveWidget(
+ builder: (context) {
+ return const SizedBox.shrink();
},
- editorImage: editorImage,
- filterKey: filterKey,
- );
- },
- appBar: (editor, rebuildStream) {
- return ReactiveAppbar(
- builder: (context) {
- return ImageEditorAppBar(
- key: const Key('image_editor_app_bar'),
- configs: editor.configs,
- done: () => editor.done(),
- close: () => editor.close(),
- );
- },
- stream: rebuildStream,
- );
- },
+ stream: rebuildStream,
+ ),
+ filterButton:
+ (
+ filter,
+ isSelected,
+ scaleFactor,
+ onSelectFilter,
+ editorImage,
+ filterKey,
+ ) {
+ return ImageEditorFilterBar(
+ filterModel: filter,
+ isSelected: isSelected,
+ onSelectFilter: () {
+ onSelectFilter.call();
+ editorKey.currentState?.setState(() {});
+ },
+ editorImage: editorImage,
+ filterKey: filterKey,
+ );
+ },
+ appBar: (editor, rebuildStream) {
+ return ReactiveAppbar(
+ builder: (context) {
+ return ImageEditorAppBar(
+ key: const Key('image_editor_app_bar'),
+ configs: editor.configs,
+ done: () => editor.done(),
+ close: () => editor.close(),
+ );
+ },
+ stream: rebuildStream,
+ );
+ },
+ ),
),
- ),
- tuneEditor: TuneEditorConfigs(
- style: TuneEditorStyle(background: colors.backgroundBase),
- widgets: TuneEditorWidgets(
- appBar: (editor, rebuildStream) {
- return ReactiveAppbar(
- builder: (context) {
- return ImageEditorAppBar(
- enableRedo: editor.canRedo,
- enableUndo: editor.canUndo,
- key: const Key('image_editor_app_bar'),
- redo: () => editor.redo(),
- undo: () => editor.undo(),
- configs: editor.configs,
- done: () => editor.done(),
- close: () => editor.close(),
- );
- },
- stream: rebuildStream,
- );
- },
- bottomBar: (editorState, rebuildStream) {
- return ReactiveWidget(
- builder: (context) {
- return ImageEditorTuneBar(
- configs: editorState.configs,
- callbacks: editorState.callbacks,
- editor: editorState,
- );
- },
- stream: rebuildStream,
- );
- },
+ tuneEditor: TuneEditorConfigs(
+ style: TuneEditorStyle(background: colors.backgroundBase),
+ widgets: TuneEditorWidgets(
+ appBar: (editor, rebuildStream) {
+ return ReactiveAppbar(
+ builder: (context) {
+ return ImageEditorAppBar(
+ enableRedo: editor.canRedo,
+ enableUndo: editor.canUndo,
+ key: const Key('image_editor_app_bar'),
+ redo: () => editor.redo(),
+ undo: () => editor.undo(),
+ configs: editor.configs,
+ done: () => editor.done(),
+ close: () => editor.close(),
+ );
+ },
+ stream: rebuildStream,
+ );
+ },
+ bottomBar: (editorState, rebuildStream) {
+ return ReactiveWidget(
+ builder: (context) {
+ return ImageEditorTuneBar(
+ configs: editorState.configs,
+ callbacks: editorState.callbacks,
+ editor: editorState,
+ );
+ },
+ stream: rebuildStream,
+ );
+ },
+ ),
),
- ),
- blurEditor: const BlurEditorConfigs(),
- emojiEditor: EmojiEditorConfigs(
- checkPlatformCompatibility: true,
- style: EmojiEditorStyle(
- bottomActionBarConfig: BottomActionBarConfig(
- showSearchViewButton: true,
- buttonColor: colors.backgroundBase,
- buttonIconColor: colors.iconColor,
+ blurEditor: const BlurEditorConfigs(),
+ emojiEditor: EmojiEditorConfigs(
+ checkPlatformCompatibility: true,
+ style: EmojiEditorStyle(
+ bottomActionBarConfig: BottomActionBarConfig(
+ showSearchViewButton: true,
+ buttonColor: colors.backgroundBase,
+ buttonIconColor: colors.iconColor,
+ backgroundColor: colors.backgroundBase,
+ ),
backgroundColor: colors.backgroundBase,
),
- backgroundColor: colors.backgroundBase,
),
- ),
- stickerEditor: StickerEditorConfigs(
- builder: (setLayer, scrollController) {
- return const SizedBox.shrink();
- },
+ stickerEditor: StickerEditorConfigs(
+ builder: (setLayer, scrollController) {
+ return const SizedBox.shrink();
+ },
+ ),
),
),
),
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart
index 30bcdf6ab2..6ec37d35b5 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart
@@ -1,13 +1,9 @@
-import "dart:math";
-
import "package:ente_components/ente_components.dart";
import "package:ente_strings/ente_strings.dart";
import "package:flutter/material.dart";
import "package:hugeicons/hugeicons.dart";
-import "package:photos/ui/tools/editor/image_editor/circular_icon_button.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_app_bar.dart";
import "package:photos/ui/tools/editor/image_editor/image_editor_color_picker.dart";
-import "package:photos/ui/tools/editor/image_editor/image_editor_constants.dart";
import "package:pro_image_editor/core/models/styles/sub_editor_page_style.dart";
import "package:pro_image_editor/pro_image_editor.dart";
@@ -29,7 +25,6 @@ TextEditorConfigs imageEditorTextConfigs(BuildContext context) {
final colors = context.componentColors;
final textScaler = MediaQuery.textScalerOf(context);
return TextEditorConfigs(
- enableTapOutsideToSave: false,
initialPrimaryColor: Colors.white,
initialSecondaryColor: Colors.black,
initialBackgroundColorMode: LayerBackgroundMode.backgroundAndColor,
@@ -41,15 +36,21 @@ TextEditorConfigs imageEditorTextConfigs(BuildContext context) {
TextStyle(
fontFamily:
"packages/${TextStyles.fontPackage}/${TextStyles.outfitFontFamily}",
- fontWeight: FontWeight.w600,
+ fontWeight: FontWeight.w500,
),
TextStyle(fontFamily: "packages/${TextStyles.fontPackage}/Gochi Hand"),
],
+ inputTextFieldAlign: Alignment.topCenter,
style: TextEditorStyle(
background: colors.specialScrim,
inputCursorColor: colors.primary,
inputHintColor: Colors.white70,
textFieldMargin: EdgeInsets.zero,
+ textFieldPadding: EdgeInsets.only(
+ top: MediaQuery.orientationOf(context) == Orientation.landscape
+ ? 0
+ : MediaQuery.sizeOf(context).height * _textFieldTopFraction,
+ ),
),
widgets: TextEditorWidgets(
appBar: (editor, rebuildStream) => ReactiveAppbar(
@@ -78,7 +79,23 @@ TextEditorConfigs imageEditorTextConfigs(BuildContext context) {
);
}
-enum _TextAction { color, font, background, align }
+const _textFieldTopFraction = 0.12;
+const _controlSize = 48.0;
+const _rowHeight = 48.0;
+const _pillRadius = 25.0;
+const _fontMenuWidth = 196.0;
+const _fontMenuItemHeight = 52.0;
+const _hueColors = [
+ Color(0xFFFF0000),
+ Color(0xFFFFFF00),
+ Color(0xFF00FF00),
+ Color(0xFF00FFFF),
+ Color(0xFF0000FF),
+ Color(0xFFFF00FF),
+ Color(0xFFFF0000),
+];
+
+enum _ColorTarget { text, background }
class ImageEditorTextBar extends StatefulWidget {
const ImageEditorTextBar({super.key, required this.editor});
@@ -90,107 +107,267 @@ class ImageEditorTextBar extends StatefulWidget {
}
class _ImageEditorTextBarState extends State<ImageEditorTextBar> {
- _TextAction? _selectedAction;
+ final _fontMenuLink = LayerLink();
+ final _fontMenu = OverlayPortalController();
+ var _colorTarget = _ColorTarget.text;
+ var _showHueSlider = false;
+ var _swatchesAtStart = true;
+ var _swatchesAtEnd = true;
late double _textColorHue = _initialHue(widget.editor.primaryColor);
late double _backgroundColorHue = _initialHue(widget.editor.secondaryColor);
+ TextEditorState get _editor => widget.editor;
+
+ List<TextStyle> get _fonts => _editor.textEditorConfigs.customTextStyles!;
+
+ TextStyle get _font => _fonts.firstWhere(
+ (font) => font.fontFamily == _editor.selectedTextStyle.fontFamily,
+ orElse: () => _fonts.first,
+ );
+
+ bool get _isBold => _editor.selectedTextStyle.fontWeight == FontWeight.w700;
+
+ bool get _isItalic => _editor.selectedTextStyle.fontStyle == FontStyle.italic;
+
+ bool get _forBackground => _colorTarget == _ColorTarget.background;
+
+ Color get _color =>
+ (_forBackground ? _editor.secondaryColor : _editor.primaryColor)
+ .withValues(alpha: 1);
+
double _initialHue(Color color) {
final hsv = HSVColor.fromColor(color);
return hsv.saturation == 0 ? 0.5 : hsv.hue / 360;
}
- void _selectAction(_TextAction action) {
- widget.editor.focusNode.unfocus();
+ String _fontName(TextStyle font) => font.fontFamily!.split('/').last;
+
+ void _setTextStyle({TextStyle? font, bool? bold, bool? italic}) {
+ _editor.setTextStyle(
+ (font ?? _font).copyWith(
+ fontWeight: (bold ?? _isBold) ? FontWeight.w700 : null,
+ fontStyle: (italic ?? _isItalic) ? FontStyle.italic : null,
+ ),
+ );
+ }
+
+ void _toggleFontMenu() => setState(_fontMenu.toggle);
+
+ void _selectColor(Color value) {
+ if (_forBackground) {
+ _editor.secondaryColor = value.withValues(
+ alpha: _editor.secondaryColor.a,
+ );
+ } else {
+ _editor.primaryColor = value;
+ }
+ }
+
+ void _selectHue(double value) {
setState(() {
- _selectedAction = _selectedAction == action ? null : action;
+ if (_forBackground) {
+ _backgroundColorHue = value;
+ } else {
+ _textColorHue = value;
+ }
});
+ _selectColor(HSVColor.fromAHSV(1, value * 360, 1, 1).toColor());
+ }
+
+ void _selectColorTarget(_ColorTarget target) {
+ if (target == _ColorTarget.background && _editor.secondaryColor.a == 0) {
+ _editor.secondaryColor = _editor.secondaryColor.withValues(alpha: 1);
+ }
+ setState(() => _colorTarget = target);
+ }
+
+ void _cycleBackground() {
+ final alpha = _editor.secondaryColor.a;
+ final next = alpha == 0
+ ? 1.0
+ : alpha == 1
+ ? 0.5
+ : 0.0;
+ _editor.secondaryColor = _editor.secondaryColor.withValues(alpha: next);
+ if (next == 0) setState(() => _colorTarget = _ColorTarget.text);
+ }
+
+ void _toggleHueSlider() {
+ setState(() {
+ _showHueSlider = !_showHueSlider;
+ _textColorHue = _initialHue(_editor.primaryColor);
+ _backgroundColorHue = _initialHue(_editor.secondaryColor);
+ });
+ }
+
+ bool _updateSwatchFades(ScrollMetrics metrics) {
+ final atStart = metrics.extentBefore <= 0;
+ final atEnd = metrics.extentAfter <= 0;
+ if (atStart != _swatchesAtStart || atEnd != _swatchesAtEnd) {
+ setState(() {
+ _swatchesAtStart = atStart;
+ _swatchesAtEnd = atEnd;
+ });
+ }
+ return false;
}
@override
Widget build(BuildContext context) {
- final strings = context.strings;
- final editor = widget.editor;
- final mediaQuery = MediaQuery.of(editor.context);
- final keyboardHeight = mediaQuery.viewInsets.bottom;
- final maxToolbarHeight = max(
- 0.0,
- mediaQuery.size.height -
- mediaQuery.viewPadding.vertical -
- keyboardHeight -
- kToolbarHeight -
- 64,
- );
+ final landscape =
+ MediaQuery.orientationOf(context) == Orientation.landscape;
return Padding(
- padding: EdgeInsets.only(bottom: keyboardHeight),
+ padding: EdgeInsets.only(
+ bottom: MediaQuery.of(_editor.context).viewInsets.bottom,
+ ),
child: Material(
color: context.componentColors.backgroundBase,
child: SafeArea(
top: false,
- child: ConstrainedBox(
- constraints: BoxConstraints(maxHeight: maxToolbarHeight),
- child: SingleChildScrollView(
- primary: false,
+ child: Padding(
+ padding: EdgeInsets.symmetric(
+ horizontal: Spacing.md,
+ vertical: landscape ? 0 : Spacing.sm,
+ ),
+ child: landscape
+ ? SizedBox(
+ height: _rowHeight,
+ child: ListView(
+ scrollDirection: Axis.horizontal,
+ children: [
+ SizedBox(width: 320, child: _buildStyleRow(context)),
+ const SizedBox(width: Spacing.md),
+ SizedBox(width: 320, child: _buildColorRow(context)),
+ ],
+ ),
+ )
+ : Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ SizedBox(
+ height: _rowHeight,
+ child: _buildStyleRow(context),
+ ),
+ const SizedBox(height: Spacing.lg),
+ SizedBox(
+ height: _rowHeight,
+ child: _buildColorRow(context),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildStyleRow(BuildContext context) {
+ final strings = context.strings;
+ final (alignLabel, alignIcon) = switch (_editor.align) {
+ TextAlign.left => (
+ strings.imageEditorAlignLeft,
+ HugeIcons.strokeRoundedTextAlignLeft,
+ ),
+ TextAlign.right => (
+ strings.imageEditorAlignRight,
+ HugeIcons.strokeRoundedTextAlignRight,
+ ),
+ _ => (
+ strings.imageEditorAlignCenter,
+ HugeIcons.strokeRoundedTextAlignCenter,
+ ),
+ };
+ return Row(
+ children: [
+ Expanded(
+ child: Align(
+ alignment: AlignmentDirectional.centerStart,
+ child: _buildFontButton(context),
+ ),
+ ),
+ const SizedBox(width: Spacing.sm),
+ _BarButton(
+ label: strings.imageEditorBold,
+ icon: HugeIcons.strokeRoundedTextBold,
+ isSelected: _isBold,
+ onTap: () => _setTextStyle(bold: !_isBold),
+ ),
+ const SizedBox(width: Spacing.sm),
+ _BarButton(
+ label: strings.imageEditorItalic,
+ icon: HugeIcons.strokeRoundedTextItalic,
+ isSelected: _isItalic,
+ onTap: () => _setTextStyle(italic: !_isItalic),
+ ),
+ const SizedBox(width: Spacing.sm),
+ _BarButton(
+ label: alignLabel,
+ icon: alignIcon,
+ onTap: _editor.toggleTextAlign,
+ ),
+ const SizedBox(width: Spacing.sm),
+ _buildBackgroundButton(context),
+ ],
+ );
+ }
+
+ Widget _buildFontButton(BuildContext context) {
+ final colors = context.componentColors;
+ final isOpen = _fontMenu.isShowing;
+ final name = _fontName(_font);
+ return Semantics(
+ button: true,
+ label: context.strings.font,
+ value: name,
+ excludeSemantics: true,
+ onTap: _toggleFontMenu,
+ child: GestureDetector(
+ onTap: _toggleFontMenu,
+ behavior: HitTestBehavior.opaque,
+ child: Center(
+ widthFactor: 1,
+ child: CompositedTransformTarget(
+ link: _fontMenuLink,
+ child: OverlayPortal(
+ controller: _fontMenu,
+ overlayChildBuilder: _buildFontMenu,
child: Container(
- constraints: BoxConstraints(
- minHeight: keyboardHeight > 0
- ? 0
- : min(editorBottomBarHeight, maxToolbarHeight),
+ height: _controlSize,
+ padding: const EdgeInsetsDirectional.only(
+ start: Spacing.lg,
+ end: Spacing.md,
+ ),
+ decoration: BoxDecoration(
+ color: isOpen
+ ? colors.fillBase.withValues(alpha: 0.9)
+ : colors.fillLight,
+ borderRadius: BorderRadius.circular(_pillRadius),
),
- padding: const EdgeInsets.symmetric(vertical: 12),
- child: Column(
+ child: Row(
mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
children: [
- LayoutBuilder(
- builder: (context, constraints) => SingleChildScrollView(
- scrollDirection: Axis.horizontal,
- child: ConstrainedBox(
- constraints: BoxConstraints(
- minWidth: constraints.maxWidth,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: [
- _action(
- _TextAction.color,
- strings.color,
- HugeIcons.strokeRoundedTextColor,
- ),
- _action(
- _TextAction.font,
- strings.font,
- HugeIcons.strokeRoundedTextFont,
- ),
- _action(
- _TextAction.background,
- strings.background,
- HugeIcons.strokeRoundedTextSquare,
- ),
- _action(
- _TextAction.align,
- strings.align,
- switch (editor.align) {
- TextAlign.left =>
- HugeIcons.strokeRoundedTextAlignLeft,
- TextAlign.right =>
- HugeIcons.strokeRoundedTextAlignRight,
- _ => HugeIcons.strokeRoundedTextAlignCenter,
- },
- ),
- ],
- ),
+ Flexible(
+ child: Text(
+ name,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: _font.copyWith(
+ inherit: false,
+ fontSize: TextStyles.body.fontSize,
+ height: TextStyles.body.height,
+ color: isOpen ? colors.textReverse : colors.iconColor,
),
),
),
- if (_selectedAction != null && keyboardHeight == 0) ...[
- const SizedBox(height: 12),
- switch (_selectedAction!) {
- _TextAction.color => _buildColorPicker(),
- _TextAction.font => _buildFontPicker(),
- _TextAction.background => _buildBackgroundPicker(),
- _TextAction.align => _buildAlignPicker(),
- },
- ],
+ const SizedBox(width: 6),
+ HugeIcon(
+ icon: isOpen
+ ? HugeIcons.strokeRoundedArrowDown01
+ : HugeIcons.strokeRoundedArrowUp01,
+ size: IconSizes.tiny,
+ color: isOpen ? colors.textReverse : colors.textLight,
+ ),
],
),
),
@@ -201,244 +378,406 @@ class _ImageEditorTextBarState extends State<ImageEditorTextBar> {
);
}
- Widget _action(_TextAction action, String label, List<List<dynamic>> icon) {
- return CircularIconButton(
- label: label,
- hugeIcon: icon,
- size: 40,
- width: 90 * max(1, MediaQuery.textScalerOf(context).scale(14) / 14),
- isSelected: _selectedAction == action,
- onTap: () => _selectAction(action),
- );
- }
-
- Widget _buildColorPicker({bool forBackground = false}) {
- final editor = widget.editor;
- final color = (forBackground ? editor.secondaryColor : editor.primaryColor)
- .withValues(alpha: 1);
- final label = forBackground
- ? context.strings.imageEditorBackgroundColor
- : context.strings.imageEditorTextColor;
-
- void selectColor(Color value) {
- if (forBackground) {
- editor.secondaryColor = value.withValues(
- alpha: editor.secondaryColor.a,
- );
- } else {
- editor.primaryColor = value;
- }
- }
-
- void selectHue(double value) {
- setState(() {
- if (forBackground) {
- _backgroundColorHue = value;
- } else {
- _textColorHue = value;
- }
- });
- selectColor(HSVColor.fromAHSV(1, value * 360, 1, 1).toColor());
- }
-
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
+ Widget _buildFontMenu(BuildContext context) {
+ final colors = context.componentColors;
+ final borderSide = BorderSide(color: colors.strokeFaint);
+ return Stack(
children: [
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 20),
- child: Text(
- label,
- style: TextStyles.mini.copyWith(
- color: context.componentColors.textLight,
+ Positioned.fill(
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: _toggleFontMenu,
+ ),
+ ),
+ Positioned(
+ left: 0,
+ top: 0,
+ child: CompositedTransformFollower(
+ link: _fontMenuLink,
+ showWhenUnlinked: false,
+ targetAnchor: Alignment.topLeft,
+ followerAnchor: Alignment.bottomLeft,
+ offset: const Offset(0, -Spacing.sm),
+ child: Material(
+ color: colors.fillLight,
+ clipBehavior: Clip.antiAlias,
+ shape: RoundedRectangleBorder(
+ side: borderSide,
+ borderRadius: BorderRadius.circular(Radii.button),
+ ),
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(
+ maxHeight: _fontMenuItemHeight * 4.5,
+ ),
+ child: SizedBox(
+ width: _fontMenuWidth,
+ child: ListView(
+ shrinkWrap: true,
+ padding: EdgeInsets.zero,
+ children: [
+ for (final font in _fonts)
+ _buildFontOption(context, font, borderSide),
+ ],
+ ),
+ ),
+ ),
),
),
),
- const SizedBox(height: 8),
- Row(
- children: [
- const SizedBox(width: 12),
- for (final (swatch, swatchLabel) in [
- (Colors.white, context.strings.imageEditorWhite),
- (Colors.black, context.strings.black),
- ])
- _option(
- label: swatchLabel,
- isSelected: color == swatch,
- onTap: () => selectColor(swatch),
- child: Container(
- width: 24,
- height: 24,
- decoration: BoxDecoration(
- color: swatch,
- shape: BoxShape.circle,
- border: Border.all(
- color: context.componentColors.strokeFaint,
+ ],
+ );
+ }
+
+ Widget _buildFontOption(
+ BuildContext context,
+ TextStyle font,
+ BorderSide borderSide,
+ ) {
+ final colors = context.componentColors;
+ final isSelected = font == _font;
+ return Semantics(
+ button: true,
+ selected: isSelected,
+ child: InkWell(
+ onTap: () {
+ _setTextStyle(font: font);
+ _toggleFontMenu();
+ },
+ child: Container(
+ height: _fontMenuItemHeight,
+ padding: const EdgeInsets.symmetric(horizontal: Spacing.lg),
+ decoration: BoxDecoration(
+ border: font == _fonts.last ? null : Border(bottom: borderSide),
+ ),
+ child: Row(
+ children: [
+ SizedBox(
+ width: 24,
+ child: ExcludeSemantics(
+ child: Text(
+ 'Aa',
+ textAlign: TextAlign.center,
+ maxLines: 1,
+ softWrap: false,
+ overflow: TextOverflow.visible,
+ style: font.copyWith(
+ inherit: false,
+ fontSize: TextStyles.body.fontSize,
+ height: TextStyles.body.height,
+ color: colors.textBase,
),
),
),
),
- Expanded(
- child: ImageEditorColorPicker(
- value: forBackground ? _backgroundColorHue : _textColorHue,
- semanticLabel: label,
- onChangeStart: selectHue,
- onChanged: selectHue,
+ const SizedBox(width: 6),
+ Expanded(
+ child: Text(
+ _fontName(font),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyles.mini.copyWith(color: colors.textBase),
+ ),
),
- ),
- ],
+ if (isSelected)
+ HugeIcon(
+ icon: HugeIcons.strokeRoundedTick02,
+ size: IconSizes.small,
+ color: colors.iconColor,
+ ),
+ ],
+ ),
),
- ],
+ ),
);
}
- Widget _buildFontPicker() {
- final editor = widget.editor;
- return _optionsRow([
- for (final style in editor.textEditorConfigs.customTextStyles!)
- _option(
- label: style.fontFamily!.split('/').last,
- isSelected: editor.selectedTextStyle == style,
- onTap: () => editor.setTextStyle(style),
- child: Text(
- style.fontFamily!.split('/').last,
- style: style.copyWith(
- fontSize: 16,
- color: context.componentColors.textBase,
- ),
+ Widget _buildBackgroundButton(BuildContext context) {
+ final strings = context.strings;
+ final colors = context.componentColors;
+ final background = _editor.secondaryColor;
+ final label = background.a == 0
+ ? strings.imageEditorNoBackground
+ : background.a == 1
+ ? strings.imageEditorSolidBackground
+ : strings.imageEditorTranslucentBackground;
+ final isDark =
+ ThemeData.estimateBrightnessForColor(background.withValues(alpha: 1)) ==
+ Brightness.dark;
+ return _BarButton(
+ label: label,
+ onTap: _cycleBackground,
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: Spacing.xs),
+ decoration: BoxDecoration(
+ color: background,
+ borderRadius: BorderRadius.circular(Radii.xs),
+ ),
+ child: Text(
+ 'Aa',
+ maxLines: 1,
+ softWrap: false,
+ style: TextStyles.bodyBold.copyWith(
+ color: background.a == 0
+ ? colors.iconColor
+ : isDark
+ ? Colors.white
+ : Colors.black,
),
),
- ]);
+ ),
+ );
}
- Widget _buildBackgroundPicker() {
+ Widget _buildColorRow(BuildContext context) {
final strings = context.strings;
- final editor = widget.editor;
final colors = context.componentColors;
- final alpha = editor.secondaryColor.a;
- final selectedOpacity = alpha == 0 || alpha == 1 ? alpha : 0.5;
- return Column(
- mainAxisSize: MainAxisSize.min,
+ final label = _forBackground
+ ? strings.imageEditorBackgroundColor
+ : strings.imageEditorTextColor;
+ return Row(
children: [
- _optionsRow([
- for (final (opacity, label) in [
- (0.0, strings.imageEditorNoBackground),
- (1.0, strings.imageEditorSolidBackground),
- (0.5, strings.imageEditorTranslucentBackground),
- ])
- _option(
- label: label,
- isSelected: selectedOpacity == opacity,
- onTap: () => editor.secondaryColor = editor.secondaryColor
- .withValues(alpha: opacity),
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 4),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(4),
- color: colors.textBase.withValues(alpha: opacity),
+ Container(
+ height: _controlSize,
+ padding: EdgeInsets.zero,
+ decoration: BoxDecoration(
+ color: colors.fillLight,
+ borderRadius: BorderRadius.circular(_pillRadius),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ for (final (target, targetLabel, icon) in [
+ (
+ _ColorTarget.text,
+ strings.imageEditorTextColor,
+ HugeIcons.strokeRoundedTextColor,
),
- child: Text(
- 'Aa',
- style: TextStyles.large.copyWith(
- color: opacity == 0 ? colors.textBase : colors.textReverse,
- ),
+ (
+ _ColorTarget.background,
+ strings.imageEditorBackgroundColor,
+ HugeIcons.strokeRoundedTextSquare,
),
- ),
- ),
- ]),
- if (alpha > 0) ...[
- const SizedBox(height: 12),
- _buildColorPicker(forBackground: true),
- ],
+ ])
+ _BarButton(
+ label: targetLabel,
+ icon: icon,
+ isSelected: _colorTarget == target,
+ size: const Size.square(_controlSize),
+ restingColor: Colors.transparent,
+ onTap: () => _selectColorTarget(target),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(width: Spacing.sm),
+ Expanded(
+ child: _showHueSlider
+ ? ImageEditorColorPicker(
+ value: _forBackground ? _backgroundColorHue : _textColorHue,
+ semanticLabel: label,
+ onChangeStart: _selectHue,
+ onChanged: _selectHue,
+ padding: EdgeInsets.zero,
+ )
+ : _buildSwatches(context),
+ ),
+ const SizedBox(width: Spacing.sm),
+ _buildHueSliderButton(context),
],
);
}
- Widget _buildAlignPicker() {
+ List<(Color, String)> _swatches(BuildContext context) {
final strings = context.strings;
- final editor = widget.editor;
- return _optionsRow([
- for (final (alignment, icon, label) in [
- (
- TextAlign.left,
- HugeIcons.strokeRoundedTextAlignLeft,
- strings.imageEditorAlignLeft,
- ),
- (
- TextAlign.center,
- HugeIcons.strokeRoundedTextAlignCenter,
- strings.imageEditorAlignCenter,
- ),
- (
- TextAlign.right,
- HugeIcons.strokeRoundedTextAlignRight,
- strings.imageEditorAlignRight,
- ),
- ])
- _option(
- label: label,
- isSelected: editor.align == alignment,
- onTap: () => editor.setState(() => editor.align = alignment),
- child: HugeIcon(
- icon: icon,
- size: 22,
- color: context.componentColors.iconColor,
+ final colors = context.componentColors;
+ return [
+ (Colors.black, strings.black),
+ (Colors.white, strings.imageEditorWhite),
+ (colors.blue, strings.imageEditorBlue),
+ (colors.warning, strings.imageEditorRed),
+ (colors.green, strings.imageEditorGreen),
+ (colors.caution, strings.imageEditorOrange),
+ (colors.accentPink, strings.imageEditorPink),
+ (colors.accentTeal, strings.imageEditorTeal),
+ (colors.purple, strings.imageEditorPurple),
+ ];
+ }
+
+ Widget _buildSwatches(BuildContext context) {
+ final colors = context.componentColors;
+ return Container(
+ height: _controlSize,
+ clipBehavior: Clip.antiAlias,
+ decoration: BoxDecoration(
+ color: colors.fillLight,
+ borderRadius: BorderRadius.circular(_pillRadius),
+ ),
+ child: NotificationListener<ScrollMetricsNotification>(
+ onNotification: (notification) =>
+ _updateSwatchFades(notification.metrics),
+ child: NotificationListener<ScrollUpdateNotification>(
+ onNotification: (notification) =>
+ _updateSwatchFades(notification.metrics),
+ child: ShaderMask(
+ blendMode: BlendMode.dstIn,
+ shaderCallback: (rect) => LinearGradient(
+ begin: AlignmentDirectional.centerStart,
+ end: AlignmentDirectional.centerEnd,
+ colors: [
+ _swatchesAtStart ? Colors.white : Colors.transparent,
+ Colors.white,
+ Colors.white,
+ _swatchesAtEnd ? Colors.white : Colors.transparent,
+ ],
+ stops: const [0, 0.1, 0.9, 1],
+ ).createShader(rect, textDirection: Directionality.of(context)),
+ child: ListView(
+ scrollDirection: Axis.horizontal,
+ padding: const EdgeInsets.symmetric(horizontal: Spacing.xs),
+ children: [
+ for (final (swatch, name) in _swatches(context))
+ _Swatch(
+ color: swatch,
+ label: name,
+ isSelected: _color == swatch,
+ onTap: () => _selectColor(swatch),
+ ),
+ ],
+ ),
),
),
- ]);
+ ),
+ );
}
- Widget _optionsRow(List<Widget> children) {
- return LayoutBuilder(
- builder: (context, constraints) => SingleChildScrollView(
- scrollDirection: Axis.horizontal,
- padding: const EdgeInsets.symmetric(horizontal: 12),
- child: ConstrainedBox(
- constraints: BoxConstraints(
- minWidth: max(0, constraints.maxWidth - 24),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: children,
+ Widget _buildHueSliderButton(BuildContext context) {
+ final strings = context.strings;
+ if (_showHueSlider) {
+ return _BarButton(
+ label: strings.close,
+ icon: HugeIcons.strokeRoundedCancel01,
+ onTap: _toggleHueSlider,
+ );
+ }
+ return _BarButton(
+ label: strings.imageEditorCustomColor,
+ onTap: _toggleHueSlider,
+ child: _SwatchRing(
+ isSelected: !_swatches(context).any((swatch) => swatch.$1 == _color),
+ child: const DecoratedBox(
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ gradient: SweepGradient(colors: _hueColors),
),
),
),
);
}
+}
+
+class _BarButton extends StatelessWidget {
+ const _BarButton({
+ required this.label,
+ required this.onTap,
+ this.icon,
+ this.child,
+ this.isSelected,
+ this.size = const Size.square(_controlSize),
+ this.restingColor,
+ });
+
+ final String label;
+ final VoidCallback onTap;
+ final List<List<dynamic>>? icon;
+ final Widget? child;
+ final bool? isSelected;
+ final Size size;
+ final Color? restingColor;
- Widget _option({
- required String label,
- required bool isSelected,
- required VoidCallback onTap,
- required Widget child,
- }) {
+ @override
+ Widget build(BuildContext context) {
final colors = context.componentColors;
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 4),
- child: Semantics(
- button: true,
- selected: isSelected,
- label: label,
- child: Tooltip(
- message: label,
- excludeFromSemantics: true,
- child: InkWell(
- onTap: onTap,
- borderRadius: BorderRadius.circular(24),
+ final isSelected = this.isSelected ?? false;
+ return Semantics(
+ button: true,
+ selected: this.isSelected,
+ label: label,
+ excludeSemantics: true,
+ onTap: onTap,
+ child: Tooltip(
+ message: label,
+ excludeFromSemantics: true,
+ child: GestureDetector(
+ onTap: onTap,
+ behavior: HitTestBehavior.opaque,
+ child: Center(
+ widthFactor: 1,
child: Container(
- constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
- padding: const EdgeInsets.symmetric(horizontal: 12),
+ width: size.width,
+ height: size.height,
+ alignment: Alignment.center,
decoration: BoxDecoration(
color: isSelected
- ? colors.primary.withValues(alpha: 0.24)
- : colors.fillLight,
- borderRadius: BorderRadius.circular(24),
- border: Border.all(
- color: isSelected ? colors.primary : colors.fillLight,
- width: 2,
+ ? colors.fillBase.withValues(alpha: 0.9)
+ : restingColor ?? colors.fillLight,
+ borderRadius: BorderRadius.circular(_pillRadius),
+ ),
+ child:
+ child ??
+ HugeIcon(
+ icon: icon!,
+ size: IconSizes.small,
+ color: isSelected ? colors.textReverse : colors.iconColor,
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class _Swatch extends StatelessWidget {
+ const _Swatch({
+ required this.color,
+ required this.label,
+ required this.isSelected,
+ required this.onTap,
+ });
+
+ final Color color;
+ final String label;
+ final bool isSelected;
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ return Semantics(
+ button: true,
+ selected: isSelected,
+ label: label,
+ onTap: onTap,
+ child: Tooltip(
+ message: label,
+ excludeFromSemantics: true,
+ child: GestureDetector(
+ onTap: onTap,
+ behavior: HitTestBehavior.opaque,
+ child: SizedBox(
+ width: _controlSize,
+ child: Center(
+ child: _SwatchRing(
+ isSelected: isSelected,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ color: color,
+ shape: BoxShape.circle,
+ border: Border.all(
+ color: context.componentColors.strokeFaint,
+ ),
+ ),
),
),
- alignment: Alignment.center,
- child: ExcludeSemantics(child: child),
),
),
),
@@ -446,3 +785,29 @@ class _ImageEditorTextBarState extends State<ImageEditorTextBar> {
);
}
}
+
+class _SwatchRing extends StatelessWidget {
+ const _SwatchRing({required this.isSelected, required this.child});
+
+ final bool isSelected;
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) {
+ return Container(
+ width: 32,
+ height: 32,
+ padding: const EdgeInsets.all(3),
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ border: Border.all(
+ color: isSelected
+ ? context.componentColors.fillBase
+ : Colors.transparent,
+ width: 2,
+ ),
+ ),
+ child: child,
+ );
+ }
+}
diff --git a/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart b/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart
index 9bffc1cf92..ed6a36590d 100644
--- a/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart
+++ b/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart
@@ -1,11 +1,16 @@
+import 'dart:math' as math;
+
import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:image/image.dart' as img;
import 'package:photos/ente_theme_data.dart';
+import 'package:photos/ui/tools/editor/image_editor/image_editor_layer_selection.dart';
import 'package:photos/ui/tools/editor/image_editor/image_editor_main_bottom_bar.dart';
import 'package:photos/ui/tools/editor/image_editor/image_editor_text_bar.dart';
+import 'package:pro_image_editor/features/paint_editor/widgets/paint_editor_layer_editor.dart';
import 'package:pro_image_editor/features/text_editor/widgets/rounded_background_text/rounded_background_text.dart';
import 'package:pro_image_editor/pro_image_editor.dart';
@@ -17,31 +22,34 @@ void main() {
.load();
});
- testWidgets('hue selection is explicit and colors stay independent', (
+ testWidgets('swatches and hue selection keep colors independent', (
tester,
) async {
final editor = await _openEditor(tester);
final text = tester.state<TextEditorState>(find.byType(TextEditor));
const cyan = Color(0xFF00FFFF);
- await _tap(tester, find.text('Color'));
+ expect(find.byType(Slider), findsNothing);
+ await _tap(tester, find.byTooltip('Custom color'));
expect(tester.widget<Slider>(find.byType(Slider)).value, 0.5);
expect(text.primaryColor, Colors.white);
- expect(find.byType(Slider), paints..circle(color: cyan));
await _tap(tester, find.byType(Slider));
expect(text.primaryColor, cyan);
expect(text.secondaryColor, Colors.black);
- await _tap(tester, find.text('Background'));
+ await _tap(tester, find.byTooltip('Background color'));
expect(tester.widget<Slider>(find.byType(Slider)).value, 0.5);
expect(text.secondaryColor, Colors.black);
await _tap(tester, find.byType(Slider));
expect(text.secondaryColor, cyan);
+ await _tap(tester, find.byTooltip('Close'));
+ expect(find.byType(Slider), findsNothing);
await _tap(tester, find.byTooltip('White'));
expect(text.primaryColor, cyan);
expect(text.secondaryColor, Colors.white);
- expect(find.byType(Slider), paints..circle(color: cyan));
- await _tap(tester, find.text('Color'));
+
+ await _tap(tester, find.byTooltip('Text color'));
+ await _tap(tester, find.byTooltip('Custom color'));
await tester.drag(find.byType(Slider), const Offset(60, 0));
await tester.pumpAndSettle();
final chosenColor = text.primaryColor;
@@ -54,43 +62,72 @@ void main() {
final reopened = tester.state<TextEditorState>(find.byType(TextEditor));
expect(reopened.primaryColor, chosenColor);
expect(reopened.secondaryColor, Colors.white);
- await _tap(tester, find.text('Color'));
+ await _tap(tester, find.byTooltip('Custom color'));
expect(
tester.widget<Slider>(find.byType(Slider)).value,
closeTo(HSVColor.fromColor(chosenColor).hue / 360, 0.001),
);
});
- testWidgets('applied text renders each selected font', (tester) async {
+ testWidgets('applied text renders the selected font and style', (
+ tester,
+ ) async {
final editor = await _openEditor(tester);
- for (final font in ['Inter', 'Outfit', 'Gochi Hand']) {
- await _tap(tester, find.text('Font'));
- await _tap(tester, find.text(font));
+ RoundedBackgroundText rendered() => tester.widget<RoundedBackgroundText>(
+ find.byType(RoundedBackgroundText),
+ );
+ Future<void> reopen() =>
+ _tap(tester, find.byKey(editor.activeLayers.single.keyInternalSize));
+
+ var current = 'Inter';
+ for (final font in ['Outfit', 'Gochi Hand', 'Inter']) {
+ await _tap(tester, find.text(current));
+ await _tap(tester, find.text(font).last);
await _tap(tester, find.text('Done'));
- final rendered = tester.widget<RoundedBackgroundText>(
- find.byType(RoundedBackgroundText),
+ expect(
+ rendered().text.style!.fontFamily,
+ 'packages/ente_components/$font',
);
- expect(rendered.text.style!.fontFamily, 'packages/ente_components/$font');
- if (font != 'Gochi Hand') {
- await _tap(
- tester,
- find.byKey(editor.activeLayers.single.keyInternalSize),
- );
- }
+ await reopen();
+ current = font;
}
+
+ await _tap(tester, find.byTooltip('Bold'));
+ await _tap(tester, find.byTooltip('Italic'));
+ await _tap(tester, find.text('Inter'));
+ await _tap(tester, find.text('Outfit'));
+ await _tap(tester, find.text('Done'));
+ expect(
+ rendered().text.style!.fontFamily,
+ 'packages/ente_components/Outfit',
+ );
+ expect(rendered().text.style!.fontWeight, FontWeight.w700);
+ expect(rendered().text.style!.fontStyle, FontStyle.italic);
+
+ await reopen();
+ await _tap(tester, find.byTooltip('Bold'));
+ await _tap(tester, find.byTooltip('Italic'));
+ await _tap(tester, find.text('Done'));
+ expect(rendered().text.style!.fontWeight, FontWeight.w500);
+ expect(rendered().text.style!.fontStyle, isNull);
});
- for (final (style, opacity) in [
- ('No background', 0.0),
- ('Translucent background', 0.5),
+ for (final (style, taps, opacity) in [
+ ('No background', 2, 0.0),
+ ('Translucent background', 1, 0.5),
]) {
testWidgets('$style preserves the chosen background when reopened', (
tester,
) async {
final editor = await _openEditor(tester);
- await _tap(tester, find.text('Background'));
+ await _tap(tester, find.byTooltip('Background color'));
+ await _tap(tester, find.byTooltip('Custom color'));
await _tap(tester, find.byType(Slider));
- await _tap(tester, find.byTooltip(style));
+ await _tap(tester, find.byTooltip('Solid background'));
+ if (taps == 2) {
+ await _tap(tester, find.byTooltip('Translucent background'));
+ }
+ expect(find.byTooltip(style), findsOneWidget);
await _tap(tester, find.text('Done'));
final layer = editor.activeLayers.single as TextLayer;
expect(layer.background.a, closeTo(opacity, 1 / 255));
@@ -99,8 +136,12 @@ void main() {
await _tap(tester, find.byKey(layer.keyInternalSize));
final reopened = tester.state<TextEditorState>(find.byType(TextEditor));
expect(reopened.secondaryColor, layer.background);
- await _tap(tester, find.text('Background'));
- await _tap(tester, find.byTooltip('Solid background'));
+ if (opacity == 0) {
+ await _tap(tester, find.byTooltip('Background color'));
+ } else {
+ await _tap(tester, find.byTooltip(style));
+ await _tap(tester, find.byTooltip('No background'));
+ }
expect(reopened.secondaryColor, const Color(0xFF00FFFF));
expect(reopened.primaryColor, Colors.white);
});
@@ -119,11 +160,12 @@ void main() {
14,
);
expect(
- MediaQuery.textScalerOf(tester.element(find.text('Font'))).scale(14),
+ MediaQuery.textScalerOf(tester.element(find.text('Inter'))).scale(14),
21,
);
- await tester.ensureVisible(find.text('Background'));
- await _tap(tester, find.text('Background'));
+ await _tap(tester, find.text('Inter'));
+ await _tap(tester, find.text('Gochi Hand'));
+ await _tap(tester, find.byTooltip('Custom color'));
expect(
tester
.state<TextEditorState>(find.byType(TextEditor))
@@ -134,9 +176,8 @@ void main() {
expect(tester.takeException(), isNull);
await tester.tapAt(const Offset(10, 100));
await tester.pumpAndSettle();
- expect(find.byType(TextEditor), findsOneWidget);
- expect(editor.activeLayers, isEmpty);
- await _tap(tester, find.text('Cancel'));
+ expect(find.byType(TextEditor), findsNothing);
+ expect(editor.activeLayers, hasLength(1));
await tester.ensureVisible(find.text('Filter'));
await _tap(tester, find.text('Filter'));
expect(
@@ -146,14 +187,297 @@ void main() {
21,
);
});
+
+ testWidgets('color controls have 48 point tap targets', (tester) async {
+ await _openEditor(tester);
+ expect(tester.getSize(find.byTooltip('Text color')), const Size(48, 48));
+ expect(tester.getSize(find.byTooltip('White')), const Size(48, 48));
+ });
+
+ testWidgets('portrait text control rows stay separated on a narrow screen', (
+ tester,
+ ) async {
+ tester.view.physicalSize = const Size(320, 640);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.resetPhysicalSize);
+ addTearDown(tester.view.resetDevicePixelRatio);
+ await _openEditor(tester);
+ await _tap(tester, find.text('Inter'));
+ await _tap(tester, find.text('Gochi Hand'));
+ await _tap(tester, find.byTooltip('Italic'));
+
+ final styleRowBottom = tester.getRect(find.byTooltip('Italic')).bottom;
+ final colorRowTop = tester.getRect(find.byTooltip('Text color')).top;
+ expect(colorRowTop - styleRowBottom, greaterThanOrEqualTo(16));
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('applied text is selected and can be duplicated or deleted', (
+ tester,
+ ) async {
+ final editor = await _openEditor(tester, selectable: true);
+ await _tap(tester, find.text('Done'));
+ expect(editor.activeLayers, hasLength(1));
+ await _tap(tester, find.byTooltip('Duplicate'));
+ expect(editor.activeLayers, hasLength(2));
+ await _tap(tester, find.byTooltip('Delete'));
+ expect(editor.activeLayers, hasLength(1));
+ });
+
+ testWidgets('double tapping applied text reopens it for typing', (
+ tester,
+ ) async {
+ var now = DateTime(2026);
+ final editor = await _openEditor(tester, selectable: true, now: () => now);
+ await _tap(tester, find.text('Done'));
+ final layer = find.byKey(editor.activeLayers.single.keyInternalSize);
+
+ await _tap(tester, layer);
+ expect(find.byType(TextEditor), findsNothing);
+ now = now.add(kDoubleTapTimeout + const Duration(milliseconds: 1));
+ await tester.tap(layer);
+ await tester.pump(const Duration(milliseconds: 50));
+ expect(find.byType(TextEditor), findsNothing);
+ now = now.add(const Duration(milliseconds: 50));
+ await _tap(tester, layer);
+ final reopened = tester.state<TextEditorState>(find.byType(TextEditor));
+ expect(reopened.textCtrl.text, 'Hello');
+ expect(reopened.focusNode.hasFocus, isTrue);
+ expect(tester.testTextInput.isVisible, isTrue);
+
+ await tester.enterText(find.byType(TextField), 'Hello again');
+ await _tap(tester, find.text('Done'));
+ expect((editor.activeLayers.single as TextLayer).text, 'Hello again');
+ });
+
+ testWidgets('text cannot reopen while the creation editor is closing', (
+ tester,
+ ) async {
+ final editor = await _openEditor(tester, selectable: true);
+ await tester.tap(find.text('Done'));
+ await tester.pump();
+ expect(editor.isSubEditorOpen, isTrue);
+ expect(editor.activeLayers, hasLength(1));
+ final layer = find.byKey(editor.activeLayers.single.keyInternalSize);
+ await tester.tap(layer);
+ await tester.tap(layer);
+ await tester.pumpAndSettle();
+ expect(find.byType(TextEditor), findsNothing);
+ expect(editor.activeLayers, hasLength(1));
+
+ editor.undoAction();
+ await tester.pumpAndSettle();
+ expect(editor.activeLayers, isEmpty);
+ });
+
+ testWidgets('editing text keeps undo and redo history in sync', (
+ tester,
+ ) async {
+ final editor = await _openEditor(tester, selectable: true);
+ await _tap(tester, find.text('Done'));
+
+ await _tap(tester, find.byTooltip('Edit'));
+ await tester.enterText(find.byType(TextField), 'Changed');
+ await _tap(tester, find.text('Done'));
+ expect((editor.activeLayers.single as TextLayer).text, 'Changed');
+
+ editor.undoAction();
+ await tester.pumpAndSettle();
+ expect((editor.activeLayers.single as TextLayer).text, 'Hello');
+
+ editor.redoAction();
+ await tester.pumpAndSettle();
+ expect((editor.activeLayers.single as TextLayer).text, 'Changed');
+ });
+
+ testWidgets('pinching and dragging text do not open the text editor', (
+ tester,
+ ) async {
+ final editor = await _openEditor(tester, selectable: true);
+ await _tap(tester, find.text('Done'));
+ final layer = find.byKey(editor.activeLayers.single.keyInternalSize);
+ final center = tester.getCenter(layer);
+ final first = await tester.startGesture(center - const Offset(12, 0));
+ final second = await tester.startGesture(center + const Offset(12, 0));
+ await first.moveBy(const Offset(-20, 0));
+ await second.moveBy(const Offset(20, 0));
+ await first.up();
+ await second.up();
+ await tester.pumpAndSettle();
+ expect(find.byType(TextEditor), findsNothing);
+
+ await tester.tapAt(center);
+ await tester.dragFrom(center, const Offset(45, 0));
+ await tester.dragFrom(center + const Offset(45, 0), const Offset(-45, 0));
+ await tester.pumpAndSettle();
+ expect(find.byType(TextEditor), findsNothing);
+ });
+
+ testWidgets('the text field stays put while the keyboard opens and closes', (
+ tester,
+ ) async {
+ tester.view.physicalSize = const Size(402, 874);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.reset);
+ await _openEditor(tester);
+ await tester.pumpAndSettle();
+ final field = find.byType(TextField);
+ final resting = tester.getTopLeft(field);
+
+ for (final keyboard in [120.0, 336.0, 0.0]) {
+ tester.view.viewInsets = FakeViewPadding(bottom: keyboard);
+ await tester.pump();
+ expect(tester.getTopLeft(field), resting);
+ }
+ });
+
+ testWidgets('typed text remains visible above the bar in landscape', (
+ tester,
+ ) async {
+ tester.view.physicalSize = const Size(874, 402);
+ tester.view.devicePixelRatio = 1;
+ tester.view.viewInsets = const FakeViewPadding(bottom: 250);
+ addTearDown(tester.view.reset);
+ await _openEditor(tester);
+ await tester.pumpAndSettle();
+
+ final fieldBottom = tester.getBottomLeft(find.byType(TextField)).dy;
+ final barTop = tester.getTopLeft(find.byType(ImageEditorTextBar)).dy;
+ expect(fieldBottom, lessThanOrEqualTo(barTop));
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('editing text keeps it where it was dragged', (tester) async {
+ final editor = await _openEditor(tester, selectable: true);
+ await _tap(tester, find.text('Done'));
+ final before = editor.activeLayers.single.offset;
+
+ await tester.drag(
+ find.byKey(editor.activeLayers.single.keyInternalSize),
+ const Offset(60, -80),
+ );
+ await tester.pumpAndSettle();
+ final moved = editor.activeLayers.single.offset;
+ expect(moved, isNot(before));
+
+ await _tap(tester, find.byTooltip('Edit'));
+ await tester.enterText(find.byType(TextField), 'Hello again');
+ await _tap(tester, find.text('Done'));
+ expect(editor.activeLayers.single.offset, moved);
+ });
+
+ testWidgets('reopening enlarged text does not change its line breaks', (
+ tester,
+ ) async {
+ tester.view.physicalSize = const Size(402, 874);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.reset);
+ final editor = await _openEditor(tester, selectable: true);
+ await tester.enterText(find.byType(TextField), 'Hello from Ente editor');
+ await _tap(tester, find.text('Done'));
+ final layer = editor.activeLayers.single as TextLayer;
+ layer.scale = 2;
+ editor.setState(() {});
+ await tester.pumpAndSettle();
+ final before = tester.getSize(find.byType(RoundedBackgroundText));
+
+ await _tap(tester, find.byTooltip('Edit'));
+ await _tap(tester, find.text('Done'));
+ final after = tester.getSize(find.byType(RoundedBackgroundText));
+ expect(after.height, closeTo(before.height, 1));
+ expect((editor.activeLayers.single as TextLayer).text, layer.text);
+ });
+
+ testWidgets('selection actions stay below the app bar for tall layers', (
+ tester,
+ ) async {
+ tester.view.physicalSize = const Size(320, 640);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.reset);
+ final editor = await _openEditor(tester, selectable: true);
+ await _tap(tester, find.text('Done'));
+ final layer = editor.activeLayers.single;
+ layer
+ ..scale = 12
+ ..rotation = math.pi / 2;
+ editor.selectLayerById(layer.id);
+ await tester.pumpAndSettle();
+
+ final actions = tester.getRect(find.byTooltip('Delete'));
+ expect(actions.top, greaterThanOrEqualTo(kToolbarHeight));
+ expect(actions.bottom, lessThanOrEqualTo(640 - 80));
+ });
+
+ testWidgets('a selected stroke can open its edit sheet', (tester) async {
+ final editor = await _openEditor(tester, selectable: true);
+ await _tap(tester, find.text('Done'));
+ editor.unselectAllLayers();
+ final stroke = PaintLayer(
+ item: PaintedModel(
+ mode: PaintMode.arrow,
+ offsets: const [Offset(0, 0), Offset(100, 80)],
+ erasedOffsets: const [],
+ color: Colors.white,
+ strokeWidth: 4,
+ opacity: 1,
+ fill: false,
+ ),
+ rawSize: const Size(100, 80),
+ opacity: 1,
+ );
+ editor.addLayer(stroke);
+ await tester.pumpAndSettle();
+ editor.unselectAllLayers();
+ await tester.pump();
+ editor.selectLayerById(stroke.id);
+ await tester.pumpAndSettle();
+ await _tap(tester, find.byTooltip('Edit'));
+ expect(find.byType(PaintEditorLayerEditor), findsOneWidget);
+ });
+
+ testWidgets('a new drawing is not selected after leaving Draw', (
+ tester,
+ ) async {
+ final editor = await _openEditor(tester, selectable: true);
+ await _tap(tester, find.text('Cancel'));
+ editor.openPaintEditor();
+ await tester.pumpAndSettle();
+ await tester.dragFrom(const Offset(200, 300), const Offset(100, 60));
+ await tester.pumpAndSettle();
+ editor.paintEditor.currentState!.done();
+ await tester.pumpAndSettle();
+ expect(editor.activeLayers.whereType<PaintLayer>(), isNotEmpty);
+ expect(editor.layerInteractionManager.selectedLayerIds, isEmpty);
+ expect(find.byTooltip('Delete'), findsNothing);
+ });
+
+ testWidgets('rotated text keeps its rotation when reopened and saved', (
+ tester,
+ ) async {
+ final editor = await _openEditor(tester, selectable: true);
+ await _tap(tester, find.text('Done'));
+ final layer = editor.activeLayers.single;
+ layer.rotation = math.pi / 4;
+ editor.selectLayerById(layer.id);
+ await tester.pumpAndSettle();
+
+ await _tap(tester, find.byTooltip('Edit'));
+ expect(tester.widget<TextEditor>(find.byType(TextEditor)).heroTag, isNull);
+ await _tap(tester, find.text('Done'));
+ expect(editor.activeLayers.single.rotation, math.pi / 4);
+ expect(find.byTooltip('Edit'), findsOneWidget);
+ });
}
Future<ProImageEditorState> _openEditor(
WidgetTester tester, {
double textScale = 1,
+ bool selectable = false,
+ DateTime Function()? now,
}) async {
final key = GlobalKey<ProImageEditorState>();
SubEditor? activeSubEditor;
+ final doubleTap = ImageEditorLayerDoubleTap(() => key.currentState, now: now);
await tester.pumpWidget(
MaterialApp(
theme: darkThemeData,
@@ -166,38 +490,62 @@ Future<ProImageEditorState> _openEditor(
child: child!,
),
home: Builder(
- builder: (context) => ProImageEditor.memory(
- Uint8List.fromList(img.encodePng(img.Image(width: 400, height: 300))),
- key: key,
- callbacks: ProImageEditorCallbacks(
- mainEditorCallbacks: MainEditorCallbacks(
- onOpenSubEditor: (editor) => activeSubEditor = editor,
- ),
- ),
- configs: ProImageEditorConfigs(
- theme: Theme.of(context),
- imageGeneration: const ImageGenerationConfigs(
- enableIsolateGeneration: false,
- enableBackgroundGeneration: false,
+ builder: (context) => Listener(
+ onPointerDown: doubleTap.onPointerDown,
+ onPointerMove: doubleTap.onPointerMove,
+ onPointerUp: doubleTap.onPointerUp,
+ onPointerCancel: doubleTap.onPointerCancel,
+ child: ProImageEditor.memory(
+ Uint8List.fromList(
+ img.encodePng(img.Image(width: 400, height: 300)),
),
- layerInteraction: const LayerInteractionConfigs(
- selectable: LayerInteractionSelectable.disabled,
+ key: key,
+ callbacks: ProImageEditorCallbacks(
+ mainEditorCallbacks: MainEditorCallbacks(
+ onOpenSubEditor: (editor) => activeSubEditor = editor,
+ onLayerTapDown: selectable ? doubleTap.onLayerDown : null,
+ onLayerTapUp: selectable ? doubleTap.onLayerUp : null,
+ onCreateTextLayer: () =>
+ imageEditorCreateTextLayer(() => key.currentState),
+ onEndCloseSubEditor: (editor) {
+ if (editor == SubEditor.paint) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ key.currentState?.unselectAllLayers();
+ });
+ }
+ },
+ ),
),
- textEditor: imageEditorTextConfigs(context),
- mainEditor: MainEditorConfigs(
- style: MainEditorStyle(
- subEditorPage: imageEditorSubEditorPageStyle(
- () => activeSubEditor,
- ),
+ configs: ProImageEditorConfigs(
+ theme: Theme.of(context),
+ imageGeneration: const ImageGenerationConfigs(
+ enableIsolateGeneration: false,
+ enableBackgroundGeneration: false,
),
- widgets: MainEditorWidgets(
- bottomBar: (editor, stream, barKey) => ReactiveWidget(
- key: barKey,
- stream: stream,
- builder: (_) => ImageEditorMainBottomBar(
- editor: editor,
- configs: editor.configs,
- callbacks: editor.callbacks,
+ layerInteraction: selectable
+ ? imageEditorLayerInteractionConfigs(
+ context,
+ () => key.currentState,
+ )
+ : const LayerInteractionConfigs(
+ selectable: LayerInteractionSelectable.disabled,
+ ),
+ textEditor: imageEditorTextConfigs(context),
+ mainEditor: MainEditorConfigs(
+ style: MainEditorStyle(
+ subEditorPage: imageEditorSubEditorPageStyle(
+ () => activeSubEditor,
+ ),
+ ),
+ widgets: MainEditorWidgets(
+ bottomBar: (editor, stream, barKey) => ReactiveWidget(
+ key: barKey,
+ stream: stream,
+ builder: (_) => ImageEditorMainBottomBar(
+ editor: editor,
+ configs: editor.configs,
+ callbacks: editor.callbacks,
+ ),
),
),
),
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index d6183188de..743c1e2265 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -1955,23 +1955,34 @@
"imageEditorAlignLeft": "Align left",
"imageEditorAlignRight": "Align right",
"imageEditorBackgroundColor": "Background color",
+ "imageEditorBlue": "Blue",
+ "imageEditorBold": "Bold",
"imageEditorBrightness": "Brightness",
"imageEditorContrast": "Contrast",
+ "imageEditorCustomColor": "Custom color",
+ "imageEditorDuplicate": "Duplicate",
"imageEditorEnterText": "Enter text",
"imageEditorExposure": "Exposure",
"imageEditorFade": "Fade",
+ "imageEditorGreen": "Green",
"imageEditorHue": "Hue",
+ "imageEditorItalic": "Italic",
"imageEditorLuminance": "Luminance",
"imageEditorNoBackground": "No background",
"@imageEditorNoBackground": {
"description": "Text background style with no visible background"
},
+ "imageEditorOrange": "Orange",
+ "imageEditorPink": "Pink",
+ "imageEditorPurple": "Purple",
+ "imageEditorRed": "Red",
"imageEditorSaturation": "Saturation",
"imageEditorSharpness": "Sharpness",
"imageEditorSolidBackground": "Solid background",
"@imageEditorSolidBackground": {
"description": "Text background style with a fully opaque color"
},
+ "imageEditorTeal": "Teal",
"imageEditorTemperature": "Temperature",
"imageEditorText": "Text",
"@imageEditorText": {