#987 viewer: fixed snack bar bottom margin
This commit is contained in:
parent
66713cb663
commit
8776a3cc44
4 changed files with 15 additions and 14 deletions
|
@ -21,12 +21,15 @@ import 'package:provider/provider.dart';
|
||||||
|
|
||||||
enum FeedbackType { info, warn }
|
enum FeedbackType { info, warn }
|
||||||
|
|
||||||
|
typedef MarginComputer = EdgeInsets Function(BuildContext context);
|
||||||
|
|
||||||
mixin FeedbackMixin {
|
mixin FeedbackMixin {
|
||||||
static final ValueNotifier<EdgeInsets?> snackBarMarginOverrideNotifier = ValueNotifier(null);
|
static final ValueNotifier<MarginComputer?> snackBarMarginOverrideNotifier = ValueNotifier(null);
|
||||||
|
|
||||||
static EdgeInsets snackBarMarginDefault(BuildContext context) {
|
static EdgeInsets snackBarMarginDefault(BuildContext context) {
|
||||||
final mq = context.read<MediaQueryData>();
|
return EdgeInsets.only(
|
||||||
return EdgeInsets.only(bottom: max(mq.effectiveBottomPadding, mq.systemGestureInsets.bottom));
|
bottom: context.select<MediaQueryData, double>((mq) => max(mq.effectiveBottomPadding, mq.systemGestureInsets.bottom)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dismissFeedback(BuildContext context) => ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
void dismissFeedback(BuildContext context) => ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
|
@ -69,11 +72,12 @@ mixin FeedbackMixin {
|
||||||
notificationOverlayEntry = showOverlayNotification(
|
notificationOverlayEntry = showOverlayNotification(
|
||||||
(context) => SafeArea(
|
(context) => SafeArea(
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: ValueListenableBuilder<EdgeInsets?>(
|
child: ValueListenableBuilder<MarginComputer?>(
|
||||||
valueListenable: snackBarMarginOverrideNotifier,
|
valueListenable: snackBarMarginOverrideNotifier,
|
||||||
builder: (context, margin, child) {
|
builder: (context, marginComputer, child) {
|
||||||
|
final margin = (marginComputer ?? snackBarMarginDefault).call(context);
|
||||||
return AnimatedPadding(
|
return AnimatedPadding(
|
||||||
padding: margin ?? snackBarMarginDefault(context),
|
padding: margin,
|
||||||
duration: ADurations.pageTransitionAnimation,
|
duration: ADurations.pageTransitionAnimation,
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
|
|
|
@ -24,10 +24,6 @@ class EntryViewerPage extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
State<EntryViewerPage> createState() => _EntryViewerPageState();
|
State<EntryViewerPage> createState() => _EntryViewerPageState();
|
||||||
|
|
||||||
static EdgeInsets snackBarMargin(BuildContext context) {
|
|
||||||
return EdgeInsets.only(bottom: ViewerBottomOverlay.actionSafeHeight(context));
|
|
||||||
}
|
|
||||||
|
|
||||||
static Color getBackground(BuildContext context) => Theme.of(context).isDark ? Colors.black : Colors.white;
|
static Color getBackground(BuildContext context) => Theme.of(context).isDark ? Colors.black : Colors.white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -312,11 +312,13 @@ class _EntryViewerStackState extends State<EntryViewerStack> with EntryViewContr
|
||||||
void didPushNext() => _resetSnackBarMargin();
|
void didPushNext() => _resetSnackBarMargin();
|
||||||
|
|
||||||
void _overrideSnackBarMargin() {
|
void _overrideSnackBarMargin() {
|
||||||
|
MarginComputer marginComputer;
|
||||||
if (isViewingImage) {
|
if (isViewingImage) {
|
||||||
FeedbackMixin.snackBarMarginOverrideNotifier.value = EdgeInsets.only(bottom: ViewerBottomOverlay.actionSafeHeight(context));
|
marginComputer = (context) => EdgeInsets.only(bottom: ViewerBottomOverlay.actionSafeHeight(context));
|
||||||
} else {
|
} else {
|
||||||
FeedbackMixin.snackBarMarginOverrideNotifier.value = FeedbackMixin.snackBarMarginDefault(context);
|
marginComputer = FeedbackMixin.snackBarMarginDefault;
|
||||||
}
|
}
|
||||||
|
FeedbackMixin.snackBarMarginOverrideNotifier.value = marginComputer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _resetSnackBarMargin() => FeedbackMixin.snackBarMarginOverrideNotifier.value = null;
|
void _resetSnackBarMargin() => FeedbackMixin.snackBarMarginOverrideNotifier.value = null;
|
||||||
|
|
|
@ -46,8 +46,7 @@ class ViewerBottomOverlay extends StatefulWidget {
|
||||||
State<StatefulWidget> createState() => _ViewerBottomOverlayState();
|
State<StatefulWidget> createState() => _ViewerBottomOverlayState();
|
||||||
|
|
||||||
static double actionSafeHeight(BuildContext context) {
|
static double actionSafeHeight(BuildContext context) {
|
||||||
final mq = context.read<MediaQueryData>();
|
final mqPaddingBottom = context.select<MediaQueryData, double>((mq) => max(mq.effectiveBottomPadding, mq.systemGestureInsets.bottom));
|
||||||
final mqPaddingBottom = max(mq.effectiveBottomPadding, mq.systemGestureInsets.bottom);
|
|
||||||
final buttonHeight = ViewerButtons.preferredHeight(context);
|
final buttonHeight = ViewerButtons.preferredHeight(context);
|
||||||
final thumbnailHeight = (settings.showOverlayThumbnailPreview ? ViewerThumbnailPreview.preferredHeight : 0);
|
final thumbnailHeight = (settings.showOverlayThumbnailPreview ? ViewerThumbnailPreview.preferredHeight : 0);
|
||||||
return mqPaddingBottom + buttonHeight + thumbnailHeight;
|
return mqPaddingBottom + buttonHeight + thumbnailHeight;
|
||||||
|
|
Loading…
Reference in a new issue