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

Mobile: Migrate to react-native-paper #7477

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Dec 18, 2022

Summary

  • react-native-action-button is no longer maintained and is blocking upgrade to the most recent version of React Native (see the relevant forum post).
  • react-native-paper provides a FAB.Group component that looks and acts very similar to react-native-action-button.

Screenshots

screenshot of the closed add new menu

screenshot of the open add new menu showing add note and add todo buttons. The background is gray.

screenshot of the edit note button in the note view

Testing plan

  1. Using the "add new" menu, make a new to-do.
  2. Using the "add new" menu, make a new note.
  3. Open and close the "add new" menu.
  4. Edit a note using the "edit note" button

Notes

  • The "edit" button can be used when the sidebar is open: screenshot of sidebar open with add note FAB group also open
    • react-native-paper provides its own sidebar. Switching to that might fix this issue (and current sidebar-related accessibility issues).

Copy link
Owner

@laurent22 laurent22 left a comment

Choose a reason for hiding this comment

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

Looks like a good change, but aren't we adding a huge dependency with React Native Paper.

That being said, over the medium term it would make sense to start using an existing UI lib to make our life easier. How good is React Native Paper compared to other popular alternatives?

Comment on lines 53 to 57
"react-native-paper": "^5.0.2",
"react-native-popup-menu": "0.16.1",
"react-native-quick-actions": "0.3.13",
"react-native-rsa-native": "2.0.5",
"react-native-safe-area-context": "^4.4.1",
Copy link
Owner

Choose a reason for hiding this comment

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

Dependencies must be pinned (no ^)

PRODUCT_BUNDLE_IDENTIFIER = net.cozic.joplin.ShareExtension;
PRODUCT_BUNDLE_IDENTIFIER = net.personalizedrefrigerator.joplin.ShareExtension;
Copy link
Owner

Choose a reason for hiding this comment

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

That should probably not be changed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops! Sorry! That was for my own custom build!!! I'll fix that!!!

GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = ShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 12.10.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = net.cozic.joplin.ShareExtension;
PRODUCT_BUNDLE_IDENTIFIER = net.personalizedrefrigerator.joplin.ShareExtension;
Copy link
Owner

Choose a reason for hiding this comment

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

Same, shouldn't be changed

