hm21 / pro_image_editor

The pro_image_editor is a Flutter widget designed for image editing within your application. It provides a flexible and convenient way to integrate image editing capabilities into your Flutter project.
https://hm21.github.io/pro_image_editor/
BSD 3-Clause "New" or "Revised" License
94 stars 59 forks source link

[Feature request] Highlight the selected filter item. #135

Closed thanglq1 closed 2 months ago

thanglq1 commented 2 months ago

Platforms

Android, iOS

Description

It would be nice if we could highlight the selected filter item. Please add configuration options for border width and border color for it. Simulator Screenshot - iPhone SE (3rd generation) - 2024-06-23 at 22 03 52

Why

No response

hm21 commented 2 months ago

This is already possible with customWidgets as you can see in the WhatsApp-Example here. The design of the current WhatsApp filter button can you see here.

thanglq1 commented 2 months ago

Thank you @hm21

thanglq1 commented 2 months ago

Hi @hm21. I'm trying to use the default FilterEditor, but it doesn't work. Please help explain.

filterEditor: CustomWidgetsFilterEditor(
              appBar: (filterEditor, rebuildStream) => ReactiveCustomAppbar(
                stream: rebuildStream,
                builder: (_) => _appBarFilterEditor(filterEditor),
              ),
              filterButton: (
                  filter,
                  isSelected,
                  scaleFactor,
                  onSelectFilter,
                  editorImage,
                  filterKey,
                  ) {
                return WhatsAppFilterBtn(
                  filter: filter,
                  isSelected: isSelected,
                  onSelectFilter: () {
                    onSelectFilter.call();
                    editorKey.currentState?.setState(() {});
                  },
                  editorImage: editorImage,
                  filterKey: filterKey,
                  scaleFactor: scaleFactor,
                );
              },
            ),

Simulator Screenshot - iPhone SE (3rd generation) - 2024-06-24 at 20 18 52

hm21 commented 2 months ago

I'm not sure what didn't work because you didn't mention it. But what I saw is that you are invoking the wrong editor. In the WhatsApp example, the filter editor is inside the main editor, but in the default example, the filter editor is standalone. You can access the filter editor like below:

filterEditor: CustomWidgetsFilterEditor(
  filterButton: (
    filter,
    isSelected,
    scaleFactor,
    onSelectFilter,
    editorImage,
    filterKey,
  ) {
    return WhatsAppFilterBtn(
      filter: filter,
      isSelected: isSelected,
      onSelectFilter: () {
        onSelectFilter.call();
        editorKey.currentState?.filterEditor.currentState
            ?.setState(() {});
      },
      editorImage: editorImage,
      filterKey: filterKey,
      scaleFactor: scaleFactor ?? 1,
    );
  },
),
thanglq1 commented 2 months ago

Hi @hm21. Thank you so much. You are right. I'm using wrong editor.