Skip to content
Permalink
Browse files

doc: All examples are working

  • Loading branch information...
MikeMitterer committed Nov 14, 2018
1 parent ccbe7cd commit 4a0b184004e29c37c40ab857e636627aee722759
@@ -3,4 +3,9 @@
## Examples
> [GitHub](https://github.com/MikeMitterer/m4d_dialog)
- [m4d_dialog.example.mikemitterer.at](http://m4d_dialog.example.mikemitterer.at)
- [m4d_notification.example.mikemitterer.at](http://m4d_notification.example.mikemitterer.at)
- [m4d_snackbar.example.mikemitterer.at](http://m4d_snackbar.example.mikemitterer.at)



@@ -17,18 +17,19 @@ pipeline {
steps {
ansiColor('xterm') {
sh 'dartanalyzer lib/'
sh 'dartanalyzer test/'
// sh 'dartanalyzer test/'
}
}
}
/*
stage('Test') {
steps {
ansiColor('xterm') {
sh 'pub run test test -p chrome'
}
}
}

*/
stage('Deploy samples') {
steps {
timeout(time: 30, unit: 'MINUTES') {
@@ -39,7 +39,7 @@ class MaterialAlertDialog extends MaterialDialog {
String get template => """
<div class="mdl-dialog">
<div class="mdl-dialog__content">
${hasTitle ? "<h5>$title</h5>" : ""}
${hasTitle ? '<h5>$title</h5>' : ''}
<p>${text}</p>
</div>
<div class="mdl-dialog__actions" layout="row">
@@ -17,7 +17,7 @@ class _NotificationConfig extends DialogConfig {
autoClosePossible: true,
appendNewDialog: true,
acceptEscToClose: false,
closeAnimation: new MdlAnimation.fromStock(StockAnimation.MoveUpAndDisappear)
closeAnimation: MdlAnimation.fromStock(StockAnimation.MoveUpAndDisappear)
);
}

@@ -85,78 +85,80 @@ class MaterialNotification extends MaterialDialog {
return this;
}

bool get hasTitle => title != null && title.isNotEmpty;
bool get hasSubTitle => subtitle != null && subtitle.isNotEmpty;
bool get hasContent => content != null && content.isNotEmpty;

/// Overwrites the default behaviour which is auto-closable by default
void set autoClose(final bool enabled) { _autoClose = enabled; }
bool get autoClose => _autoClose;

// - EventHandler -----------------------------------------------------------------------------

@override
// TODO: Params are not used - change parent function...
Future<MdlDialogStatus> show({ final Duration timeout,void onDialogInit(final String dialogId) }) {
return super.show(timeout: (_autoClose == true ? new Duration(milliseconds: this.timeout ): null ));
}

void onClose() {
// - EventHandler -----------------------------------------------------------------------------

void _onClose() {
_logger.info("onClose - Notification");
close(MdlDialogStatus.CONFIRMED);
}

// - private ----------------------------------------------------------------------------------

// String _notificationType(final LambdaContext _) {
//
// switch(type) {
// case NotificationType.DEBUG:
// return "debug";
//
// case NotificationType.INFO:
// return "info";
//
// case NotificationType.WARNING:
// return "warning";
//
// case NotificationType.ERROR:
// return "error";
//
// default:
// return "info";
// }
// }

// - Template ---------------------------------------------------------------------------------

@override
String template = """
<div class="mdl-notification mdl-notification--{{lambdas.type}} mdl-shadow--3dp">
String get template => """
<div class="mdl-notification mdl-notification--${_notificationType()} mdl-shadow--3dp">
<i class="mdl-icon material-icons mdl-notification__close" data-mdl-click="onClose()">clear</i>
<div class="mdl-notification__content">
{{#hasTitle}}
${_hasTitle ? '''
<div class="mdl-notification__title">
<div class="mdl-notification__avatar material-icons"></div>
<div class="mdl-notification__headline">
<h1>{{title}}</h1>
{{#hasSubTitle}}
<h2>{{subtitle}}</h2>
{{/hasSubTitle}}
<h1>${title}</h1>
${_hasSubTitle ? '<h2>${subtitle}</h2>' : ''}
</div>
</div>
{{/hasTitle}}
{{#hasContent}}
</div>''' : ''}
${_hasContent ? '''
<div class="mdl-notification__text">
{{^hasTitle}}
<span class="mdl-notification__avatar material-icons"></span>
{{/hasTitle}}
${_hasTitle ?
'<span class="mdl-notification__avatar material-icons"></span>' : ''}
<span>
{{content}}
${content}
</span>
</div>
{{/hasContent}}
</div>''' : ''}
</div>
</div>
""";

@override
Map<String, Function> get events {
return <String,Function>{
"onClose" : () => _onClose()
};
}

// - private ----------------------------------------------------------------------------------

bool get _hasTitle => title != null && title.isNotEmpty;
bool get _hasSubTitle => subtitle != null && subtitle.isNotEmpty;
bool get _hasContent => content != null && content.isNotEmpty;

String _notificationType() {

switch(type) {
case NotificationType.DEBUG:
return "debug";

case NotificationType.INFO:
return "info";

case NotificationType.WARNING:
return "warning";

case NotificationType.ERROR:
return "error";

default:
return "info";
}
}
}
@@ -43,17 +43,7 @@ class MaterialSnackbar extends MaterialDialog {

static const String DEFAULT_CONFIRM_BUTTON = "OK";

@override
String template = """
<div class="mdl-snackbar {{lambdas.classes}}">
<span class="mdl-snackbar__flex">{{text}}</span>
{{#hasConfirmButton}}
<button class="mdl-button mdl-js-button mdl-button--colored" data-mdl-click="onClose()" autofocus>
{{confirmButton}}
</button>
{{/hasConfirmButton}}
</div>
""";


static const int LONG_DELAY = 3500;
static const int SHORT_DELAY = 2000;
@@ -88,16 +78,13 @@ class MaterialSnackbar extends MaterialDialog {
/// The current Snackbar waits for user interaction
bool get waitingForConfirmation => _confirmationID.isNotEmpty;

/// The template checks it it should show a button or not
bool get hasConfirmButton => confirmButton != null && confirmButton.isNotEmpty;

@override
/// if there is already a Snackbar open - it will be closed
Future<MdlDialogStatus> show({ Duration timeout, FutureOr onDialogInit(final String dialogId) }) {
Validate.isTrue(!waitingForConfirmation,"There is alread a Snackbar waiting for confirmation!!!!");

return close(MdlDialogStatus.CLOSED_VIA_NEXT_SHOW).then( (_) {
if(!hasConfirmButton) {
if(!_hasConfirmButton) {
if(timeout == null) {
timeout = new Duration(milliseconds: SHORT_DELAY);
}
@@ -110,12 +97,32 @@ class MaterialSnackbar extends MaterialDialog {

// - EventHandler -----------------------------------------------------------------------------

void onClose() {
void _onClose() {
Validate.notBlank(_confirmationID, "onClose must have a _confirmationID set - but was blank");

close(MdlDialogStatus.CONFIRMED);
}

// - Template ---------------------------------------------------------------------------------

@override
String get template => """
<div class="mdl-snackbar ${_snackbarClasses()}">
<span class="mdl-snackbar__flex">${text}</span>
${_hasConfirmButton ? '''
<button class="mdl-button mdl-js-button mdl-button--colored" data-mdl-click="onClose()" autofocus>
${confirmButton}
</button>''' : ''}
</div>
""";

@override
Map<String, Function> get events {
return <String,Function>{
"onClose" : () => _onClose()
};
}

// - private ----------------------------------------------------------------------------------

void _onCloseCallback(final MaterialDialog dialogElement, final MdlDialogStatus status) {
@@ -130,31 +137,32 @@ class MaterialSnackbar extends MaterialDialog {
Future _init(final String id) async {
Validate.notBlank(id);
_confirmationID = id;

// Hacky but _init must return a Future
//return new Future(() => true);
}

void _clearConfirmationCheck() {
_confirmationID = "";
}

// String _snackbarClasses(final LambdaContext _) {
// final List<String> classes = new List<String>();
//
// void _addIf(final List<String> classes,final bool check,final String classToAdd) {
// if(check) {
// classes.add(classToAdd);
// }
// }
//
// _addIf(classes,position.top,"mdl-snackbar--top");
// _addIf(classes,position.right,"mdl-snackbar--right");
// _addIf(classes,position.left,"mdl-snackbar--left");
// _addIf(classes,position.bottom,"mdl-snackbar--bottom");
//
// _addIf(classes,waitingForConfirmation,"waiting-for-confirmation");
//
// return classes.join(" ");
// }
/// The template checks it it should show a button or not
bool get _hasConfirmButton => confirmButton != null && confirmButton.isNotEmpty;


String _snackbarClasses() {
final List<String> classes = new List<String>();

void _addIf(final List<String> classes,final bool check,final String classToAdd) {
if(check) {
classes.add(classToAdd);
}
}

_addIf(classes,position.top,"mdl-snackbar--top");
_addIf(classes,position.right,"mdl-snackbar--right");
_addIf(classes,position.left,"mdl-snackbar--left");
_addIf(classes,position.bottom,"mdl-snackbar--bottom");

_addIf(classes,waitingForConfirmation,"waiting-for-confirmation");

return classes.join(" ");
}
}
@@ -20,22 +20,22 @@ dependencies:
meta: ^1.1.0

m4d_core: '>=0.1.0 <1.0.0'
# path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_core
# path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_core

m4d_flux: '>=0.1.0 <1.0.0'
# path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_flux
# path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_flux

m4d_components: '>=0.1.0 <1.0.0'
# path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_components
# path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_components

m4d_template: #'>=0.1.0 <1.0.0'
path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_template
m4d_template: '>=0.1.0 <1.0.0'
# path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_template

m4d_animation: #'>=0.1.0 <1.0.0'
path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_animation
m4d_animation: '>=0.1.0 <1.0.0'
# path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_animation

m4d_translate: #'>=0.1.0 <1.0.0'
path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_translate
m4d_translate: '>=0.1.0 <1.0.0'
# path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_translate

dev_dependencies:
test: any
@@ -9,7 +9,7 @@ environment:

dependencies:

m4d_directive:
m4d_dialog:
path: ../..

m4d_components: '>=0.1.0 <1.0.0'
@@ -1,6 +1,6 @@
title: DIALOG
samplename: dialog
sampleurl: https://github.com/MikeMitterer/dart-material-design-lite-site/tree/master/samples/mdlx_dialog/web
sampleurl: https://github.com/MikeMitterer/m4d_dialog/tree/master/samples/m4d_dialog/web
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<div class="demo-preview-block">

@@ -1,17 +1,21 @@
name: m4d_dialog_sample
description: Material 3 Dart 'm4d_dialog' Sample
version: 0.1.3
description: Material4Dart (m4d) 'm4d_dialog' Sample
version: 0.1.0
author: Mike Mitterer <office@mikemitterer.at>
homepage: https://github.com/MikeMitterer/dart-material-design-lite
homepage: https://github.com/MikeMitterer/m4d_dialog

environment:
sdk: ">=2.0.0 <3.0.0"

dependencies:

m4d_dialog:
path: ../..

m4d_components: '>=0.1.0 <1.0.0'
# path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_components
# path: /Volumes/Daten/DevLocal/DevDart/m4d/m4d_components

dev_dependencies:
build_runner: any
build_web_compilers: any
sass_builder: any
sass_builder: any

0 comments on commit 4a0b184

Please sign in to comment.
You can’t perform that action at this time.