Giter Club home page Giter Club logo

ionic-starter-template's Introduction

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:

  • Design your application with a maintainable code using Sass and writing less code using Autoprefixer. Concatenate and Minify styles in a stylesheet.
  • Concatenate and Uglify javascript files using Source maps to debug the code easily.
  • Compress images to reduce the size of your application.
  • Compress html templates, respecting your structure.
  • Clean unnecessary files downloaded with Bower.
  • Use CSS animations with Animate.css.
  • Use SQLite with a service pattern. You can use Pre-filled databases.

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

| | :---: |:---: |:---: |

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

Path Explanation
./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.html The init page.
./www/css/ Other css styles like Animate.css, etc.
./www/lib Download scripts using bower.

Using bower to download libraries (npm preen included)

  • Download the script. Eg: bower install ionic-datepicker --save
  • Add the path of the files that you will use in bower.json from www/lib. Eg:
"preen": {
	//... More libraries
	"ionic-datepicker": [
		"dist/*.js"
		//Other files and folders will be deleted to reduce the size of your app
	]
}
  • Run gulp in the CLI. Eg: gulp or gulp lib
  • That's all, folks!!

Animate elements using Animate.css

  • Do you want to animate Modals? This template have an example. More examples here
//Using the Modals service in this template
Modals.openModal($scope, 'templates/modals/users.html', 'animated rotateInDownLeft');
  • Do you want to animate Popups and other elements? See an example:
$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

  • Debug in the browser: Test using the ./app/js/queries.js file to create your queries (Drop tables, create tables, insert data, etc).
  • Debug in the device: Test using the ./www/pre.db file, you can edit the database using DB Browser for SQLite

SQLite examples using Angular Services

  • Returns the first element in a sequence that satisfies a specified condition, throws an exception if no matching element is found in source:
var query = "SELECT * FROM Users WHERE Name LIKE '%?%'";
return $q.when($sqliteService.getFirstItem(query, ['Juan']));
  • Returns the first element of a sequence that satisfies a specified condition, or a default value if the sequence contains no elements:
var query = "SELECT * FROM Users WHERE Name LIKE '%?%'";
return $q.when($sqliteService.getFirstOrDefaultItem(query, ['Juan']));
  • Returns all the elements of a sequence that satisfies a specified condition:
var query = "SELECT * FROM Users WHERE Name LIKE '%?%'";
return $q.when($sqliteService.getItems(query, ['Juan']));
  • Execute a SQL query:
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

  • Ionic View LifeCycle: More here
$scope.$on('$ionicView.beforeEnter', function(){
  alert("Before to enter to the view");
});
$scope.$on('$ionicView.afterEnter', function(){
  alert("After to enter to the view");
});
  • Reload the current state:
$state.go($state.current, {}, {reload: true});
  • Disable the back option before to navigate to other state:
$ionicHistory.nextViewOptions({
    disableBack: true,
    disableAnimate : true,
    historyRoot  : true
});
  • Clear the cache:
$ionicHistory.clearCache();
  • Clear the history:
$ionicHistory.clearHistory();
  • Change the direction before to navigate to other state:
$ionicViewSwitcher.nextDirection('back');
  • Navigate to other state:
$state.go("app.login");
  • Disable the drag to open the side menu:
$ionicSideMenuDelegate.canDragContent(false);
  • Check the current platform
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();
  • Disabling the tap system (To disable the tap for an element and all of its children elements)
<div data-tap-disabled="true">
    <div id="google-map"></div>
</div>
  • Using Ionic gestures (Events) with options from Angular Directives
$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.
...
  • Execute when device is ready
ionic.Platform.ready(function(){
  //Code...
});

Global configuration:

  • Enable the native scrolling (Enable or Disable jsScrolling):
$ionicConfigProvider.scrolling.jsScrolling(false);
  • Set the Maximum number of view elements to cache in the DOM:
$ionicConfigProvider.views.maxCache(5);
  • Select the position of the tabs
$ionicConfigProvider.tabs.position('top');
$ionicConfigProvider.tabs.position('bottom');
  • Center align the title in the navBar:
$ionicConfigProvider.navBar.alignTitle('center');
  • Disable swipeback on iOS:
$ionicConfigProvider.views.swipeBackEnabled(false);
  • Set the back button text to empty:
$ionicConfigProvider.backButton.previousTitleText(false).text('');
  • Change global Ionic gestures options:
