Home

Awesome

An advanced Ionic v1.x template

Ionic Framework + Gulp

Introduction

You need to obfuscate your code and reduce the size of your mobile applications. With this project you can work with Gulp in the best way, allowing improve your development workflow. This project seeks to improve the following tasks:

Demo

Do you want to see this starter in action? Visit https://jdnichollsc.github.io/Ionic-Starter-Template/ yay!

Automatically deployed to GitHub Pages using Gulp - Check the last task into gulpfile.js

<img width="242px" height="411px" src="https://s3.amazonaws.com/ionic-marketplace/ionic-starter-template/screenshot_1.png">| <img width="242px" height="411px" src="https://s3.amazonaws.com/ionic-marketplace/ionic-starter-template/screenshot_2.png">| <img width="242px" height="411px" src="https://s3.amazonaws.com/ionic-marketplace/ionic-starter-template/screenshot_3.png"> :---: |:---: |:---: |

Projects using this template

Do you have a project using this template? Let me know to share it with everyone!

Instructions

  1. Download this template.
  2. Execute the command npm install
  3. Execute the command gulp
  4. Run Ionic:
    • ionic serve to test on the browser (Gulp is running by default).
    • ionic run android --livereload to test on the device.
  5. Modify this template and create your hybrid mobile app.
  6. Check the John Papa's Angular Style Guide.

Template Structure

PathExplanation
./app/img/Images in your app.
./app/js/Scripts (Controllers, Services, Directives, etc).
./app/scss/The styles of your app using Sass.
./app/templates/Views in your app. (Only html files)
./app/index.htmlThe init page.
./www/css/Other css styles like Animate.css, etc.
./www/libDownload scripts using bower.

Using bower to download libraries (npm preen included)

"preen": {
	//... More libraries
	"ionic-datepicker": [
		"dist/*.js"
		//Other files and folders will be deleted to reduce the size of your app
	]
}

Animate elements using Animate.css

//Using the Modals service in this template
Modals.openModal($scope, 'templates/modals/users.html', 'animated rotateInDownLeft');
$ionicPopup.alert({
	title: 'Hello World',
	template: 'This is the best template to start with Ionic Framework!',
	cssClass: 'animated bounceInDown'
});

SQLite databases on Android, iOS and Windows (Using cordova-sqlite-ext plugin)

This template include an example (pre-populated database), you can test in the browser using Google Chrome or in your Device.

Cordova SQLite

SQLite examples using Angular Services

var query = "SELECT * FROM Users WHERE Name LIKE '%?%'";
return $q.when($sqliteService.getFirstItem(query, ['Juan']));
var query = "SELECT * FROM Users WHERE Name LIKE '%?%'";
return $q.when($sqliteService.getFirstOrDefaultItem(query, ['Juan']));
var query = "SELECT * FROM Users WHERE Name LIKE '%?%'";
return $q.when($sqliteService.getItems(query, ['Juan']));
var query = "DELETE FROM Users WHERE Name LIKE '%?%'";
return $q.when($sqliteService.executeSql(query, ['Juan']));

Note: If you don't want to use SQLite, you must perform the following steps:

  1. Remove ./www/pre.db file.
  2. Remove ./app/js/queries.js file.
  3. Remove ./app/js/services/sqlite.js file.
  4. Uninstall the plugin using the CLI: ionic plugin rm cordova-sqlite-ext --save
  5. Remove the following line from ./app/js/app.js file:
$sqliteService.preloadDataBase(true);

Ionic Tips

$scope.$on('$ionicView.beforeEnter', function(){
  alert("Before to enter to the view");
});
$scope.$on('$ionicView.afterEnter', function(){
  alert("After to enter to the view");
});
$state.go($state.current, {}, {reload: true});
$ionicHistory.nextViewOptions({
    disableBack: true,
    disableAnimate : true,
    historyRoot  : true
});
$ionicHistory.clearCache();
$ionicHistory.clearHistory();
$ionicViewSwitcher.nextDirection('back');
$state.go("app.login");
$ionicSideMenuDelegate.canDragContent(false);
var deviceInformation = ionic.Platform.device();

