Skip to content

Commit

Permalink
🎉 release: [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz committed Sep 12, 2017
1 parent bc6acfd commit 0d62052
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 111 deletions.
1 change: 1 addition & 0 deletions demo/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
</platform>
<engine name="android" spec="^6.2.3" />
<engine name="ios" spec="^4.4.0" />
<plugin name="cordova-plugin-console" spec="^1.0.5" />
<plugin name="cordova-plugin-device" spec="^1.1.4" />
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
Expand Down
6 changes: 4 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
"@ionic-native/status-bar": "3.12.1",
"@ionic/storage": "2.0.1",
"cordova-android": "^6.2.3",
"cordova-ios": "^4.4.0",
"cordova-plugin-console": "^1.0.5",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"ion2-calendar": "^2.0.0-beta.7",
"ion2-calendar": "^2.0.0",
"ionic-angular": "3.6.0",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
Expand Down Expand Up @@ -58,7 +59,8 @@
"ionic-plugin-keyboard": {}
},
"platforms": [
"android"
"android",
"ios"
]
}
}
1 change: 1 addition & 0 deletions demo/src/pages/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
basic
</ion-card-title>
<ion-calendar [(ngModel)]="date"
(onChange)="onChange($event)"
[format]="format">
</ion-calendar>
<p>{{date}}</p>
Expand Down
236 changes: 128 additions & 108 deletions demo/src/pages/home/home.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { ModalController, NavController } from 'ionic-angular';

import { CalendarComponentOptions, CalendarController, DayConfig } from 'ion2-calendar'
import {
CalendarComponentOptions,
CalendarModalOptions,
CalendarModal,
DayConfig
} from 'ion2-calendar'

import * as moment from 'moment'
@Component({
selector: 'page-home',
templateUrl: 'home.html'
Expand All @@ -12,7 +18,7 @@ export class HomePage {
days: Array<any> = [];
date: string;
dateMulti = [];
dateRangeObj: any;
dateRangeObj: { from: string; to: string; };
format = 'YYYY-MM-DD';
optionsMulti: CalendarComponentOptions = {
pickMode: 'multi'
Expand All @@ -24,174 +30,188 @@ export class HomePage {
};

constructor(public navCtrl: NavController,
public calendarCtrl: CalendarController,) {
public modalCtrl: ModalController) {

}

basic() {
onChange($event) {
console.log($event);
}

this.calendarCtrl.openCalendar({
basic() {
const options = {
title: 'BASIC',
canBackwardsSelected: true,
color: 'cal-color',
doneIcon: true,
closeIcon: true
})
.then((res: any) => {
console.log(res)
})
.catch(() => {
};
let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});

myCalendar.present();

myCalendar.onDidDismiss(date => {
console.log(date);
})
}

multi() {
this.calendarCtrl.openCalendar({
const options = {
pickMode: 'multi',
title: 'MULTI',
defaultDates: [new Date(2017, 7, 20), new Date(2017, 7, 18).getTime()]
})
.then((res: any) => {
console.log(res)
defaultDates: [moment(), moment().add(1, 'd'), moment().add(2, 'd')]
};

let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});

myCalendar.present();

myCalendar.onDidDismiss(date => {
console.log(date);
})
.catch(() => {
}

dateRange() {
const options: CalendarModalOptions = {
pickMode: 'range',
title: 'RANGE',
canBackwardsSelected: true,
color: 'danger'
};

let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});

myCalendar.present();

myCalendar.onDidDismiss(date => {
console.log(date);
});
}

setDefaultDate() {
this.calendarCtrl.openCalendar({
const options: CalendarModalOptions = {
from: new Date(2017, 1, 1),
defaultScrollTo: new Date(2017, 4, 1),
defaultDate: new Date(2017, 4, 1)
};

})
.then((res: any) => {
console.log(res)
})
.catch(() => {
})
}
let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});

myCalendar.present();

myCalendar.onDidDismiss(date => {
console.log(date);
});

}

setCssClass() {
this.calendarCtrl.openCalendar({
const options: CalendarModalOptions = {
cssClass: 'my-class',
color: 'secondary',
pickMode: 'range',
autoDone: true
})
.then((res: any) => {
console.log(res)
})
.catch(() => {
})
}
};

dateRange() {
this.calendarCtrl.openCalendar({
pickMode: 'range',
title: 'RANGE',
canBackwardsSelected: true,
color: 'danger'
})
.then((res: any) => {
console.log(res)
})
.catch(() => {
})
let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});

myCalendar.present();

myCalendar.onDidDismiss(date => {
console.log(date);
});
}

optional() {
this.calendarCtrl.openCalendar({
const options: CalendarModalOptions = {
from: new Date(2017, 1, 1),
to: new Date(2017, 2, 5),
})
.then((res: any) => {
console.log(res)
})
.catch(() => {
})
};

let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});

myCalendar.present();

myCalendar.onDidDismiss(date => {
console.log(date);
});
}

disableWeekdays() {
this.calendarCtrl.openCalendar({
const options: CalendarModalOptions = {
disableWeeks: [0, 6],
canBackwardsSelected: true,
})
.then((res: any) => {
console.log(res)
})
.catch(() => {
})
};

let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});

myCalendar.present();

myCalendar.onDidDismiss(date => {
console.log(date);
});
}

local() {

this.calendarCtrl.openCalendar({
const options: CalendarModalOptions = {
monthFormat: 'yyyy 年 MM 月 ',
weekdays: ['天', '一', '二', '三', '四', '五', '六'],
weekStart: 1,
color: 'light',
defaultDate: new Date()
})
.then((res: any) => {
console.log(res)
})
.catch(() => {
})
}
};

daysConfig() {
let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});

myCalendar.present();

let _daysConfig: DayConfig[] = [
{
date: new Date(2017, 0, 1),
subTitle: 'New Year\'s',
marked: true,
cssClass: 'day-danger',
},
{
date: new Date(2017, 1, 14),
subTitle: 'Valentine\'s',
},
{
date: new Date(2017, 3, 1),
subTitle: 'April Fools',
marked: true
},
{
date: new Date(2017, 3, 7),
subTitle: 'World Health',
},
{
date: new Date(2017, 4, 31),
subTitle: 'No-Smoking',
},
{
date: new Date(2017, 5, 1),
subTitle: 'Children\'s',
}
];
myCalendar.onDidDismiss(date => {
console.log(date);
});
}

daysConfig() {
let _daysConfig: DayConfig[] = [];
for (let i = 0; i < 31; i++) {
this.days.push({
_daysConfig.push({
date: new Date(2017, 0, i + 1),
subTitle: `$${i + 1}`
})
}

_daysConfig.push(...this.days);

this.calendarCtrl.openCalendar({
const options: CalendarModalOptions = {
from: new Date(2017, 0, 1),
to: new Date(2017, 11.1),
daysConfig: _daysConfig,
cssClass: 'my-cal',
})
.then((res: any) => {
console.log(res)
})
};

.catch(() => {
})
let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});

myCalendar.present();

myCalendar.onDidDismiss(date => {
console.log(date);
});
}


}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ion2-calendar",
"version": "2.0.0-beta.7",
"version": "2.0.0",
"description": "A date picker for ionic2 ",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
Expand Down

0 comments on commit 0d62052

Please sign in to comment.