ionic.Gestures.gestures.Hold.defaults.hold_threshold = 20;
  • Platform Customization

    Platform CSS Class
    Browser platform-browser
    Cordova platform-cordova
    Webview platform-webview
    iOS platform-ios
    iPad platform-ipad
    Android platform-android
    Windows Phone platform-windowsphone
    • Dynamically Loading Templates
    .state('tab', {
      templateUrl: function() {
        if (ionic.Platform.isAndroid()) {
            return  "templates/home-android.html";
        }
        return "templates/home.html";
      }
    });

Crosswalk

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

Command Action
ionic browser list Show all the browsers available by platform
ionic browser rm crosswalk Remove a browser
ionic browser add crosswalk Install the Chromium browser for Android
ionic browser add [email protected] Specifies a version of Chromium
ionic browser add crosswalk-lite Install the Crosswalk lite version
ionic browser revert android Remove any custom browser that was installed for the platform by replacing it with the system default browser

npm commands

Command Action
npm i ionic cordova bower gulp -g Install Ionic, Cordova, Bower and Gulp packages globally
npm cache clean Remove the cache to force update the packages. Useful to solve npm issues using the CLI.

Ionic commands

Command Action
ionic login To get logged in the CLI and use the Ionic services
ionic upload Upload your app to Ionic repository and debug remotely (Your clients) using the useful Ionic View App
ionic serve Test on the browser
ionic serve --lab Test on the browser iOS and Android version
ionic lib update Update Ionic library files
ionic resources Generate icons and splash screens. The images are located in ./resources/ directory. More info here.
ionic resources --icon Generate only the icons. icon.png, icon.psd or icon.ai is located in ./resources/ directory
ionic resources --splash Generate only the splash screens. splash.png, splash.psd or splash.ai is located in ./resources/ directory
ionic resources ios --icon Generate icons per platform

Cordova commands

Command Action
cordova platform add android Add the platform to build your app. android - ios - windows
cordova platform rm android Remove the platform
cordova plugin add git_url --save Add a plugin to use native capabilities. Native Devs are your friends
cordova plugin list See the plugins that you're using. Find more here!
cordova plugin rm plugin_name --save Remove 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

Name Description
Visual Studio Code Build and debug your app using a extension
GapDebug Only debug in the device
GenyMotion Better Android Emulation

Visual Studio Code commands and shortcuts

Command/Shortcut Action
code . Open the editor from CLI
F1 Open the Command Palette
Ctrl + Shift + N Open 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

ionic-starter-template's People

Contributors

alsastre avatar gianpaj avatar jdnichollsc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ionic-starter-template's Issues

Estructura por componentes

Hola

Seria genial que la estrucutra trabajara por componentes, con ello al remover uno tan solo es quitar una carpeta ejemplo:

home/ home.sass home.tpl.html home.js

about/ about.sass about.tpl.html about.js

Saludos!

Two template folders?

Hey man, everything working great so far! Was curious, what is the diifference b/w app/templates and www/templates. Seems app/templates is the rendered template, but www/templates still needs to be populated for a view to work. Any input?

URL parameters preventing the view to load

Hi there, we are started using your template to build a mobile app. We are having some problem with passing variables on the query string in app.js. It's working fine in ionic blank and Ionic Material projects.

Here is my sample code on app.js

.state('app.subservice', { url: "/subservice/:subserviceId/", cache: false, views: { viewContent: { templateUrl: "templates/subservice.html", controller: 'SubServiceController' } } })

The problem is when I try to access http://localhost:8100/#/app/subservice/3 or just http://localhost:8100/#/app/subservice/ it redirect back to the default state. But when I removed the "/:subserviceId" and try to access http://localhost:8100/#/app/subservice/ then it works fine.

I really appreciate your help!

Ionic 2.0 and gulp?

Hey I just updated to Ionic 2.0 and gulp doesn't seem to be rebuilding on file change. Ionic reloads when files change but gulp doesn't log any of the stuff it normally does (scripts built, templates built, etc).

Any idea? I'm a huge noob when it comes to gulp and only finally becoming moderately comfortable with Ionic :(

Sass changes but not gulp .scss files again - ionic serve

When I change my files (.js, .html), it gulp again these files and show me the change in live preview (ionic serve). But when I change .scss files, it only update the page, but not gulp again my .scss files, forcing me to stop "ionic serve", type "gulp" process, and type "ionic serve" again. But it causes me a lot of time in .scss files changes. How could I fix it?

Thanks in advance!

Update version in market

The version in the ionic market should be updated or at least specified in the description that the lastest version can be found on github

Db Transactions only execute in browser

Hi,

I've been using your starter template (It's great, thanks). I noticed when deployed to a device (Android) the "preload" database transactions specified do not execute unless it is in the browser.

