Skip to content

Commit f577e54

Browse files
Srecko Smodisbrandyscarney
authored andcommitted
feat(alert): add ability to set the mode on alert
1 parent 6797ce5 commit f577e54

File tree

6 files changed

+32
-1
lines changed

6 files changed

+32
-1
lines changed

src/components/alert/alert-component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class AlertCmp {
7878
message?: string;
7979
title?: string;
8080
subTitle?: string;
81+
mode?: string;
8182
buttons?: any[];
8283
inputs?: any[];
8384
enableBackdropDismiss?: boolean;
@@ -104,7 +105,7 @@ export class AlertCmp {
104105
// gesture blocker is used to disable gestures dynamically
105106
this.gestureBlocker = gestureCtrl.createBlocker(BLOCK_ALL);
106107
this.d = params.data;
107-
this.mode = config.get('mode');
108+
this.mode = this.d.mode || config.get('mode');
108109
_renderer.setElementClass(_elementRef.nativeElement, `alert-${this.mode}`, true);
109110

110111
if (this.d.cssClass) {

src/components/alert/alert-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface AlertOptions {
44
subTitle?: string;
55
message?: string;
66
cssClass?: string;
7+
mode?: string;
78
inputs?: Array<AlertInputOptions>;
89
buttons?: Array<any>;
910
enableBackdropDismiss?: boolean;

src/components/alert/alert.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ export class Alert extends ViewController {
7474
this.data.cssClass = cssClass;
7575
}
7676

77+
/**
78+
* @param {string} mode Set the mode of the alert (ios, md, wp).
79+
*/
80+
setMode(mode: string) {
81+
this.data.mode = mode;
82+
}
83+
7784
/**
7885
* Present the alert instance.
7986
*
@@ -220,6 +227,7 @@ export class Alert extends ViewController {
220227
* | subTitle | `string` | The subtitle for the alert. |
221228
* | message | `string` | The message for the alert. |
222229
* | cssClass | `string` | Additional classes for custom styles, separated by spaces. |
230+
* | mode | `string` | Set alert mode (ios, md, wp). |
223231
* | inputs | `array` | An array of inputs for the alert. See input options. |
224232
* | buttons | `array` | An array of buttons for the alert. See buttons options. |
225233
* | enableBackdropDismiss | `boolean` | Whether the alert should be dismissed by tapping the backdrop. |

src/components/alert/test/basic/app.module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,16 @@ export class E2EPage {
283283
alert.present();
284284
}
285285

286+
doAlertWithMode(alertMode: string) {
287+
let alert = this.alertCtrl.create({
288+
title: 'Alert!',
289+
mode: alertMode,
290+
buttons: ['OK']
291+
});
292+
293+
alert.present();
294+
}
295+
286296
ionViewDidLeave() {
287297
console.log('E2EPage, ionViewDidLeave');
288298
}

src/components/alert/test/basic/e2e.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,11 @@ it('should open disabled backdrop alert', function() {
7474
it('should close with button click', function() {
7575
element(by.css('.alert-button:last-child')).click();
7676
});
77+
78+
it('should open alert with mode', function() {
79+
element(by.css('.e2eAlertMode')).click();
80+
});
81+
82+
it('should close with button click', function() {
83+
element(by.css('.alert-button:last-child')).click();
84+
});

src/components/alert/test/basic/main.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<button ion-button block class="e2eOpenCheckbox" (click)="doCheckbox()">Checkbox</button>
2020
<button ion-button block class="e2eFastClose" (click)="doFastClose()">Fast Close</button>
2121
<button ion-button block class="e2eDisabledBackdrop" (click)="doDisabledBackdropAlert()">Disabled Backdrop Click</button>
22+
<button ion-button block class="e2eAlertMode" (click)="doAlertWithMode('md')">md Mode</button>
23+
<button ion-button block class="e2eAlertMode" (click)="doAlertWithMode('ios')">ios Mode</button>
24+
<button ion-button block class="e2eAlertMode" (click)="doAlertWithMode('wp')">wp Mode</button>
2225

2326
<pre>
2427
Confirm Opened: {{testConfirmOpen}}

0 commit comments

Comments
 (0)