From cef6c8b4797a0e9514a5dd83b4f5a09b4bdbbbd8 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Thu, 11 Mar 2021 09:47:17 +0900 Subject: [PATCH] removed flushbar, upgraded expansion_tile_card --- lib/main.dart | 7 ++++++ lib/theme/durations.dart | 3 +-- lib/utils/constants.dart | 6 ----- .../collection/entry_set_action_delegate.dart | 24 ++++++++++--------- .../common/action_mixins/feedback.dart | 20 ++++------------ .../common/identity/aves_expansion_tile.dart | 2 ++ .../common/chip_action_delegate.dart | 20 +++++++++------- lib/widgets/viewer/entry_viewer_stack.dart | 4 ++-- pubspec.lock | 13 +++------- pubspec.yaml | 4 ---- 10 files changed, 44 insertions(+), 59 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 948167cd2..239986259 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -83,6 +83,13 @@ class _AvesAppState extends State { ), ), ), + snackBarTheme: SnackBarThemeData( + backgroundColor: Colors.grey[800], + contentTextStyle: TextStyle( + color: Colors.white, + ), + behavior: SnackBarBehavior.floating, + ), elevatedButtonTheme: ElevatedButtonThemeData( style: ElevatedButton.styleFrom( primary: accentColor, diff --git a/lib/theme/durations.dart b/lib/theme/durations.dart index bbbf6fd35..f0c590209 100644 --- a/lib/theme/durations.dart +++ b/lib/theme/durations.dart @@ -3,7 +3,6 @@ import 'package:flutter/scheduler.dart'; class Durations { // common animations static const iconAnimation = Duration(milliseconds: 300); - static const opToastAnimation = Duration(milliseconds: 600); static const sweeperOpacityAnimation = Duration(milliseconds: 150); static const sweepingAnimation = Duration(milliseconds: 650); static const popupMenuAnimation = Duration(milliseconds: 300); // ref _PopupMenuRoute._kMenuDuration @@ -43,7 +42,7 @@ class Durations { static const xmpStructArrayCardTransition = Duration(milliseconds: 300); // delays & refresh intervals - static const opToastDisplay = Duration(seconds: 2); + static const opToastDisplay = Duration(seconds: 3); static const collectionScrollMonitoringTimerDelay = Duration(milliseconds: 100); static const collectionScalingCompleteNotificationDelay = Duration(milliseconds: 300); static const highlightScrollInitDelay = Duration(milliseconds: 800); diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index d265a608c..d0b702c35 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -234,12 +234,6 @@ class Constants { licenseUrl: 'https://github.com/Skylled/expansion_tile_card/blob/master/LICENSE', sourceUrl: 'https://github.com/Skylled/expansion_tile_card', ), - Dependency( - name: 'Flushbar', - license: 'Apache 2.0', - licenseUrl: 'https://github.com/AndreHaueisen/flushbar/blob/master/LICENSE', - sourceUrl: 'https://github.com/AndreHaueisen/flushbar', - ), Dependency( name: 'Flutter Highlight', license: 'MIT', diff --git a/lib/widgets/collection/entry_set_action_delegate.dart b/lib/widgets/collection/entry_set_action_delegate.dart index 2c3a0404c..55d422265 100644 --- a/lib/widgets/collection/entry_set_action_delegate.dart +++ b/lib/widgets/collection/entry_set_action_delegate.dart @@ -109,14 +109,6 @@ class EntrySetActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAware itemCount: todoCount, onDone: (processed) async { final movedOps = processed.where((e) => e.success).toSet(); - final movedCount = movedOps.length; - if (movedCount < todoCount) { - final count = todoCount - movedCount; - showFeedback(context, copy ? context.l10n.collectionCopyFailureFeedback(count) : context.l10n.collectionMoveFailureFeedback(count)); - } else { - final count = movedCount; - showFeedback(context, copy ? context.l10n.collectionCopySuccessFeedback(count) : context.l10n.collectionMoveSuccessFeedback(count)); - } await source.updateAfterMove( todoEntries: todoEntries, favouriteEntries: favouriteEntries, @@ -126,6 +118,15 @@ class EntrySetActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAware ); collection.browse(); source.resumeMonitoring(); + + final movedCount = movedOps.length; + if (movedCount < todoCount) { + final count = todoCount - movedCount; + showFeedback(context, copy ? context.l10n.collectionCopyFailureFeedback(count) : context.l10n.collectionMoveFailureFeedback(count)); + } else { + final count = movedCount; + showFeedback(context, copy ? context.l10n.collectionCopySuccessFeedback(count) : context.l10n.collectionMoveSuccessFeedback(count)); + } }, ); } @@ -164,14 +165,15 @@ class EntrySetActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAware itemCount: selectionCount, onDone: (processed) { final deletedUris = processed.where((event) => event.success).map((event) => event.uri).toSet(); + source.removeEntries(deletedUris); + collection.browse(); + source.resumeMonitoring(); + final deletedCount = deletedUris.length; if (deletedCount < selectionCount) { final count = selectionCount - deletedCount; showFeedback(context, context.l10n.collectionDeleteFailureFeedback(count)); } - source.removeEntries(deletedUris); - collection.browse(); - source.resumeMonitoring(); }, ); } diff --git a/lib/widgets/common/action_mixins/feedback.dart b/lib/widgets/common/action_mixins/feedback.dart index 06dcbce87..297f669b9 100644 --- a/lib/widgets/common/action_mixins/feedback.dart +++ b/lib/widgets/common/action_mixins/feedback.dart @@ -1,26 +1,16 @@ import 'package:aves/theme/durations.dart'; -import 'package:flushbar/flushbar.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/scheduler.dart'; import 'package:intl/intl.dart'; import 'package:percent_indicator/circular_percent_indicator.dart'; mixin FeedbackMixin { - Flushbar _flushbar; - - Future dismissFeedback() => _flushbar?.dismiss(); + void dismissFeedback(BuildContext context) => ScaffoldMessenger.of(context).hideCurrentSnackBar(); void showFeedback(BuildContext context, String message) { - _flushbar = Flushbar( - message: message, - margin: EdgeInsets.all(8), - borderRadius: 8, - borderColor: Colors.white30, - borderWidth: 0.5, - duration: Durations.opToastDisplay * timeDilation, - flushbarPosition: FlushbarPosition.TOP, - animationDuration: Durations.opToastAnimation, - )..show(context); + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text(message), + duration: Durations.opToastDisplay, + )); } // report overlay for multiple operations diff --git a/lib/widgets/common/identity/aves_expansion_tile.dart b/lib/widgets/common/identity/aves_expansion_tile.dart index e82b64955..7eabb8a4d 100644 --- a/lib/widgets/common/identity/aves_expansion_tile.dart +++ b/lib/widgets/common/identity/aves_expansion_tile.dart @@ -36,8 +36,10 @@ class AvesExpansionTile extends StatelessWidget { ), expandable: enabled, initiallyExpanded: initiallyExpanded, + finalPadding: EdgeInsets.symmetric(vertical: 6.0), baseColor: Colors.grey[900], expandedColor: Colors.grey[850], + shadowColor: Theme.of(context).shadowColor, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/widgets/filter_grids/common/chip_action_delegate.dart b/lib/widgets/filter_grids/common/chip_action_delegate.dart index 07e5c0e5c..a9a0e452d 100644 --- a/lib/widgets/filter_grids/common/chip_action_delegate.dart +++ b/lib/widgets/filter_grids/common/chip_action_delegate.dart @@ -142,13 +142,14 @@ class AlbumChipActionDelegate extends ChipActionDelegate with FeedbackMixin, Per itemCount: selectionCount, onDone: (processed) { final deletedUris = processed.where((event) => event.success).map((event) => event.uri).toSet(); + source.removeEntries(deletedUris); + source.resumeMonitoring(); + final deletedCount = deletedUris.length; if (deletedCount < selectionCount) { final count = selectionCount - deletedCount; showFeedback(context, context.l10n.collectionDeleteFailureFeedback(count)); } - source.removeEntries(deletedUris); - source.resumeMonitoring(); }, ); } @@ -180,13 +181,6 @@ class AlbumChipActionDelegate extends ChipActionDelegate with FeedbackMixin, Per itemCount: todoCount, onDone: (processed) async { final movedOps = processed.where((e) => e.success).toSet(); - final movedCount = movedOps.length; - if (movedCount < todoCount) { - final count = todoCount - movedCount; - showFeedback(context, context.l10n.collectionMoveFailureFeedback(count)); - } else { - showFeedback(context, context.l10n.genericSuccessFeedback); - } final pinned = settings.pinnedFilters.contains(filter); await source.updateAfterMove( todoEntries: todoEntries, @@ -201,6 +195,14 @@ class AlbumChipActionDelegate extends ChipActionDelegate with FeedbackMixin, Per settings.pinnedFilters = settings.pinnedFilters..add(newFilter); } source.resumeMonitoring(); + + final movedCount = movedOps.length; + if (movedCount < todoCount) { + final count = todoCount - movedCount; + showFeedback(context, context.l10n.collectionMoveFailureFeedback(count)); + } else { + showFeedback(context, context.l10n.genericSuccessFeedback); + } }, ); } diff --git a/lib/widgets/viewer/entry_viewer_stack.dart b/lib/widgets/viewer/entry_viewer_stack.dart index 00001b3e9..592e7be0e 100644 --- a/lib/widgets/viewer/entry_viewer_stack.dart +++ b/lib/widgets/viewer/entry_viewer_stack.dart @@ -360,10 +360,10 @@ class _EntryViewerStackState extends State with SingleTickerPr ); } - Future _onVerticalPageChanged(int page) async { + void _onVerticalPageChanged(int page) { _currentVerticalPage.value = page; if (page == transitionPage) { - await _actionDelegate.dismissFeedback(); + _actionDelegate.dismissFeedback(context); _popVisual(); } else if (page == infoPage) { // prevent hero when viewer is offscreen diff --git a/pubspec.lock b/pubspec.lock index baf50608e..bb4c8d89b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -181,10 +181,10 @@ packages: description: path: "." ref: HEAD - resolved-ref: "51fe2b12588356fade82ce65daef5482beed54e7" + resolved-ref: b80a0b322622f28bd783cccef3663aa7aa806e01 url: "git://github.com/deckerst/expansion_tile_card.git" source: git - version: "1.0.3" + version: "2.0.0" fake_async: dependency: transitive description: @@ -269,13 +269,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" - flushbar: - dependency: "direct main" - description: - name: flushbar - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.4" flutter: dependency: "direct main" description: flutter @@ -1106,4 +1099,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.12.0 <3.0.0" - flutter: ">=1.24.0-10" + flutter: ">=1.26.0-0" diff --git a/pubspec.yaml b/pubspec.yaml index 249fd8347..bae85e558 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,8 +7,6 @@ publish_to: none environment: sdk: '>=2.10.0 <3.0.0' -# TODO TLAD merge null safe `expansion_tile_card` to fork -# TODO TLAD migrate from `flushbar` to basic SnackBar or `another_flushbar` # TODO TLAD remove explicit `overlay_support` version when 1.2.0 is stable (1.0.5 uses deprecated `ancestorWidgetOfExactType`) # TODO TLAD switch to Flutter dev/beta when possible, currently on master because of the following mess: @@ -21,7 +19,6 @@ environment: # `charts_flutter` - https://github.com/google/charts/issues/579 # `country_code` - unmaintained? # `decorated_icon` - https://github.com/benPesso/flutter_decorated_icon/issues/2 -# `flushbar` - discontinued # `flutter_ijkplayer` - unmaintained? # `flutter_map` - https://github.com/fleaflet/flutter_map/issues/829 # `latlong` - archived - migrate to maps_toolkit? cf https://github.com/fleaflet/flutter_map/pull/750 @@ -47,7 +44,6 @@ dependencies: firebase_core: firebase_analytics: firebase_crashlytics: - flushbar: flutter_highlight: flutter_ijkplayer: # path: ../flutter_ijkplayer