Skip to content

Commit

Permalink
test(snapshot): add assistive popover to change direction (#11976)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitMY authored and brandyscarney committed Jun 8, 2017
1 parent d0ae810 commit bb57474
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
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: [
AssistiveTouchComponent,
],
imports: [
IonicPageModule.forChild(AssistiveTouchComponent),
AssistivePopoverModule
],
exports: [
AssistiveTouchComponent
],
providers: [
AssistiveTouchProvider
]
})
export class AssistiveTouchComponentModule {
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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() {
Expand All @@ -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;

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

0 comments on commit bb57474

Please sign in to comment.