diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..dc01b9e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +root = true + +[*] +charset = utf-8 +end_of_line = crlf +indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 100 +tab_width = 4 + +[*.dart] +max_line_length = 120 + +[*.yaml] +indent_size = 2 \ No newline at end of file diff --git a/.github/workflows/deploy_web.yml b/.github/workflows/deploy_web.yml index 6f05f56..2415a2e 100644 --- a/.github/workflows/deploy_web.yml +++ b/.github/workflows/deploy_web.yml @@ -18,7 +18,7 @@ jobs: - name: Setup Flutter uses: subosito/flutter-action@v1 with: - channel: 'dev' + channel: 'stable' - run: flutter config --enable-web - run: flutter pub get diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fa47f93..7228680 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,6 @@ name: CI -on: [push] +on: [push, pull_request] jobs: build: @@ -16,10 +16,13 @@ jobs: - name: Setup Flutter uses: subosito/flutter-action@v1 with: - channel: 'dev' + channel: 'stable' - run: flutter config --enable-web - run: flutter pub get + - name: Project format check + run: flutter format -l 120 -n . + - name: Flutter unit test run: flutter test --coverage --coverage-path=lcov.info diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c464379 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "[dart]": { + "editor.formatOnSave": true, + "editor.formatOnType": true, + "editor.rulers": [ + 80 + ], + "editor.selectionHighlight": false, + "editor.suggest.snippetsPreventQuickSuggestions": false, + "editor.suggestSelection": "first", + "editor.tabCompletion": "onlySnippets", + "editor.wordBasedSuggestions": false + }, + "dart.lineLength": 120 +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index de47c7a..764b7b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.0.5] - 2020/7/20 +* Expose duration to `showSimpleNotification` [#46](https://github.com/boyan01/overlay_support/pull/46) by [Elvis Sun](https://github.com/elvisun) + ## [1.0.4] - 2020/5/26 * Support for `BottomSlideNotification`. [#40](https://github.com/boyan01/overlay_support/pull/40) by [Giles Correia Morton](https://github.com/gilescm) * Upgrade min dart sdk version to 2.1.0. [Policy](https://dart.dev/tools/pub/publishing#publishing-prereleases) diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..a43eb34 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,5 @@ +linter: + # TODO: add more rules + rules: + - avoid_empty_else + # - lines_longer_than_80_chars # not yet tested \ No newline at end of file diff --git a/example/.gitignore b/example/.gitignore index 8487566..5f6d825 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -27,6 +27,7 @@ .pub-cache/ .pub/ build/ +.flutter-plugins-dependencies # Android related **/android/**/gradle-wrapper.jar diff --git a/example/lib/main.dart b/example/lib/main.dart index 494f7b9..4ce912a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -83,8 +83,7 @@ class _NavigationTiles extends StatelessWidget { ListTile( title: Text("Star On GitHub"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute(builder: (context) => PageWithIme())); + Navigator.of(context).push(MaterialPageRoute(builder: (context) => PageWithIme())); }, ) ], diff --git a/lib/src/notification/overlay_notification.dart b/lib/src/notification/overlay_notification.dart index 5652f00..c87f0af 100644 --- a/lib/src/notification/overlay_notification.dart +++ b/lib/src/notification/overlay_notification.dart @@ -3,14 +3,14 @@ import 'package:overlay_support/overlay_support.dart'; import 'package:overlay_support/src/notification/notification.dart'; import 'package:overlay_support/src/overlay.dart'; -/// popup a notification at the top of screen +/// Popup a notification at the top of screen. /// -///[duration] the notification 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 notification display duration , overlay will auto dismiss after [duration]. +/// if null , will be set to [kNotificationDuration]. +/// if zero , will not auto dismiss in the future. /// /// [position] the position of notification, default is [NotificationPosition.top], -/// can be [NotificationPosition.top] or [NotificationPosition.bottom] +/// can be [NotificationPosition.top] or [NotificationPosition.bottom]. /// OverlaySupportEntry showOverlayNotification( WidgetBuilder builder, { @@ -23,8 +23,7 @@ OverlaySupportEntry showOverlayNotification( } return showOverlay((context, t) { MainAxisAlignment alignment = MainAxisAlignment.start; - if (position == NotificationPosition.bottom) - alignment = MainAxisAlignment.end; + if (position == NotificationPosition.bottom) alignment = MainAxisAlignment.end; return Column( mainAxisAlignment: alignment, children: [ @@ -37,23 +36,23 @@ OverlaySupportEntry showOverlayNotification( } /// -///show a simple notification above the top of window +/// Show a simple notification above the top of window. /// /// -/// [content] see more [ListTile.title] -/// [leading] see more [ListTile.leading] -/// [subtitle] see more [ListTile.subtitle] -/// [trailing] see more [ListTile.trailing] -/// [contentPadding] see more [ListTile.contentPadding] +/// [content] see more [ListTile.title]. +/// [leading] see more [ListTile.leading]. +/// [subtitle] see more [ListTile.subtitle]. +/// [trailing] see more [ListTile.trailing]. +/// [contentPadding] see more [ListTile.contentPadding]. /// -/// [background] the background color for notification , default is [ThemeData.accentColor] -/// [foreground] see more [ListTileTheme.textColor],[ListTileTheme.iconColor] +/// [background] the background color for notification , default is [ThemeData.accentColor]. +/// [foreground] see more [ListTileTheme.textColor],[ListTileTheme.iconColor]. /// -/// [elevation] the elevation of notification, see more [Material.elevation] -/// [autoDismiss] true to auto hide after duration [kNotificationDuration] -/// [slideDismiss] support left/right to dismiss notification +/// [elevation] the elevation of notification, see more [Material.elevation]. +/// [autoDismiss] true to auto hide after duration [kNotificationDuration]. +/// [slideDismiss] support left/right to dismiss notification. /// [position] the position of notification, default is [NotificationPosition.top], -/// can be [NotificationPosition.top] or [NotificationPosition.bottom] +/// can be [NotificationPosition.top] or [NotificationPosition.bottom]. /// OverlaySupportEntry showSimpleNotification(Widget content, {Widget leading, @@ -80,10 +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?.title?.color, + iconColor: foreground ?? Theme.of(context)?.accentTextTheme?.title?.color, child: ListTile( leading: leading, title: content, diff --git a/pubspec.yaml b/pubspec.yaml index 41deb21..2ad8eb1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: overlay_support description: proivder support for overlay, easy to build toast and internal notification -version: 1.0.4 +version: 1.0.5 author: YangBin homepage: https://github.com/boyan01/overlay_support diff --git a/test/overlay_support_test.dart b/test/overlay_support_test.dart index 217c66c..52dfb32 100644 --- a/test/overlay_support_test.dart +++ b/test/overlay_support_test.dart @@ -70,8 +70,7 @@ void main() { await tester.pumpWidget(_FakeOverlay(child: Builder(builder: (context) { return FlatButton( onPressed: () { - entry = - showSimpleNotification(Text('message'), autoDismiss: false); + entry = showSimpleNotification(Text('message'), autoDismiss: false); }, child: Text('notification')); }))); @@ -95,8 +94,7 @@ void main() { await tester.pumpWidget(_FakeOverlay(child: Builder(builder: (context) { return FlatButton( onPressed: () { - final entry = - showSimpleNotification(Text('message'), autoDismiss: false); + final entry = showSimpleNotification(Text('message'), autoDismiss: false); //dismiss immediately entry.dismiss(); }, @@ -163,14 +161,12 @@ void main() { children: [ FlatButton( onPressed: () { - showSimpleNotification(Text('message'), - autoDismiss: false, key: ValueKey('hello')); + showSimpleNotification(Text('message'), autoDismiss: false, key: ValueKey('hello')); }, child: Text('notification')), FlatButton( onPressed: () { - showSimpleNotification(Text('message2'), - autoDismiss: false, key: ValueKey('hello')); + showSimpleNotification(Text('message2'), autoDismiss: false, key: ValueKey('hello')); }, child: Text('notification2')), ], @@ -203,14 +199,12 @@ void main() { children: [ FlatButton( onPressed: () { - showSimpleNotification(Text('message'), - autoDismiss: false, key: ModalKey('hello')); + showSimpleNotification(Text('message'), autoDismiss: false, key: ModalKey('hello')); }, child: Text('notification')), FlatButton( onPressed: () { - showSimpleNotification(Text('message2'), - autoDismiss: false, key: ModalKey('hello')); + showSimpleNotification(Text('message2'), autoDismiss: false, key: ModalKey('hello')); }, child: Text('notification2')), ], @@ -237,8 +231,7 @@ void main() { await tester.pumpWidget(_FakeOverlay(child: Builder(builder: (context) { return FlatButton( onPressed: () { - showSimpleNotification(Text('message'), - trailing: Builder(builder: (context) { + showSimpleNotification(Text('message'), trailing: Builder(builder: (context) { return FlatButton( onPressed: () { entry = OverlaySupportEntry.of(context); @@ -265,8 +258,7 @@ void main() { await tester.pumpWidget(_FakeOverlay(child: Builder(builder: (context) { return FlatButton( onPressed: () { - entry = - showSimpleNotification(Text('message'), autoDismiss: true); + entry = showSimpleNotification(Text('message'), autoDismiss: true); }, child: Text('notification')); })));