@@ -265,12 +265,12 @@
ORGANIZATIONNAME = joplinapp.org;
TargetAttributes = {
13B07F861A680F5B00A75B9A = {
DevelopmentTeam = A9BXAFS6CT;
Copy link
Owner

Choose a reason for hiding this comment

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

In fact I suspect all the changes in this file should be undone, because it looks like it's changes from your profile

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for catching this! I've reverted changes to the ios/ directory and re-run npx pod-install.

@personalizedrefrigerator personalizedrefrigerator changed the title Mobile: Migrate to react-native-paper WIP: Mobile: Migrate to react-native-paper Dec 18, 2022
@personalizedrefrigerator
Copy link
Collaborator Author

personalizedrefrigerator commented Dec 18, 2022

Looks like a good change, but aren't we adding a huge dependency with React Native Paper.

That being said, over the medium term it would make sense to start using an existing UI lib to make our life easier. How good is React Native Paper compared to other popular alternatives?

We are adding a huge dependency. According to yarnpkg.com's "size in browser", react-native-paper is at least 230 KiB, though only about 60 KiB if gzipped.

I looked at two other popular alternatives. Neither have floating action button groups.

  • nativebase
    • Advertises its accessibility.
    • Developed by GeekyAnts
    • Doesn't seem to have floating action button groups or a navigation drawer.
      • It does have normal floating action buttons. We could use these to implement the nested floating action buttons used by Joplin.
      • Suggests using react-native-navigation for a navigation drawer.
  • react-native-elements
    • Also doesn't seem to have floating action button groups or a navigation drawer (sidebar).

We could also try forking react-native-action-button (there haven't been new commits since 2020) or submitting a pull request to a fork (react-native-action-button-warnings-fixed).

I'm also looking at component libraries for sidebars (navigation drawers) as well. Our app's current sidebar library react-native-side-menu-updated is not very accessible — when using a screen reader, the app's (closed) sidebar can still be focused, and is navigated through before the main content of the app. Additionally, when using a screen reader, I can drag my finger across the screen and have the screen reader focus/read what I move my finger over. It reads and focuses the sidebar even when it's closed. This is very annoying.

I did notice some accessibility issues in the React Native Paper demo app with their sidebar — the sidebar can't be closed with a screen reader. I think we can work around this, though.

In fact I suspect all the changes in this file should be undone, because it looks like it's changes from your profile

I changed the iOS project team to allow running the app on my device, then ran npx pod-install and committed the result. I should have run npx pod-install before changing project settings in XCode. I'll do that and commit the result.

@personalizedrefrigerator personalizedrefrigerator changed the title WIP: Mobile: Migrate to react-native-paper Mobile: Migrate to react-native-paper Dec 18, 2022
@laurent22
Copy link
Owner

Thanks for checking the libs. Ideally we also want to find one that is likely to be well supported over the long term, although usually we can't really know. RNP appears to be growing more popular, while the other two are going down or stagnating in terms of downloads:

image

@laurent22
Copy link
Owner

When I try to run this pull request, I'm getting this error:

ERROR  Invariant Violation: requireNativeComponent: "RNCSafeAreaProvider" was not found in the UIManager.

This error is located at:
	in RNCSafeAreaProvider (at SafeAreaContext.tsx:87)
	in SafeAreaProvider (at SafeAreaProviderCompat.tsx:50)
	in SafeAreaProviderCompat (at Provider.tsx:102)
	in Provider (created by AppComponent)
	in AppComponent (created by Connect(AppComponent))
	in Connect(AppComponent) (created by Root)
	in Provider (created by Root)
	in Root (at renderApplication.js:50)
	in RCTView (at View.js:32)
	in View (at AppContainer.js:92)
	in RCTView (at View.js:32)
	in View (at AppContainer.js:119)
	in AppContainer (at renderApplication.js:43)
	in Joplin(RootComponent) (at renderApplication.js:60)

Have you ever had this issue and do you know how to fix it? I wanted to try RN Paper to develop the Profile Switcher UI, as a way to assess if we can use it as our main UI lib.

@personalizedrefrigerator
Copy link
Collaborator Author

personalizedrefrigerator commented Jan 5, 2023

When I try to run this pull request, I'm getting this error:

ERROR  Invariant Violation: requireNativeComponent: "RNCSafeAreaProvider" was not found in the UIManager.
...

Have you ever had this issue and do you know how to fix it? I wanted to try RN Paper to develop the Profile Switcher UI, as a way to assess if we can use it as our main UI lib.

If you're building from this branch, re-run npx pod-install and re-deploy from XCode. If you're adding react-native-paper as a new dependency, be sure to follow their getting started guide!

@laurent22
Copy link
Owner

Yes that was it, thank you. I thought pod installation would happen during yarn install but looks like it didn't. It seems to be working well now. I'll do more tests and if we go for RN paper, we can merge this PR

@laurent22
Copy link
Owner

Ok I've created the profile switcher using react-native-paper and it seems good enough for our use. Could you fix the conflicts please? Then I'll merge it, and then merge mine since it's based on this PR.

@personalizedrefrigerator
Copy link
Collaborator Author

personalizedrefrigerator commented Jan 6, 2023

Ok I've created the profile switcher using react-native-paper and it seems good enough for our use. Could you fix the conflicts please? Then I'll merge it, and then merge mine since it's based on this PR.

I won't be able to fix the conflicts for a few hours — I need access to a Mac to resolve conflicts in Podfile.lock. Expect conflicts to be resolved later tonight. Edit: Done.

@laurent22 laurent22 merged commit 257a241 into laurent22:dev Jan 8, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 8, 2023
@laurent22
Copy link
Owner

The old action button indeed seems incompatible with RN-0.69

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

Successfully merging this pull request may close these issues.

None yet

2 participants