Design and UI
Through this succint tutorial, we will go through the design and development of a small expense manager in React Native. This app will help a user save and tag expenses on a remote server using a REST API. It will need to store data locally when no Internet connection is available and sync it when a connection is detected.
The following is not intended to be a full tutorial, but rather a compilation of notes and troubleshooting tips.
UI Design
The app will have 3 main screens:
- SplashScreen
- MainScreen containing a list of all the expenses
- AddExpenseScreen where the user can input the amount, category of the expense

Setup Environment
For this app, I am going to use React Native without Expo. You can see why not to use Expo here
Set ANDROID_HOME variable
You will need to make the ANDROID_HOME variable available. You can do this by setting it in the end of ~/.bashrc or ~/.bash_profile files:
1 2 3 4 |
sudo nano ~/.bashrc export ANDROID_HOME=/path/to/Android/Sdk export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools export JAVA_HOME=/usr/lib/jvm/java-8-oracle |
Install dependencies using yarn
If you don’t have yarn installed, head to this page. I do not recommend using npm commands alongside yarn’s.
1 2 3 |
# yarn add global react-native # yarn add global react-native-cli # npm install -g react-native-cli |
Now use the cli to scaffold the app skeleton:
1 |
# react-native init ExpenseManager |
This will generate the following structure:

Run the app
Now test everything by running:
1 |
# react-native run-android |
You will need to run an emulator or plugin a device beforehand.

App Architecture
# Requirement 1: Persistence
https://github.com/rt2zz/redux-persist
# Requirement 2: Offline usage
https://github.com/redux-offline/redux-offline
Create the UI
First, we are going to create the three screens with dummy data.
Create a folder called components at the root of the app’s folder and under components/screens create three files: SplashScreen.js, MainScreen.js and AddExpenseScreen
In order to navigate between all different screens, I am going to use React Native Navigation.
Install it:
1 |
yarn add react-native-navigation --save |
Along with React Native Navigation, we will be using React Native Redux which will offer us the possibility to manage an app wide store state of the app. Install React Native Redux:
1 |
yarn add redux react-redux redux-logger react-native-gesture-handler --save |
redux-logger is quite handy to see the content of the store state
Setup Navigation
Create a new file name Navigator.js in a Navigation folder:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import React from 'react' import SplashScreen from '../components/screens/SplashScreen' import MainScreen from '../components/screens/MainScreen' import AddExpenseScreen from '../components/screens/AddExpenseScreen' import { createStackNavigator, createAppContainer, } from 'react-navigation' const RootStack = createStackNavigator({ SplashScreen: { screen: SplashScreen }, MainScreen: { screen: MainScreen }, AddExpenseScreen: { screen: AddExpenseScreen }, },{ initialRouteName: 'SplashScreen', headerMode: 'none' }) const App = createAppContainer(RootStack) export default App |
Setup the reducer
Add a new file caller Reducer.js at the app’s root folder:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import { Navigator } from './Navigation/Navigator' import { NavigationActions } from 'react-navigation' const initialAction = { type: NavigationActions.Init } const initialState = { expenses: [], isLoading: true }; export default (state = initialState, action) => { return { ...state } } |
We will handle persisting the store state later. Now, import the newly created reducer in the App.js file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import React, { Component } from 'react'; import { createStore, combineReducers, applyMiddleware } from 'redux' import { Provider } from 'react-redux' import logger from 'redux-logger' import Reducer from './Reducer' import Navigator from './Navigation/Navigator' const reducer = combineReducers({ Reducer }) const store = createStore(reducer, applyMiddleware(logger)) export default class App extends Component { render() { return ( <Provider store={store}> <Navigator /> </Provider> ); } } |
Create SplashScreen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
// SplashScreen.js import React, { Component } from 'react' import { StyleSheet, View, Text } from 'react-native' import Colors from '../../utils/Colors' export default class SplashScreen extends Component { render() { return ( <View style={styles.container}> <Text style={styles.title}>Expense Manager</Text> </View> ) } } const styles = StyleSheet.create({ container: { flex:1, backgroundColor: Colors.background, justifyContent: 'center', alignItems: 'center' }, title: { position: 'absolute', fontFamily: 'Roboto', fontStyle: 'normal', fontWeight: 'bold', fontSize: 48, lineHeight: 45, alignSelf: 'center', letterSpacing: -0.02, color: '#FFFFFF' } }) |
The Splash Screen contains a simple text and no significant code. Here is the result:

