Skip to content

armgit / ente

Public Imported from GitHub
0

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

Merge upstream main into photos text editor branch

r4khul540d7ef5dcda
diff --cc mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart
index 6fd0ce5db9,32cca1c067..ed9bfe9bec
--- 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
@@@ -52,45 -54,37 +54,45 @@@ class CircularIconButton extends Statel
iconContent = child!;
}
- return SizedBox(
- width: width,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- GestureDetector(
- onTap: onTap,
- child: Container(
- height: size,
- width: size,
- decoration: BoxDecoration(
- color: isSelected
- ? colors.primary.withValues(alpha: 0.24)
- : colors.fillLight,
- shape: BoxShape.circle,
- border: Border.all(
- color: isSelected ? colors.primary : colors.fillLight,
- width: 2,
+ return Semantics(
+ button: true,
+ selected: isSelected,
+ label: label,
+ excludeSemantics: true,
+ onTap: onTap,
+ child: GestureDetector(
+ onTap: onTap,
+ behavior: HitTestBehavior.opaque,
+ child: SizedBox(
- width: 90,
++ width: width,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Container(
+ height: size,
+ width: size,
+ decoration: BoxDecoration(
+ color: isSelected
+ ? colors.primary.withValues(alpha: 0.24)
+ : colors.fillLight,
+ shape: BoxShape.circle,
+ border: Border.all(
+ color: isSelected ? colors.primary : colors.fillLight,
+ width: 2,
+ ),
),
+ child: Center(child: iconContent),
),
- child: Center(child: iconContent),
- ),
- ),
- const SizedBox(height: 6),
- Text(
- label,
- style: TextStyles.body.copyWith(color: colors.textBase),
- textAlign: TextAlign.center,
+ const SizedBox(height: 6),
+ Text(
+ label,
+ style: TextStyles.body.copyWith(color: colors.textBase),
+ textAlign: TextAlign.center,
+ ),
+ ],
),
- ],
+ ),
),
);
}
diff --cc mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
index 4256ca9c7f,5b18dbb84f..d7969f1392
--- 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
@@@ -239,333 -255,392 +258,323 @@@ class _ImageEditorPageState extends Sta
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(
- 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(tuneEditor: tuneI18n),
- imageGeneration: const ImageGenerationConfigs(
- jpegQuality: 100,
- enableIsolateGeneration: true,
- captureImageByteFormat: ui.ImageByteFormat.rawStraightRgba,
- outputFormat: OutputFormat.png,
- pngLevel: 0,
- ),
- layerInteraction: const LayerInteractionConfigs(
- hideToolbarOnInteraction: false,
+ 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;
+ },
+ ),
),
- 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,
- ),
++ tuneEditor: tuneI18n,
),
- 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.emoji,
- ],
- style: MainEditorStyle(
- subEditorPage: const SubEditorPageStyle(
- positionTop: 0,
- positionBottom: 0,
- positionLeft: 0,
- positionRight: 0,
+ layerInteraction: imageEditorLayerInteractionConfigs(
+ context,
+ () => editorKey.currentState,
+ ),
+ theme: ThemeData(
+ scaffoldBackgroundColor: colors.backgroundBase,
+ appBarTheme: AppBarTheme(
+ titleTextStyle: actionTextStyle,
+ backgroundColor: colors.backgroundBase,
+ ),
+ bottomAppBarTheme: BottomAppBarThemeData(
+ color: colors.backgroundBase,
),
- uiOverlayStyle: editorUiOverlayStyle,
- 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,
- ),
++ uiOverlayStyle: editorUiOverlayStyle,
+ 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,
- uiOverlayStyle: editorUiOverlayStyle,
- ),
- 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: TextEditorConfigs(
- showBackgroundModeButton: true,
- showTextAlignButton: true,
- style: const TextEditorStyle(
- background: Colors.transparent,
- textFieldMargin: EdgeInsets.only(top: kToolbarHeight),
+ ),
+ ),
),
- widgets: TextEditorWidgets(
- appBar: (textEditor, rebuildStream) => ReactiveAppbar(
- builder: (context) {
- return ImageEditorAppBar(
- key: const Key('image_editor_app_bar'),
- configs: textEditor.configs,
- done: () => textEditor.done(),
- close: () => textEditor.close(),
+ paintEditor: PaintEditorConfigs(
+ style: PaintEditorStyle(
+ initialColor: const Color(0xFF00FFFF),
+ background: colors.backgroundBase,
++ uiOverlayStyle: editorUiOverlayStyle,
+ ),
+ 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,
);
},
- stream: rebuildStream,
- ),
- bodyItems: (editor, rebuildStream) {
- return [
- ReactiveWidget(
+ colorPicker:
+ (paintEditor, rebuildStream, currentColor, setColor) =>
+ null,
+ bottomBar: (editorState, rebuildStream) {
+ return ReactiveWidget(
builder: (context) {
- return Positioned.fill(
- child: GestureDetector(
- onTap: () {},
- child: Container(color: Colors.transparent),
- ),
+ return ImageEditorPaintBar(
+ configs: editorState.configs,
+ callbacks: editorState.callbacks,
+ editor: editorState,
+ i18nColor: 'Color',
);
},
stream: rebuildStream,
- ),
- ];
- },
- colorPicker:
- (textEditor, rebuildStream, currentColor, setColor) => null,
- bottomBar: (editorState, rebuildStream) {
- return ReactiveWidget(
- builder: (context) {
- return ImageEditorTextBar(
- configs: editorState.configs,
- callbacks: editorState.callbacks,
- editor: editorState,
- );
- },
- stream: rebuildStream,
- );
- },
- ),
- ),
- cropRotateEditor: CropRotateEditorConfigs(
- rotateDirection: RotateDirection.right,
- style: CropRotateEditorStyle(
- background: colors.backgroundBase,
- cropCornerColor: colors.primary,
- uiOverlayStyle: editorUiOverlayStyle,
- ),
- 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,
- uiOverlayStyle: editorUiOverlayStyle,
- ),
- widgets: FilterEditorWidgets(
- slider:
- (
- editorState,
- rebuildStream,
- value,
- onChanged,
- onChangeEnd,
- ) => ReactiveWidget(
+ textEditor: imageEditorTextConfigs(context),
+ cropRotateEditor: CropRotateEditorConfigs(
++ rotateDirection: RotateDirection.right,
+ style: CropRotateEditorStyle(
+ background: colors.backgroundBase,
+ cropCornerColor: colors.primary,
++ uiOverlayStyle: editorUiOverlayStyle,
+ ),
+ widgets: CropRotateEditorWidgets(
+ appBar: (editor, rebuildStream) {
+ return ReactiveAppbar(
builder: (context) {
- return const SizedBox.shrink();
+ 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,
- ),
- 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,
- );
- },
+ );
+ },
+ bottomBar: (cropRotateEditor, rebuildStream) =>
+ ReactiveWidget(
+ stream: rebuildStream,
+ builder: (_) => ImageEditorCropRotateBar(
+ configs: cropRotateEditor.configs,
+ callbacks: cropRotateEditor.callbacks,
+ editor: cropRotateEditor,
+ ),
+ ),
+ ),
),
- ),
- tuneEditor: TuneEditorConfigs(
- style: TuneEditorStyle(
- background: colors.backgroundBase,
- uiOverlayStyle: editorUiOverlayStyle,
+ filterEditor: FilterEditorConfigs(
+ fadeInUpDuration: fadeInDuration,
+ fadeInUpStaggerDelayDuration: fadeInDelay,
+ filterList: filterList,
- style: FilterEditorStyle(background: colors.backgroundBase),
++ style: FilterEditorStyle(
++ background: colors.backgroundBase,
++ uiOverlayStyle: editorUiOverlayStyle,
++ ),
+ widgets: FilterEditorWidgets(
+ slider:
+ (
+ editorState,
+ rebuildStream,
+ value,
+ onChanged,
+ onChangeEnd,
+ ) => ReactiveWidget(
+ builder: (context) {
+ return const SizedBox.shrink();
+ },
+ 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,
+ );
+ },
+ ),
),
- 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),
++ style: TuneEditorStyle(
++ background: colors.backgroundBase,
++ uiOverlayStyle: editorUiOverlayStyle,
++ ),
+ 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 --cc mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart
index 6ec37d35b5,fde18279a4..72b544ac61
--- 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,106 -1,28 +1,110 @@@
import "package:ente_components/ente_components.dart";
import "package:ente_strings/ente_strings.dart";
-import 'package:flutter/material.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_configs_mixin.dart";
-import "package:photos/ui/tools/editor/image_editor/image_editor_constants.dart";
-import 'package:pro_image_editor/core/mixins/converted_configs.dart';
-import 'package:pro_image_editor/pro_image_editor.dart';
-
-class ImageEditorTextBar extends StatefulWidget with SimpleConfigsAccess {
- const ImageEditorTextBar({
- super.key,
- required this.configs,
- required this.callbacks,
- required this.editor,
- });
+import "package:pro_image_editor/core/models/styles/sub_editor_page_style.dart";
+import "package:pro_image_editor/pro_image_editor.dart";
- final TextEditorState editor;
+SubEditorPageStyle imageEditorSubEditorPageStyle(
+ ValueGetter<SubEditor?> activeEditor,
+) {
+ return SubEditorPageStyle(
++ positionTop: 0,
++ positionBottom: 0,
++ positionLeft: 0,
++ positionRight: 0,
+ transitionsBuilder: (context, animation, secondaryAnimation, child) =>
+ FadeTransition(
+ opacity: animation,
+ child: activeEditor() == SubEditor.text
+ ? MediaQuery.withNoTextScaling(child: child)
+ : child,
+ ),
+ );
+}
- @override
- final ProImageEditorConfigs configs;
- @override
- final ProImageEditorCallbacks callbacks;
+TextEditorConfigs imageEditorTextConfigs(BuildContext context) {
+ final colors = context.componentColors;
+ final textScaler = MediaQuery.textScalerOf(context);
+ return TextEditorConfigs(
+ initialPrimaryColor: Colors.white,
+ initialSecondaryColor: Colors.black,
+ initialBackgroundColorMode: LayerBackgroundMode.backgroundAndColor,
+ customTextStyles: const [
+ TextStyle(
+ fontFamily:
+ "packages/${TextStyles.fontPackage}/${TextStyles.fontFamily}",
+ ),
+ TextStyle(
+ fontFamily:
+ "packages/${TextStyles.fontPackage}/${TextStyles.outfitFontFamily}",
+ 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(
+ stream: rebuildStream,
+ builder: (context) => PreferredSize(
+ preferredSize: const Size.fromHeight(kToolbarHeight),
+ child: MediaQuery(
+ data: MediaQuery.of(context).copyWith(textScaler: textScaler),
+ child: ImageEditorAppBar(
+ configs: editor.configs,
+ done: editor.done,
+ close: editor.close,
+ ),
+ ),
+ ),
+ ),
+ colorPicker: (_, _, _, _) => null,
+ bottomBar: (editor, rebuildStream) => ReactiveWidget(
+ stream: rebuildStream,
+ builder: (context) => MediaQuery(
+ data: MediaQuery.of(context).copyWith(textScaler: textScaler),
+ child: ImageEditorTextBar(editor: editor),
+ ),
+ ),
+ ),
+ );
+}
+
+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});
+
+ final TextEditorState editor;
@override
State<ImageEditorTextBar> createState() => _ImageEditorTextBarState();
diff --cc mobile/packages/strings/lib/l10n/arb/strings_en.arb
index 743c1e2265,a95552fcd1..813687d004
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@@ -1951,49 -1952,14 +1952,48 @@@
"ignore": "Ignore",
"ignored": "ignored",
"ignorePerson": "Ignore person",
+ "imageEditorAlignCenter": "Align center",
+ "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": {
+ "description": "Tool for adding text to a photo"
+ },
+ "imageEditorTextColor": "Text color",
+ "imageEditorTint": "Tint",
+ "imageEditorTranslucentBackground": "Translucent background",
+ "@imageEditorTranslucentBackground": {
+ "description": "Text background style with a half-transparent color"
+ },
+ "imageEditorWhite": "White",
"imageNotAnalyzed": "Image not analyzed",
"immediate": "Immediate",
"immediately": "Immediately",