-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
059a4ce
commit b26c600
Showing
6 changed files
with
316 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
<ActionBar> | ||
<Label text="Home"></Label> | ||
<Label text="NativeScript SweetAlert"></Label> | ||
</ActionBar> | ||
|
||
<GridLayout> | ||
<!-- Add your page content here --> | ||
<GridLayout rows="*,*,*,*,*,*,*,*" verticalAlignment="top"> | ||
<Button row="0" text="SweetAlert NORMAL" (tap)="showNormal()"></Button> | ||
<Button row="1" text="SweetAlert ERROR" (tap)="showError()"></Button> | ||
<Button row="2" text="SweetAlert SUCCESS" (tap)="showSuccess()"></Button> | ||
<Button row="3" text="SweetAlert WARNING" (tap)="showWarning()"></Button> | ||
<Button row="4" text="SweetAlert CUSTOM IMAGE" (tap)="showCustomImage()"></Button> | ||
<Button row="5" text="SweetAlert DARK MODE" (tap)="showDarkMode()"></Button> | ||
<Button row="6" text="SweetAlert TEXTVIEW" (tap)="showText()"></Button> | ||
<Button row="7" text="SweetAlert CHECKBOX" (tap)="showCheckbox()"></Button> | ||
</GridLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,118 @@ | ||
import { Component, OnInit } from "@angular/core"; | ||
import { Component } from "@angular/core"; | ||
import { SweetAlert } from "nativescript-sweet-alert"; | ||
import { ShowCustomImage, ShowWarning, ShowSuccess, ShowError, ShowNormal, ShowText, ShowCheckbox, SweetAlertDialogTypes } from 'nativescript-sweet-alert/classes'; | ||
import * as application from "tns-core-modules/application"; | ||
|
||
const Toast = android.widget.Toast; | ||
const context = application.android.startActivity; | ||
|
||
@Component({ | ||
selector: "Home", | ||
templateUrl: "./home.component.html" | ||
}) | ||
export class HomeComponent implements OnInit { | ||
export class HomeComponent { | ||
|
||
showNormal() { | ||
const options: ShowNormal = { | ||
text: "Merhaba", | ||
contentText: "İlk Alert Denemesi", | ||
confirmButtonText: "Tamam", | ||
cancelButtonText: "Kapat", | ||
successMessageText: "Başarılı!", | ||
successMessageContentText: "Başarıyla tamamlandı.", | ||
successMessageButtonText: "Kapat" | ||
} | ||
SweetAlert.showNormal(options).then(value => { | ||
Toast.makeText(context, "result: " + value, Toast.LENGTH_SHORT).show(); | ||
}); | ||
} | ||
|
||
showError() { | ||
const options: ShowError = { | ||
text: "Merhaba", | ||
contentText: "İlk Alert Denemesi", | ||
confirmButtonText: "Tamam", | ||
cancelButtonText: "Kapatt" | ||
} | ||
SweetAlert.showError(options).then(value => { | ||
Toast.makeText(context, "result: " + value, Toast.LENGTH_SHORT).show(); | ||
}); | ||
} | ||
|
||
showSuccess() { | ||
const options: ShowSuccess = { | ||
text: "Merhaba", | ||
contentText: "İlk Alert Denemesi", | ||
confirmButtonText: "Tamam", | ||
cancelButtonText: "Kapat" | ||
} | ||
SweetAlert.showSuccess(options).then(value => { | ||
Toast.makeText(context, "result: " + value, Toast.LENGTH_SHORT).show(); | ||
}); | ||
} | ||
|
||
showWarning() { | ||
const options: ShowWarning = { | ||
text: "Merhaba", | ||
contentText: "İlk Alert Denemesi", | ||
confirmButtonText: "Tamam", | ||
cancelButtonText: "Kapat" | ||
} | ||
SweetAlert.showWarning(options).then(value => { | ||
Toast.makeText(context, "result: " + value, Toast.LENGTH_SHORT).show(); | ||
}); | ||
} | ||
|
||
showCustomImage() { | ||
const options: ShowCustomImage = { | ||
imagePath: "~/assets/images/nmb.jpeg", | ||
text: "Merhaba", | ||
contentText: "Big <font color='green'>green </font><b><i> bold</i></b>", | ||
confirmButtonText: "Tamam", | ||
cancelButtonText: "Kapat" | ||
} | ||
SweetAlert.showCustomImage(options).then(value => { | ||
Toast.makeText(context, "result: " + value, Toast.LENGTH_SHORT).show(); | ||
}); | ||
} | ||
|
||
showDarkMode() { | ||
const options: ShowSuccess = { | ||
text: "Merhaba", | ||
contentText: "İlk Alert Denemesi", | ||
confirmButtonText: "Tamam", | ||
cancelButtonText: "Kapat", | ||
darkMode: true | ||
} | ||
SweetAlert.showSuccess(options).then(value => { | ||
Toast.makeText(context, "result: " + value, Toast.LENGTH_SHORT).show(); | ||
}); | ||
} | ||
|
||
constructor() { | ||
// Use the component constructor to inject providers. | ||
showText() { | ||
const options: ShowText = { | ||
text: "Merhaba", | ||
confirmButtonText: "Tamam", | ||
cancelButtonText: "Kapat", | ||
textViewText: "I'm text field.", | ||
customImage: "~/assets/images/nmb.jpeg" | ||
} | ||
SweetAlert.showText(options).then(value => { | ||
Toast.makeText(context, "result: " + value, Toast.LENGTH_SHORT).show(); | ||
}); | ||
} | ||
|
||
ngOnInit(): void { | ||
// Init your component properties here. | ||
showCheckbox() { | ||
const options: ShowCheckbox = { | ||
text: "Merhaba", | ||
checkBoxChecked: true, | ||
checkBoxText: "Notification Sound", | ||
confirmButtonText: "Tamam", | ||
cancelButtonText: "Kapat", | ||
customImage: SweetAlertDialogTypes.SUCCESS_TYPE | ||
} | ||
SweetAlert.showCheckbox(options).then(value => { | ||
Toast.makeText(context, "result: " + value, Toast.LENGTH_SHORT).show(); | ||
}); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
SweetAlert library for NativeScript Android. | ||
|
||
Based on: | ||
|
||
- Android [F0RIS/sweet-alert-dialog](https://github.com/F0RIS/sweet-alert-dialog) | ||
|
||
# Install | ||
|
||
### NativeScript 6x | ||
|
||
```bash | ||
tns plugin add nativescript-sweet-alert | ||
``` | ||
|
||
 | ||
|
||
|
||
# Android Specifications | ||
|
||
#### Usage Examples | ||
|
||
NOTE: "options" may vary according to each method. | ||
|
||
```js | ||
import { SweetAlert } from 'nativescript-sweet-alert'; | ||
import { ShowSuccess , ShowError } from 'nativescript-sweet-alert/classes'; | ||
|
||
|
||
// showSuccess | ||
const options: ShowSuccess = { | ||
text: "Hello", | ||
contentText: "Alert Content Text", | ||
confirmButtonText: "Ok", | ||
cancelButtonText: "Close" | ||
} | ||
SweetAlert.showSuccess(options).then(value => { | ||
// result: true, false, CLOSED | ||
}); | ||
|
||
// showError | ||
const options: ShowError = { | ||
text: "Hello", | ||
contentText: "Alert Content Text", | ||
confirmButtonText: "Ok", | ||
cancelButtonText: "Close" | ||
} | ||
SweetAlert.showError(options).then(value => { | ||
// result: true, false, CLOSED | ||
}); | ||
|
||
``` | ||
|
||
#### NativeScript SweetAlert - Methods | ||
|
||
- `showNormal(options: ShowNormal): Promise<any>` | ||
- `showError(options: ShowError): Promise<any>` | ||
- `showSuccess(options: ShowSuccess): Promise<any>` | ||
- `showWarning(options: ShowWarning): Promise<any>` | ||
- `showCustomImage(options: ShowCustomImage): Promise<any>` | ||
- `showText(options: ShowText): Promise<any>` | ||
- `showCheckbox(options: ShowCheckbox): Promise<any>` | ||
|
||
|
||
## Why the TNS prefixed name? | ||
|
||
`TNS` stands for **T**elerik **N**ative**S**cript | ||
|
||
iOS uses classes prefixed with `NS` (stemming from the [NeXTSTEP](https://en.wikipedia.org/wiki/NeXTSTEP) days of old): | ||
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/ | ||
|
||
To avoid confusion with iOS native classes, `TNS` is used instead. | ||
|
||
## Demo | ||
|
||
Need extra help getting these SweetAlert working in your application? Check out these tutorials that make use of the plugin: | ||
|
||
[SweetAlert in a NativeScript Core Demo](https://github.com/NazimMertBilgi/nativescript-sweet-alert/blob/master/demo/app/home/home-page.ts) | ||
|
||
## License | ||
|
||
MIT |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters