From bb574743d981985d4c92fb8031ef5bc3d061e374 Mon Sep 17 00:00:00 2001 From: Amit Moryossef Date: Thu, 8 Jun 2017 17:56:34 +0300 Subject: [PATCH] test(snapshot): add assistive popover to change direction (#11976) --- .../assistive-popover/assistive-popover.html | 4 +++ .../assistive-popover.module.ts | 21 ++++++++++++++ .../assistive-popover/assistive-popover.ts | 29 +++++++++++++++++++ .../assistive-touch/assistive-touch.module.ts | 6 ++-- .../assistive-touch/assistive-touch.ts | 14 +++++---- 5 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.html create mode 100644 src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.module.ts create mode 100644 src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.ts diff --git a/src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.html b/src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.html new file mode 100644 index 00000000000..b400987af9d --- /dev/null +++ b/src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.html @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.module.ts b/src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.module.ts new file mode 100644 index 00000000000..cb31c014669 --- /dev/null +++ b/src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.module.ts @@ -0,0 +1,21 @@ +import { AssistivePopover } from './assistive-popover'; +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../../module'; +import { AssistiveTouchProvider } from '../../../providers/assistive-touch/assistive-touch'; + +@NgModule({ + declarations: [ + AssistivePopover, + ], + imports: [ + IonicPageModule.forChild(AssistivePopover), + ], + exports: [ + AssistivePopover + ], + providers: [ + AssistiveTouchProvider + ] +}) +export class AssistivePopoverModule { +} diff --git a/src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.ts b/src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.ts new file mode 100644 index 00000000000..4e8c24f2d16 --- /dev/null +++ b/src/components/snapshot/test/basic/components/assistive-touch/assistive-popover/assistive-popover.ts @@ -0,0 +1,29 @@ +import { Component } from '@angular/core'; +import { IonicPage } from '../../../../../../../navigation/ionic-page'; +import { AssistiveTouchProvider } from '../../../providers/assistive-touch/assistive-touch'; +import { ViewController } from '../../../../../../../navigation/view-controller'; +import { Platform } from '../../../../../../../platform/platform'; + +@IonicPage() +@Component({ + templateUrl: 'assistive-popover.html' +}) +export class AssistivePopover { + constructor(private assistive: AssistiveTouchProvider, + private plt: Platform, + private viewCtrl: ViewController) {} + + homeButton() { + this.assistive.closeButton.emit(); + this.close(); + } + + flipDirection() { + this.plt.setDir(this.plt.dir() === 'ltr' ? 'rtl' : 'ltr', true); + this.close(); + } + + private close() { + this.viewCtrl.dismiss(); + } +} diff --git a/src/components/snapshot/test/basic/components/assistive-touch/assistive-touch.module.ts b/src/components/snapshot/test/basic/components/assistive-touch/assistive-touch.module.ts index eb51e5ecc45..51c1f3e153c 100644 --- a/src/components/snapshot/test/basic/components/assistive-touch/assistive-touch.module.ts +++ b/src/components/snapshot/test/basic/components/assistive-touch/assistive-touch.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { AssistiveTouchComponent } from './assistive-touch'; import { IonicPageModule } from '../../../../../../module'; -import { AssistiveTouchProvider } from '../../providers/assistive-touch/assistive-touch'; +import { AssistivePopoverModule } from './assistive-popover/assistive-popover.module'; @NgModule({ declarations: [ @@ -9,12 +9,10 @@ import { AssistiveTouchProvider } from '../../providers/assistive-touch/assistiv ], imports: [ IonicPageModule.forChild(AssistiveTouchComponent), + AssistivePopoverModule ], exports: [ AssistiveTouchComponent - ], - providers: [ - AssistiveTouchProvider ] }) export class AssistiveTouchComponentModule { diff --git a/src/components/snapshot/test/basic/components/assistive-touch/assistive-touch.ts b/src/components/snapshot/test/basic/components/assistive-touch/assistive-touch.ts index 5eded67cb0a..235f0163eac 100644 --- a/src/components/snapshot/test/basic/components/assistive-touch/assistive-touch.ts +++ b/src/components/snapshot/test/basic/components/assistive-touch/assistive-touch.ts @@ -1,6 +1,7 @@ import { AfterViewInit, Component, ElementRef, Renderer2 } from '@angular/core'; import { DomController } from '../../../../../../platform/dom-controller'; -import { AssistiveTouchProvider } from '../../providers/assistive-touch/assistive-touch'; +import { PopoverController } from '../../../../../popover/popover-controller'; +import { AssistivePopover } from './assistive-popover/assistive-popover'; @Component({ selector: 'assistive-touch', @@ -18,7 +19,10 @@ export class AssistiveTouchComponent implements AfterViewInit { private elemWidthOffset: number; private elemHeightOffset: number; - constructor(private assistive: AssistiveTouchProvider, public element: ElementRef, public renderer: Renderer2, public domCtrl: DomController) { + constructor(private popoverCtrl: PopoverController, + public element: ElementRef, + public renderer: Renderer2, + public domCtrl: DomController) { } ngAfterViewInit() { @@ -35,7 +39,7 @@ export class AssistiveTouchComponent implements AfterViewInit { this.updatePosition(); } - private handlePan(ev: {center: {x: number, y: number}}) { + private handlePan(ev: { center: { x: number, y: number } }) { let newX = ev.center.x; let newY = ev.center.y; @@ -77,8 +81,6 @@ export class AssistiveTouchComponent implements AfterViewInit { } openControl() { - // TODO when custom alerts are out, this should open a custom alert - // Allow setting direction, close, whatever - this.assistive.closeButton.emit(); + this.popoverCtrl.create(AssistivePopover).present(); } }