BlueBase
  • 💧Introduction
  • Tutorial
    • 1. Getting Started
      • 1.1 Setup
      • 1.2 Add Plugins
      • 1.3 Create Custom Plugin
    • 2. Backend API
      • 2.1 Create Backend API
      • 2.2 Setup Apollo Client
      • 2.3 Generate Typescript Interfaces
    • 3. Create Screens
      • 3.1 Pending Tasks Screen
      • 3.2 Edit Task Screen
      • 3.3 Task Create Screen
      • 3.4 Tab Navigation
    • 4. CRUD Operations
      • 4.1 Creating Tasks
      • 4.2 Reading Tasks
      • 4.3 Updating Tasks
      • 4.4 Deleting Tasks
    • 5. Enhancements
      • 5.1 Internationalisation
      • 5.2 Theming
      • 5.3 Dynamic Images
      • 5.4 Settings & Configurations
      • User Management
  • Key Concepts
    • 🎡Lifecycle Events
    • â›Šī¸Main App Layout
    • 🔌Plugins
      • Plugin API
      • Register a Plugin
      • Making a Plugin Configurable
      • Developing an Analytics Plugin
      • Developing a Logger Plugin
      • Developing a Theme Plugin
    • 🚇Filters
    • 🎁Components
      • Components API
      • Registering a Component
      • Accessing Components
      • Higher Order Components
    • 🎨Themes
      • Consuming Selected Theme
      • Customise Themes
      • Customise Components
      • Theme Configs
      • Theme Structure
    • đŸŽ›ī¸Configs
  • API
    • 📈Analytics
    • 📔Logger
    • đŸ“ĻBlueBase Modules
    • Registry
  • Guides
    • âœ‚ī¸Code Splitting
    • đŸ‘ŊMigrating to V8
  • Components
    • ActivityIndicator
    • BlueBase
      • BlueBaseApp 📌
      • BlueBaseConsumer 📌
      • BlueBaseFilter 📌
      • ThemeConsumer 📌
    • Button
    • ComponentState 📌
    • EmptyState 📌
    • ErrorState 📌
    • Icons
      • Icon
      • DynamicIcon 📌
      • PluginIcon 📌
    • JsonSchema 📌
    • LoadingState 📌
    • Noop 📌
    • Observers
      • DataObserver 📌
      • ErrorObserver 📌
      • HoverObserver 📌
      • WaitObserver 📌
    • StatefulComponent 📌
    • Typography
    • View
Powered by GitBook
On this page
  • Step 1: Add Tab Navigator
  • Step 2: Tab Icons

Was this helpful?

Export as PDF
  1. Tutorial
  2. 3. Create Screens

3.4 Tab Navigation

To improve the user experience of our app, we want to add tabs on the main page. One tab will show all pending tasks, while the other one will show the completed tasks.

Step 1: Add Tab Navigator

It is possible to add nested routes in BlueBase. Whenever we want to do this, we will add a navigator property in the route. There are several navigators available to use (i.e. switch, stack, tab, bottom-tabs, drawer).

Inside the navigator, we add our desired routes:

{
	name: 'TasksApp',
	screen: Noop,
	path: '',
	exact: false,
	
	options: {
		title: 'My Tasks',
		headerRight: () => <TaskCreateButton />
	},
	
	navigator: {
		headerMode: 'none',
		type: 'tab',
	
		routes: [{
			exact: true,
			name: 'PendingTask',
			path: 'pending',
			screen: 'PendingTasksScreen',

			options: {
				title: 'Pending',
			},
		}, {
			exact: true,
			name: 'CompletedTasks',
			path: 'completed',
			screen: 'CompletedTasksScreen',

			options: {
				title: 'Completed',
			},
		}],
	},
}

When you run the app, you should now see 2 tabs on the main page like the screenshots below:

Step 2: Tab Icons

Another thing we can do to make our UI pleasing is by adding icons to our tabs. This is done by:

  • Adding tabBarIcon to route.options.

  • Adding tabBarOptions to the navigator.

See the code below for example:

src/routes.ts
{
	name: 'TasksApp',
	screen: Noop,
	path: '',
	exact: false,
	
	options: {
		title: 'My Tasks',
		headerRight: () => <TaskCreateButton />
	},
	
	navigator: {
		headerMode: 'none',
		type: 'tab',
	
		routes: [{
			exact: true,
			name: 'PendingTask',
			path: 'pending',
			screen: 'PendingTasksScreen',

			options: {
				title: 'Pending',
				tabBarIcon: ({ color }) => <Icon name="checkbox-multiple-blank-outline" color={color} />,
			},
		}, {
			exact: true,
			name: 'CompletedTasks',
			path: 'completed',
			screen: 'CompletedTasksScreen',

			options: {
				title: 'Completed',
				tabBarIcon: ({ color }) => <Icon name="checkbox-multiple-marked" color={color} />,
			},
		}],
	
		tabBarOptions: {
			showIcon: true,
			tabStyle: {
				flexDirection: 'row',
			},
		},
	},
}
Previous3.3 Task Create ScreenNext4. CRUD Operations

Last updated 3 years ago

Was this helpful?

Web
iOS
Web
iOS