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: mobile tool bar basic features #161

Merged

Conversation

hyj1204
Copy link
Contributor

@hyj1204 hyj1204 commented Jun 2, 2023

1. Build basic structure for toolbar items in mobile.

Currently, there has two types of MobileToolbarItem: action and withMenu. action is for the feature which implement directly after click the toolbar Item, like code inline. withMenu is for the one needs to open a menu then implement features, like textDecorationMobileToolbarItem

image

2. Add the following toolbar items.

When the selection changes, MobileToolbarWidget gets rebuilt based on the current/updated selection(all the item menus will be closed).

All the testing code of following checked features have been added.

The unchecked features will be add in other PRs in the future.

MobileToolbarItem Sub buttons on its menu
textDecoration bold ✔️
italic ✔️
underline ✔️
strikethrough ✔️
colorDecoration text color picker ToDo
highlight color picker ToDo
code None ✔️
link link input ✔️
Setting for exist link Need redesign
Same as desktop for now
header heading 1 ✔️
heading 2 ✔️
heading 3 ✔️
list bulleted list ✔️
numbered list ✔️
todo list None ✔️
quote None ✔️
divider None ToDo

Some videoshots, like text decoration and code inline

Screen.Recording.2023-06-02.at.11.14.04.AM.mov
Screen.Recording.2023-06-02.at.11.30.03.AM.mov

3. Add MobileToolbarStyle as InheritedWidget to manage all the cosmetic parameters in MobileToolbar

  • To customize the style of MobileToolbar, just give the value directly to MobileToolbar
MobileToolbar(
                  backgroundColor: Colors.white,
                  foregroundColor: Colors.black,
                  itemHighlightColor: Colors.blue,
                  editorState: editorState,
                  toolbarItems: [
                    textDecorationMobileToolbarItem,   
                    linkMobileToolbarItem,
                    codeMobileToolbarItem, 
                  ],
  • If no value is provided, it will use the default value here.

image

  • Use MobileToolbarStyle.of(context) to access its cosmetic parameters in child widgets.
    image

4. Chores:

  • move all the tests in mobile to test/mobile
  • move toolbar/items to toolbar/desktop/items

@hyj1204 hyj1204 requested a review from LucasXu0 June 2, 2023 16:34
@hyj1204 hyj1204 self-assigned this Jun 2, 2023
@hyj1204 hyj1204 force-pushed the feat/mobile_tool_bar_text_decoration branch 2 times, most recently from 4b03aaf to 4fbe1b3 Compare June 6, 2023 20:54
@AppFlowy-IO AppFlowy-IO deleted a comment from codecov bot Jun 8, 2023
@hyj1204 hyj1204 linked an issue Jun 8, 2023 that may be closed by this pull request
@hyj1204 hyj1204 changed the title Feat: mobile tool bar text decoration Feat: mobile tool bar basic features Jun 8, 2023
@hyj1204 hyj1204 requested a review from LucasXu0 June 8, 2023 20:21
@codecov
Copy link

codecov bot commented Jun 9, 2023

Codecov Report

Merging #161 (11f602c) into main (7fe5bb8) will increase coverage by 4.74%.
The diff coverage is 97.43%.

@@            Coverage Diff             @@
##             main     #161      +/-   ##
==========================================
+ Coverage   58.81%   63.56%   +4.74%     
==========================================
  Files         215      228      +13     
  Lines        9643    10062     +419     
==========================================
+ Hits         5672     6396     +724     
+ Misses       3971     3666     -305     
Impacted Files Coverage Δ
...lbar/desktop/items/bulleted_list_toolbar_item.dart 80.00% <ø> (ø)
...editor/toolbar/desktop/items/color/color_menu.dart 0.00% <ø> (ø)
...itor/toolbar/desktop/items/color/color_picker.dart 80.24% <ø> (ø)
...ktop/items/color/highlight_color_toolbar_item.dart 83.33% <ø> (ø)
...r/desktop/items/color/text_color_toolbar_item.dart 83.33% <ø> (ø)
...or/toolbar/desktop/items/format_toolbar_items.dart 96.29% <ø> (ø)
...r/toolbar/desktop/items/heading_toolbar_items.dart 73.68% <ø> (ø)
.../toolbar/desktop/items/highlight_toolbar_item.dart 0.00% <ø> (ø)
...editor/toolbar/desktop/items/icon_item_widget.dart 100.00% <ø> (ø)
...c/editor/toolbar/desktop/items/link/link_menu.dart 100.00% <ø> (ø)
... and 21 more

... and 23 files with indirect coverage changes

await editorState.formatDelta(selection, {
FlowyRichTextKeys.href: value,
});
mobileToolbarItemMenuStateKey.currentState?.closeItemMenu();
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about passing the state by the itemMenuBuilder callback instead of using mobileToolbarItemMenuKey?

itemMenuBuilder: (editorState, selection, menuState)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use mobileToolbarItemMenuStateKey to close MobileToolbarItemMenu(make it show a SizedBox.shrink()).
I got confused about how can I get the state of MobileToolbarItemMenu without using Key?
image

Comment on lines 4 to 5
GlobalKey<MobileToolbarItemMenuState> mobileToolbarItemMenuStateKey =
GlobalKey();
Copy link
Collaborator

Choose a reason for hiding this comment

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

try to remove the global key here.

@LucasXu0 LucasXu0 changed the title Feat: mobile tool bar basic features feat: mobile tool bar basic features Jun 13, 2023
@LucasXu0
Copy link
Collaborator

LGTM

@LucasXu0 LucasXu0 merged commit 6a4a8ae into AppFlowy-IO:main Jun 13, 2023
@hyj1204 hyj1204 deleted the feat/mobile_tool_bar_text_decoration branch June 14, 2023 14:30
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.

[FR] Mobile toolbar features
2 participants