Now add the logic to transition from SplashScreen to the MainScreen. We will just use a timeout. Add this to the SplashScreen component:
1 2 3 4 5 6 7 |
... componentDidMount(){ setTimeout(()=>{ this.props.navigation.navigate('MainScreen') }, 5000); } ... |
Create MainScreen
The main screen is comprised of 3 components:
- Header
- AddExpense Button
- List of all Expenses
We are going to use the components from React Native Elements. Add the dependencies:
1 2 3 4 5 |
# yarn add react-native-elements --save # yarn add react-native-vector-icons --save # yarn add react-native-config --save # react-native link react-native-config # react-native link react-native-vector-icons |
Checkout this excellent tutorial on how to use flex for designing the UI: https://medium.com/wix-engineering/the-full-react-native-layout-cheat-sheet-a4147802405c
Create AddExpenseScreen
This screen has the following sections:
- A header with two buttons
- An input text for the expense amount
- A list to select the expense category
- A date picker
- A text input for expense comment
Add the following dependencies:
1 2 |
# yarn add react-native-sectioned-multi-select --save # yarn add react-native-datepicker --save |
react-native-sectioned-multi-select is a handy select component which we will use to let the user see a predefined categories list. This list is the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
export default categories = [ { name: "Food", id: 0, children: [ { name: "Food", id: 10, }, { name: "Groceries", id: 20, }, { name: "Other groceries", id: 30, } ] }, { name: "Utility services", id: 1, children: [ { name: "Heating", id: 40, }, { name: "Security", id: 50, }, { name: "Electricity", id: 60, }, { name: "Natural gas", id: 70, }, { name: "Rent", id: 80, }, { name: "Telephone", id: 90, }, { name: "Internet", id: 100, }, { name: "Water", id: 110, }, { name: "Other utility expenses", id: 120, } ] }, { name: "Household", id: 2, children: [ { name: "Home, construction, garden", id: 130, }, { name: "Household goods", id: 140, }, { name: "Household products and electronics", id: 150, } ] }, { name: "Transportation", id: 3, children: [ { name: "Parking", id: 160, }, { name: "Fuel", id: 170, }, { name: "Transportation expenses", id: 180, }, { name: "Vehicle purchase, maintenance", id: 190, } ] }, { name: "Clothing", id: 4, children: [ { name: "Shoes", id: 200, }, { name: "Clothing", id: 210, }, { name: "Other clothing expenses", id: 220, } ] }, { name: "Leisure activities, traveling", id: 5, children: [ { name: "Charity", id: 230, }, { name: "Gifts", id: 240, }, { name: "Books, newspapers, magazines", id: 250, }, { name: "Pets", id: 260, }, { name: "Accommodation, travel expenses", id: 270, }, { name: "Sport and sports goods", id: 280, }, { name: "Theatre, music, cinema", id: 290, }, { name: "Hobbies and other leisure time activities", id: 300, }, { name: "Nightlife", id: 310, } ] }, { name: "Education, health and beauty", id: 6, children: [ { name: "Education and courses", id: 320 }, { name: "Beauty, cosmetics", id: 330 }, { name: "Social security", id: 340 }, { name: "Health and pharmaceuticals", id: 350 }, { name: "Other expenses for education, health, beauty", id: 360 } ] }, { name: "Children", id: 7, children: [ { name: "Children's clothing", id: 370 }, { name: "Hobbies and toys", id: 380 }, { name: "Pocket money", id: 390 }, { name: "School and baby-sitting", id: 400 }, { name: "Other child-related expenses", id: 410 } ] }, { name: "Insurance", id: 8, children: [ { name: "Life insurance", id: 420 }, { name: "Car insurance", id: 430 }, { name: "Home insurance", id: 440 }, { name: "Loan insurance", id: 450 }, ] }, { name: "Loans and financial services", id: 9, children: [ { name: "Financial services and commission", id: 460 }, { name: "Fines", id: 470 }, { name: "Loans", id: 480 }, { name: "Payday loans", id: 490 }, { name: "Consumer loans", id: 500 }, { name: "Leasing", id: 510 }, { name: "Car Leasing", id: 520 }, { name: "Mortgage", id: 530 }, { name: "Credit card repayment", id: 540 }, { name: "Credit line", id: 550 }, { name: "Student loans", id: 560 }, { name: "Overdraft", id: 570 } ] }, { name: "Other", id: 5, children: [ { name: "Other", id: 580 } ] } ] |
The selector is very easy to use:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
... <SectionedMultiSelect items={dataList} uniqueKey='id' single={true} showChips={false} subKey='children' selectText='Choose category...' showDropDowns={true} readOnlyHeadings={true} onSelectedItemsChange={this.onSelectedItemsChange} selectedItems={this.state.expense.category} /> ... |
Similarly the date picker is used like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
... <DatePicker date={this.state.expense.date} mode="date" placeholder="select date" format="DD-MM-YYYY" minDate="01-01-2019" maxDate="01-01-2035" confirmBtnText="Confirm" cancelBtnText="Cancel" onDateChange={this.onDateChange} /> ... |
The screen will look like this. It is a little bit different from the first design but I have found this card based layout a little bit easier to use.

Now that the visual components are done, head to part 2 of this tutorial to see how we fetch data from the API.