GithubHelp home page GithubHelp logo

brucelane / ionic-react-tabs-menus-custom Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alanmontgomery/ionic-react-tabs-menus-custom

0.0 1.0 0.0 1.29 MB

Rough example of using React Context API to control the side menu and custom page content, tabs etc

HTML 2.19% CSS 17.04% JavaScript 71.52% Swift 8.08% Ruby 1.17%

ionic-react-tabs-menus-custom's Introduction

ionic-react-tabs-menus-custom

An example project of using React Context API to control the side menu in an Ionic app using React along with ALOT of cool features and tidy ways of doing things (see below)

Run

npm install then ionic serve

Check out this Twitter thread for some explanations (hopefully it doesn't outdate) https://twitter.com/93alan/status/1370754596801552391

  • Custom TabMenu with Routes
  • Custom Tab Children pages
  • Custom Sub pages
  • Navigate to a url (page) or perform an action by click event
  • Changing side menu with react context api hook
  • Easy custom Side Menu per tab
  • Add an object to tabRoutes array in AllRoutes.js to add a new tab to the main tab bar

Other things included

  • Example of rendering a list/items based on array of objects
  • Layout for email style inbox / simple list of items
  • Example of searching a list using filter() function
  • Example of changing component rendered based on state
  • Navigating to pages throughout the app /tabs/tab1 from side menu, and content area
  • Navigating to modals (or showing modals) throughout the app from different places in the app including side menu
  • Navigating to sub pages from a list from a main page, e.g. /tabs/tab2/1 making use of the useParams and useIonViewWillEnter hooks
  • Accessing properties associated to the current side menu setup in a tab page using context api

Adding a new tab to the tab menu and main app routing

  1. Go to AllRoutes.js
  2. Add an object to the tabRoutes array specifying a label, component, icon, path and a few flags

Adding a new tab child to the main app routing

  1. Go to AllRoutes.js
  2. Add an object to the tabChildrenRoutes array specifying a label, component, icon, path and a few flags

Adding a new sub-page to app routing

  1. Go to AllRoutes.js
  2. Add an object to the subPageRoutes array specifying a label, component, icon, path setting isTab bool to false

Changing the side menu per tab

  1. Find the relative sideMenu within the PageSideMenus.js file, e.g. tab1SideMenu
  2. Alter one of the objects in the array or add one by changing the params passed to the buildSideMenuObject function or call the function for a new one
  3. Alternatively, remove or add a new menu completely by creating a new array
  4. Specify the side you want the side menu button to appear in the useEffect on the main tab component

Adding a back button, action button with associated properties

  1. Look at CustomPage.js and what props it expects
  2. You can easily add a back button, action button (like add, search or something which could open a modal or navigate to a page) to the toolbar

Example of side menu options found in PageSideMenus.js this is then imported via AllRoutes.js

export const tab1SideMenu = [

    buildSideMenuObject(false, "Go to Inbox", mailOutline, "/tabs/tab2"),
    buildSideMenuObject(false, "Go to Places", mapOutline, "/tabs/tab3"),
    buildSideMenuObject(true),
    buildSideMenuObject(false, "Account Settings", settingsOutline, null),
    buildSideMenuObject(false, "Settings Sub Page", cogOutline, "/tabs/tab1/settings"),
    buildSideMenuObject(false, "Privacy", eyeOutline, null),
    buildSideMenuObject(false, "Logout", logOutOutline, null)
];
  • url can be like /tabs/tab1
  • clickEvent can be a function, can be a global function call from within PageSideMenus.js, alternatively find your side menu option in a loop/filter on the main component and reassign the clickEvent object property

ionic-react-tabs-menus-custom's People

Contributors

alanmontgomery avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.