├── .gitignore ├── README.md ├── angular.json ├── browserslist ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.json ├── img └── calendar.png ├── ionic.config.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.ts │ ├── app.module.ts │ └── home │ │ ├── home.module.ts │ │ ├── home.page.html │ │ ├── home.page.scss │ │ └── home.page.ts ├── assets │ ├── icon │ │ └── favicon.png │ └── shapes.svg ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── global.scss ├── index.html ├── main.ts ├── polyfills.ts ├── test.ts ├── theme │ └── variables.scss └── zone-flags.ts ├── tsconfig.app.json ├── tsconfig.json ├── tsconfig.spec.json ├── tslint.json └── typings └── cordova-typings.d.ts /.gitignore: -------------------------------------------------------------------------------- 1 | /.angular/cache 2 | # Specifies intentionally untracked files to ignore when using Git 3 | # http://git-scm.com/docs/gitignore 4 | 5 | *~ 6 | *.sw[mnpcod] 7 | .tmp 8 | *.tmp 9 | *.tmp.* 10 | *.sublime-project 11 | *.sublime-workspace 12 | .DS_Store 13 | Thumbs.db 14 | UserInterfaceState.xcuserstate 15 | $RECYCLE.BIN/ 16 | 17 | *.log 18 | log.txt 19 | npm-debug.log* 20 | 21 | /.idea 22 | /.ionic 23 | /.sass-cache 24 | /.sourcemaps 25 | /.versions 26 | /.vscode 27 | /coverage 28 | /dist 29 | /node_modules 30 | /platforms 31 | /plugins 32 | /www 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # :zap: Ionic Angular Calendar 2 | 3 | * App to show an Ionic calendar with events stored in Firebase. This is another great tutorial from [Jameson Saunders of JamiBot, Youtube video 'Ionic 4 Custom Calendar Tutorial'](https://www.youtube.com/watch?v=SYz-tH3XOF8&t=766s) that I have updated. 4 | 5 | ![GitHub repo size](https://img.shields.io/github/repo-size/AndrewJBateman/ionic-angular-calendar?style=plastic) 6 | ![GitHub pull requests](https://img.shields.io/github/issues-pr/AndrewJBateman/ionic-angular-calendar?style=plastic) 7 | ![GitHub Repo stars](https://img.shields.io/github/stars/AndrewJBateman/ionic-angular-calendar?style=plastic) 8 | ![GitHub last commit](https://img.shields.io/github/last-commit/AndrewJBateman/ionic-angular-calendar?style=plastic) 9 | 10 | ## :page_facing_up: Table of contents 11 | 12 | * [:zap: Ionic Angular Calendar](#zap-ionic-angular-calendar) 13 | * [:page_facing_up: Table of contents](#page_facing_up-table-of-contents) 14 | * [:books: General info](#books-general-info) 15 | * [:camera: Screenshots](#camera-screenshots) 16 | * [:signal_strength: Technologies](#signal_strength-technologies) 17 | * [:floppy_disk: Setup](#floppy_disk-setup) 18 | * [:computer: Code Examples](#computer-code-examples) 19 | * [:cool: Features](#cool-features) 20 | * [:clipboard: Status & To-do list](#clipboard-status--to-do-list) 21 | * [:clap: Inspiration](#clap-inspiration) 22 | * [:file_folder: License](#file_folder-license) 23 | * [:envelope: Contact](#envelope-contact) 24 | 25 | ## :books: General info 26 | 27 | * Uses the [ionic2-calendar](https://www.npmjs.com/package/ionic2-calendar) package to display events input by the user. 28 | * This app is set up to use a Google Firebase backend to store calender entries. 29 | 30 | ## :camera: Screenshots 31 | 32 | ![screenshot](./img/calendar.png) 33 | 34 | ## :signal_strength: Technologies 35 | 36 | * [Ionic v6](https://ionicframework.com/) 37 | * [Ionic/angular v6](https://ionicframework.com/) 38 | * [Angular v15](https://angular.io/) 39 | * [ionic2-calendar v0.6.9](https://www.npmjs.com/package/ionic2-calendar) 40 | * [Angular/Fire v7](https://www.npmjs.com/package/@angular/fire) for Google Firebase Database connection. 41 | 42 | ## :floppy_disk: Setup 43 | 44 | * Create a Google Firebase database and add access credentials to environment.ts 45 | * To start the server on _localhost://8100_ type: 'ionic serve' 46 | * To start the server on a mobile using Ionic devapp and connected via wifi, type: 'ionic serve --devapp' 47 | * The Ionic DevApp was installed on an Android device from the Google Play app store. 48 | 49 | ## :computer: Code Examples 50 | 51 | * function to add a new event - including start and end time. Title is derived from seconds and is intended to create semi-random data. 52 | 53 | ```typescript 54 | addNewEvent() { 55 | const start = this.selectedDate; 56 | const end = this.selectedDate; 57 | end.setMinutes(end.getMinutes() + 60); 58 | 59 | const event = { 60 | title: 'Event #' + start.getMinutes(), 61 | startTime: start, 62 | endTime: end, 63 | allDay: false 64 | }; 65 | 66 | this.db.collection('events').add(event); 67 | } 68 | ``` 69 | 70 | ## :cool: Features 71 | 72 | * Google Firebase storage of calendar events. Data is retrieved from Firebase in the constructor function at the beginning of the page lifecycle. 73 | * Calender date format can be changed using options from the ionic2-calender. 74 | 75 | ## :clipboard: Status & To-do list 76 | 77 | * Status: Working 78 | * To-do: A lot more complexity can be added to this calendar app. The option to change the view from day to week to month would be useful - as shown in the [demo project](https://github.com/twinssbc/Ionic2-Calendar/tree/v5/demo). 79 | 80 | ## :clap: Inspiration 81 | 82 | * [Jameson Saunders of JamiBot, Youtube video 'Ionic 4 Custom Calendar Tutorial'](https://www.youtube.com/watch?v=SYz-tH3XOF8&t=766s) 83 | * [Ionic2-Calendar github repo](https://github.com/twinssbc/Ionic2-Calendar) 84 | * [demo project](https://github.com/twinssbc/Ionic2-Calendar/tree/v5/demo). 85 | 86 | ## :file_folder: License 87 | 88 | * N/A 89 | 90 | ## :envelope: Contact 91 | 92 | * Repo created by [ABateman](https://github.com/AndrewJBateman), email: gomezbateman@yahoo.com 93 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "app": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": {}, 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "outputPath": "www", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "tsconfig.app.json", 21 | "assets": [ 22 | { 23 | "glob": "**/*", 24 | "input": "src/assets", 25 | "output": "assets" 26 | }, 27 | { 28 | "glob": "**/*.svg", 29 | "input": "node_modules/ionicons/dist/ionicons/svg", 30 | "output": "./svg" 31 | } 32 | ], 33 | "styles": [ 34 | { 35 | "input": "src/theme/variables.scss", 36 | "inject": true 37 | }, 38 | { 39 | "input": "src/global.scss", 40 | "inject": true 41 | } 42 | ], 43 | "scripts": [], 44 | "aot": false, 45 | "vendorChunk": true, 46 | "extractLicenses": false, 47 | "buildOptimizer": false, 48 | "sourceMap": true, 49 | "optimization": false, 50 | "namedChunks": true 51 | }, 52 | "configurations": { 53 | "production": { 54 | "fileReplacements": [ 55 | { 56 | "replace": "src/environments/environment.ts", 57 | "with": "src/environments/environment.prod.ts" 58 | } 59 | ], 60 | "optimization": true, 61 | "outputHashing": "all", 62 | "sourceMap": false, 63 | "namedChunks": false, 64 | "aot": true, 65 | "extractLicenses": true, 66 | "vendorChunk": false, 67 | "buildOptimizer": true, 68 | "budgets": [ 69 | { 70 | "type": "initial", 71 | "maximumWarning": "2mb", 72 | "maximumError": "5mb" 73 | } 74 | ] 75 | }, 76 | "ci": { 77 | "progress": false 78 | }, 79 | "development": {} 80 | }, 81 | "defaultConfiguration": "production" 82 | }, 83 | "serve": { 84 | "builder": "@angular-devkit/build-angular:dev-server", 85 | "options": { 86 | "browserTarget": "app:build:development" 87 | }, 88 | "configurations": { 89 | "production": { 90 | "browserTarget": "app:build:production" 91 | }, 92 | "ci": { 93 | }, 94 | "development": { 95 | "browserTarget": "app:build:development" 96 | } 97 | }, 98 | "defaultConfiguration": "development" 99 | }, 100 | "extract-i18n": { 101 | "builder": "@angular-devkit/build-angular:extract-i18n", 102 | "options": { 103 | "browserTarget": "app:build" 104 | } 105 | }, 106 | "test": { 107 | "builder": "@angular-devkit/build-angular:karma", 108 | "options": { 109 | "main": "src/test.ts", 110 | "polyfills": "src/polyfills.ts", 111 | "tsConfig": "tsconfig.spec.json", 112 | "karmaConfig": "karma.conf.js", 113 | "styles": [], 114 | "scripts": [], 115 | "assets": [ 116 | { 117 | "glob": "favicon.ico", 118 | "input": "src/", 119 | "output": "/" 120 | }, 121 | { 122 | "glob": "**/*", 123 | "input": "src/assets", 124 | "output": "/assets" 125 | } 126 | ] 127 | }, 128 | "configurations": { 129 | "ci": { 130 | "progress": false, 131 | "watch": false 132 | } 133 | } 134 | }, 135 | "e2e": { 136 | "builder": "@angular-devkit/build-angular:protractor", 137 | "options": { 138 | "protractorConfig": "e2e/protractor.conf.js" 139 | }, 140 | "configurations": { 141 | "production": { 142 | "devServerTarget": "app:serve:production" 143 | }, 144 | "ci": { 145 | "devServerTarget": "app:serve:ci" 146 | }, 147 | "development": { 148 | "devServerTarget": "app:serve:development" 149 | } 150 | }, 151 | "defaultConfiguration": "development" 152 | }, 153 | "ionic-cordova-build": { 154 | "builder": "@ionic/angular-toolkit:cordova-build", 155 | "options": { 156 | "browserTarget": "app:build" 157 | }, 158 | "configurations": { 159 | "production": { 160 | "browserTarget": "app:build:production" 161 | } 162 | } 163 | }, 164 | "ionic-cordova-serve": { 165 | "builder": "@ionic/angular-toolkit:cordova-serve", 166 | "options": { 167 | "cordovaBuildTarget": "app:ionic-cordova-build", 168 | "devServerTarget": "app:serve" 169 | }, 170 | "configurations": { 171 | "production": { 172 | "cordovaBuildTarget": "app:ionic-cordova-build:production", 173 | "devServerTarget": "app:serve:production" 174 | } 175 | } 176 | } 177 | } 178 | } 179 | }, 180 | "cli": { 181 | "schematicCollections": [ 182 | "@ionic/angular-toolkit" 183 | ] 184 | }, 185 | "schematics": { 186 | "@ionic/angular-toolkit:component": { 187 | "styleext": "scss" 188 | }, 189 | "@ionic/angular-toolkit:page": { 190 | "styleext": "scss" 191 | } 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | not IE 9-11 # For IE 9-11 support, remove 'not'. 13 | -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('new App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should be blank', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toContain('The world is your oyster.'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.deepCss('app-root ion-content')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /img/calendar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrewJBateman/ionic-angular-calendar/ec5246140e50cd56d177812812e757657ae8b681/img/calendar.png -------------------------------------------------------------------------------- /ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic-angular-calendar", 3 | "integrations": {}, 4 | "type": "angular" 5 | } 6 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic-angular-calendar", 3 | "version": "0.0.1", 4 | "author": "Ionic Framework", 5 | "homepage": "https://ionicframework.com/", 6 | "scripts": { 7 | "ng": "ng", 8 | "start": "ng serve", 9 | "build": "ng build", 10 | "test": "ng test", 11 | "lint": "ng lint", 12 | "e2e": "ng e2e" 13 | }, 14 | "private": true, 15 | "dependencies": { 16 | "@angular/common": "^15.1.0", 17 | "@angular/compiler": "^15.1.0", 18 | "@angular/core": "^15.1.0", 19 | "@angular/fire": "^7.5.0", 20 | "@angular/forms": "^15.1.0", 21 | "@angular/platform-browser": "^15.1.0", 22 | "@angular/platform-browser-dynamic": "^15.1.0", 23 | "@angular/router": "^15.1.0", 24 | "@ionic-native/core": "^5.36.0", 25 | "@ionic-native/splash-screen": "^5.36.0", 26 | "@ionic-native/status-bar": "^5.36.0", 27 | "@ionic/angular": "^6.4.2", 28 | "ajv": "^8.12.0", 29 | "core-js": "^3.27.1", 30 | "firebase": "^9.15.0", 31 | "ionic2-calendar": "^0.6.9", 32 | "promise-polyfill": "^8.2.3", 33 | "rxjs": "^7.8.0", 34 | "rxjs-compat": "^6.6.7", 35 | "tslib": "^2.4.1", 36 | "zone.js": "^0.12.0" 37 | }, 38 | "devDependencies": { 39 | "@angular-devkit/architect": "^0.1501.1", 40 | "@angular-devkit/build-angular": "^15.1.1", 41 | "@angular-devkit/core": "^15.1.1", 42 | "@angular-devkit/schematics": "^15.1.1", 43 | "@angular/cli": "^15.1.1", 44 | "@angular/compiler-cli": "^15.1.0", 45 | "@angular/language-service": "^15.1.0", 46 | "@ionic/angular-toolkit": "^7.0.0", 47 | "@types/jasmine": "~4.3.1", 48 | "@types/jasminewd2": "~2.0.10", 49 | "@types/node": "~18.11.18", 50 | "codelyzer": "^6.0.2", 51 | "jasmine-core": "~4.5.0", 52 | "jasmine-spec-reporter": "~7.0.0", 53 | "karma": "~6.4.1", 54 | "karma-chrome-launcher": "~3.1.1", 55 | "karma-coverage-istanbul-reporter": "~3.0.3", 56 | "karma-jasmine": "~5.1.0", 57 | "karma-jasmine-html-reporter": "^2.0.0", 58 | "protractor": "~7.0.0", 59 | "ts-node": "~10.9.1", 60 | "tslint": "~6.1.3", 61 | "typescript": "~4.8.4" 62 | }, 63 | "description": "An Ionic project" 64 | } 65 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; 3 | 4 | const routes: Routes = [ 5 | { path: '', redirectTo: 'home', pathMatch: 'full' }, 6 | { path: 'home', loadChildren: () => import('./home/home.module').then( m => m.HomePageModule)}, 7 | ]; 8 | 9 | @NgModule({ 10 | imports: [ 11 | RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) 12 | ], 13 | exports: [RouterModule] 14 | }) 15 | export class AppRoutingModule { } 16 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrewJBateman/ionic-angular-calendar/ec5246140e50cd56d177812812e757657ae8b681/src/app/app.component.scss -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | import { Platform } from '@ionic/angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 5 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 6 | 7 | @Component({ 8 | selector: 'app-root', 9 | templateUrl: 'app.component.html', 10 | styleUrls: ['app.component.scss'] 11 | }) 12 | export class AppComponent { 13 | constructor( 14 | private platform: Platform, 15 | private splashScreen: SplashScreen, 16 | private statusBar: StatusBar 17 | ) { 18 | this.initializeApp(); 19 | } 20 | 21 | initializeApp() { 22 | this.platform.ready().then(() => { 23 | this.statusBar.styleDefault(); 24 | this.splashScreen.hide(); 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { RouteReuseStrategy } from '@angular/router'; 4 | 5 | import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; 6 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 7 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 8 | 9 | import { AppComponent } from './app.component'; 10 | import { AppRoutingModule } from './app-routing.module'; 11 | import { NgCalendarModule } from 'ionic2-calendar'; 12 | 13 | import { AngularFireModule } from '@angular/fire/compat'; 14 | import { AngularFirestoreModule } from '@angular/fire/compat/firestore'; 15 | import { AngularFireAuthModule } from '@angular/fire/compat/auth'; 16 | import { environment } from 'src/environments/environment'; 17 | 18 | @NgModule({ 19 | declarations: [AppComponent], 20 | imports: [ 21 | BrowserModule, 22 | IonicModule.forRoot(), 23 | AppRoutingModule, 24 | NgCalendarModule, 25 | AngularFireModule.initializeApp(environment.firebase), 26 | AngularFirestoreModule, 27 | AngularFireAuthModule 28 | ], 29 | providers: [ 30 | StatusBar, 31 | SplashScreen, 32 | { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } 33 | ], 34 | bootstrap: [AppComponent], 35 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 36 | }) 37 | export class AppModule {} 38 | -------------------------------------------------------------------------------- /src/app/home/home.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { IonicModule } from '@ionic/angular'; 4 | import { FormsModule } from '@angular/forms'; 5 | import { RouterModule } from '@angular/router'; 6 | import { NgCalendarModule } from 'ionic2-calendar'; 7 | 8 | import { HomePage } from './home.page'; 9 | 10 | @NgModule({ 11 | imports: [ 12 | CommonModule, 13 | FormsModule, 14 | IonicModule, 15 | RouterModule.forChild([ 16 | { 17 | path: '', 18 | component: HomePage 19 | } 20 | ]), 21 | NgCalendarModule 22 | ], 23 | declarations: [HomePage] 24 | }) 25 | export class HomePageModule {} 26 | -------------------------------------------------------------------------------- /src/app/home/home.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ionic Calendar 5 | 6 | 7 | 8 | 9 | 10 |
11 | Add New Event 12 | 13 | 21 | 22 | 23 | 24 |
25 |
26 | -------------------------------------------------------------------------------- /src/app/home/home.page.scss: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/app/home/home.page.ts: -------------------------------------------------------------------------------- 1 | import { Component } from "@angular/core"; 2 | import { AngularFirestore } from "@angular/fire/compat/firestore"; 3 | 4 | @Component({ 5 | selector: "app-home", 6 | templateUrl: "home.page.html", 7 | styleUrls: ["home.page.scss"], 8 | }) 9 | export class HomePage { 10 | eventSource = []; 11 | 12 | calendar = { 13 | mode: "month", 14 | currentDate: new Date(), 15 | }; 16 | selectedDate = new Date(); 17 | 18 | constructor(private db: AngularFirestore) { 19 | this.db 20 | .collection(`events`) 21 | .snapshotChanges() 22 | .subscribe((colSnap) => { 23 | this.eventSource = []; 24 | colSnap.forEach((snap) => { 25 | const event: any = snap.payload.doc.data(); 26 | event.id = snap.payload.doc.id; 27 | event.startTime = event.startTime.toDate(); 28 | event.endTime = event.endTime.toDate(); 29 | console.log(event); 30 | this.eventSource.push(event); 31 | }); 32 | }); 33 | } 34 | 35 | addNewEvent() { 36 | const start = this.selectedDate; 37 | const end = this.selectedDate; 38 | end.setMinutes(end.getMinutes() + 60); 39 | 40 | // event object created to include semi-random title 41 | const event = { 42 | title: "Event #" + start.getMinutes(), 43 | startTime: start, 44 | endTime: end, 45 | allDay: false, 46 | }; 47 | 48 | this.db.collection("events").add(event); 49 | } 50 | 51 | onViewTitleChanged(title) { 52 | console.log(title); 53 | } 54 | 55 | onEventSelected(event) { 56 | console.log( 57 | "Event selected:" + 58 | event.startTime + 59 | "-" + 60 | event.endTime + 61 | "," + 62 | event.title 63 | ); 64 | } 65 | 66 | onTimeSelected(ev) { 67 | console.log( 68 | "Selected time: " + 69 | ev.selectedTime + 70 | ", hasEvents: " + 71 | (ev.events !== undefined && ev.events.length !== 0) + 72 | ", disabled: " + 73 | ev.disabled 74 | ); 75 | this.selectedDate = ev.selectedTime; 76 | } 77 | 78 | onCurrentDateChanged(event: Date) { 79 | console.log("current date change: " + event); 80 | } 81 | 82 | onRangeChanged(ev) { 83 | console.log( 84 | "range changed: startTime: " + ev.startTime + ", endTime: " + ev.endTime 85 | ); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/assets/icon/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrewJBateman/ionic-angular-calendar/ec5246140e50cd56d177812812e757657ae8b681/src/assets/icon/favicon.png -------------------------------------------------------------------------------- /src/assets/shapes.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false, 7 | firebase: { 8 | 9 | } 10 | }; 11 | 12 | /* 13 | * For easier debugging in development mode, you can import the following file 14 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 15 | * 16 | * This import should be commented out in production mode because it will have a negative impact 17 | * on performance if an error is thrown. 18 | */ 19 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 20 | -------------------------------------------------------------------------------- /src/global.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * App Global CSS 3 | * ---------------------------------------------------------------------------- 4 | * Put style rules here that you want to apply globally. These styles are for 5 | * the entire app and not just one component. Additionally, this file can be 6 | * used as an entry point to import other CSS/Sass files to be included in the 7 | * output CSS. 8 | * For more information on global stylesheets, visit the documentation: 9 | * https://ionicframework.com/docs/layout/global-stylesheets 10 | */ 11 | 12 | /* Core CSS required for Ionic components to work properly */ 13 | @import "~@ionic/angular/css/core.css"; 14 | 15 | /* Basic CSS for apps built with Ionic */ 16 | @import "~@ionic/angular/css/normalize.css"; 17 | @import "~@ionic/angular/css/structure.css"; 18 | @import "~@ionic/angular/css/typography.css"; 19 | @import '~@ionic/angular/css/display.css'; 20 | 21 | /* Optional CSS utils that can be commented out */ 22 | @import "~@ionic/angular/css/padding.css"; 23 | @import "~@ionic/angular/css/float-elements.css"; 24 | @import "~@ionic/angular/css/text-alignment.css"; 25 | @import "~@ionic/angular/css/text-transformation.css"; 26 | @import "~@ionic/angular/css/flex-utils.css"; 27 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Ionic App 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | import { CalendarComponent } from 'ionic2-calendar/calendar'; 8 | import { MonthViewComponent } from 'ionic2-calendar/monthview'; 9 | import { WeekViewComponent } from 'ionic2-calendar/weekview'; 10 | import { DayViewComponent } from 'ionic2-calendar/dayview'; 11 | 12 | if (environment.production) { 13 | enableProdMode(); 14 | } 15 | 16 | platformBrowserDynamic().bootstrapModule(AppModule) 17 | .catch(err => console.log(err)); 18 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * By default, zone.js will patch all possible macroTask and DomEvents 23 | * user can disable parts of macroTask/DomEvents patch by setting following flags 24 | * because those flags need to be set before `zone.js` being loaded, and webpack 25 | * will put import in the top of bundle, so user need to create a separate file 26 | * in this directory (for example: zone-flags.ts), and put the following flags 27 | * into that file, and then add the following code before importing zone.js. 28 | * import './zone-flags.ts'; 29 | * 30 | * The flags allowed in zone-flags.ts are listed here. 31 | * 32 | * The following flags will work for all browsers. 33 | * 34 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 35 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 36 | * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 37 | * 38 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 39 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 40 | * 41 | * (window as any).__Zone_enable_cross_context_check = true; 42 | * 43 | */ 44 | 45 | import './zone-flags.ts'; 46 | 47 | /*************************************************************************************************** 48 | * Zone JS is required by default for Angular itself. 49 | */ 50 | 51 | import 'zone.js'; // Included with Angular CLI. 52 | 53 | 54 | /*************************************************************************************************** 55 | * APPLICATION IMPORTS 56 | */ 57 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | // First, initialize the Angular testing environment. 11 | getTestBed().initTestEnvironment( 12 | BrowserDynamicTestingModule, 13 | platformBrowserDynamicTesting(), { 14 | teardown: { destroyAfterEach: false } 15 | } 16 | ); 17 | -------------------------------------------------------------------------------- /src/theme/variables.scss: -------------------------------------------------------------------------------- 1 | // Ionic Variables and Theming. For more info, please see: 2 | // http://ionicframework.com/docs/theming/ 3 | 4 | /** Ionic CSS Variables **/ 5 | :root { 6 | /** primary **/ 7 | --ion-color-primary: #3880ff; 8 | --ion-color-primary-rgb: 56, 128, 255; 9 | --ion-color-primary-contrast: #ffffff; 10 | --ion-color-primary-contrast-rgb: 255, 255, 255; 11 | --ion-color-primary-shade: #3171e0; 12 | --ion-color-primary-tint: #4c8dff; 13 | 14 | /** secondary **/ 15 | --ion-color-secondary: #0cd1e8; 16 | --ion-color-secondary-rgb: 12, 209, 232; 17 | --ion-color-secondary-contrast: #ffffff; 18 | --ion-color-secondary-contrast-rgb: 255, 255, 255; 19 | --ion-color-secondary-shade: #0bb8cc; 20 | --ion-color-secondary-tint: #24d6ea; 21 | 22 | /** tertiary **/ 23 | --ion-color-tertiary: #7044ff; 24 | --ion-color-tertiary-rgb: 112, 68, 255; 25 | --ion-color-tertiary-contrast: #ffffff; 26 | --ion-color-tertiary-contrast-rgb: 255, 255, 255; 27 | --ion-color-tertiary-shade: #633ce0; 28 | --ion-color-tertiary-tint: #7e57ff; 29 | 30 | /** success **/ 31 | --ion-color-success: #10dc60; 32 | --ion-color-success-rgb: 16, 220, 96; 33 | --ion-color-success-contrast: #ffffff; 34 | --ion-color-success-contrast-rgb: 255, 255, 255; 35 | --ion-color-success-shade: #0ec254; 36 | --ion-color-success-tint: #28e070; 37 | 38 | /** warning **/ 39 | --ion-color-warning: #ffce00; 40 | --ion-color-warning-rgb: 255, 206, 0; 41 | --ion-color-warning-contrast: #ffffff; 42 | --ion-color-warning-contrast-rgb: 255, 255, 255; 43 | --ion-color-warning-shade: #e0b500; 44 | --ion-color-warning-tint: #ffd31a; 45 | 46 | /** danger **/ 47 | --ion-color-danger: #f04141; 48 | --ion-color-danger-rgb: 245, 61, 61; 49 | --ion-color-danger-contrast: #ffffff; 50 | --ion-color-danger-contrast-rgb: 255, 255, 255; 51 | --ion-color-danger-shade: #d33939; 52 | --ion-color-danger-tint: #f25454; 53 | 54 | /** dark **/ 55 | --ion-color-dark: #222428; 56 | --ion-color-dark-rgb: 34, 34, 34; 57 | --ion-color-dark-contrast: #ffffff; 58 | --ion-color-dark-contrast-rgb: 255, 255, 255; 59 | --ion-color-dark-shade: #1e2023; 60 | --ion-color-dark-tint: #383a3e; 61 | 62 | /** medium **/ 63 | --ion-color-medium: #989aa2; 64 | --ion-color-medium-rgb: 152, 154, 162; 65 | --ion-color-medium-contrast: #ffffff; 66 | --ion-color-medium-contrast-rgb: 255, 255, 255; 67 | --ion-color-medium-shade: #86888f; 68 | --ion-color-medium-tint: #a2a4ab; 69 | 70 | /** light **/ 71 | --ion-color-light: #f4f5f8; 72 | --ion-color-light-rgb: 244, 244, 244; 73 | --ion-color-light-contrast: #000000; 74 | --ion-color-light-contrast-rgb: 0, 0, 0; 75 | --ion-color-light-shade: #d7d8da; 76 | --ion-color-light-tint: #f5f6f9; 77 | } 78 | -------------------------------------------------------------------------------- /src/zone-flags.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Prevents Angular change detection from 3 | * running with certain Web Component callbacks 4 | */ 5 | (window as any).__Zone_disable_customElements = true; 6 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "include": [ 8 | "src/**/*.ts" 9 | ], 10 | "exclude": [ 11 | "src/test.ts", 12 | "src/**/*.spec.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "esnext", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "importHelpers": true, 13 | "target": "ES2022", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ], 21 | "skipLibCheck": true, 22 | "useDefineForClassFields": false 23 | }, 24 | "angularCompilerOptions": { 25 | "fullTemplateTypeCheck": true, 26 | "strictInjectionParameters": true 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/zone-flags.ts", 13 | "src/polyfills.ts" 14 | ], 15 | "include": [ 16 | "src/**/*.spec.ts", 17 | "src/**/*.d.ts" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rulesDirectory": [ 4 | "codelyzer" 5 | ], 6 | "rules": { 7 | "array-type": false, 8 | "arrow-parens": false, 9 | "deprecation": { 10 | "severity": "warn" 11 | }, 12 | "import-blacklist": [ 13 | true, 14 | "rxjs/Rx" 15 | ], 16 | "indent": [ 17 | true, 18 | "tabs", 19 | 2 20 | ], 21 | "interface-name": false, 22 | "max-classes-per-file": false, 23 | "max-line-length": [ 24 | true, 25 | 140 26 | ], 27 | "member-access": false, 28 | "member-ordering": [ 29 | true, 30 | { 31 | "order": [ 32 | "static-field", 33 | "instance-field", 34 | "static-method", 35 | "instance-method" 36 | ] 37 | } 38 | ], 39 | "no-consecutive-blank-lines": false, 40 | "no-console": [ 41 | true, 42 | "debug", 43 | "info", 44 | "time", 45 | "timeEnd", 46 | "trace" 47 | ], 48 | "no-empty": false, 49 | "no-inferrable-types": [ 50 | true, 51 | "ignore-params" 52 | ], 53 | "no-non-null-assertion": true, 54 | "no-redundant-jsdoc": true, 55 | "no-switch-case-fall-through": true, 56 | "no-use-before-declare": true, 57 | "no-var-requires": false, 58 | "object-literal-key-quotes": [ 59 | true, 60 | "as-needed" 61 | ], 62 | "object-literal-sort-keys": false, 63 | "ordered-imports": false, 64 | "quotemark": [ 65 | true, 66 | "single" 67 | ], 68 | "trailing-comma": false, 69 | "no-output-on-prefix": true, 70 | "no-inputs-metadata-property": true, 71 | "no-host-metadata-property": true, 72 | "no-input-rename": true, 73 | "no-output-rename": true, 74 | "use-lifecycle-interface": true, 75 | "use-pipe-transform-interface": true, 76 | "one-variable-per-declaration": false, 77 | "component-class-suffix": [true, "Page", "Component"], 78 | "directive-class-suffix": true, 79 | "directive-selector": [ 80 | true, 81 | "attribute", 82 | "app", 83 | "camelCase" 84 | ], 85 | "component-selector": [ 86 | true, 87 | "element", 88 | "app", 89 | "page", 90 | "kebab-case" 91 | ] 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /typings/cordova-typings.d.ts: -------------------------------------------------------------------------------- 1 | 2 | /// 3 | /// --------------------------------------------------------------------------------