diff --git a/CHANGELOG.md b/CHANGELOG.md index 5823e857..957f697b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 7.3.0 +- **FEAT**(dependencies): Update `emoji_picker_flutter` to `4.2.0` and `image` to `4.5.2`. Adds support for custom translations in emoji editor for emoji search. + ## 7.2.0 - **FEAT**(export-history): Introduce the `serializeSticker` parameter to `ExportEditorConfigs` to enable exporting only `StickerLayerData` without converting the sticker to a `Uint8List`. This change incorporates the updates from pull request [#306](https://github.com/hm21/pro_image_editor/pull/306). diff --git a/lib/models/editor_configs/emoji_editor_configs.dart b/lib/models/editor_configs/emoji_editor_configs.dart index 7c8d3fee..f2a63a21 100644 --- a/lib/models/editor_configs/emoji_editor_configs.dart +++ b/lib/models/editor_configs/emoji_editor_configs.dart @@ -1,5 +1,7 @@ // Project imports: +import 'dart:ui'; + import 'emoji_editor_configs.dart'; export 'package:emoji_picker_flutter/emoji_picker_flutter.dart' @@ -34,7 +36,8 @@ class EmojiEditorConfigs { this.minScale = double.negativeInfinity, this.maxScale = double.infinity, this.checkPlatformCompatibility = true, - this.emojiSet = defaultEmojiSet, + this.emojiSet, + this.locale = const Locale('en'), this.style = const EmojiEditorStyle(), this.icons = const EmojiEditorIcons(), }) : assert(initScale > 0, 'initScale must be positive'), @@ -50,8 +53,21 @@ class EmojiEditorConfigs { /// Verify that emoji glyph is supported by the platform (Android only) final bool checkPlatformCompatibility; - /// Custom emojis; if set, overrides default emojis provided by the library. - final List emojiSet; + /// Useful to provide a customized list of Emoji or add/remove the support + /// for specific locales + /// (create similar method as in default_emoji_set_locale.dart). If not + /// provided, the default emoji set will be used based on the locales that + /// are available in the package. + final List Function(Locale)? emojiSet; + + /// Locale to choose the fitting language for the emoji set This will affect + /// the emoji search results + /// + /// The package currently supports following languages: + /// en, de, es, fr, hi, it, ja, pt, ru, zh. + /// + /// Default: const Locale('en') + final Locale locale; /// The minimum scale factor from the layer. final double minScale; @@ -75,7 +91,7 @@ class EmojiEditorConfigs { bool? enabled, double? initScale, bool? checkPlatformCompatibility, - List? emojiSet, + List Function(Locale)? emojiSet, double? minScale, double? maxScale, EmojiEditorStyle? style, diff --git a/lib/modules/emoji_editor/emoji_editor.dart b/lib/modules/emoji_editor/emoji_editor.dart index 3512c050..6f7bee14 100644 --- a/lib/modules/emoji_editor/emoji_editor.dart +++ b/lib/modules/emoji_editor/emoji_editor.dart @@ -2,6 +2,7 @@ import 'dart:math'; import 'package:emoji_picker_flutter/emoji_picker_flutter.dart'; +import 'package:emoji_picker_flutter/locales/default_emoji_set_locale.dart'; import 'package:flutter/foundation.dart' show defaultTargetPlatform; import 'package:flutter/material.dart'; import 'package:pro_image_editor/modules/emoji_editor/widgets/emoji_editor_category_view.dart'; @@ -94,6 +95,7 @@ class EmojiEditorState extends State Config _getEditorConfig(BoxConstraints constraints) { return Config( height: double.infinity, + locale: emojiEditorConfigs.locale, emojiSet: emojiEditorConfigs.emojiSet, checkPlatformCompatibility: emojiEditorConfigs.checkPlatformCompatibility, emojiTextStyle: _textStyle, @@ -190,7 +192,8 @@ class EmojiEditorState extends State key: _emojiSearchPageKey, config: _getEditorConfig(constraints), state: EmojiViewState( - emojiEditorConfigs.emojiSet, + (emojiEditorConfigs.emojiSet ?? + getDefaultEmojiLocale)(emojiEditorConfigs.locale), (category, emoji) { Navigator.pop( context, diff --git a/lib/modules/emoji_editor/widgets/emoji_editor_bottom_bar.dart b/lib/modules/emoji_editor/widgets/emoji_editor_bottom_bar.dart index 3c37e0f4..636d0d69 100644 --- a/lib/modules/emoji_editor/widgets/emoji_editor_bottom_bar.dart +++ b/lib/modules/emoji_editor/widgets/emoji_editor_bottom_bar.dart @@ -25,10 +25,6 @@ class EmojiEditorBottomBar extends StatelessWidget { /// Callback function for closing the skin tone overlay. final VoidCallback closeSkinToneOverlay; - List get _categories { - return categoryEmojis.where((el) => el.emoji.isNotEmpty).toList(); - } - @override Widget build(BuildContext context) { return SizedBox( @@ -48,9 +44,9 @@ class EmojiEditorBottomBar extends StatelessWidget { onTap: (index) { closeSkinToneOverlay(); EmojiStateManager.of(context) - ?.setActiveCategory(_categories[index].category); + ?.setActiveCategory(categoryEmojis[index].category); }, - tabs: _categories + tabs: categoryEmojis .asMap() .entries .map( diff --git a/lib/modules/emoji_editor/widgets/emoji_picker_view.dart b/lib/modules/emoji_editor/widgets/emoji_picker_view.dart index fa0fbf61..73f21aa5 100644 --- a/lib/modules/emoji_editor/widgets/emoji_picker_view.dart +++ b/lib/modules/emoji_editor/widgets/emoji_picker_view.dart @@ -258,9 +258,7 @@ class _DefaultEmojiPickerViewState extends State } List get _categories { - return widget.state.categoryEmoji - .where((el) => el.emoji.isNotEmpty) - .toList(); + return widget.state.categoryEmoji.toList(); } @override diff --git a/pubspec.yaml b/pubspec.yaml index a3bfcc54..63defb22 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pro_image_editor description: "A Flutter image editor: Seamlessly enhance your images with user-friendly editing features." -version: 7.2.0 +version: 7.3.0 homepage: https://github.com/hm21/pro_image_editor/ repository: https://github.com/hm21/pro_image_editor/ issue_tracker: https://github.com/hm21/pro_image_editor/issues/ @@ -38,9 +38,9 @@ dependencies: flutter: sdk: flutter - emoji_picker_flutter: ">=3.1.0 <3.2.0" + emoji_picker_flutter: ^4.2.0 http: ^1.2.2 - image: ^4.3.0 + image: ^4.5.2 mime: ^2.0.0 vibration: ^2.0.1 web: ^1.1.0