Skip to content

Commit

Permalink
Merge pull request #52 from boyan01/dev-docs
Browse files Browse the repository at this point in the history
Improve comment and docs
  • Loading branch information
boyan01 authored Sep 12, 2020
2 parents 2af2919 + bb0242b commit 35f6467
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 192 deletions.
6 changes: 4 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ tab_width = 4

[*.dart]
max_line_length = 120
tab_width = 2

[*.yaml]
indent_size = 2
[{*.yaml, *.yml}]
indent_size = 2
tab_width = 2
5 changes: 3 additions & 2 deletions .github/workflows/deploy_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: deploy

on:
release:
types: [published, edited]
types: [ published, edited ]

jobs:
build:
Expand All @@ -18,7 +18,8 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v1
with:
channel: 'stable'
# only dev channel support web.
channel: 'dev'
- run: flutter config --enable-web
- run: flutter pub get

Expand Down
119 changes: 0 additions & 119 deletions .idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
# overlay_support
[![Pub](https://img.shields.io/pub/v/overlay_support.svg)](https://pub.dartlang.org/packages/overlay_support)
[![Pub](https://img.shields.io/pub/v/overlay_support.svg)](https://pub.dev/packages/overlay_support)
[![CI](https://github.com/boyan01/overlay_support/workflows/CI/badge.svg)](https://github.com/boyan01/overlay_support/actions)
[![codecov](https://codecov.io/gh/boyan01/overlay_support/branch/master/graph/badge.svg)](https://codecov.io/gh/boyan01/overlay_support)


provider support for overlay, easy to build **toast** and **internal notification**.
Provider support for `overlay`, make it easy to build **toast** and **In-App notification**.

**this library support platform Android、iOS 、Linux、macOS、Windows and Web**
**this library support ALL platform**

## Interation
## Interaction

If you want to see the ui effect of this library, just click here [https://boyan01.github.io/overlay_support/#/](https://boyan01.github.io/overlay_support/#/)

## How To Use

1. add dependencies into you project pubspec.yaml file
1. add dependencies into you project `pubspec.yaml` file
```
dependencies:
overlay_support: latest_version
```
* Current latest_version is [![Pub](https://img.shields.io/pub/v/overlay_support.svg)](https://pub.dev/packages/overlay_support)

2. wrap your AppWidget with `OverlaySupport`
```dart #build()
return OverlaySupport(child: MaterialApp());
Expand All @@ -27,16 +29,20 @@ dependencies:
3. show toast or simple notifications

```dart
//popup a toast
toast('Hello world!');
import 'package:overlay_support/overlay_support.dart';
void onClick() {
// popup a toast.
toast('Hello world!');
//show a notification at top of screen
showSimpleNotification(
// show a notification at top of screen.
showSimpleNotification(
Text("this is a message from simple notification"),
background: Colors.green);
}
```

more instructions check here : [example/readme.md](./example/)
more instructions check here : [example/README.md](./example/README.md)

## License

Expand Down
2 changes: 1 addition & 1 deletion example/lib/notification/ios_toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class IosStyleToast extends StatelessWidget {
Widget build(BuildContext context) {
return SafeArea(
child: DefaultTextStyle(
style: Theme.of(context).textTheme.body1.copyWith(color: Colors.white),
style: Theme.of(context).textTheme.bodyText2.copyWith(color: Colors.white),
child: Padding(
padding: const EdgeInsets.all(16),
child: Center(
Expand Down
8 changes: 4 additions & 4 deletions lib/overlay_support.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
library overlay_support;

export 'src/notification/overlay_notification.dart';
export 'src/notification/notification.dart';
export 'src/notification/overlay_notification.dart';
export 'src/overlay.dart';
export 'src/toast/toast.dart';
export 'src/theme.dart';
export 'src/toast/toast.dart';

///The length of time the notification is fully displayed
/// The length of time the notification is fully displayed.
Duration kNotificationDuration = const Duration(milliseconds: 2000);

///Notification display or hidden animation duration
/// Notification display or hidden animation duration.
Duration kNotificationSlideDuration = const Duration(milliseconds: 300);
8 changes: 4 additions & 4 deletions lib/src/notification/notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:overlay_support/overlay_support.dart';

/// a notification show in front of screen and shown at the top
/// A notification show in front of screen and shown at the top.
class TopSlideNotification extends StatelessWidget {
///build notification content
/// Which used to build notification content.
final WidgetBuilder builder;

final double progress;
Expand Down Expand Up @@ -38,7 +38,7 @@ class BottomSlideNotification extends StatelessWidget {
}
}

///can be dismiss by left or right slide
/// Can be dismiss by left or right slide.
class SlideDismissible extends StatelessWidget {
final Widget child;

Expand All @@ -57,7 +57,7 @@ class SlideDismissible extends StatelessWidget {
child: child,
key: key,
onDismissed: (direction) {
OverlaySupportEntry.of(context, requireForDebug: this).dismiss(animate: false);
OverlaySupportEntry.of(context).dismiss(animate: false);
},
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/notification/overlay_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ OverlaySupportEntry showSimpleNotification(Widget content,
bottom: position == NotificationPosition.bottom,
top: position == NotificationPosition.top,
child: ListTileTheme(
textColor: foreground ?? Theme.of(context)?.accentTextTheme?.title?.color,
iconColor: foreground ?? Theme.of(context)?.accentTextTheme?.title?.color,
textColor: foreground ?? Theme.of(context)?.accentTextTheme?.headline6?.color,
iconColor: foreground ?? Theme.of(context)?.accentTextTheme?.headline6?.color,
child: ListTile(
leading: leading,
title: content,
Expand Down
32 changes: 15 additions & 17 deletions lib/src/overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,42 @@ import 'package:overlay_support/overlay_support.dart';
import 'package:overlay_support/src/theme.dart';

part 'overlay_animation.dart';

part 'overlay_entry.dart';

part 'overlay_key.dart';

/// to build a widget with animated value
/// To build a widget with animated value.
/// [progress] : the progress of overlay animation from 0 - 1
///
/// a simple use case is [TopSlideNotification] in [showOverlayNotification]
/// A simple use case is [TopSlideNotification] in [showOverlayNotification].
///
typedef Widget AnimatedOverlayWidgetBuilder(BuildContext context, double progress);

///basic api to show overlay widget
/// Basic api to show overlay widget.
///
///[duration] the overlay display duration , overlay will auto dismiss after [duration]
///if null , will be set to [kNotificationDuration]
///if zero , will not auto dismiss in the future
/// [duration] : the overlay display duration , overlay will auto dismiss after [duration].
/// if null , will be set to [kNotificationDuration].
/// if zero , will not auto dismiss in the future.
///
///[builder], see [AnimatedOverlayWidgetBuilder]
/// [builder] : see [AnimatedOverlayWidgetBuilder].
///
///[curve], adjust the rate of change of an animation
/// [curve] : adjust the rate of change of an animation.
///
///[key] to identify a OverlayEntry.
/// [key] : to identify a OverlayEntry.
///
/// for example:
/// ```dart
/// final key = ValueKey('my overlay');
///
/// //step 1: popup a overlay
/// // step 1: popup a overlay
/// showOverlay(builder, key: key);
///
/// //step 2: popup a overlay use the same key
/// // step 2: popup a overlay use the same key
/// showOverlay(builder2, key: key);
/// ```
///
/// if the notification1 of step1 is showing, the step2 will dismiss previous notification1.
/// If the notification1 of step1 is showing, the step2 will dismiss previous notification1.
///
/// if you want notification1' exist to prevent step2, please see [ModalKey]
/// If you want notification1' exist to prevent step2, please see [ModalKey]
///
///
OverlaySupportEntry showOverlay(
Expand All @@ -63,7 +61,7 @@ OverlaySupportEntry showOverlay(
final OverlayState overlay = _overlayState;
if (overlay == null) {
assert(() {
debugPrint('overlay not avaliable, dispose this call : $key');
debugPrint('overlay not available, dispose this call : $key');
return true;
}());
return OverlaySupportEntry.empty();
Expand Down Expand Up @@ -153,7 +151,7 @@ class OverlaySupport extends StatelessWidget {
@override
Widget build(BuildContext context) {
assert(() {
if (context.ancestorWidgetOfExactType(OverlaySupport) != null) {
if (context.findAncestorWidgetOfExactType<OverlaySupport>() != null) {
throw FlutterError('There is already an OverlaySupport in the Widget tree.');
}
return true;
Expand Down
6 changes: 3 additions & 3 deletions lib/src/overlay_animation.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
part of 'overlay.dart';

class _AnimatedOverlay extends StatefulWidget {
///overlay display total duration
///zero means overlay display forever
/// The total duration of overlay display.
/// [Duration.zero] means overlay display forever.
final Duration duration;

///overlay show/hide animation duration
/// The duration overlay show/hide's animation.
final Duration animationDuration;

final AnimatedOverlayWidgetBuilder builder;
Expand Down
Loading

0 comments on commit 35f6467

Please sign in to comment.