question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reg ToolbarAndroid

See original GitHub issue

React’s lean core effort is going full steam and now ToolbarAndroid is no longer available in the codebase though, as of today, the documentation does exist on the main doc site.

Examples in this repo that use ToolbarAndroid, like the Twitter sample, currently call it from react-native and this is bound to break in versions of react-native higher that v61, as i found out as well in my project.

Please let me know if you are considering shipping an Android variant sometime in the future.

Pitches for having it in the library:

  • Navigation React Native does have an iOS variant (in TitleBarIOS I think) so it can balance things out
  • it is a key and recognizable UI artefact that perhaps is firmly tied in in premises of router solutions
  • my project uses it 😃. Actually i suspect a rather high percentage of projects expect to use some form of a toolbar since it is a natively available across platforms and predictably familiar to users

To get a feel of Android native module integration with the router, my initial attempts at a crude/copy-paste integration results in errors currently. I get the dreaded ‘Invariant Violation’ error (“expected a string for built-in components…you likely forgot to export your component from the file it is defined in…”). I think i did the right things, at least after cross-checking with how the other modules - like the tabs - were integrated, but somehow i keep getting the error i mentioned above.

Steps i undertook:

  • i pulled the relevant java code/source from an earlier react-native release, dumped them into a toolbar directory in java/com/navigation/reactnative. The files created are DrawableWithIntrinsicSize.java, ReactToolbar.java and ReactToolbarManager.java in the root toolbar directory and in a nested events directory i have ToolbarClickEvent.java. The code is verbatim from an earlier react-native version that did have the implementation.
  • updated the NavigationPackage.java file with the import: import com.navigation.reactnative.toolbar.ReactToolbarManager; and subsequent call to new ReactToolbarManager().
  • the build works fine and i copy the new navigation-react-native directory to my node_modules
  • despite not being type-defined as yet i went ahead with a named import of ToolbarAndroid from navigation-react-native and attempted calling it in one of my components with a simple <ToolbarAndroid title="Home" />

Im still not to sure if just pulling in the code as-is from an earlier version somehow messes up the licensing bit even if the comments and attributions are intact. My guess is it should be ok for FOSS projects.

This original ToolbarAndroid module is quite comprehensive and if indeed you are looking at having a common Toolbar component across platforms across both the platforms, some rationalization or simplification may be warranted i think.

If you are not too keen on having it integrated i can always use the same approach but have it exposed via NativeModules. It perhaps may work. Or may not. Or maybe totally simplify it just for for my needs -> a back button, a title and perhaps a menu button/icon

UPDATE:

I have to make a few changes to .tsx files as well. Will update here after completing those.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:51 (50 by maintainers)

github_iconTop GitHub Comments

2reactions
emerson233commented, Oct 18, 2019

I open a PR for this issue. Hope this helps!

1reaction
grahammendickcommented, Oct 30, 2019

Fixed by #311

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toolbar | Android Developers
A standard toolbar for use within application content. A Toolbar is a generalization of action bars for use within application layouts.
Read more >
ToolbarAndroid - React Native
React component that wraps the Android-only Toolbar widget. A Toolbar can display a logo, navigation icon (e.g. hamburger menu), ...
Read more >
How to Design Custom Toolbar of App in Android Studio?
How to make responsive Registration and Login Activity using constraint Layout in ... How To Create Custom Toolbar Android Studio Java.
Read more >
Collapsing Toolbar in Android Studio - YouTube
... in Android Studio | Android Studio Tutorial | Android CollapsingToolbarLayout | Android Collapsing Toolbar Android Studio | Collapsing ...
Read more >
Setting position of image in toolbar in android - Stack Overflow
When I use the following code, the app crashes: mToolbar.setLayoutParams(new Toolbar.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found