var isWebView = ionic.Platform.isWebView();
var isIPad = ionic.Platform.isIPad();
var isIOS = ionic.Platform.isIOS();
var isAndroid = ionic.Platform.isAndroid();
var isWindowsPhone = ionic.Platform.isWindowsPhone();

var currentPlatform = ionic.Platform.platform();
var currentPlatformVersion = ionic.Platform.version();
<div data-tap-disabled="true">
    <div id="google-map"></div>
</div>
$ionicGesture.on('hold', function (e) {
  //Code...
}, element, { hold_threshold: 20 });
ionic.trigger("hold", { target: document.getElementsByClassName("item")[0] });
ionic.DomUtil.requestAnimationFrame(callback); //Calls requestAnimationFrame, or a polyfill if not available.
ionic.DomUtil.getPositionInParent(element);    //Find an element’s scroll offset within its container.
ionic.DomUtil.blurAll();                       //Blurs any currently focused input element.
...
ionic.Platform.ready(function(){
  //Code...
});

Global configuration:

$ionicConfigProvider.scrolling.jsScrolling(false);
$ionicConfigProvider.views.maxCache(5);
$ionicConfigProvider.tabs.position('top');
$ionicConfigProvider.tabs.position('bottom');
$ionicConfigProvider.navBar.alignTitle('center');
$ionicConfigProvider.views.swipeBackEnabled(false);
$ionicConfigProvider.backButton.previousTitleText(false).text('');
ionic.Gestures.gestures.Hold.defaults.hold_threshold = 20;

Crosswalk

Improve the performance of your HTML, CSS, and JavaScript if is required.

CommandAction
ionic browser listShow all the browsers available by platform
ionic browser rm crosswalkRemove a browser
ionic browser add crosswalkInstall the Chromium browser for Android
ionic browser add crosswalk@10.39.235.15Specifies a version of Chromium
ionic browser add crosswalk-liteInstall the Crosswalk lite version
ionic browser revert androidRemove any custom browser that was installed for the platform by replacing it with the system default browser

npm commands

CommandAction
npm i ionic cordova bower gulp -gInstall Ionic, Cordova, Bower and Gulp packages globally
npm cache cleanRemove the cache to force update the packages. Useful to solve npm issues using the CLI.

Ionic commands

CommandAction
ionic loginTo get logged in the CLI and use the Ionic services
ionic uploadUpload your app to Ionic repository and debug remotely (Your clients) using the useful Ionic View App
ionic serveTest on the browser
ionic serve --labTest on the browser iOS and Android version
ionic lib updateUpdate Ionic library files
ionic resourcesGenerate icons and splash screens. The images are located in ./resources/ directory. More info here.
ionic resources --iconGenerate only the icons. icon.png, icon.psd or icon.ai is located in ./resources/ directory
ionic resources --splashGenerate only the splash screens. splash.png, splash.psd or splash.ai is located in ./resources/ directory
ionic resources ios --iconGenerate icons per platform

Cordova commands

CommandAction
cordova platform add androidAdd the platform to build your app. android - ios - windows
cordova platform rm androidRemove the platform
cordova plugin add git_url --saveAdd a plugin to use native capabilities. Native Devs are your friends
cordova plugin listSee the plugins that you're using. Find more here!
cordova plugin rm plugin_name --saveRemove a plugin
cordova build windows -- --appx=8.1-win --archs="x86"Build the app to Windows (Open the Solution platforms/windows/*.sln on Visual Studio)

Tools

NameDescription
Visual Studio CodeBuild and debug your app using a extension
GapDebugOnly debug in the device
GenyMotionBetter Android Emulation

Visual Studio Code commands and shortcuts

Command/ShortcutAction
code .Open the editor from CLI
F1Open the Command Palette
Ctrl + Shift + NOpen other Visual Studio Code instance
Ctrl + }Toogle comment code
Ctrl + ñOpen the Integrated Terminal

Sign to Android (Commands)

  1. cordova build --release android
  2. keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
  3. jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name
  4. zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk

Links

Your code is mine!

Supporting

I believe in Unicorns 🦄 Support me, if you do too.

Happy coding

Made with <3

<img width="150px" src="https://github.com/jdnichollsc/jdnichollsc.github.io/blob/master/assets/nicholls.png?raw=true" align="right">