Smashing Magazine has published a great 4-part article on how to build a Tip Calculator mobile app using various mobile technologies, one of them being jQuery Mobile + PhoneGap. As Appery.io platform is based on jQuery Mobile + PhoneGap, I figured I will show that it is even faster and easier to build exactly the same app in Appery.io.
Let’s start!
Creating a new mobile app in Appery.io
The first step is to create a new mobile app in Appery.io. If you don’t have an Appery.io account, get the free Starter plan. To create a new mobile app takes just a few seconds. This is how it looks when the app builder loads (with updated theme: flat-ui, swatch: B):
Creating the app UI
The app has two pages:
- Main tip calculations page
- Settings page (popup)
The UI is built by drag and dropping components into the page and setting their properties. This is how the tip page looks:
This is how the settings page (popup) looks:
The page has a Select component to change the tip percent (10%, 15%, 20%).
Performing tip calculations
The Calculate Tip button has a Run JavaScript action defined (on Click event) that does the tip calculations. Here is a screen show which followed by the code:
Code to calculate the tip:
var billAmount = Number(Apperyio("billAmount").val()); if (billAmount === 0) { alert ("Please enter bill amount."); return; } var tipFromSettings = localStorage.getItem('tipPercent'); if (tipFromSettings) { tipPercent = tipFromSettings; } var tipAmount = billAmount * tipPercent/100 ; var totalAmount = billAmount + tipAmount; Apperyio('tipAmount').text('$' + tipAmount.toFixed(2)); Apperyio('totalAmount').text('$' + totalAmount.toFixed(2));
Line 1: Read the value from the input component
Line 3-6: Basic input validation to make sure an amount was entered
Line 8-12: Read the value from local storage. If the value is set, then use it as the tip percent. The tip percent value is saved into local storage in settings popup.
Line 14-15: Perform tip calculations
Line 17-18: Set the tip value and total amount value into the label components (inside the grid)
In the settings popup, when a new percent value is selected (value change event), we save the new value into local storage:
var tip = Apperyio('tipListSettings').val(); localStorage.setItem('tipPercent', tip);
Testing the app
You can test the app right in the browser:
By scanning the QR code (requires a QR code app), you can also test the app directly on the device.
Publishing as HTML5 mobile app
To publish this app as HTML5 mobile app, simply give the app a sub-domain name. You can also publish using a custom domain:
After a few seconds, the app is published and live:
Publishing as PhoneGap app
It’s as easy to build a binary for Android or iOS using PhoneGap:
Once the binary build is done, you will be able to download and then publish the app to the app store.
Summary
Appery.io uses standard mobile technologies such as HTML5, jQuery Mobile, and PhoneGap to create mobile apps. Using a cloud-based visual platform, you dramatically increase speed of development and productivity.
Leave a Reply