Skip to content

Commit

Permalink
Merge pull request #6 from cb-cloud/use_overlay_api_to_show_notificat…
Browse files Browse the repository at this point in the history
…ion_#5

Use overlay api to show notification
  • Loading branch information
Kurogoma4D authored Jun 17, 2021
2 parents ec90f68 + 18d942d commit 22f7191
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 140 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 0.3.0
### FEAT
- **BREAKING: Overall, changes API.**
- Removed `InAppNotification.of()`. To show notificaiton, use `InAppNotification.show()` instead.
- Changed usage of `InAppNotification`, see Usage section in README.
- Replaced `Stack` with `OverlayEntry` on showing notification sysytem.
- Removed `minAlertHeight` property. Notification size is decided from specified Widget now.
- Removed `safeAreaPadding` property. Notification position is now considering safe area automatically.
- Added `curve` property to `InAppNotification.show()` method.

## 0.2.0+1
Organize documents.

Expand Down
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,23 @@ A Flutter package to show custom in-app notification with any Widgets.
import 'package:in_app_notification/in_app_notification.dart';
```
2. Place `InAppNotification` Widget into your app.
We recommend to place it in the `builder` of the `MaterialApp`.

```dart
return MaterialApp(
home: const HomePage(),
builder: (context, child) => InAppNotification(
safeAreaPadding: MediaQuery.of(context).viewPadding,
minAlertHeight: 60.0,
child: child,
return InAppNotification(
child: MaterialApp(
title: 'In-App Notification Demo',
home: const HomePage(),
),
);
```

3. Get `InAppNotification` instance via `of()` method, and invoke `show()` method.
3. Invoke `show()` static method of `InAppNotification`.

```dart
InAppNotification.of(context).show(
child: YourOwnWidget(),
onTap: () => print('Notification tapped!'),
duration: Duration(milliseconds: _duration),
InAppNotification.show(
child: NotificationBody(count: _count),
context: context,
onTap: () => print('Notification tapped!'),
);
```

Expand All @@ -47,9 +44,9 @@ A Flutter package to show custom in-app notification with any Widgets.
- Implementation for more gesture
- Swipe horizontal
- Performance optimization
- Currently `InAppNotification` is recommended to use in `builder` of `MaterialApp`, but it means create instance each time of routing.
- ~~Currently `InAppNotification` is recommended to use in `builder` of `MaterialApp`, but it means create instance each time of routing.~~ ✅
- Animation improvement
- So far, we have confirmed that using a Widget with a height higher than the `minAlertHeight ` specified for `InApp` will slightly break the animation.
- ~~So far, we have confirmed that using a Widget with a height higher than the `minAlertHeight ` specified for `InApp` will slightly break the animation.~~ ✅

## 💭 Have a question?
If you have a question or found issue, feel free to [create an issue](https://github.com/cb-cloud/flutter_in_app_notification/issues/new).
24 changes: 11 additions & 13 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ class App extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'In-App Notification Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: const HomePage(),
builder: (context, child) => InAppNotification(
safeAreaPadding: MediaQuery.of(context).viewPadding,
minAlertHeight: 60.0,
child: child!,
return InAppNotification(
child: MaterialApp(
title: 'In-App Notification Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: const HomePage(),
),
);
}
Expand Down Expand Up @@ -64,8 +61,9 @@ class _HomePageState extends State<HomePage> {
ElevatedButton(
onPressed: () {
_incrementCount();
InAppNotification.of(context)?.show(
InAppNotification.show(
child: NotificationBody(count: _count),
context: context,
onTap: () => print('Notification tapped!'),
duration: Duration(milliseconds: _duration),
);
Expand Down Expand Up @@ -93,7 +91,7 @@ class NotificationBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 24, 16, 0),
padding: const EdgeInsets.fromLTRB(16, 4, 16, 0),
child: DecoratedBox(
decoration: BoxDecoration(
boxShadow: [
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.0"
version: "0.3.0"
matcher:
dependency: transitive
description:
Expand Down
Loading

0 comments on commit 22f7191

Please sign in to comment.