├── .bowerrc ├── .gitignore ├── README.md ├── bower.json ├── config.xml ├── gulpfile.js ├── hooks ├── README.md ├── after_platform_add │ └── 010_install_plugins.js ├── after_plugin_add │ └── 010_register_plugin.js ├── after_plugin_rm │ └── 010_deregister_plugin.js ├── after_prepare │ ├── 010_add_platform_class.js │ └── 020_remove_sass_from_platforms.js └── before_platform_add │ └── init_directories.js ├── ionic.config.json ├── package.json ├── screens ├── last checkout.jpg ├── login.jpg ├── main.jpg ├── main2.jpg └── splash.jpg ├── scss └── ionic.app.scss └── www ├── css └── style.css ├── img ├── ionic.png └── output_LoXQFP.gif ├── index.html ├── js ├── app.js ├── controllers │ ├── accountsController.js │ ├── cartController.js │ ├── dashController.js │ └── restNameController.js └── services │ ├── cartFactory.js │ ├── dataFactory.js │ └── userFactory.js └── templates ├── cart.html ├── tab-account.html ├── tab-dash.html ├── tab-rest-name.html └── tabs.html /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "www/lib" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | 3 | # http://git-scm.com/docs/gitignore 4 | 5 | 6 | node_modules/ 7 | 8 | platforms/ 9 | 10 | plugins/ 11 | 12 | .idea/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TheFoodShop 2 | 3 | >Using Ionic and Firebase, It's a Real-Time food court app where user can order food from different restaurants menu. 4 | >With Facebook SignIn Integration and local auth login system. 5 | >Changes occur real time. 6 | >An Ionic framework/cordova project. 7 | >Backend implemention on firebase. 8 | 9 | 10 | --- 11 | Please feel free to report an **Issue** or ask for a **feature** that you want to see in this project Or a **Pull Request** would be welcome. 12 | 13 | 14 | # Screen Shots of the App 15 | 16 | 17 | 18 | 19 | ## Pre Requisites 20 | 1. Node.js 21 | 2. Cordova 22 | 3. Ionic 23 | 4. Bower 24 | 25 | ## Installation 26 | Clone this repository 27 | ```bash 28 | $ git clone https://github.com/mjunaidsalaat/TheFoodShop.git 29 | $ cd TheFoodShop 30 | $ bower install 31 | 32 | $ ionic serve 33 | // locally serve ionic project 34 | 35 | // SignUp or Use email: 'mj@mj.com' pass : 'mj' for quick access. 36 | ``` 37 | 38 | ```bash 39 | $ ionic platform add android 40 | // add android platform 41 | ``` 42 | 43 | ```bash 44 | $ ionic build android 45 | // An android-debug.apk file will be generated in the "android\build\outputs\apk" 46 | ``` 47 | 48 | OR 49 | 50 | ```bash 51 | $ ionic run android 52 | // To run apk directly to the connected phone 53 | ``` 54 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "myChatApp", 3 | "private": "true", 4 | "devDependencies": { 5 | "ionic": "driftyco/ionic-bower#1.3.1" 6 | }, 7 | "dependencies": { 8 | "angularfire": "1.2.0", 9 | "firebase": "2.4.2", 10 | "ngCordova": "^0.1.26-alpha" 11 | } 12 | } -------------------------------------------------------------------------------- /config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TheFoodShop 4 | 5 | An Ionic Framework and Cordova project with FireBase Implementation. 6 | 7 | 8 | M. Junaid Salaat 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var gutil = require('gulp-util'); 3 | var bower = require('bower'); 4 | var concat = require('gulp-concat'); 5 | var sass = require('gulp-sass'); 6 | var minifyCss = require('gulp-minify-css'); 7 | var rename = require('gulp-rename'); 8 | var sh = require('shelljs'); 9 | 10 | var paths = { 11 | sass: ['./scss/**/*.scss'] 12 | }; 13 | 14 | gulp.task('default', ['sass']); 15 | 16 | gulp.task('sass', function(done) { 17 | gulp.src('./scss/ionic.app.scss') 18 | .pipe(sass()) 19 | .pipe(gulp.dest('./www/css/')) 20 | .pipe(minifyCss({ 21 | keepSpecialComments: 0 22 | })) 23 | .pipe(rename({ extname: '.min.css' })) 24 | .pipe(gulp.dest('./www/css/')) 25 | .on('end', done); 26 | }); 27 | 28 | gulp.task('watch', function() { 29 | gulp.watch(paths.sass, ['sass']); 30 | }); 31 | 32 | gulp.task('install', ['git-check'], function() { 33 | return bower.commands.install() 34 | .on('log', function(data) { 35 | gutil.log('bower', gutil.colors.cyan(data.id), data.message); 36 | }); 37 | }); 38 | 39 | gulp.task('git-check', function(done) { 40 | if (!sh.which('git')) { 41 | console.log( 42 | ' ' + gutil.colors.red('Git is not installed.'), 43 | '\n Git, the version control system, is required to download Ionic.', 44 | '\n Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.', 45 | '\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.' 46 | ); 47 | process.exit(1); 48 | } 49 | done(); 50 | }); 51 | -------------------------------------------------------------------------------- /hooks/README.md: -------------------------------------------------------------------------------- 1 | 21 | # Cordova Hooks 22 | 23 | This directory may contain scripts used to customize cordova commands. This 24 | directory used to exist at `.cordova/hooks`, but has now been moved to the 25 | project root. Any scripts you add to these directories will be executed before 26 | and after the commands corresponding to the directory name. Useful for 27 | integrating your own build systems or integrating with version control systems. 28 | 29 | __Remember__: Make your scripts executable. 30 | 31 | ## Hook Directories 32 | The following subdirectories will be used for hooks: 33 | 34 | after_build/ 35 | after_compile/ 36 | after_docs/ 37 | after_emulate/ 38 | after_platform_add/ 39 | after_platform_rm/ 40 | after_platform_ls/ 41 | after_plugin_add/ 42 | after_plugin_ls/ 43 | after_plugin_rm/ 44 | after_plugin_search/ 45 | after_prepare/ 46 | after_run/ 47 | after_serve/ 48 | before_build/ 49 | before_compile/ 50 | before_docs/ 51 | before_emulate/ 52 | before_platform_add/ 53 | before_platform_rm/ 54 | before_platform_ls/ 55 | before_plugin_add/ 56 | before_plugin_ls/ 57 | before_plugin_rm/ 58 | before_plugin_search/ 59 | before_prepare/ 60 | before_run/ 61 | before_serve/ 62 | pre_package/ <-- Windows 8 and Windows Phone only. 63 | 64 | ## Script Interface 65 | 66 | All scripts are run from the project's root directory and have the root directory passes as the first argument. All other options are passed to the script using environment variables: 67 | 68 | * CORDOVA_VERSION - The version of the Cordova-CLI. 69 | * CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios). 70 | * CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer) 71 | * CORDOVA_HOOK - Path to the hook that is being executed. 72 | * CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate) 73 | 74 | If a script returns a non-zero exit code, then the parent cordova command will be aborted. 75 | 76 | 77 | ## Writing hooks 78 | 79 | We highly recommend writting your hooks using Node.js so that they are 80 | cross-platform. Some good examples are shown here: 81 | 82 | [http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/) 83 | 84 | -------------------------------------------------------------------------------- /hooks/after_platform_add/010_install_plugins.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Install all plugins listed in package.json 5 | * https://raw.githubusercontent.com/diegonetto/generator-ionic/master/templates/hooks/after_platform_add/install_plugins.js 6 | */ 7 | var exec = require('child_process').exec; 8 | var path = require('path'); 9 | var sys = require('sys'); 10 | 11 | var packageJSON = null; 12 | 13 | try { 14 | packageJSON = require('../../package.json'); 15 | } catch(ex) { 16 | console.log('\nThere was an error fetching your package.json file.') 17 | console.log('\nPlease ensure a valid package.json is in the root of this project\n') 18 | return; 19 | } 20 | 21 | var cmd = process.platform === 'win32' ? 'cordova.cmd' : 'cordova'; 22 | // var script = path.resolve(__dirname, '../../node_modules/cordova/bin', cmd); 23 | 24 | packageJSON.cordovaPlugins = packageJSON.cordovaPlugins || []; 25 | packageJSON.cordovaPlugins.forEach(function (plugin) { 26 | exec('cordova plugin add ' + plugin, function (error, stdout, stderr) { 27 | sys.puts(stdout); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /hooks/after_plugin_add/010_register_plugin.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Push plugins to cordovaPlugins array after_plugin_add 5 | */ 6 | var fs = require('fs'), 7 | packageJSON = require('../../package.json'), 8 | path = require('path'); 9 | 10 | packageJSON.cordovaPlugins = packageJSON.cordovaPlugins || []; 11 | process.env.CORDOVA_PLUGINS.split(',').forEach(function (plugin) { 12 | var configString, 13 | idRegEx, 14 | id, 15 | pluginXmlPath, 16 | pluginToAdd; 17 | 18 | if(plugin.indexOf('https') != -1 || plugin.indexOf('git') != -1) { 19 | console.log('Installing plugin from url'); 20 | } 21 | 22 | if(plugin.indexOf('/') != -1) { 23 | try { 24 | pluginXmlPath = path.resolve(plugin, 'plugin.xml'); 25 | console.log('got pluginXmlPath:', pluginXmlPath); 26 | if (!fs.existsSync(pluginXmlPath)) { 27 | var errorMessage = ['There was no plugin.xml file found for path: ', pluginXmlPath].join(''); 28 | return; 29 | } 30 | 31 | configString = fs.readFileSync(pluginXmlPath,{encoding: 'utf8'}); 32 | idRegEx = new RegExp(']*id="(.*)"', 'i'); 33 | id = idRegEx.exec(configString)[1] 34 | pluginToAdd = {id: id, locator: plugin}; 35 | } catch(ex) { 36 | console.log('There was an error retrieving the plugin.xml filr from the 010_register_plugin.js hook', ex); 37 | } 38 | } else { 39 | pluginToAdd = plugin; 40 | } 41 | 42 | if(typeof pluginToAdd == 'string' && packageJSON.cordovaPlugins.indexOf(pluginToAdd) == -1) { 43 | packageJSON.cordovaPlugins.push(pluginToAdd); 44 | } else if (typeof pluginToAdd == 'object') { 45 | var pluginExists = false; 46 | packageJSON.cordovaPlugins.forEach(function(checkPlugin) { 47 | if(typeof checkPlugin == 'object' && checkPlugin.id == pluginToAdd.id) { 48 | pluginExists = true; 49 | } 50 | }) 51 | if(!pluginExists) { 52 | packageJSON.cordovaPlugins.push(pluginToAdd); 53 | } 54 | } 55 | }); 56 | 57 | fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2)); 58 | -------------------------------------------------------------------------------- /hooks/after_plugin_rm/010_deregister_plugin.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Remove plugins from cordovaPlugins array after_plugin_rm 5 | */ 6 | var fs = require('fs'); 7 | var packageJSON = require('../../package.json'); 8 | 9 | packageJSON.cordovaPlugins = packageJSON.cordovaPlugins || []; 10 | 11 | process.env.CORDOVA_PLUGINS.split(',').forEach(function (plugin) { 12 | var index = packageJSON.cordovaPlugins.indexOf(plugin); 13 | if (index > -1) { 14 | packageJSON.cordovaPlugins.splice(index, 1); 15 | } else { 16 | //If it didnt find a match, it may be listed as {id,locator} 17 | for(var i = 0, j = packageJSON.cordovaPlugins.length; i < j; i++) { 18 | var packagePlugin = packageJSON.cordovaPlugins[i]; 19 | if(typeof packagePlugin == 'object' && packagePlugin.id == plugin) { 20 | packageJSON.cordovaPlugins.splice(index, 1); 21 | break; 22 | } 23 | } 24 | } 25 | }); 26 | 27 | fs.writeFile('package.json', JSON.stringify(packageJSON, null, 2)); 28 | -------------------------------------------------------------------------------- /hooks/after_prepare/010_add_platform_class.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // Add Platform Class 4 | // v1.0 5 | // Automatically adds the platform class to the body tag 6 | // after the `prepare` command. By placing the platform CSS classes 7 | // directly in the HTML built for the platform, it speeds up 8 | // rendering the correct layout/style for the specific platform 9 | // instead of waiting for the JS to figure out the correct classes. 10 | 11 | var fs = require('fs'); 12 | var path = require('path'); 13 | 14 | var rootdir = process.argv[2]; 15 | 16 | function addPlatformBodyTag(indexPath, platform) { 17 | // add the platform class to the body tag 18 | try { 19 | var platformClass = 'platform-' + platform; 20 | var cordovaClass = 'platform-cordova platform-webview'; 21 | 22 | var html = fs.readFileSync(indexPath, 'utf8'); 23 | 24 | var bodyTag = findBodyTag(html); 25 | if(!bodyTag) return; // no opening body tag, something's wrong 26 | 27 | if(bodyTag.indexOf(platformClass) > -1) return; // already added 28 | 29 | var newBodyTag = bodyTag; 30 | 31 | var classAttr = findClassAttr(bodyTag); 32 | if(classAttr) { 33 | // body tag has existing class attribute, add the classname 34 | var endingQuote = classAttr.substring(classAttr.length-1); 35 | var newClassAttr = classAttr.substring(0, classAttr.length-1); 36 | newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote; 37 | newBodyTag = bodyTag.replace(classAttr, newClassAttr); 38 | 39 | } else { 40 | // add class attribute to the body tag 41 | newBodyTag = bodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">'); 42 | } 43 | 44 | html = html.replace(bodyTag, newBodyTag); 45 | 46 | fs.writeFileSync(indexPath, html, 'utf8'); 47 | 48 | process.stdout.write('add to body class: ' + platformClass + '\n'); 49 | } catch(e) { 50 | process.stdout.write(e); 51 | } 52 | } 53 | 54 | function findBodyTag(html) { 55 | // get the body tag 56 | try{ 57 | return html.match(/])(.*?)>/gi)[0]; 58 | }catch(e){} 59 | } 60 | 61 | function findClassAttr(bodyTag) { 62 | // get the body tag's class attribute 63 | try{ 64 | return bodyTag.match(/ class=["|'](.*?)["|']/gi)[0]; 65 | }catch(e){} 66 | } 67 | 68 | if (rootdir) { 69 | 70 | // go through each of the platform directories that have been prepared 71 | var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []); 72 | 73 | for(var x=0; xa>i{ 79 | color:#ffffff !important; 80 | } 81 | .tab-nav.tabs>a.tab-item-active>i{ 82 | color:#ef473a !important; 83 | } 84 | .tab-nav.tabs{ 85 | background-color: rgb(51, 51, 51) !important; 86 | border-top-color: #ef473a;; 87 | } 88 | .ratingAlignment{ 89 | float: right; 90 | margin-right: -40px !important; 91 | } 92 | .removeLinkBtn{ 93 | position: absolute; 94 | right: 0; 95 | z-index: 1000; 96 | top: 0; 97 | } -------------------------------------------------------------------------------- /www/img/ionic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JSalaat/TheFoodShop/b125b6611960b3e2b753b0764b18283e0c65dbbb/www/img/ionic.png -------------------------------------------------------------------------------- /www/img/output_LoXQFP.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JSalaat/TheFoodShop/b125b6611960b3e2b753b0764b18283e0c65dbbb/www/img/output_LoXQFP.gif -------------------------------------------------------------------------------- /www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 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 | -------------------------------------------------------------------------------- /www/js/app.js: -------------------------------------------------------------------------------- 1 | 2 | var foodShop = angular.module('foodShop', ['ionic','firebase','ngCordova']) 3 | 4 | .run(function($ionicPlatform,$rootScope) { 5 | $rootScope.cart = []; 6 | 7 | $ionicPlatform.ready(function() { 8 | if (window.cordova && window.cordova.plugins.Keyboard) { 9 | cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); 10 | } 11 | if (window.StatusBar) { 12 | StatusBar.styleDefault(); 13 | } 14 | }); 15 | }) 16 | 17 | .config(function($stateProvider, $urlRouterProvider) { 18 | 19 | $stateProvider 20 | 21 | .state('tab', { 22 | url: "/tab", 23 | abstract: true, 24 | templateUrl: "templates/tabs.html" 25 | }) 26 | 27 | 28 | .state('tab.dash', { 29 | url: '/dash', 30 | cache: false, 31 | views: { 32 | 'tab-dash': { 33 | templateUrl: 'templates/tab-dash.html', 34 | controller: 'dashController' 35 | } 36 | } 37 | }) 38 | 39 | .state('tab.restName', { 40 | url: '/dash/:id', 41 | views: { 42 | 'tab-dash': { 43 | templateUrl: 'templates/tab-rest-name.html', 44 | controller: 'restNameController' 45 | } 46 | } 47 | }) 48 | 49 | .state('tab.cart', { 50 | url: '/cart', 51 | views: { 52 | 'tab-dash': { 53 | templateUrl: 'templates/cart.html', 54 | controller: 'cartController' 55 | } 56 | } 57 | }) 58 | 59 | .state('tab.account', { 60 | url: '/account', 61 | views: { 62 | 'tab-account': { 63 | templateUrl: 'templates/tab-account.html', 64 | controller: 'accountsController' 65 | } 66 | } 67 | }); 68 | 69 | $urlRouterProvider.otherwise('/tab/account'); 70 | 71 | }); 72 | 73 | foodShop.config(['$ionicConfigProvider', function($ionicConfigProvider) { 74 | 75 | $ionicConfigProvider.tabs.position('bottom'); 76 | 77 | }]); 78 | -------------------------------------------------------------------------------- /www/js/controllers/accountsController.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by M.JUNAID on 2015-03-10. 3 | */ 4 | 5 | foodShop.controller('accountsController', function($scope, $ionicPopup, $ionicLoading, userFactory) { 6 | 7 | $scope.user = {}; 8 | $scope.myUser = userFactory.getAuthData(); 9 | 10 | $scope.register = function (user) { 11 | 12 | if (user.email && user.password){ 13 | 14 | $scope.show(); 15 | userFactory.createUser(user) 16 | .then(function () { 17 | console.log('user created'); 18 | $scope.login(user); 19 | $scope.hide(); 20 | }, function (error) { 21 | console.log('user creation error', error); 22 | $scope.hide(); 23 | }) 24 | } 25 | else{ 26 | $ionicPopup.alert({ 27 | title: 'Invalid Parameters', 28 | template: 'Please fill both Fields above.' 29 | }) 30 | } 31 | 32 | }; 33 | 34 | $scope.login = function (user) { 35 | 36 | if (user.email && user.password) { 37 | 38 | $scope.show(); 39 | userFactory.login(user) 40 | .then(function (data) { 41 | console.log('user logged in', data); 42 | $scope.myUser = userFactory.getAuthData(); 43 | $scope.hide(); 44 | }, function (error) { 45 | console.log('user login error', error); 46 | $scope.hide(); 47 | }) 48 | } 49 | else{ 50 | $ionicPopup.alert({ 51 | title: 'Invalid Parameters', 52 | template: 'Please fill both Fields above.' 53 | }) 54 | } 55 | }; 56 | 57 | 58 | $scope.logout = function () { 59 | $scope.user = {}; 60 | userFactory.logout(); 61 | $scope.myUser = userFactory.getAuthData(); 62 | }; 63 | 64 | $scope.fb = function () { 65 | $scope.show(); 66 | userFactory.loginWithFb() 67 | .then(function (data) { 68 | console.log('user fb logged in', data); 69 | $scope.myUser = userFactory.getAuthData(); 70 | $scope.hide(); 71 | }, function (error) { 72 | console.log('user fb login error', error); 73 | $scope.hide(); 74 | }) 75 | }; 76 | 77 | $scope.show = function() { 78 | $ionicLoading.show({ 79 | template: '' 80 | }); 81 | }; 82 | 83 | $scope.hide = function(){ 84 | $ionicLoading.hide(); 85 | }; 86 | 87 | } 88 | ); -------------------------------------------------------------------------------- /www/js/controllers/cartController.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by M.JUNAID on 2015-03-10. 3 | */ 4 | 5 | foodShop.controller('cartController', function($scope, cartFactory, $cordovaToast) { 6 | 7 | $scope.cart = cartFactory.getCartData(); 8 | $scope.total = getTotal(); 9 | 10 | function getTotal (){ 11 | var total = 0; 12 | $scope.cart.forEach(function (item) { 13 | if(item.price){ 14 | total = total + item.price; 15 | } 16 | }); 17 | return total 18 | } 19 | 20 | $scope.removeItem = function(index){ 21 | cartFactory.removeItem(index); 22 | $scope.total = getTotal(); 23 | }; 24 | 25 | $scope.showTotals = function(){ 26 | $cordovaToast.show('Your Total is '+$scope.total, 'long', 'bottom') 27 | .then(function(success) { 28 | // success 29 | }, function (error) { 30 | // error 31 | }); 32 | } 33 | 34 | }); 35 | 36 | -------------------------------------------------------------------------------- /www/js/controllers/dashController.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by M.JUNAID on 2015-03-10. 3 | */ 4 | 5 | foodShop.controller('dashController',function($scope, $ionicPopup, $ionicLoading, userFactory, dataFactory, $state) { 6 | 7 | $scope.user = userFactory.getAuthData(); 8 | console.log($scope.user); 9 | 10 | if($scope.user){ 11 | 12 | 13 | $scope.restaurants = dataFactory.getRestData(); 14 | console.log($scope.restaurants); 15 | 16 | $scope.show = function() { 17 | $ionicLoading.show({ 18 | template: '' 19 | }); 20 | }; 21 | $scope.hide = function(){ 22 | $ionicLoading.hide(); 23 | }; 24 | 25 | $scope.show(); 26 | 27 | $scope.restaurants.$loaded().then(function() { 28 | $scope.hide(); 29 | }); 30 | 31 | } 32 | else{ 33 | $ionicPopup.alert({ 34 | title: "No User", 35 | template: "You're not Signed In, Please Sign In Or Register" 36 | }); 37 | $state.go('tab.account') 38 | } 39 | 40 | 41 | }); 42 | -------------------------------------------------------------------------------- /www/js/controllers/restNameController.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by M.JUNAID on 2015-03-10. 3 | */ 4 | 5 | foodShop.controller('restNameController', function($scope, $ionicPopup, $state, $stateParams, dataFactory, cartFactory) { 6 | 7 | $scope.selectedRes = dataFactory.getSelectedRestData($stateParams.id); 8 | 9 | $scope.addToCart = function(i){ 10 | cartFactory.addCartItem($scope.selectedRes.item[i]); 11 | $ionicPopup.alert({ 12 | title: 'Successfully added to Cart!', 13 | template: $scope.selectedRes.item[i].dish_n 14 | }); 15 | }; 16 | 17 | $scope.changeState = function(){ 18 | $state.go('tab.cart') 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /www/js/services/cartFactory.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by mjunaidsalaat on 6/24/16. 3 | */ 4 | 5 | foodShop.factory('cartFactory', function($q, $firebaseObject) { 6 | 7 | var cart = []; 8 | 9 | return { 10 | getCartData : function () { 11 | return cart; 12 | }, 13 | 14 | addCartItem : function (cartItem) { 15 | cart.push(cartItem); 16 | }, 17 | 18 | removeItem : function (index) { 19 | cart.splice(index,1); 20 | } 21 | } 22 | }); -------------------------------------------------------------------------------- /www/js/services/dataFactory.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by mjunaidsalaat on 6/24/16. 3 | */ 4 | 5 | foodShop.factory('dataFactory', function($q, $firebaseArray) { 6 | 7 | var ref = new Firebase("https://foodpanda-mcc201.firebaseio.com/"); 8 | var messagesRef = ref.child("restuarants/-Jh39v_3eydHBVdSYWBU"); 9 | var restData = $firebaseArray(messagesRef); 10 | 11 | return { 12 | getRestData : function () { 13 | return restData; 14 | }, 15 | 16 | getSelectedRestData : function (id) { 17 | return restData.find(function (item) { 18 | return item.id == id; 19 | }); 20 | } 21 | } 22 | }); -------------------------------------------------------------------------------- /www/js/services/userFactory.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by mjunaidsalaat on 6/24/16. 3 | */ 4 | 5 | foodShop.factory('userFactory', function($q) { 6 | 7 | var ref = new Firebase("https://foodpanda-mcc201.firebaseio.com/"); 8 | 9 | var _createUser = function (user) { 10 | 11 | var deferred = $q.defer(); 12 | 13 | ref.createUser({ 14 | email: user.email, 15 | password: user.password 16 | }, function (error) { 17 | if (error === null) { 18 | console.log("User created successfully"); 19 | deferred.resolve(); 20 | } 21 | else{ 22 | deferred.reject(error); 23 | } 24 | }); 25 | 26 | return deferred.promise; 27 | }; 28 | 29 | var _login = function (user) { 30 | 31 | var deferred = $q.defer(); 32 | 33 | ref.authWithPassword({ 34 | email: user.email, 35 | password: user.password 36 | }, function (error, authData) { 37 | if (error) { 38 | console.log("Login Failed!", error); 39 | deferred.reject(error); 40 | 41 | } else { 42 | console.log("Authenticated successfully with payload:", authData); 43 | user = authData; 44 | deferred.resolve(authData); 45 | } 46 | }); 47 | 48 | return deferred.promise; 49 | }; 50 | 51 | 52 | var _getAuthData = function () { 53 | var authData = ref.getAuth(); 54 | if (authData) { 55 | console.log("User " + authData.uid + " is logged in with " + authData.provider); 56 | return authData; 57 | } else { 58 | console.log("User is logged out"); 59 | return authData; 60 | } 61 | }; 62 | 63 | var _logout = function () { 64 | localStorage.clear(); 65 | ref.unauth(); 66 | }; 67 | 68 | var _loginWithFb = function () { 69 | var deferred = $q.defer(); 70 | 71 | ref.authWithOAuthPopup("facebook", function(error, authData) { 72 | if (error) { 73 | console.log("Login Failed!", error); 74 | deferred.reject(error); 75 | 76 | } else { 77 | console.log("Authenticated successfully with payload:", authData); 78 | user = authData; 79 | deferred.resolve(authData); 80 | } 81 | }); 82 | 83 | return deferred.promise; 84 | }; 85 | 86 | return { 87 | createUser: _createUser, 88 | getAuthData: _getAuthData, 89 | login: _login, 90 | loginWithFb: _loginWithFb, 91 | logout: _logout 92 | } 93 | 94 | }); 95 | -------------------------------------------------------------------------------- /www/templates/cart.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Your Cart 7 | 8 | 9 | 10 | Remove Item 11 | 12 | 13 | 14 | Item {{$index+1}}: {{item.dish_n}} 15 | 16 | 17 | {{item.price}} Rs 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Checkout 28 | 29 | 30 | Your Total {{total}} Rs 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /www/templates/tab-account.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Log In the Shop 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Login 30 | 31 | 32 | 33 | 34 | 35 | Register 36 | 37 | 38 | 39 | 40 | 41 | Connect with Facebook 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | Login as 52 | {{ myUser.password.email }} 53 | {{ myUser.facebook.displayName }} 54 | 55 | 56 | Logout 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /www/templates/tab-dash.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Please Sign In to View 5 | 6 | 7 | 8 | 9 | 10 | Select a Restaurant 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | {{restaurant.rating}} 23 | 24 | {{restaurant.name}} 25 | {{ type }} 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /www/templates/tab-rest-name.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {{selectedRes.name}} 10 | {{selectedRes.address}} 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | {{item.dish_n}} 20 | 21 | 22 | {{item.price}} Rs 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | View Cart 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /www/templates/tabs.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | --------------------------------------------------------------------------------
{{selectedRes.address}}