Permalink
Browse files

feature: Notification-Animation works

  • Loading branch information...
MikeMitterer committed Nov 30, 2015
1 parent da53e70 commit 8273d61143a3bb79f17cb87fae9def3002e41877
View
@@ -30,6 +30,7 @@ import 'package:mdl/mdlcore.dart';
import 'package:mdl/mdlcomponets.dart';
import 'package:mdl/mdlapplication.dart';
import 'package:mdl/mdltemplate.dart';
import 'package:mdl/mdlanimation.dart';
part "src/dialog/MaterialDialog.dart";
part "src/dialog/MaterialAlertDialog.dart";
@@ -51,4 +51,7 @@ class StockAnimation {
static const StockAnimation FadeOut =
const StockAnimation(const Duration(milliseconds: 500), _FadeOut,AnimationTiming.EASE_IN_OUT);
static const StockAnimation MoveUpAndDisappear =
const StockAnimation(const Duration(milliseconds: 400), _MoveUpAndDisappear,AnimationTiming.EASE_IN_OUT);
}
@@ -37,7 +37,7 @@ const _FadeOut = const <int, Map<String, Object>>{
"opacity" : 1},
100 : const <String, Object>{
"opacity" : 2}
"opacity" : 0}
};
const _BounceInRight = const <int, Map<String, Object>>{
@@ -58,3 +58,30 @@ const _BounceInRight = const <int, Map<String, Object>>{
"opacity" : 1,
"transform" : "translateX(0)"}
};
/// More on http://codepen.io/MikeMitterer/pen/QjeOov
const _Shrink = const <int, Map<String, Object>>{
0 : const <String, Object>{
"opacity" : 1 },
10 : const <String, Object>{
"opacity" : 1 },
100 : const <String, Object>{
"transform" : "scaleY(0)",
"height" : 0,
"opacity" : 1 }
};
/// More on http://codepen.io/MikeMitterer/pen/QjeOov
const _MoveUpAndDisappear = const <int, Map<String, Object>>{
0 : const <String, Object>{
"opacity" : 1 },
10 : const <String, Object>{
"opacity" : 0.1 },
100 : const <String, Object>{
"transform" : "translateY(-50px)",
"opacity" : 0.1 }
};
@@ -63,19 +63,24 @@ class DialogConfig {
/// is not the case, for example, with Notifications
final bool appendNewDialog;
/// Sets the [MdlAnimation] if the user clicks on close or if the dialog has and "auto-close" timer
final MdlAnimation closeAnimation;
DialogConfig({ final String rootTagInTemplate: "mdl-dialog",
final bool closeOnBackDropClick: true,
final bool acceptEscToClose: true,
final String parentSelector: _DEFAULT_PARENT_SELECTOR,
final bool autoClosePossible: false,
final bool appendNewDialog: false })
final bool appendNewDialog: false,
final MdlAnimation closeAnimation: null })
: this.rootTagInTemplate = rootTagInTemplate,
this.closeOnBackDropClick = closeOnBackDropClick,
this.acceptEscToClose = acceptEscToClose,
this.parentSelector = parentSelector,
this.autoClosePossible = autoClosePossible,
this.appendNewDialog = appendNewDialog {
this.appendNewDialog = appendNewDialog,
this.closeAnimation = closeAnimation {
Validate.notBlank(rootTagInTemplate);
}
@@ -241,9 +246,16 @@ abstract class MaterialDialog extends Object with TemplateComponent implements S
_dialogContainer.classes.add(_cssClasses.IS_HIDDEN);
}
return new Future.delayed(new Duration(milliseconds: 200), () {
return _destroy(status);
});
if(_config.closeAnimation != null && _element != null) {
final MdlAnimation animation = _config.closeAnimation;
return animation(_element).then((_) => _destroy(status));
} else {
return new Future.delayed(new Duration(milliseconds: 200), () {
return _destroy(status);
});
}
}
/// The dialog gets removed from the DOM
@@ -8,6 +8,8 @@ class _MaterialNotificationCssClasses {
const _MaterialNotificationCssClasses();
}
final MdlAnimation shrinkNotification = new MdlAnimation.fromStock(StockAnimation.MoveUpAndDisappear);
class _NotificationConfig extends DialogConfig {
static const _MaterialNotificationCssClasses _cssClasses = const _MaterialNotificationCssClasses();
@@ -16,8 +18,8 @@ class _NotificationConfig extends DialogConfig {
closeOnBackDropClick: false,
autoClosePossible: true,
appendNewDialog: true,
acceptEscToClose: false
acceptEscToClose: false,
closeAnimation: shrinkNotification
);
}
@@ -90,6 +92,7 @@ class MaterialNotification extends MaterialDialog {
// TODO: Params are not used - change parent function...
Future<MdlDialogStatus> show({ final Duration timeout,void dialogIDCallback(final String dialogId) }) {
return super.show(timeout: new Duration(milliseconds: this.timeout));
//return super.show();
}
void onClose() {

0 comments on commit 8273d61

Please sign in to comment.