Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
refactor(#228): move disconnect remote control
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker committed Oct 27, 2019
1 parent a696abd commit 60907f3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions remote/src/app/app-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class AppRoot {
<ion-nav id="menu-content"/>

<ion-modal-controller></ion-modal-controller>
<ion-alert-controller></ion-alert-controller>

</ion-app>
);
Expand Down
32 changes: 29 additions & 3 deletions remote/src/app/pages/app-remote/app-remote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,30 @@ export class AppRemote {
await this.accelerometerService.stop();
}

private async openDisconnectConfirm() {
const alert: HTMLIonAlertElement = await IonControllerUtils.createAlert({
header: 'Disconnect',
message: 'The remote control must be disconnected from the presentation?',
cssClass: 'custom-info',
buttons: [
{
text: 'No',
role: 'cancel',
handler: () => {
// Nothing
}
}, {
text: 'Yes',
handler: async () => {
await this.disconnect();
}
}
]
});

await alert.present();
}

@Listen('drawing')
isDrawing(event: CustomEvent) {
this.drawing = event.detail;
Expand Down Expand Up @@ -477,6 +501,10 @@ export class AppRemote {
<ion-button onClick={() => this.openSlidePicker()}>
<ion-icon src="/assets/icons/chapters.svg"></ion-icon>
</ion-button>

<ion-button onClick={() => this.openDisconnectConfirm()}>
<ion-icon name="log-out"></ion-icon>
</ion-button>
</ion-buttons>;
}

Expand Down Expand Up @@ -587,9 +615,7 @@ export class AppRemote {
</ion-fab-list>
<ion-fab-list side="top">
{this.renderExtraActions()}
<ion-fab-button color="medium" onClick={() => this.disconnect()}>
<ion-icon name="log-out"></ion-icon>
</ion-fab-button>

</ion-fab-list>
</ion-fab>
);
Expand Down
13 changes: 12 additions & 1 deletion remote/src/app/services/utils/ion-controller-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ModalOptions} from '@ionic/core';
import {AlertOptions, ModalOptions} from '@ionic/core';

export class IonControllerUtils {

Expand All @@ -13,4 +13,15 @@ export class IonControllerUtils {
});
}

static createAlert(opts: AlertOptions): Promise<HTMLIonAlertElement> {
return new Promise<HTMLIonAlertElement>(async (resolve) => {
const alertController: HTMLIonAlertControllerElement = document.querySelector('ion-alert-controller');
await alertController.componentOnReady();

const alert: HTMLIonAlertElement = await alertController.create(opts);

resolve(alert);
});
}

}

0 comments on commit 60907f3

Please sign in to comment.