From 7ea9871042c1e5459eda4dd5821c15dc94e0ed0e Mon Sep 17 00:00:00 2001 From: Anastasia Artemyeva Date: Tue, 28 Jul 2020 18:02:15 +0300 Subject: [PATCH] Add comments --- README.md | 2 ++ lib/src/animation/appear_widget.dart | 4 ++++ lib/src/dialog_factory.dart | 1 + lib/src/dialog_helper.dart | 3 +++ lib/src/entity/dialog_action.dart | 2 ++ lib/src/entity/dialog_style.dart | 2 ++ pubspec.yaml | 2 +- 7 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 16fed7a..2cf86d1 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ A Flutter package for showing platform dialogs without using new routes. - Supports Material and Cupertino dialogs - Flutter-based solution, no additional imports needed +![Overlay Dialog Demo](https://github.com/mera-company/flutter-overlay-dialog/blob/master/doc/overlay_dialog_demo.gif?raw=true =300x533) + # What's the problem? During project develop we stucks with several problems with Flutter dialogs. This package solves several problems of standart Flutter approach. diff --git a/lib/src/animation/appear_widget.dart b/lib/src/animation/appear_widget.dart index d26c239..e1eca18 100644 --- a/lib/src/animation/appear_widget.dart +++ b/lib/src/animation/appear_widget.dart @@ -4,11 +4,15 @@ import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/widgets.dart'; +// Supported animation type +// opacity creates fade in / out effect +// blur makes background blurred enum AppearStyle { opacity, blur } +// Uses to animate dialog appearance class AppearWidget extends StatefulWidget { final Widget _child; final Stream _progress; diff --git a/lib/src/dialog_factory.dart b/lib/src/dialog_factory.dart index 225bd35..59b47dc 100644 --- a/lib/src/dialog_factory.dart +++ b/lib/src/dialog_factory.dart @@ -7,6 +7,7 @@ import 'package:flutter/widgets.dart'; import 'entity/dialog_action.dart'; import 'entity/dialog_style.dart'; +// Platform dialog factory class DialogFactory { factory DialogFactory(DialogStyle type) { if (type == DialogStyle.material) { diff --git a/lib/src/dialog_helper.dart b/lib/src/dialog_helper.dart index b477966..b924dd4 100644 --- a/lib/src/dialog_helper.dart +++ b/lib/src/dialog_helper.dart @@ -22,6 +22,7 @@ class DialogHelper { Function _currentCallback; StreamController _currentController; + // Shows the dialog void show(BuildContext context, DialogWidget dialog, {bool rootOverlay = true}) { hideImmediate(context); @@ -63,6 +64,7 @@ class DialogHelper { _currentController.add(1.0); } + // Hide opened dialog with animation void hide(BuildContext context) { if (_currentCallback != null) { ModalRoute.of(context)?.removeScopedWillPopCallback(_currentCallback); @@ -84,6 +86,7 @@ class DialogHelper { } } + // Hide opened dialog without animation, clear closable callback if any void hideImmediate(BuildContext context) { //reset back press handler if (_currentCallback != null) { diff --git a/lib/src/entity/dialog_action.dart b/lib/src/entity/dialog_action.dart index f9bc115..a7ad14d 100644 --- a/lib/src/entity/dialog_action.dart +++ b/lib/src/entity/dialog_action.dart @@ -1,5 +1,7 @@ import 'package:flutter/widgets.dart'; +// Default action to handle dialog button tap +// isDefault and isDestructive flags are used for Cupertino dialogs class DialogAction { String title; Function handler; diff --git a/lib/src/entity/dialog_style.dart b/lib/src/entity/dialog_style.dart index ece4faa..bb65b2f 100644 --- a/lib/src/entity/dialog_style.dart +++ b/lib/src/entity/dialog_style.dart @@ -1,3 +1,5 @@ +// Dialog style, +// adaptive dialog chooses style depends on platform enum DialogStyle { material, cupertino, diff --git a/pubspec.yaml b/pubspec.yaml index 4254ada..dfd9296 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: overlay_dialog description: A Flutter package for showing platform dialogs without using new routes. version: 0.0.2 -homepage: https://ctogitlab.mera.com/anartem/flutter-overlay-dialog +homepage: https://github.com/mera-company/flutter-overlay-dialog environment: sdk: ">=2.7.0 <3.0.0"