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

Implement list block in React Native #14636

Merged
merged 31 commits into from
Apr 5, 2019
Merged

Implement list block in React Native #14636

merged 31 commits into from
Apr 5, 2019

Conversation

SergioEstevao
Copy link
Contributor

@SergioEstevao SergioEstevao commented Mar 26, 2019

Description

This PR implements the list block by only changing components and not touching the code of the block ( no need to create a native version).

This achieved by improving the implementation of the block-edit context in RNMobile in order to send the isSelected and onFocus props to the RichText components.

For the moment it doesn't implement the indent and outdent buttons, but those should be relatively after a better understanding of the format and selection code behind it.

At the moment the block allows the breaking of the list by tapping two enters in a row on an empty list element. This can be solved by changing Aztec to send the event up instead of breaking the list by itself.

How has this been tested?

This can be tested using this PR on gb-mobile: wordpress-mobile/gutenberg-mobile#704

simulator screen shot - iphone xr - 2019-03-05 at 22 29 37

@SergioEstevao SergioEstevao added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label Mar 26, 2019
@SergioEstevao SergioEstevao added this to the 5.4 (Gutenberg) milestone Mar 26, 2019
@SergioEstevao SergioEstevao self-assigned this Mar 26, 2019
return {
clientId: context.clientId,
isSelected: context.isSelected,
onFocus: context.onFocus,
Copy link
Member

Choose a reason for hiding this comment

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

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 saw that but it looks we don't use the same logic on the native part on our block manager.

Copy link
Member

Choose a reason for hiding this comment

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

how is going your solution work with multiple RichText controls included in a single block?

@SergioEstevao
Copy link
Contributor Author

SergioEstevao commented Mar 27, 2019 via email

@hypest hypest self-assigned this Mar 27, 2019
@hypest
Copy link
Contributor

hypest commented Apr 4, 2019

Pushed 08318ca which includes a fix for the toggling of list type in nested lists.

Known issues:

  1. On iOS, only the current list item changes type (when nested; the root list does change type fine)
  2. The toolbar list type button doesn't update to match the list type of the nested list Fixed with 9dcd23b, fd62f01.
  3. On Android, the list type toolbar button "flickers" between the types when changing the type on a nested list.

Copy link
Contributor

@Tug Tug left a comment

Choose a reason for hiding this comment

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

Tested with Stefanos latest changes on iOS, this LGTM 👍

@ellatrix
Copy link
Member

ellatrix commented Apr 4, 2019

@hypest Could you perhaps also update the web version?

* @return {boolean} True if the root list or nothing is selected, false if an
* inner list is selected.
*/
function isListRootSelected( value ) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not replace getStartListFormat with both isListRootSelected and isActiveListType? This seems weird to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

👋 @ellatrix , not sure I follow. Do you mean to completely remove getStartListFormat and implement its pieces inside isListRootSelected and isActiveListType?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, export isListRootSelected and isActiveListType from rich-text as unstable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done with 4451cb3.

Copy link
Member

@ellatrix ellatrix left a comment

Choose a reason for hiding this comment

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

Would be great to update web version and also change the function names (it's ok to have to separate one for the two different purposes.

@hypest
Copy link
Contributor

hypest commented Apr 5, 2019

@hypest Could you perhaps also update the web version?

@ellatrix , is it OK for you if we do it in a separate PR so we unblock this one?

@@ -6,7 +6,7 @@ import { Toolbar } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import {
changeListType,
getStartListFormat,
getLineListFormat,
Copy link
Member

Choose a reason for hiding this comment

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

I meant to rename it as getLineNestingLevel, back when it was only about the nesting. I think it's better to export two functions instead of overloading one for multiple purposes. 66e971d#r272474533

Copy link
Contributor

Choose a reason for hiding this comment

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

Aha, I see. I will work on that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I pushed da0e1a7, splitting the function into separate ones and marking them as unstable. Let me know what you think @ellatrix , thanks!

@ellatrix
Copy link
Member

ellatrix commented Apr 5, 2019

@hypest Ok. I thought it's useful to know that the functions you introduce work in both scenarios.

@hypest
Copy link
Contributor

hypest commented Apr 5, 2019

I thought it's useful to know that the functions you introduce work in both scenarios.

Yes, that's perfect information to know @ellatrix , thanks for assessing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants