mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
test(overlay): use injectable overlay controllers
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {ionicBootstrap, ActionSheet, Alert, Modal, NavController, ViewController, Platform} from '../../../../../src';
|
||||
import { ionicBootstrap, ActionSheetController, AlertController, ModalController, ViewController, Platform } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -8,12 +8,12 @@ import {ionicBootstrap, ActionSheet, Alert, Modal, NavController, ViewController
|
||||
class E2EPage {
|
||||
result: string = '';
|
||||
|
||||
constructor(private nav: NavController, private platform: Platform) {}
|
||||
constructor(private actionSheetCtrl: ActionSheetController, private alertCtrl: AlertController, private modalCtrl: ModalController, private platform: Platform) {}
|
||||
|
||||
presentActionSheet1() {
|
||||
this.result = '';
|
||||
|
||||
let actionSheet = ActionSheet.create({
|
||||
let actionSheet = this.actionSheetCtrl.create({
|
||||
title: 'Albums',
|
||||
buttons: [
|
||||
{
|
||||
@ -37,8 +37,8 @@ class E2EPage {
|
||||
text: 'Play',
|
||||
icon: !this.platform.is('ios') ? 'arrow-dropright-circle' : null,
|
||||
handler: () => {
|
||||
let modal = Modal.create(ModalPage);
|
||||
this.nav.present(modal);
|
||||
let modal = this.modalCtrl.create(ModalPage);
|
||||
modal.present();
|
||||
|
||||
// returning false does not allow the actionsheet to be closed
|
||||
return false;
|
||||
@ -64,13 +64,13 @@ class E2EPage {
|
||||
]
|
||||
});
|
||||
|
||||
this.nav.present(actionSheet);
|
||||
actionSheet.present();
|
||||
}
|
||||
|
||||
presentActionSheet2(ev) {
|
||||
presentActionSheet2() {
|
||||
this.result = '';
|
||||
|
||||
let actionSheet = ActionSheet.create({
|
||||
let actionSheet = this.actionSheetCtrl.create({
|
||||
enableBackdropDismiss: false,
|
||||
buttons: [
|
||||
{
|
||||
@ -99,20 +99,20 @@ class E2EPage {
|
||||
]
|
||||
});
|
||||
|
||||
this.nav.present(actionSheet);
|
||||
actionSheet.present(actionSheet);
|
||||
}
|
||||
|
||||
presentActionSheet3(ev) {
|
||||
presentActionSheet3() {
|
||||
this.result = '';
|
||||
|
||||
let actionSheet = ActionSheet.create({
|
||||
let actionSheet = this.actionSheetCtrl.create({
|
||||
buttons: [
|
||||
{
|
||||
text: 'Open Alert',
|
||||
handler: () => {
|
||||
this.result = 'Opened alert';
|
||||
|
||||
let alert = Alert.create();
|
||||
let alert = this.alertCtrl.create();
|
||||
alert.setTitle('Alert!');
|
||||
alert.setMessage('Alert opened from an action sheet');
|
||||
alert.addButton({
|
||||
@ -129,7 +129,7 @@ class E2EPage {
|
||||
}
|
||||
});
|
||||
|
||||
this.nav.present(alert).then(() => {
|
||||
alert.present().then(() => {
|
||||
this.result = 'Alert from action sheet opened';
|
||||
});
|
||||
|
||||
@ -147,7 +147,7 @@ class E2EPage {
|
||||
]
|
||||
});
|
||||
|
||||
this.nav.present(actionSheet);
|
||||
actionSheet.present();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {ionicBootstrap, Alert, Modal, NavController, ViewController} from '../../../../../src';
|
||||
import { ionicBootstrap, AlertController, ModalController, ViewController } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -15,21 +15,21 @@ class E2EPage {
|
||||
testCheckboxOpen: boolean = false;
|
||||
testCheckboxResult: string = '';
|
||||
|
||||
constructor(private nav: NavController) { }
|
||||
constructor(private alertCtrl: AlertController, private modalCtrl: ModalController) { }
|
||||
|
||||
doAlert() {
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Alert',
|
||||
subTitle: 'Subtitle',
|
||||
message: 'This is an alert message.',
|
||||
buttons: ['OK']
|
||||
});
|
||||
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
doConfirm() {
|
||||
let alert = Alert.create();
|
||||
let alert = this.alertCtrl.create();
|
||||
alert.setTitle('Confirm!');
|
||||
alert.setMessage('Message <strong>text</strong>!!!');
|
||||
alert.addButton({
|
||||
@ -50,30 +50,30 @@ class E2EPage {
|
||||
}
|
||||
});
|
||||
|
||||
this.nav.present(alert).then(() => {
|
||||
alert.present(alert).then(() => {
|
||||
this.testConfirmOpen = true;
|
||||
});
|
||||
}
|
||||
|
||||
doAlertLongMessage() {
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Alert',
|
||||
message: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum hendrerit diam lorem, a faucibus turpis sagittis eu. In finibus augue in dui varius convallis. Donec vulputate nibh gravida odio vulputate commodo. Suspendisse imperdiet consequat egestas. Nulla feugiat consequat urna eu tincidunt. Cras nec blandit turpis, eu auctor nunc. Pellentesque finibus, magna eu vestibulum imperdiet, arcu ex lacinia massa, eget volutpat quam leo a orci. Etiam mauris est, elementum at feugiat at, dictum in sapien. Mauris efficitur eros sodales convallis egestas. Phasellus eu faucibus nisl. In eu diam vitae libero egestas lacinia. Integer sed convallis metus, nec commodo felis. Duis libero augue, ornare at tempus non, posuere vel augue. Cras mattis dui at tristique aliquam. Phasellus fermentum nibh ligula, porta hendrerit ligula elementum eu. Suspendisse sollicitudin enim at libero iaculis pulvinar. Donec ac massa id purus laoreet rutrum quis eu urna. Mauris luctus erat vel magna porttitor, vel varius erat rhoncus. Donec eu turpis vestibulum, feugiat urna id, gravida mauris. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at lobortis tortor. Nam ultrices volutpat elit, sed pharetra nulla suscipit at. Nunc eu accumsan eros, id auctor libero. Suspendisse potenti. Nam vitae dapibus metus. Maecenas nisi dui, sagittis et condimentum eu, bibendum vel eros. Vivamus malesuada, tortor in accumsan iaculis, urna velit consectetur ante, nec semper sem diam a diam. In et semper ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus blandit, velit vel porttitor euismod, neque risus blandit nulla, non laoreet libero dolor et odio. Nulla enim risus, feugiat eu urna sed, ultrices semper felis. Sed blandit mi diam. Nunc quis mi ligula. Pellentesque a elit eu orci volutpat egestas. Aenean fermentum eleifend quam, ut tincidunt eros tristique et. Nam dapibus tincidunt ligula, id faucibus felis sodales quis. Donec tincidunt lectus ipsum, ac semper tellus cursus ac. Vestibulum nec dui a lectus accumsan vestibulum quis et velit. Aliquam finibus justo et odio euismod, viverra condimentum eros tristique. Sed eget luctus risus. Pellentesque lorem magna, dictum non congue sodales, laoreet eget quam. In sagittis vulputate dolor a ultricies. Donec viverra leo sed ex maximus, in finibus elit gravida. Aliquam posuere vulputate mi. Suspendisse potenti. Nunc consectetur congue arcu, at pharetra dui varius non. Etiam vestibulum congue felis, id ullamcorper neque convallis ultrices. Aenean congue, diam a iaculis mollis, nisl eros maximus arcu, nec hendrerit purus felis porta diam. Nullam vitae ultrices dui, ac dictum sapien. Phasellus eu magna luctus, varius urna id, molestie quam. Nulla in semper tellus. Curabitur lacinia tellus sit amet lacinia dapibus. Sed id condimentum tellus, nec aliquam sapien. Vivamus luctus at ante a tincidunt.',
|
||||
buttons: ['Cancel', 'OK']
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present(alert);
|
||||
}
|
||||
|
||||
doAlertNoMessage() {
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Alert',
|
||||
buttons: ['OK']
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
doMultipleButtons() {
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Alert',
|
||||
subTitle: 'Subtitle',
|
||||
message: 'This is an alert message.'
|
||||
@ -82,19 +82,18 @@ class E2EPage {
|
||||
alert.addButton({
|
||||
text: 'Open Modal',
|
||||
handler: () => {
|
||||
let modal = Modal.create(ModalPage);
|
||||
this.nav.present(modal);
|
||||
this.modalCtrl.create(ModalPage).present();
|
||||
|
||||
// do not close the alert when this button is pressed
|
||||
return false;
|
||||
}
|
||||
});
|
||||
alert.addButton('Delete');
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
doPrompt() {
|
||||
let alert = Alert.create();
|
||||
let alert = this.alertCtrl.create();
|
||||
alert.setTitle('Prompt!');
|
||||
alert.addInput({
|
||||
placeholder: 'Placeholder 1'
|
||||
@ -112,7 +111,7 @@ class E2EPage {
|
||||
});
|
||||
alert.addButton({
|
||||
text: 'Cancel',
|
||||
handler: data => {
|
||||
handler: (data: any) => {
|
||||
console.log('500ms delayed prompt close');
|
||||
|
||||
setTimeout(() => {
|
||||
@ -126,24 +125,24 @@ class E2EPage {
|
||||
});
|
||||
alert.addButton({
|
||||
text: 'Ok',
|
||||
handler: data => {
|
||||
handler: (data: any) => {
|
||||
console.log('Prompt data:', data);
|
||||
this.testPromptOpen = false;
|
||||
this.testPromptResult = data;
|
||||
}
|
||||
});
|
||||
|
||||
this.nav.present(alert).then(() => {
|
||||
alert.present().then(() => {
|
||||
this.testPromptOpen = true;
|
||||
});
|
||||
|
||||
alert.onDismiss((data, role) => {
|
||||
alert.onDismiss((data: any, role: any) => {
|
||||
console.log('onDismiss, data:', data, 'role:', role);
|
||||
});
|
||||
}
|
||||
|
||||
doRadio() {
|
||||
let alert = Alert.create();
|
||||
let alert = this.alertCtrl.create();
|
||||
alert.setTitle('Radio!');
|
||||
|
||||
alert.addInput({
|
||||
@ -186,20 +185,20 @@ class E2EPage {
|
||||
alert.addButton('Cancel');
|
||||
alert.addButton({
|
||||
text: 'Ok',
|
||||
handler: data => {
|
||||
handler: (data: any) => {
|
||||
console.log('Radio data:', data);
|
||||
this.testRadioOpen = false;
|
||||
this.testRadioResult = data;
|
||||
}
|
||||
});
|
||||
|
||||
this.nav.present(alert).then(() => {
|
||||
alert.present().then(() => {
|
||||
this.testRadioOpen = true;
|
||||
});
|
||||
}
|
||||
|
||||
doCheckbox() {
|
||||
let alert = Alert.create();
|
||||
let alert = this.alertCtrl.create();
|
||||
alert.setTitle('Checkbox!');
|
||||
|
||||
alert.addInput({
|
||||
@ -242,25 +241,25 @@ class E2EPage {
|
||||
alert.addButton('Cancel');
|
||||
alert.addButton({
|
||||
text: 'Ok',
|
||||
handler: data => {
|
||||
handler: (data: any) => {
|
||||
console.log('Checkbox data:', data);
|
||||
this.testCheckboxOpen = false;
|
||||
this.testCheckboxResult = data;
|
||||
}
|
||||
});
|
||||
|
||||
this.nav.present(alert).then(() => {
|
||||
alert.present().then(() => {
|
||||
this.testCheckboxOpen = true;
|
||||
});
|
||||
}
|
||||
|
||||
doFastClose() {
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Alert!',
|
||||
buttons: ['OK']
|
||||
});
|
||||
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
|
||||
setTimeout(() => {
|
||||
alert.dismiss();
|
||||
@ -268,7 +267,7 @@ class E2EPage {
|
||||
}
|
||||
|
||||
doDisabledBackdropAlert() {
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
enableBackdropDismiss: false
|
||||
});
|
||||
alert.setTitle('Disabled Backdrop Click'),
|
||||
@ -281,7 +280,7 @@ class E2EPage {
|
||||
}
|
||||
});
|
||||
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
ionViewDidLeave() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {ionicBootstrap, Alert, Loading, NavController} from '../../../../index';
|
||||
import { ionicBootstrap, AlertController, LoadingController, NavController } from '../../../../index';
|
||||
import { FormBuilder, ControlGroup, Validators } from '@angular/common';
|
||||
|
||||
|
||||
@ -8,10 +8,10 @@ import {FormBuilder, ControlGroup, Validators} from '@angular/common';
|
||||
})
|
||||
export class E2EPage {
|
||||
|
||||
constructor(private nav: NavController) {}
|
||||
constructor(private alertCtrl: AlertController, private nav: NavController) {}
|
||||
|
||||
submit() {
|
||||
var alert = Alert.create({
|
||||
var alert = this.alertCtrl.create({
|
||||
title: 'Not logged in',
|
||||
message: 'Sign in to continue.',
|
||||
buttons: [
|
||||
@ -29,7 +29,7 @@ export class E2EPage {
|
||||
this.nav.push(AnotherPage);
|
||||
});
|
||||
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ export class E2EPage {
|
||||
class AnotherPage {
|
||||
form: ControlGroup;
|
||||
|
||||
constructor(private nav: NavController, private builder: FormBuilder) {
|
||||
constructor(private nav: NavController, private alertCtrl: AlertController, private loadingCtrl: LoadingController, private builder: FormBuilder) {
|
||||
this.form = builder.group({
|
||||
name: builder.control('', Validators.compose([
|
||||
Validators.required,
|
||||
@ -75,12 +75,13 @@ class AnotherPage {
|
||||
submit(value: any): void {
|
||||
if (this.form.valid) {
|
||||
console.log(value);
|
||||
|
||||
} else {
|
||||
this.nav.present(Alert.create({
|
||||
this.alertCtrl.create({
|
||||
title: 'Invalid input data',
|
||||
subTitle: "Please correct the errors and resubmit the data.",
|
||||
buttons: [ 'OK' ]
|
||||
}));
|
||||
}).present();
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ class AnotherPage {
|
||||
}
|
||||
|
||||
showConfirm() {
|
||||
const alert = Alert.create({
|
||||
const alert = this.alertCtrl.create({
|
||||
title: `Hi there`,
|
||||
buttons: [
|
||||
{
|
||||
@ -110,21 +111,21 @@ class AnotherPage {
|
||||
}
|
||||
]
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
doFastPop() {
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Async Nav Transition',
|
||||
message: 'This is an example of dismissing an alert, then quickly starting another transition on the same nav controller.',
|
||||
buttons: [{
|
||||
text: 'Ok',
|
||||
handler: () => {
|
||||
// present a loading indicator
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
content: 'Loading...'
|
||||
});
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
|
||||
// start an async operation
|
||||
setTimeout(() => {
|
||||
@ -150,7 +151,7 @@ class AnotherPage {
|
||||
}
|
||||
}]
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ describe('App', () => {
|
||||
it('should select the previous tab', () => {
|
||||
let nav = mockNav();
|
||||
let portal = mockNav();
|
||||
nav.setPortal(portal);
|
||||
app.setPortal(portal);
|
||||
app.setRootNav(nav);
|
||||
|
||||
let tabs = mockTabs();
|
||||
@ -42,7 +42,7 @@ describe('App', () => {
|
||||
it('should pop from the active tab, when tabs is nested is the root nav', () => {
|
||||
let nav = mockNav();
|
||||
let portal = mockNav();
|
||||
nav.setPortal(portal);
|
||||
app.setPortal(portal);
|
||||
app.setRootNav(nav);
|
||||
|
||||
let tabs = mockTabs();
|
||||
@ -94,7 +94,7 @@ describe('App', () => {
|
||||
let rootNav = mockNav();
|
||||
let nestedNav = mockNav();
|
||||
let portal = mockNav();
|
||||
rootNav.setPortal(portal);
|
||||
app.setPortal(portal);
|
||||
rootNav.registerChildNav(nestedNav);
|
||||
nestedNav.parent = rootNav;
|
||||
app.setRootNav(rootNav);
|
||||
@ -123,7 +123,7 @@ describe('App', () => {
|
||||
let rootNav = mockNav();
|
||||
let nestedNav = mockNav();
|
||||
let portal = mockNav();
|
||||
rootNav.setPortal(portal);
|
||||
app.setPortal(portal);
|
||||
app.setRootNav(rootNav);
|
||||
rootNav.registerChildNav(nestedNav);
|
||||
|
||||
@ -151,7 +151,7 @@ describe('App', () => {
|
||||
it('should pop the overlay in the portal of the root nav', () => {
|
||||
let nav = mockNav();
|
||||
let portal = mockNav();
|
||||
nav.setPortal(portal);
|
||||
app.setPortal(portal);
|
||||
app.setRootNav(nav);
|
||||
|
||||
spyOn(platform, 'exitApp');
|
||||
@ -175,7 +175,7 @@ describe('App', () => {
|
||||
it('should pop the second view in the root nav', () => {
|
||||
let nav = mockNav();
|
||||
let portal = mockNav();
|
||||
nav.setPortal(portal);
|
||||
app.setPortal(portal);
|
||||
app.setRootNav(nav);
|
||||
|
||||
spyOn(platform, 'exitApp');
|
||||
@ -196,7 +196,7 @@ describe('App', () => {
|
||||
it('should exit app when only one view in the root nav', () => {
|
||||
let nav = mockNav();
|
||||
let portal = mockNav();
|
||||
nav.setPortal(portal);
|
||||
app.setPortal(portal);
|
||||
app.setRootNav(nav);
|
||||
|
||||
spyOn(platform, 'exitApp');
|
||||
@ -219,7 +219,7 @@ describe('App', () => {
|
||||
it('should not exit app when only one view in the root nav, but navExitApp config set', () => {
|
||||
let nav = mockNav();
|
||||
let portal = mockNav();
|
||||
nav.setPortal(portal);
|
||||
app.setPortal(portal);
|
||||
app.setRootNav(nav);
|
||||
|
||||
spyOn(platform, 'exitApp');
|
||||
@ -244,7 +244,7 @@ describe('App', () => {
|
||||
it('should not go back if app is not enabled', () => {
|
||||
let nav = mockNav();
|
||||
let portal = mockNav();
|
||||
nav.setPortal(portal);
|
||||
app.setPortal(portal);
|
||||
app.setRootNav(nav);
|
||||
|
||||
spyOn(platform, 'exitApp');
|
||||
@ -372,71 +372,71 @@ describe('App', () => {
|
||||
describe('setEnabled', () => {
|
||||
it('should disable click block when app is enabled', () => {
|
||||
// arrange
|
||||
let mockClickBlock = {
|
||||
show: () => {}
|
||||
let mockClickBlock: any = {
|
||||
activate: () => {}
|
||||
};
|
||||
|
||||
spyOn(mockClickBlock, 'show');
|
||||
spyOn(mockClickBlock, 'activate');
|
||||
|
||||
app._clickBlock = mockClickBlock;
|
||||
app.clickBlock = mockClickBlock;
|
||||
|
||||
// act
|
||||
app.setEnabled(true);
|
||||
|
||||
// assert
|
||||
expect(mockClickBlock.show).toHaveBeenCalledWith(false, 0);
|
||||
expect(mockClickBlock.activate).toHaveBeenCalledWith(false, 0);
|
||||
});
|
||||
|
||||
it('should disable click block when app is disabled but duration of less than 32 passed', () => {
|
||||
// arrange
|
||||
let mockClickBlock = {
|
||||
show: () => {}
|
||||
let mockClickBlock: any = {
|
||||
activate: () => {}
|
||||
};
|
||||
|
||||
spyOn(mockClickBlock, 'show');
|
||||
spyOn(mockClickBlock, 'activate');
|
||||
|
||||
app._clickBlock = mockClickBlock;
|
||||
app.clickBlock = mockClickBlock;
|
||||
|
||||
// act
|
||||
app.setEnabled(false, 20);
|
||||
|
||||
// assert
|
||||
expect(mockClickBlock.show).toHaveBeenCalledWith(false, 0);
|
||||
expect(mockClickBlock.activate).toHaveBeenCalledWith(false, 0);
|
||||
});
|
||||
|
||||
it('should enable click block when false is passed with duration', () => {
|
||||
// arrange
|
||||
let mockClickBlock = {
|
||||
show: () => {}
|
||||
let mockClickBlock: any = {
|
||||
activate: () => {}
|
||||
};
|
||||
|
||||
spyOn(mockClickBlock, 'show');
|
||||
spyOn(mockClickBlock, 'activate');
|
||||
|
||||
app._clickBlock = mockClickBlock;
|
||||
app.clickBlock = mockClickBlock;
|
||||
|
||||
// act
|
||||
app.setEnabled(false, 200);
|
||||
|
||||
// assert
|
||||
expect(mockClickBlock.show).toHaveBeenCalledWith(true, 200 + 64);
|
||||
expect(mockClickBlock.activate).toHaveBeenCalledWith(true, 200 + 64);
|
||||
});
|
||||
|
||||
it('should enable click block when false is passed w/o duration', () => {
|
||||
// arrange
|
||||
let mockClickBlock = {
|
||||
show: () => {}
|
||||
let mockClickBlock: any = {
|
||||
activate: () => {}
|
||||
};
|
||||
|
||||
spyOn(mockClickBlock, 'show');
|
||||
spyOn(mockClickBlock, 'activate');
|
||||
|
||||
app._clickBlock = mockClickBlock;
|
||||
app.clickBlock = mockClickBlock;
|
||||
|
||||
// act
|
||||
app.setEnabled(false);
|
||||
|
||||
// assert
|
||||
// 700 is the default
|
||||
expect(mockClickBlock.show).toHaveBeenCalledWith(true, 700 + 64);
|
||||
expect(mockClickBlock.activate).toHaveBeenCalledWith(true, 700 + 64);
|
||||
});
|
||||
});
|
||||
|
||||
@ -469,7 +469,7 @@ describe('App', () => {
|
||||
beforeEach(() => {
|
||||
config = new Config();
|
||||
platform = new Platform();
|
||||
app = new App(config, null, platform);
|
||||
app = new App(config, platform);
|
||||
_cd = {
|
||||
reattach: function(){},
|
||||
detach: function(){}
|
||||
|
@ -15,6 +15,6 @@ it('should open modal', function() {
|
||||
element(by.css('.e2eCordovaOpenModal')).click();
|
||||
});
|
||||
|
||||
it('should open left menu', function() {
|
||||
element(by.css('.e2eCordovaOpenLeftMenu')).click();
|
||||
it('should close modal', function() {
|
||||
element(by.css('.e2eCordovaCloseModal')).click();
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {ionicBootstrap, NavController, Modal, ViewController} from '../../../../../src';
|
||||
import {ionicBootstrap, NavController, ModalController, ViewController} from '../../../../../src';
|
||||
import {Injectable} from '@angular/core';
|
||||
|
||||
|
||||
@ -26,9 +26,11 @@ export class OtherData {
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>This is a modal</ion-title>
|
||||
<button menuToggle class="e2eCordovaOpenLeftMenu">
|
||||
<ion-icon name="menu"></ion-icon>
|
||||
<ion-buttons left>
|
||||
<button (click)="dismissModal()" class="e2eCordovaCloseModal">
|
||||
<ion-icon name="close"></ion-icon>
|
||||
</button>
|
||||
</ion-buttons>
|
||||
<ion-buttons end>
|
||||
<button>
|
||||
<ion-icon name="funnel"></ion-icon>
|
||||
@ -76,11 +78,10 @@ class Page2 {
|
||||
page1 = Page1;
|
||||
page3 = Page3;
|
||||
|
||||
constructor(private nav: NavController) {}
|
||||
constructor(private modalCtrl: ModalController) {}
|
||||
|
||||
openModal() {
|
||||
let modal = Modal.create(MyModal);
|
||||
this.nav.present(modal);
|
||||
this.modalCtrl.create(MyModal).present();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import {ionicBootstrap, App, Alert, NavController, List, ItemSliding, Toast} from '../../../../../src';
|
||||
import { ionicBootstrap, AlertController, NavController, List, ItemSliding, ToastController } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -14,7 +14,7 @@ class E2EPage {
|
||||
moreText: string = 'Dynamic More';
|
||||
archiveText: string = 'Dynamic Archive';
|
||||
|
||||
constructor(private app: App, private nav: NavController) {
|
||||
constructor(private nav: NavController, private alertCtrl: AlertController, private toastCtrl: ToastController) {
|
||||
for (let x = 0; x < 5; x++) {
|
||||
this.items.push(x);
|
||||
}
|
||||
@ -28,6 +28,7 @@ class E2EPage {
|
||||
if (this.moreText.includes('Dynamic')) {
|
||||
this.moreText = 'Changed More';
|
||||
this.archiveText = 'Changed Archive';
|
||||
|
||||
} else {
|
||||
this.moreText = 'Dynamic More';
|
||||
this.archiveText = 'Dynamic Archive';
|
||||
@ -48,17 +49,17 @@ class E2EPage {
|
||||
didClick(item: ItemSliding) {
|
||||
console.log('Clicked, ion-item');
|
||||
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Clicked ion-item!',
|
||||
buttons: ['Ok']
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
archive(item: ItemSliding) {
|
||||
console.log('Archive, ion-item-options button', item);
|
||||
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Archived!',
|
||||
buttons: [{
|
||||
text: 'Ok',
|
||||
@ -67,13 +68,13 @@ class E2EPage {
|
||||
}
|
||||
}]
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
del(item: ItemSliding) {
|
||||
console.log('Delete ion-item-options button', item);
|
||||
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Deleted!',
|
||||
buttons: [{
|
||||
text: 'Ok',
|
||||
@ -82,17 +83,18 @@ class E2EPage {
|
||||
}
|
||||
}]
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
download(item: ItemSliding) {
|
||||
item.setClass('downloading', true);
|
||||
item.setCssClass('downloading', true);
|
||||
setTimeout(() => {
|
||||
const toast = Toast.create({
|
||||
const toast = this.toastCtrl.create({
|
||||
message: 'Item was downloaded!'
|
||||
});
|
||||
this.nav.present(toast);
|
||||
item.setClass('downloading', false);
|
||||
toast.present();
|
||||
|
||||
item.setCssClass('downloading', false);
|
||||
item.close();
|
||||
setTimeout(() => {
|
||||
toast.dismiss();
|
||||
|
@ -1,15 +1,15 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {ionicBootstrap, ActionSheet, Loading, NavController, ViewController, Platform} from '../../../../../src';
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { ionicBootstrap, LoadingController, NavController } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {
|
||||
constructor(private nav: NavController, private platform: Platform) {}
|
||||
constructor(private loadingCtrl: LoadingController, private nav: NavController) {}
|
||||
|
||||
presentLoadingIos() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
spinner: 'ios',
|
||||
duration: 1000,
|
||||
cssClass: 'my-custom-loader'
|
||||
@ -19,58 +19,58 @@ class E2EPage {
|
||||
console.log('Dismissed loading');
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
}
|
||||
|
||||
presentLoadingDots() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
spinner: 'dots',
|
||||
content: 'Loading...',
|
||||
duration: 1000
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
}
|
||||
|
||||
presentLoadingBubbles() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
spinner: 'bubbles',
|
||||
content: 'Loading...',
|
||||
duration: 1000
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
}
|
||||
|
||||
presentLoadingCircles() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
spinner: 'circles',
|
||||
content: 'Loading...',
|
||||
duration: 1000
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
}
|
||||
|
||||
presentLoadingCrescent() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
spinner: 'crescent',
|
||||
content: 'Please wait...',
|
||||
duration: 1000
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
}
|
||||
|
||||
// Pass the fixed-spinner class so we can turn off
|
||||
// spinner animation for the e2e test
|
||||
presentLoadingDefault() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
content: 'Please wait...',
|
||||
cssClass: 'fixed-spinner'
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
|
||||
setTimeout(() => {
|
||||
loading.dismiss();
|
||||
@ -78,7 +78,7 @@ class E2EPage {
|
||||
}
|
||||
|
||||
presentLoadingCustom() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
spinner: 'hide',
|
||||
content: `
|
||||
<div class="custom-spinner-container">
|
||||
@ -87,16 +87,16 @@ class E2EPage {
|
||||
duration: 1000
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
}
|
||||
|
||||
presentLoadingText() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
spinner: 'hide',
|
||||
content: 'Loading Please Wait...'
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
|
||||
setTimeout(() => {
|
||||
this.nav.push(Page2);
|
||||
@ -112,29 +112,29 @@ class E2EPage {
|
||||
}
|
||||
|
||||
presentLoadingMultiple() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
spinner: 'hide',
|
||||
content: 'Loading 1 Please Wait...'
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
|
||||
let loading2 = Loading.create({
|
||||
let loading2 = this.loadingCtrl.create({
|
||||
spinner: 'hide',
|
||||
content: 'Loading 2 Please Wait...'
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
this.nav.present(loading2);
|
||||
loading2.present();
|
||||
}, 1000);
|
||||
|
||||
let loading3 = Loading.create({
|
||||
let loading3 = this.loadingCtrl.create({
|
||||
spinner: 'hide',
|
||||
content: 'Loading 3 Please Wait...'
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
this.nav.present(loading3);
|
||||
loading3.present();
|
||||
|
||||
setTimeout(() => {
|
||||
loading3.dismiss();
|
||||
@ -152,32 +152,32 @@ class E2EPage {
|
||||
}
|
||||
|
||||
presentLoadingMultipleNav() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
spinner: 'hide',
|
||||
content: 'Loading 1 Please Wait...',
|
||||
dismissOnPageChange: true
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
|
||||
let loading2 = Loading.create({
|
||||
let loading2 = this.loadingCtrl.create({
|
||||
spinner: 'hide',
|
||||
content: 'Loading 2 Please Wait...',
|
||||
dismissOnPageChange: true
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
this.nav.present(loading2);
|
||||
loading2.present();
|
||||
}, 500);
|
||||
|
||||
let loading3 = Loading.create({
|
||||
let loading3 = this.loadingCtrl.create({
|
||||
spinner: 'hide',
|
||||
content: 'Loading 3 Please Wait...',
|
||||
dismissOnPageChange: true
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
this.nav.present(loading3);
|
||||
loading3.present();
|
||||
|
||||
setTimeout(() => {
|
||||
this.nav.push(Page2);
|
||||
@ -207,7 +207,7 @@ class E2EPage {
|
||||
`
|
||||
})
|
||||
class Page2 {
|
||||
constructor(private nav: NavController, private platform: Platform) {}
|
||||
constructor(private nav: NavController) {}
|
||||
|
||||
ionViewLoaded() {
|
||||
setTimeout(() => {
|
||||
@ -230,17 +230,17 @@ class Page2 {
|
||||
<ion-content padding>Some content</ion-content>
|
||||
`
|
||||
})
|
||||
class Page3 {
|
||||
constructor(private nav: NavController, private platform: Platform) {}
|
||||
}
|
||||
class Page3 {}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="root"></ion-nav>'
|
||||
template: `
|
||||
<link href="styles.css" rel="stylesheet">
|
||||
<ion-nav [root]="root"></ion-nav>
|
||||
`,
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
class E2EApp {
|
||||
root = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
|
||||
document.body.innerHTML += '<link href="styles.css" rel="stylesheet">'
|
||||
|
@ -1,29 +1,29 @@
|
||||
import { Component} from '@angular/core';
|
||||
import {ionicBootstrap, ActionSheet, Loading, NavController, ViewController, Platform} from '../../../../../src';
|
||||
import { ionicBootstrap, LoadingController, NavController } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {
|
||||
constructor(private nav: NavController, private platform: Platform) {}
|
||||
constructor(private loadingCtrl: LoadingController, private nav: NavController) {}
|
||||
|
||||
presentLoading() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
spinner: 'hide',
|
||||
content: 'Loading...',
|
||||
duration: 1000
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
}
|
||||
|
||||
presentLoadingNav() {
|
||||
let loading = Loading.create({
|
||||
let loading = this.loadingCtrl.create({
|
||||
content: 'Please wait...',
|
||||
});
|
||||
|
||||
this.nav.present(loading);
|
||||
loading.present();
|
||||
|
||||
setTimeout(() => {
|
||||
this.nav.push(Page2);
|
||||
@ -46,9 +46,7 @@ class E2EPage {
|
||||
<ion-content padding>Some content</ion-content>
|
||||
`
|
||||
})
|
||||
class Page2 {
|
||||
constructor(private nav: NavController, private platform: Platform) {}
|
||||
}
|
||||
class Page2 {}
|
||||
|
||||
@Component({
|
||||
template: `
|
||||
@ -63,10 +61,6 @@ export class TabsPage {
|
||||
private root1 = E2EPage;
|
||||
private root2 = Page2;
|
||||
private root3 = E2EPage;
|
||||
|
||||
constructor() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
@ -1,21 +1,21 @@
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import {ionicBootstrap, MenuController, NavController, Alert, Nav} from '../../../../../src';
|
||||
import { ionicBootstrap, MenuController, NavController, AlertController, Nav } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'page1.html'
|
||||
})
|
||||
class Page1 {
|
||||
constructor(private nav: NavController) {}
|
||||
constructor(private nav: NavController, private alertCtrl: AlertController) {}
|
||||
|
||||
presentAlert() {
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'New Friend!',
|
||||
message: 'Your friend, Obi wan Kenobi, just accepted your friend request!',
|
||||
cssClass: 'my-alert',
|
||||
buttons: ['Ok']
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
goToPage2() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import {ionicBootstrap, Nav, Alert} from '../../../../../src';
|
||||
import { ionicBootstrap, Nav, AlertController } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({templateUrl: 'page1.html'})
|
||||
@ -14,6 +14,8 @@ class E2EApp {
|
||||
|
||||
rootView = Page1;
|
||||
|
||||
constructor(private alertCtrl: AlertController) { }
|
||||
|
||||
openPage(menu: any, page: any) {
|
||||
// close the menu when clicking a link from the menu
|
||||
menu.close();
|
||||
@ -24,11 +26,11 @@ class E2EApp {
|
||||
}
|
||||
|
||||
showAlert() {
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Alert example',
|
||||
buttons: ['Ok']
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import {ionicBootstrap, Nav, Alert} from '../../../../../src';
|
||||
import { ionicBootstrap, Nav, AlertController } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({templateUrl: 'page1.html'})
|
||||
@ -14,6 +14,8 @@ class E2EApp {
|
||||
|
||||
rootView = Page1;
|
||||
|
||||
constructor(private alertCtrl: AlertController) { }
|
||||
|
||||
openPage(menu: any, page: any) {
|
||||
// close the menu when clicking a link from the menu
|
||||
menu.close();
|
||||
@ -24,11 +26,11 @@ class E2EApp {
|
||||
}
|
||||
|
||||
showAlert() {
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Alert example',
|
||||
buttons: ['Ok']
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { ActionSheet, Config, ionicBootstrap, Modal, NavController, NavParams, PageTransition, Platform, TransitionOptions, ViewController } from '../../../../../src';
|
||||
import { ActionSheetController, Config, ionicBootstrap, ModalController, NavController, NavParams, PageTransition, Platform, TransitionOptions, ViewController } from '../../../../../src';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
@ -8,7 +8,7 @@ import { ActionSheet, Config, ionicBootstrap, Modal, NavController, NavParams, P
|
||||
class E2EPage {
|
||||
platforms: string[];
|
||||
|
||||
constructor(private nav: NavController, config: Config, platform: Platform) {
|
||||
constructor(private nav: NavController, private modalCtrl: ModalController, config: Config, platform: Platform) {
|
||||
console.log('platforms', platform.platforms());
|
||||
console.log('mode', config.get('mode'));
|
||||
|
||||
@ -33,8 +33,8 @@ class E2EPage {
|
||||
}
|
||||
|
||||
presentModal() {
|
||||
let modal = Modal.create(ModalPassData, { userId: 8675309 });
|
||||
this.nav.present(modal);
|
||||
let modal = this.modalCtrl.create(ModalPassData, { userId: 8675309 });
|
||||
modal.present();
|
||||
|
||||
modal.onDismiss((data: any) => {
|
||||
console.log('modal data', data);
|
||||
@ -42,13 +42,12 @@ class E2EPage {
|
||||
}
|
||||
|
||||
presentModalChildNav() {
|
||||
let modal = Modal.create(ContactUs);
|
||||
this.nav.present(modal);
|
||||
this.modalCtrl.create(ContactUs).present();
|
||||
}
|
||||
|
||||
presentToolbarModal() {
|
||||
let modal = Modal.create(ToolbarModal);
|
||||
this.nav.present(modal);
|
||||
let modal = this.modalCtrl.create(ToolbarModal);
|
||||
modal.present();
|
||||
|
||||
modal.subscribe((data: any) => {
|
||||
console.log('modal data', data);
|
||||
@ -56,23 +55,22 @@ class E2EPage {
|
||||
}
|
||||
|
||||
presentModalWithInputs() {
|
||||
let modal = Modal.create(ModalWithInputs);
|
||||
let modal = this.modalCtrl.create(ModalWithInputs);
|
||||
modal.onDismiss((data: any) => {
|
||||
console.log('Modal with inputs data:', data);
|
||||
});
|
||||
this.nav.present(modal);
|
||||
modal.present();
|
||||
}
|
||||
|
||||
presentModalCustomAnimation() {
|
||||
let modal = Modal.create(ContactUs);
|
||||
this.nav.present(modal, {
|
||||
let modal = this.modalCtrl.create(ContactUs);
|
||||
modal.present({
|
||||
animation: 'my-fade-in'
|
||||
});
|
||||
}
|
||||
|
||||
presentNavigableModal(){
|
||||
let modal = Modal.create(NavigableModal);
|
||||
this.nav.present(modal);
|
||||
this.modalCtrl.create(NavigableModal).present();
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,7 +344,7 @@ class ContactUs {
|
||||
class ModalFirstPage {
|
||||
|
||||
private items:any[];
|
||||
constructor(private nav: NavController) {
|
||||
constructor(private nav: NavController, private actionSheetCtrl: ActionSheetController) {
|
||||
this.items = [];
|
||||
for ( let i = 0; i < 50; i++ ){
|
||||
this.items.push({
|
||||
@ -379,7 +377,7 @@ class ModalFirstPage {
|
||||
}
|
||||
|
||||
openActionSheet() {
|
||||
let actionSheet = ActionSheet.create({
|
||||
let actionSheet = this.actionSheetCtrl.create({
|
||||
buttons: [
|
||||
{
|
||||
text: 'Destructive',
|
||||
@ -421,7 +419,7 @@ class ModalFirstPage {
|
||||
]
|
||||
});
|
||||
|
||||
this.nav.present(actionSheet);
|
||||
actionSheet.present();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {Modal, NavController, ViewController} from '../../../../src';
|
||||
import {ModalCmp} from '../../../../src/components/modal/modal';
|
||||
import { ModalController, ViewController } from '../../../../src';
|
||||
import { ModalCmp } from '../../../../src/components/modal/modal-component';
|
||||
|
||||
export function run() {
|
||||
describe('Modal', () => {
|
||||
@ -8,7 +8,8 @@ export function run() {
|
||||
describe('create', () => {
|
||||
|
||||
it('should have the correct properties on modal view controller instance', () => {
|
||||
let modalViewController = Modal.create(ComponentToPresent);
|
||||
let modalCtrl = new ModalController(null);
|
||||
let modalViewController = modalCtrl.create(ComponentToPresent);
|
||||
expect(modalViewController.componentType).toEqual(ModalCmp);
|
||||
expect(modalViewController.isOverlay).toEqual(true);
|
||||
expect(modalViewController instanceof ViewController).toEqual(true);
|
||||
@ -19,25 +20,7 @@ export function run() {
|
||||
|
||||
}
|
||||
|
||||
const STATE_ACTIVE = 'active';
|
||||
const STATE_INACTIVE = 'inactive';
|
||||
const STATE_INIT_ENTER = 'init_enter';
|
||||
const STATE_INIT_LEAVE = 'init_leave';
|
||||
const STATE_TRANS_ENTER = 'trans_enter';
|
||||
const STATE_TRANS_LEAVE = 'trans_leave';
|
||||
const STATE_REMOVE = 'remove';
|
||||
const STATE_REMOVE_AFTER_TRANS = 'remove_after_trans';
|
||||
const STATE_FORCE_ACTIVE = 'force_active';
|
||||
|
||||
|
||||
let componentToPresentSpy = {
|
||||
_ionicProjectContent: () => {},
|
||||
};
|
||||
|
||||
@Component({
|
||||
template: `<div class="myComponent"></div>`
|
||||
})
|
||||
class ComponentToPresent{
|
||||
constructor(){
|
||||
}
|
||||
}
|
||||
class ComponentToPresent{}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Component, Type, ViewChild} from '@angular/core';
|
||||
import {App, NavController, Alert, Content} from '../../../../../src';
|
||||
import {ionicBootstrap, Config} from '../../../../../src';
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { NavController, AlertController, Content } from '../../../../../src';
|
||||
import { ionicBootstrap } from '../../../../../src';
|
||||
import { NavParams, ViewController } from '../../../../../src';;
|
||||
|
||||
|
||||
@ -148,6 +148,7 @@ class FirstPage {
|
||||
class FullPage {
|
||||
constructor(
|
||||
private nav: NavController,
|
||||
private alertCtrl: AlertController,
|
||||
private params: NavParams
|
||||
) {}
|
||||
|
||||
@ -173,7 +174,7 @@ class FullPage {
|
||||
}
|
||||
|
||||
presentAlert() {
|
||||
let alert = Alert.create();
|
||||
let alert = this.alertCtrl.create();
|
||||
alert.setTitle('Hello Alert');
|
||||
alert.setMessage('Dismiss this alert, then pop one page');
|
||||
alert.addButton({
|
||||
@ -194,7 +195,7 @@ class FullPage {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
}
|
||||
@ -242,6 +243,7 @@ class FullPage {
|
||||
class PrimaryHeaderPage {
|
||||
constructor(
|
||||
private nav: NavController,
|
||||
private alertCtrl: AlertController,
|
||||
private viewCtrl: ViewController
|
||||
) {}
|
||||
|
||||
@ -270,10 +272,10 @@ class PrimaryHeaderPage {
|
||||
}
|
||||
|
||||
presentAlert() {
|
||||
let alert = Alert.create();
|
||||
let alert = this.alertCtrl.create();
|
||||
alert.setTitle('Hello Alert');
|
||||
alert.addButton({ text: 'Dismiss', role: 'cancel', });
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import {ionicBootstrap, Picker, NavController} from '../../../../../src';
|
||||
import { ionicBootstrap, PickerController } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -10,10 +10,10 @@ class E2EPage {
|
||||
smoothie: string;
|
||||
timer: string;
|
||||
|
||||
constructor(private nav: NavController) {}
|
||||
constructor(private pickerCtrl: PickerController) {}
|
||||
|
||||
twoColumns() {
|
||||
let picker = Picker.create({
|
||||
let picker = this.pickerCtrl.create({
|
||||
buttons: [
|
||||
{
|
||||
text: 'Cancel',
|
||||
@ -74,11 +74,11 @@ class E2EPage {
|
||||
]
|
||||
});
|
||||
|
||||
this.nav.present(picker);
|
||||
picker.present();
|
||||
}
|
||||
|
||||
prefixLabel() {
|
||||
let picker = Picker.create({
|
||||
let picker = this.pickerCtrl.create({
|
||||
buttons: [
|
||||
{
|
||||
text: 'Nerp',
|
||||
@ -118,11 +118,11 @@ class E2EPage {
|
||||
]
|
||||
});
|
||||
|
||||
this.nav.present(picker);
|
||||
picker.present();
|
||||
}
|
||||
|
||||
suffixLabel() {
|
||||
let picker = Picker.create({
|
||||
let picker = this.pickerCtrl.create({
|
||||
buttons: [
|
||||
{
|
||||
text: 'No',
|
||||
@ -162,11 +162,11 @@ class E2EPage {
|
||||
]
|
||||
});
|
||||
|
||||
this.nav.present(picker);
|
||||
picker.present();
|
||||
}
|
||||
|
||||
columnSizes() {
|
||||
let picker = Picker.create();
|
||||
let picker = this.pickerCtrl.create();
|
||||
|
||||
picker.addButton({
|
||||
text: 'Cancel',
|
||||
@ -188,7 +188,7 @@ class E2EPage {
|
||||
options: Array.apply(null, {length: 23}).map(Number.call, Number)
|
||||
});
|
||||
|
||||
let minuteOptions = [];
|
||||
let minuteOptions: any[] = [];
|
||||
|
||||
for (var i = 0; i < 60; i++) {
|
||||
minuteOptions.push({
|
||||
@ -205,7 +205,7 @@ class E2EPage {
|
||||
options: minuteOptions
|
||||
});
|
||||
|
||||
this.nav.present(picker);
|
||||
picker.present();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component, ViewChild, ElementRef, ViewEncapsulation } from '@angular/core';
|
||||
import {ionicBootstrap, Popover, NavController, Content, NavParams, ViewController} from '../../../../../src';
|
||||
import { ionicBootstrap, PopoverController, NavParams, ViewController } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -64,9 +64,9 @@ class PopoverRadioPage {
|
||||
background: string;
|
||||
contentEle: any;
|
||||
textEle: any;
|
||||
fontFamily;
|
||||
fontFamily: any;
|
||||
|
||||
colors = {
|
||||
colors: any = {
|
||||
'white': {
|
||||
'bg': 'rgb(255, 255, 255)',
|
||||
'fg': 'rgb(0, 0, 0)'
|
||||
@ -85,9 +85,7 @@ class PopoverRadioPage {
|
||||
},
|
||||
};
|
||||
|
||||
constructor(private navParams: NavParams) {
|
||||
|
||||
}
|
||||
constructor(private navParams: NavParams) {}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.navParams.data) {
|
||||
@ -99,7 +97,7 @@ class PopoverRadioPage {
|
||||
}
|
||||
}
|
||||
|
||||
getColorName(background) {
|
||||
getColorName(background: any) {
|
||||
let colorName = 'white';
|
||||
|
||||
if (!background) return 'white';
|
||||
@ -119,13 +117,13 @@ class PopoverRadioPage {
|
||||
}
|
||||
}
|
||||
|
||||
changeBackground(color) {
|
||||
changeBackground(color: any) {
|
||||
this.background = color;
|
||||
this.contentEle.style.backgroundColor = this.colors[color].bg;
|
||||
this.textEle.style.color = this.colors[color].fg;
|
||||
}
|
||||
|
||||
changeFontSize(direction) {
|
||||
changeFontSize(direction: any) {
|
||||
this.textEle.style.fontSize = direction;
|
||||
}
|
||||
|
||||
@ -166,9 +164,7 @@ class PopoverListPage {
|
||||
`
|
||||
})
|
||||
class PopoverLongListPage {
|
||||
items = [];
|
||||
|
||||
constructor(private viewCtrl: ViewController) {}
|
||||
items: number[] = [];
|
||||
|
||||
ngOnInit() {
|
||||
for(let i = 1; i < 21; i++) {
|
||||
@ -185,38 +181,35 @@ class E2EPage {
|
||||
@ViewChild('popoverContent', {read: ElementRef}) content: ElementRef;
|
||||
@ViewChild('popoverText', {read: ElementRef}) text: ElementRef;
|
||||
|
||||
constructor(private nav: NavController) {
|
||||
constructor(private popoverCtrl: PopoverController) {}
|
||||
|
||||
}
|
||||
|
||||
presentListPopover(ev) {
|
||||
let popover = Popover.create(PopoverListPage);
|
||||
this.nav.present(popover, {
|
||||
presentListPopover(ev: UIEvent) {
|
||||
let popover = this.popoverCtrl.create(PopoverListPage);
|
||||
popover.present({
|
||||
ev: ev
|
||||
});
|
||||
}
|
||||
|
||||
presentLongListPopover(ev) {
|
||||
let popover = Popover.create(PopoverLongListPage);
|
||||
this.nav.present(popover, {
|
||||
presentLongListPopover(ev: UIEvent) {
|
||||
let popover = this.popoverCtrl.create(PopoverLongListPage);
|
||||
popover.present({
|
||||
ev: ev
|
||||
});
|
||||
}
|
||||
|
||||
presentRadioPopover(ev) {
|
||||
let popover = Popover.create(PopoverRadioPage, {
|
||||
presentRadioPopover(ev: UIEvent) {
|
||||
let popover = this.popoverCtrl.create(PopoverRadioPage, {
|
||||
contentEle: this.content.nativeElement,
|
||||
textEle: this.text.nativeElement
|
||||
});
|
||||
|
||||
this.nav.present(popover, {
|
||||
popover.present({
|
||||
ev: ev
|
||||
});
|
||||
}
|
||||
|
||||
presentNoEventPopover() {
|
||||
let popover = Popover.create(PopoverListPage);
|
||||
this.nav.present(popover);
|
||||
this.popoverCtrl.create(PopoverListPage).present();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
|
||||
import {ionicBootstrap, NavController, NavParams, Modal, ViewController, Tabs, Tab} from '../../../../../src';
|
||||
import { ionicBootstrap, NavController, NavParams, ModalController, ViewController, Tabs, Tab } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -42,7 +42,7 @@ class TabsPage {
|
||||
tab3Root = Tab3Page1;
|
||||
@ViewChild(Tabs) tabs: Tabs;
|
||||
|
||||
constructor(private nav: NavController, private params: NavParams) {}
|
||||
constructor(private modalCtrl: ModalController, private params: NavParams) {}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.tabs.ionChange.subscribe((tab: Tab) => {
|
||||
@ -58,8 +58,7 @@ class TabsPage {
|
||||
|
||||
chat() {
|
||||
console.log('Chat clicked!');
|
||||
let modal = Modal.create(ChatPage);
|
||||
this.nav.present(modal);
|
||||
this.modalCtrl.create(ChatPage).present();
|
||||
}
|
||||
|
||||
ionViewWillEnter() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {ionicBootstrap, NavController, App, Alert, Modal, ViewController, Tab, Tabs} from '../../../../../src';
|
||||
import {ionicBootstrap, NavController, App, AlertController, ModalController, ViewController, Tab, Tabs} from '../../../../../src';
|
||||
|
||||
//
|
||||
// Modal
|
||||
@ -192,19 +192,18 @@ export class Tab2 {
|
||||
`
|
||||
})
|
||||
export class Tab3 {
|
||||
constructor(private nav: NavController, private tabs: Tabs, private app: App) {}
|
||||
constructor(private alertCtrl: AlertController, private modalCtrl: ModalController, private tabs: Tabs, private app: App) {}
|
||||
|
||||
presentAlert() {
|
||||
let alert = Alert.create({
|
||||
let alert = this.alertCtrl.create({
|
||||
title: 'Alert Title!',
|
||||
buttons: ['Dismiss']
|
||||
});
|
||||
this.nav.present(alert);
|
||||
alert.present();
|
||||
}
|
||||
|
||||
presentModal() {
|
||||
let modal = Modal.create(MyModal);
|
||||
this.nav.present(modal);
|
||||
this.modalCtrl.create(MyModal).present();
|
||||
}
|
||||
|
||||
selectPrevious() {
|
||||
|
@ -135,7 +135,7 @@ describe('Tabs', () => {
|
||||
it('should get the tab', () => {
|
||||
var tabs = mockTabs();
|
||||
var tab0 = mockTab(tabs);
|
||||
tab0.setRoot()
|
||||
tab0.setRoot(<any>{});
|
||||
var tab1 = mockTab(tabs);
|
||||
tabs.add(tab0);
|
||||
tabs.add(tab1);
|
||||
@ -199,7 +199,7 @@ describe('Tabs', () => {
|
||||
beforeEach(() => {
|
||||
config = new Config();
|
||||
platform = new Platform();
|
||||
app = new App(config, null, platform);
|
||||
app = new App(config, platform);
|
||||
_cd = {
|
||||
reattach: function(){},
|
||||
detach: function(){}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {ionicBootstrap, Toast, NavController} from '../../../../../src';
|
||||
import { ionicBootstrap, Toast, ToastController, NavController } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -22,10 +22,10 @@ class AnotherPage {}
|
||||
})
|
||||
class E2EPage {
|
||||
|
||||
constructor(private nav: NavController) { }
|
||||
constructor(private toastCtrl: ToastController, private nav: NavController) { }
|
||||
|
||||
showToast() {
|
||||
const toast = Toast.create({
|
||||
const toast = this.toastCtrl.create({
|
||||
message: 'User was created successfully'
|
||||
});
|
||||
|
||||
@ -33,7 +33,7 @@ class E2EPage {
|
||||
console.log('Dismissed toast');
|
||||
});
|
||||
|
||||
this.nav.present(toast);
|
||||
toast.present();
|
||||
|
||||
setTimeout(() => {
|
||||
this.nav.push(AnotherPage);
|
||||
@ -45,38 +45,37 @@ class E2EPage {
|
||||
}
|
||||
|
||||
showLongToast() {
|
||||
const toast = Toast.create({
|
||||
const toast = this.toastCtrl.create({
|
||||
message: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea voluptatibus quibusdam eum nihil optio, ullam accusamus magni, nobis suscipit reprehenderit, sequi quam amet impedit. Accusamus dolorem voluptates laborum dolor obcaecati.',
|
||||
duration: 5000
|
||||
});
|
||||
|
||||
toast.onDismiss(this.dismissHandler);
|
||||
this.nav.present(toast);
|
||||
toast.present();
|
||||
}
|
||||
|
||||
showDismissDurationToast() {
|
||||
const toast = Toast.create({
|
||||
const toast = this.toastCtrl.create({
|
||||
message: 'I am dismissed after 1.5 seconds',
|
||||
duration: 1500
|
||||
});
|
||||
toast.onDismiss(this.dismissHandler);
|
||||
this.nav.present(toast);
|
||||
toast.present();
|
||||
}
|
||||
|
||||
showToastWithCloseButton(positionString:string) {
|
||||
const toast = Toast.create({
|
||||
const toast = this.toastCtrl.create({
|
||||
message: 'Your internet connection appears to be offline. Data integrity is not gauranteed.',
|
||||
showCloseButton: true,
|
||||
closeButtonText: 'Ok',
|
||||
position: positionString
|
||||
});
|
||||
toast.onDismiss(this.dismissHandler);
|
||||
this.nav.present(toast);
|
||||
toast.present();
|
||||
}
|
||||
|
||||
private dismissHandler(toast: Toast) {
|
||||
console.info('Toast onDismiss()');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user