Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: insert emoji using ":" command #3025

Closed

Conversation

rizwan3395
Copy link
Contributor

Feature Preview


AppFlowy_o9xHZRPzJ9.mp4

PR Checklist

  • My code adheres to the AppFlowy Style Guide
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

This PR fixes issue #2797

@codecov
Copy link

codecov bot commented Jul 19, 2023

Codecov Report

Merging #3025 (ff786cd) into main (0fb004a) will decrease coverage by 55.71%.
The diff coverage is 37.95%.

@@             Coverage Diff             @@
##             main    #3025       +/-   ##
===========================================
- Coverage   68.70%   13.00%   -55.71%     
===========================================
  Files         426      432        +6     
  Lines       20241    20665      +424     
===========================================
- Hits        13907     2687    -11220     
- Misses       6334    17978    +11644     
Flag Coverage Δ
appflowy_flutter_integrateion_test ?
appflowy_flutter_unit_test 13.00% <37.95%> (+0.65%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...abase_view/application/field/field_controller.dart 61.55% <0.00%> (-21.41%) ⬇️
...esentation/widgets/filter/choicechip/checkbox.dart 0.00% <0.00%> (-100.00%) ⬇️
...widgets/filter/choicechip/checklist/checklist.dart 0.00% <0.00%> (-94.37%) ⬇️
...filter/choicechip/select_option/select_option.dart 0.00% <0.00%> (-90.42%) ⬇️
...on/editor_plugins/actions/block_action_button.dart 0.00% <0.00%> (-100.00%) ⬇️
...r_plugins/emoji_shortcut/emoji_picker_builder.dart 0.00% <0.00%> (ø)
...plugins/emoji_shortcut/emoji_shortcut_service.dart 0.00% <0.00%> (ø)
...nd/appflowy_flutter/lib/startup/tasks/hot_key.dart 25.00% <0.00%> (-75.00%) ⬇️
...ace/application/settings/settings_dialog_bloc.dart 0.00% <ø> (-95.46%) ⬇️
...rkspace/presentation/settings/settings_dialog.dart 0.00% <0.00%> (-94.60%) ⬇️
... and 7 more

... and 322 files with indirect coverage changes

@rizwan3395
Copy link
Contributor Author

@Xazin I made the suggested changes

Comment on lines 101 to 103
for (int i = 0; i < _emojiController.text.length + 1; i++) {
_deleteLastCharacters();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (int i = 0; i < _emojiController.text.length + 1; i++) {
_deleteLastCharacters();
}
_deleteLastCharacters(_emojiController.text.length);

@@ -8,6 +8,8 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import 'editor_plugins/emoji_shortcut/emoji_shortcut_service.dart';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this header to editor_plugins/plugins.dart.

ShortcutEmojiPickerViewState createState() => ShortcutEmojiPickerViewState();
}

@visibleForTesting
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to add @visibleForTesting

@@ -0,0 +1,92 @@
import 'package:appflowy_backend/protobuf/flowy-folder2/protobuf.dart';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test will not be executed in the CI job. Please add this test to document_test_runner.dart.

final resultsFilterCount = 35;

@override
void initState() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call the super.initState(); at the beginning.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  @override
  void initState() {
    super.initState();

    final initCategory = widget.state.categoryEmoji.indexWhere(
      (element) => element.category == widget.config.initCategory,
    );
    final initialIndex = initCategory != -1 ? initCategory : 0;
    _tabController = TabController(
      initialIndex: initialIndex,
      length: widget.state.categoryEmoji.length,
      vsync: this,
    );
    _pageController = PageController(
      initialPage: initialIndex,
    );
    _emojiFocusNode.requestFocus();

    WidgetsBinding.instance.addPostFrameCallback((_) {
      _focusNode.requestFocus();
    });
  }

super.dispose();
}

bool get isEmojiSearching =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this getter before the initState function.

searchEmojiList.emoji.isNotEmpty || _emojiController.text.isNotEmpty;

KeyEventResult _onKey(FocusNode node, RawKeyEvent event) {
final CategoryEmoji catEmoji = isEmojiSearching
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to declare the type. remove the CategoryEmoji.

} else if (event.logicalKey == LogicalKeyboardKey.arrowUp) {
newSelectedIndex -= 7;
} else if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
newSelectedIndex += 7;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why using 7? Please make it configurable.

return KeyEventResult.ignored;
}

_searchEmoji() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add return type.

widget.editorState.apply(transaction);
}

void _insertText(String text) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this function. use widget.editorState.insertTextAtCurrentSelection(text); instead

@LucasXu0
Copy link
Collaborator

@rizwan3395

  • Add the missing return type for every functions.
  • Don't force unwrap the value.
  • move all the private function behind the build function

@rileyhawk1417
Copy link
Collaborator

Could this plugin be considered an editor one or AppFlowy specific?
Just wondering since it was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants