Created
July 31, 2015 11:45
-
-
Save kasperpeulen/096125cdccbb401fcb9f to your computer and use it in GitHub Desktop.
custom mdl dialog
This file contains hidden or 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
| <!doctype html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <link rel="stylesheet" href="packages/mdl/assets/styles/material.min.css"> | |
| <link rel="stylesheet" href="styles.css"> | |
| </head> | |
| <body class="mdl-upgrading"> | |
| <div class="loading">Loading...</div> | |
| <div id="wrapper" class="mdl-shadow--2dp"> | |
| <button id="customdialog" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect"> | |
| Custom dialog | |
| </button> | |
| </div> | |
| <script type="application/dart" src="main.dart"></script> | |
| </body> | |
| </html> |
This file contains hidden or 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
| import "dart:html"; | |
| import 'package:mdl/mdl.dart'; | |
| import 'package:di/di.dart'; | |
| DivElement wrapper = querySelector('#wrapper'); | |
| ButtonElement button = querySelector("#customdialog"); | |
| main() async { | |
| registerMdl(); | |
| await componentFactory().run(); | |
| CustomDialog customDialog = new CustomDialog( | |
| title: "Hello World", yesButton: "Uh... yes !", noButton: "Maybe not ?"); | |
| button.onClick.listen((_) { | |
| customDialog.show(); | |
| }); | |
| } | |
| @MdlComponentModel | |
| @Injectable() | |
| class CustomDialog extends MaterialDialog { | |
| final String title, yesButton, noButton; | |
| CustomDialog({this.title: "", this.yesButton: 'Yes', this.noButton: 'No'}) | |
| : super(new DialogConfig()); | |
| bool get hasTitle => title.isNotEmpty; | |
| onYes() => close(MdlDialogStatus.YES); | |
| onNo() => close(MdlDialogStatus.NO); | |
| String template = """ | |
| <div class="mdl-dialog custom-dialog"> | |
| <div class="mdl-dialog__content"> | |
| {{#hasTitle}}<h5>{{title}}</h5>{{/hasTitle}} | |
| <p>Will this work ... ?</p> | |
| </div> | |
| <div class="mdl-dialog__actions"> | |
| <button class="mdl-button mdl-js-button" data-mdl-click="onNo()"> | |
| {{noButton}} | |
| </button> | |
| <button class="mdl-button mdl-js-button mdl-button--colored" data-mdl-click="onYes()"> | |
| {{yesButton}} | |
| </button> | |
| </div> | |
| </div>"""; | |
| } |
This file contains hidden or 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
| name: custom_mdl_dialog | |
| dependencies: | |
| browser: any | |
| mdl: any | |
| di: any | |
| transformers: | |
| - di |
This file contains hidden or 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
| div.loading { | |
| display: none; | |
| } | |
| body.mdl-upgrading > * { | |
| display: none; | |
| } | |
| body.mdl-upgrading div.loading { | |
| display: block; | |
| } | |
| #wrapper { | |
| width: 400px; | |
| margin: 10px auto; | |
| padding: 10px; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment