test(snapshot): add assistive popover to change direction (#11976)

This commit is contained in:
Amit Moryossef
2017-06-08 17:56:34 +03:00
committed by Brandy Carney
parent d0ae810bae
commit bb574743d9
5 changed files with 64 additions and 10 deletions

View File

@ -0,0 +1,4 @@
<ion-list no-margin>
<button ion-item (click)="homeButton()">Home Button</button>
<button ion-item (click)="flipDirection()">Flip Direction</button>
</ion-list>

View File

@ -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 {
}

View File

@ -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();
}
}

View File

@ -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 {

View File

@ -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();
}
}