In this article by Zainul Setyo Pamungkas, author of the book PhoneGap 4 Mobile Application Development Cookbook, we will see how Ionic framework is one of the most popular HTML5 framework for hybrid application development. Ionic framework provides native such as the UI component that user can use and customize.
(For more resources related to this topic, see here.)
In this article, we will create a clone of Instagram mobile app layout:
ionic start ionSnap tabs
cd ionSnap
ionic platform add ios
ionic platform add android
<ion-tabs class="tabs-icon-top tabs-color-active-positive">
<ion-tab title="Timeline" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/dash">
<ion-nav-view name="tab-dash"></ion-nav-view>
</ion-tab>
<ion-tab title="Explore" icon-off="ion-ios-search" icon-on="ion-ios-search" href="#/tab/chats">
<ion-nav-view name="tab-chats"></ion-nav-view>
</ion-tab>
<ion-tab title="Profile" icon-off="ion-ios-person-outline" icon-on="ion-person" href="#/tab/account">
<ion-nav-view name="tab-account"></ion-nav-view>
</ion-tab>
</ion-tabs>
<ion-view view-title="Timeline">
<ion-content class="padding">
</ion-content>
</ion-view>
<ion-view view-title="Explore">
<ion-content>
</ion-content>
</ion-view>
<ion-view view-title="Profile">
<ion-content>
</ion-content>
</ion-view>
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope) {})
.controller('ChatsCtrl', function($scope, Chats) {
})
.controller('ChatDetailCtrl', function($scope, $stateParams, Chats) {
})
.controller('AccountCtrl', function($scope) {
});
<ion-view view-title="Timelines">
<ion-content class="has-header">
<div class="list card">
<div class="item item-avatar">
<img src="http://placehold.it/50x50">
<h2>Some title</h2>
<p>November 05, 1955</p>
</div>
<div class="item item-body">
<img class="full-image" src="http://placehold.it/500x500">
<p>
<a href="#" class="subdued">1 Like</a>
<a href="#" class="subdued">5 Comments</a>
</p>
</div>
<div class="item tabs tabs-secondary tabs-icon-left">
<a class="tab-item" href="#">
<i class="icon ion-heart"></i> Like
</a>
<a class="tab-item" href="#">
<i class="icon ion-chatbox"></i> Comment
</a>
<a class="tab-item" href="#">
<i class="icon ion-share"></i> Share
</a>
</div>
</div>
</ion-content>
</ion-view>
Our timeline view will be like this:
.profile ul {
list-style-type: none;
}
.imageholder {
width: 100%;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;
}
.profile li img {
float: left;
border: 5px solid #fff;
width: 30%;
height: 10%;
-webkit-transition: box-shadow 0.5s ease;
-moz-transition: box-shadow 0.5s ease;
-o-transition: box-shadow 0.5s ease;
-ms-transition: box-shadow 0.5s ease;
transition: box-shadow 0.5s ease;
}
.profile li img:hover {
-webkit-box-shadow: 0px 0px 7px rgba(255, 255, 255,
0.9);
box-shadow: 0px 0px 7px rgba(255, 255, 255, 0.9);
}
<ion-view view-title="Explore">
<ion-content>
<ul class="profile" style="margin-left:5%;">
<li class="profile">
<a href="#"><img src="http://placehold.it/50x50"></a>
</li>
<li class="profile" style="list-style-type: none;">
<a href="#"><img src="http://placehold.it/50x50"></a>
</li>
<li class="profile" style="list-style-type: none;">
<a href="#"><img src="http://placehold.it/50x50"></a>
</li>
<li class="profile" style="list-style-type: none;">
<a href="#"><img src="http://placehold.it/50x50"></a>
</li>
<li class="profile" style="list-style-type: none;">
<a href="#"><img src="http://placehold.it/50x50"></a>
</li>
<li class="profile" style="list-style-type: none;">
<a href="#"><img src="http://placehold.it/50x50"></a>
</li>
</ul>
</ion-content>
</ion-view>
Now, our explore page will look like this:
.text-white{
color:#fff;
}
.profile-pic {
width: 30%;
height: auto;
display: block;
margin-top: -50%;
margin-left: auto;
margin-right: auto;
margin-bottom: 20%;
border-radius: 4em 4em 4em / 4em 4em;
}
<ion-content>
<div class="user-profile" style="width:100%;heigh:auto;background-color:#fff;float:left;">
<img src="img/cover.jpg">
<div class="avatar">
<img src="img/ionic.png" class="profile-pic">
<ul>
<li>
<p class="text-white text-center" style="margin-top:-15%;margin-bottom:10%;display:block;">@ionsnap, 6 Pictures</p>
</li>
</ul>
</div>
</div>
…
<ul class="profile" style="margin-left:5%;">
<li class="profile">
<a href="#"><img src="http://placehold.it/100x100"></a>
</li>
<li class="profile" style="list-style-type: none;">
<a href="#"><img src="http://placehold.it/100x100"></a>
</li>
<li class="profile" style="list-style-type: none;">
<a href="#"><img src="http://placehold.it/100x100"></a>
</li>
<li class="profile" style="list-style-type: none;">
<a href="#"><img src="http://placehold.it/100x100"></a>
</li>
<li class="profile" style="list-style-type: none;">
<a href="#"><img src="http://placehold.it/100x100"></a>
</li>
<li class="profile" style="list-style-type: none;">
<a href="#"><img src="http://placehold.it/100x100"></a>
</li>
</ul>
</ion-content>
Our profile page will now look like this:
In this article we have seen steps to create Instagram clone with an Ionic framework with the help of an example.
If you are a developer who wants to get started with mobile application development using PhoneGap, then this article is for you. Basic understanding of web technologies such as HTML, CSS and JavaScript is a must.