NavbarComponent Framer Module
The NavbarComponent module allows you to generate an iOS-style navigation bar with title, action buttons, and search bar. Scroll effects mimic those on iOS, and views can be navigated forward and reverse.
Copy or save the
NavbarComponent file into your project's
Adding It to Your Project
In your Framer project, add the following:
myNavbar = require "NavbarComponent"
Instantiates a new instance of NavbarComponent.
myNavbar = new NavbarComponent # General style: <string> ("light" || "dark") size: <string> ("large" || "small") title: <string> # Buttons buttonCount: <number> buttonSize: <number> buttonActions: <array of actions> imagePrefix: <string> imageSuffix: <string> backAction: <action> # Search bar searchLabel: <string> search: <boolean> dictation: <boolean> # Colors textColor: <string> (hex or rgba) backgroundColor: <string> (hex or rgba) searchBarColor: <string> (hex or rgba) searchIconColor: <string> (hex or rgba) accentColor: <string> (hex or rgba)
Activating scroll effects
NavbarComponent will need to know which layer's scroll position it ought to match. Do not attempt to set it as the header of a FlowComponent. Rather, use the
scrollWith() feature and indicate your FlowComponent or ScrollComponent to the NavbarComponent.
myNavbar.scrollWith(layer) # layer will be the name of your FlowComponent or ScrollComponent
To mimic view-by-view navigation, use
showPrevious(). When using
showNext(), provide a title for the next view. NavbarComponent will store these for purposes of returning to them with
myNavbar.showNext("Your title here") myNavbar.showPrevious()
For debugging help, you can inspect NavbarComponent's stored list of titles.
Not all iOS navbars use the large title style. You may enforce a smaller title using
The search bar
If you instantiate the NavbarComponent with
search: true, your initial navbar view will display a search bar. Your users can type in this bar. If you wish to check the current value of the search bar, use the
All images are assumed to live in the
images directory and to be numbered starting with zero. You may supply a prefix and suffix. If your button images are located in a
buttons directory within
images and named:
item0.png item1.png item2.png
imagePrefix will be
"buttons/item" and your
imageSuffix will be
Do not include the
images directory in
Action button assets are assumed to be 24pt by 24pt. If yours are of another size, supply the correct dimension with
buttonSize: <number>. This will prevent your assets from being scaled.
The back button that appears on secondary views can be given an action, as can individual action buttons. Most likely, you will want the back button to activate the NavbarComponent's
showPrevious() feature, along with any navigation relevant to your prototype (e.g., the
showPrevious() FlowComponent feature). Action button actions should be arranged in a comma-separated array, one action per line.
backAction: -> myNavbar.showPrevious() buttonActions: [ -> print "1", -> print "second", -> print "item the third" ]