This appears to be because we only execute the pre-defined transactions if
if (window.sqlitePlugin === undefined) {

Line 75: https://github.com/jdnichollsc/Ionic-Starter-Template/blob/master/app/js/services/sqlite.js

In the self.db method we already handle getting a database based on it being in app (and window.sqlitePlugin` being available or running in the browser. I don't think there is a need to check that the plugin is undefined before executing the preloading statements, without it, it appears to work fine.

I changed your version of the SQL Lite service to get an instance of the database, create (if not exists) a version history table, and then migrate from the current version to the new version if it is behind, this enables me to deploy SQL Updates to future versions of the app instead of running into problems later.

Cheers
Lee

I cannot Install you template

Hello,

I'm trying to use your awesome template but I find this error on using npm install:

npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

The link to that plugin is down and I dont know what to do: I have node-sass 4.9 installed but your templated is still requiring that specific version.

Thanks in advanced,

Alex.

Sqlite database prepopulated on android device

Hi, the template is great and it works fine on browser but I cant check it on my device (moto g) .Basically I need load a old sqlite file (with 4 big tables) and execute some sql queries, but Im not sure how debug it . On a first view it dont load the queries on my device but works fine on chrome browser (with web databases) Please, let me know if you can recommend me some tool or solution so i can check what happens and help on the development of this great project.

More than one table in model

I have extended your project, i have added another tables into database (Items, Customers, Invoices etc) and created new Items.js, Customers.js (Its same like users.js but modified for this tables)
How to modify model.js factory to work with this situation.
Ex: Model.Items.getall() or Model.Customerc.getall()

Understanding the code

Hello, I am new to developing angular / ionic and I try to understand how the prepopulated database in your example works. I tried to replicate this in a minimal example, but my database is always empty when I run the code in an android emulator. Your example works in the emulator.

What steps are necessary for a prepopulated database to work?

  • adding cordova-sqlite-ext via ionic plugin add link-to-git-repo
  • having the database in folder \www
  • accessing the database after device-ready-event

Did I miss anything out?

Any help would be much appriciated.

A module out of date?

This happened both times I installed it (on two separate servers): errors about gulp-notify and send-notify.

I cd'd into node_modules/gulp-notify ran npm install and npm update

and same in top lvl ionic template dir.

npm install -g cordova ionic

then

npm update -g

npm install -g ionic

then I logged in with Ionic

so it's either a module out of date in my -g modules or locally not quite sure. Im also not fully sure which combination of the following worked... sorry :(

Other than 1 minor other problem, I've hit no problems so far! Great stuff!

Sobreescribiendo Variables de Ionic

Buenos dias.
Estoy usando tu plantilla pero tengo un problema.
Necesito sobreescribir los valores de las variables sass de ionic como $dark o $royal, esto lo estoy intentando hacer desde un archivo sass ubicado en la ruta app/sass, es necesario incluirle algun tipo de configuracion extra para que lo detecte?

bower install

Hi Nicholls.

Is there any more detail you can add with populating 3rd party dependencies?

I am struggling and am sure I am just not understanding gulp. Just simply adding the basic example you are using, I run bower install ionic-datepicker --save in terminal and then update my bower.json file with
"ionic-datepicker": ["dist/*.js" ]. Followed by gulp in my terminal. It will not function.

Do I still need to update/inject in my index.html file like normal as well? Inject it into my app.js file? I notice as well you have injections inside the controllers? I have been plugging them in and out of all the spots and not getting a result.

Help would be greatly appreciated. Thanks, Cameron .

Failed to load “page” resource: Could not connect to the server (iOS app)

I don't know if this is a problem directly related to this template but I'm having a strange problem with my iOS App.

In my iOS device App, I'm having the following problem after I let my app a few moment in background and return to it:

screen shot 2017-05-12 at 6 30 58 pm

This image is from iOS device. I inspected from Safari.

I can use the app normally, and all the screens work well. But if I minimize the app pressing the home button on device, and wait a few moment and try to open again, the screens not load and I have errors similar to the errors of the screenshot. To solve this in the moment, it forces the user to close the app and open again to reload. Why does it happen? How can I solve this?

Thanks.

Fix Auto reload (watch)

I just started with ionic and first of all I want to thank you for your great template.
I have cloned the last github version and with the lastest version of ionic (3.19.0) the browser (ionic serve) won't update to changes in the app directory.
Investigating the problem I have found a solution here: https://forum.ionicframework.com/t/ionic-cli-doesnt-run-gulp-tasks-on-ionic-serve/49085/26
and it consist on changing the line 34 of the gulpfile.js gulp.task('serve:before', ['watch']);
for gulp.task('ionic:watch:before', ['watch'])
Thank you and great work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.