Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Anartem committed Jul 28, 2020
1 parent e04961f commit 7ea9871
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions lib/src/animation/appear_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/src/dialog_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions lib/src/dialog_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DialogHelper {
Function _currentCallback;
StreamController<double> _currentController;

// Shows the dialog
void show(BuildContext context, DialogWidget dialog, {bool rootOverlay = true}) {
hideImmediate(context);

Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/entity/dialog_action.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/entity/dialog_style.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Dialog style,
// adaptive dialog chooses style depends on platform
enum DialogStyle {
material,
cupertino,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 7ea9871

Please sign in to comment.