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

Tooltip for template selection buttons #2216

Merged
merged 41 commits into from
May 26, 2020
Merged

Conversation

geriux
Copy link
Contributor

@geriux geriux commented May 5, 2020

Fixes #2169

Gutenberg PR -> WordPress/gutenberg#21974
WordPress iOS PR -> wordpress-mobile/WordPress-iOS#14045
WordPress Android PR -> wordpress-mobile/WordPress-Android#11807

To test check the Gutenberg PR description.

Note: Bundles were generated to test the main apps builds, they will be removed before merging.

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@geriux geriux removed this from the 1.28 milestone May 11, 2020
@geriux geriux requested a review from chipsnyder May 13, 2020 07:56
@iamthomasbishop
Copy link
Contributor

@geriux I had a chance to test over the weekend and it worked as expected in terms of timing and animation.

One thing that we discussed earlier is that the colors don't match perfectly with the newish native tooltip component on WPiOS and WPAndroid (which I think is using Color Studio colors), but that I think we should start using system-defined grays on that native component anyway. I just made a proposal for that, and in the process of discussing this, @bjtitus mentioned we may have access to the system-defined colors via a new API (PlatformColor). If that is indeed the case, let's use a system gray and coordinate to decide which colors we should be using for each platform. In the meantime, we can stick with the color you've applied here.

Note: we'll also need to create a ticket and discuss/make the same decision on WPAndroid but if we do have access via that API, I suggest we utilize it 😄

Copy link
Contributor

@mkevins mkevins left a comment

Choose a reason for hiding this comment

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

I tested this on a Pixel 3a (real device) via the build apk from the WordPress-Android PR and everything is working as expected. Nice work @geriux .

I understand that it's intentional that this tooltip disappears upon interaction with anything on the page (except scrolling horizontally the template pills), but this behavior is different for the tooltip for "Create a post or page" in the main app screen. That one even survives navigating to the media library, or the post and page lists, and back to the main screen. It only seems to disappear when I tap either the tooltip itself, or the button it's anchored to. Is this difference intentional / expected? cc: @iamthomasbishop

Gerardo Pacheco added 4 commits May 21, 2020 10:48
This reverts commit 2ee4845.
# Conflicts:
#	gutenberg
#	ios/gutenberg/GutenbergViewController.swift
#	react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergBridgeJS2Parent.java
#	react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
#	react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java
#	react-native-gutenberg-bridge/index.js
#	react-native-gutenberg-bridge/ios/GutenbergBridgeDelegate.swift
#	react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.m
#	react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.swift
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented May 21, 2020

Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job!

@geriux geriux requested review from mkevins and chipsnyder May 22, 2020 15:28
@iamthomasbishop
Copy link
Contributor

@mkevins that’s a good question and a subtle one. The behavior on our side is a bit less aggressive and I think it’s okay. What we have here is feeling pretty natural in this context, so I propose that we keep the behavior as-is. This is a good thing to consider in future definitions — whether they’re persistent or passive (like ours is).

Copy link
Contributor

@chipsnyder chipsnyder left a comment

Choose a reason for hiding this comment

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

Tested on iOS LGTM!

@geriux geriux added this to the 1.29 milestone May 26, 2020
@geriux geriux merged commit 59220b0 into develop May 26, 2020
@geriux geriux deleted the feature/layout-picker-tooltip branch May 26, 2020 07:42
Comment on lines +170 to +176

/// Tells the delegate that the editor requested to show the tooltip
func gutenbergDidRequestStarterPageTemplatesTooltipShown() -> Bool

/// Tells the delegate that the editor requested to set the tooltip's visibility
/// - Parameter tooltipShown: Tooltip's visibility value
func gutenbergDidRequestSetStarterPageTemplatesTooltipShown(_ tooltipShown: Bool)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @geriux @chipsnyder !
First congrats for merging this feature 🎉

I just recently came across with these new bridge delegate methods, and I was wondering what was the intention. My first thought was that we were displaying UI on native side, but it seems like it's used only to do persistent storage of user actions (in this case, tooltips already shown to the user). In this case I was wondering if it makes sense to do this persistence internally in the bridge itself, and relieve the client from this responsibility that seems to be quite low level.

Also, it would be interesting to be able to get and set settings in general, in order to avoid new bridge messages for every different setting we might have in the future.

Furthermore, web already has a similar system in place that uses LocalStorage as persistence. It's used (between other things) to know if gutenberg should display NUX UI. Maybe we can reuse this system and create this generic bridge method to store a JSON payload in the same way that the browser's LocalStorage does.

This is clearly no hi-pri, but I've been thinking in ways to improve the bridge usage anyway.

Please let me know what do you think, or perhaps these ideas wouldn't help this feature in particular.

Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @etoledom 👋 😃 As I understand, AsyncStorage was considered (to mirror the behavior of LocalStorage), however, it was decided that though that would simplify the implementation of persistent flags, it was more desirable to have all app-level persistence in one place.

While reviewing the Android side of this feature, I had a similar thought about how this pattern might "grow". But, since there aren't any other similar flags (yet) there was nothing to DRY up. My thinking is, we should keep an eye out if a pattern emerges where we can propose a more general solution to settings / persistent flag retrieval and reduce the "footprint" of the interface / protocol.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @mkevins for the explanation!

What do you think about the first part? Maybe we still can avoid giving the responsibility to store the flag to the client. Could we do de persistence inside the bridge without the need for WP apps to know about it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we still can avoid giving the responsibility to store the flag to the client. Could we do de persistence inside the bridge without the need for WP apps to know about it?

I think this was the case in an earlier implementation:
https://github.com/WordPress/gutenberg/blob/9aaf218b11481ebb4fe227426921181b21d252b4/packages/block-editor/src/components/page-template-picker/picker.native.js#L94

I'm not sure I have all the context on the decision to centralize the persistence into the parent apps. Perhaps it is to avoid "fragmenting" settings screens, but that is purely a guess on my part. This particular flag is not a user-toggleable setting, so it seems moot in this instance, but maybe this is more of a general architecture decision? I'm not sure there is a way to access the AsyncStorage data from the native side, so perhaps that's a concern as well? Maybe @hypest or @geriux can shed some more light on this.

I found this which looks interesting, but I'm not sure if there is an equivalent iOS module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @etoledom 👋 thanks for bringing this up and also thanks @mkevins for joining the conversation.

As @mkevins mentioned when I started this feature my intention was to use AsyncStorage. Since it didn't require much other than adding the library to the main apps (because React Native removed it in favor of lean core).

In the process of that, there were some discussions about maybe avoid using AsyncStorage and use what we currently use for some flags instead. Mainly to store data in the same place, even if it's a flag. So I ended up deciding to do it this way.

For this case though, as @mkevins mentions, it is not a user-togglable setting so having it stored somewhere else would work just fine.

Also, it would be interesting to be able to get and set settings in general, in order to avoid new bridge messages for every different setting we might have in the future.

This could be an option to avoid adding extra code for these types of settings.

Furthermore, web already has a similar system in place that uses LocalStorage as persistence. It's used (between other things) to know if gutenberg should display NUX UI. Maybe we can reuse this system and create this generic bridge method to store a JSON payload in the same way that the browser's LocalStorage does.

I guess this could also work, in my experience, AsyncStorage works just fine. Not sure how complicated it would be to develop what you mention but I'd lean more for adding AsyncStorage if we decide to go for this kind of system.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you both for your explanations! Everything seems more clear now 🙂

Let's wait for a good moment to re-think this, probably when we need to store a new similar flag.

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

Successfully merging this pull request may close these issues.

Add a Tooltip for template selection buttons
5 participants