Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}