settings: improved quick action editor drag feedback
This commit is contained in:
parent
77e5e950ef
commit
d905baffcf
2 changed files with 16 additions and 7 deletions
|
@ -1,6 +1,8 @@
|
||||||
import 'package:aves/widgets/common/providers/media_query_data_provider.dart';
|
import 'package:aves/widgets/common/providers/media_query_data_provider.dart';
|
||||||
import 'package:aves/widgets/settings/common/quick_actions/action_button.dart';
|
import 'package:aves/widgets/settings/common/quick_actions/action_button.dart';
|
||||||
import 'package:aves/widgets/settings/common/quick_actions/placeholder.dart';
|
import 'package:aves/widgets/settings/common/quick_actions/placeholder.dart';
|
||||||
|
import 'package:aves/widgets/viewer/overlay/common.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
class AvailableActionPanel<T extends Object> extends StatelessWidget {
|
class AvailableActionPanel<T extends Object> extends StatelessWidget {
|
||||||
|
@ -75,10 +77,6 @@ class AvailableActionPanel<T extends Object> extends StatelessWidget {
|
||||||
Widget child,
|
Widget child,
|
||||||
) =>
|
) =>
|
||||||
LongPressDraggable<T>(
|
LongPressDraggable<T>(
|
||||||
data: action,
|
|
||||||
maxSimultaneousDrags: 1,
|
|
||||||
onDragStarted: () => _setDraggedAvailableAction(action),
|
|
||||||
onDragEnd: (details) => _setDraggedAvailableAction(null),
|
|
||||||
feedback: MediaQueryDataProvider(
|
feedback: MediaQueryDataProvider(
|
||||||
child: _buildActionButton(
|
child: _buildActionButton(
|
||||||
context,
|
context,
|
||||||
|
@ -86,6 +84,13 @@ class AvailableActionPanel<T extends Object> extends StatelessWidget {
|
||||||
showCaption: false,
|
showCaption: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
data: action,
|
||||||
|
dragAnchorStrategy: (draggable, context, position) {
|
||||||
|
return childDragAnchorStrategy(draggable, context, position) + Offset(0, OverlayButton.getSize(context));
|
||||||
|
},
|
||||||
|
maxSimultaneousDrags: 1,
|
||||||
|
onDragStarted: () => _setDraggedAvailableAction(action),
|
||||||
|
onDragEnd: (details) => _setDraggedAvailableAction(null),
|
||||||
childWhenDragging: child,
|
childWhenDragging: child,
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:aves/widgets/common/providers/media_query_data_provider.dart';
|
import 'package:aves/widgets/common/providers/media_query_data_provider.dart';
|
||||||
|
import 'package:aves/widgets/viewer/overlay/common.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
enum QuickActionPlacement { header, action, footer }
|
enum QuickActionPlacement { header, action, footer }
|
||||||
|
@ -58,16 +59,19 @@ class QuickActionButton<T extends Object> extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDraggable(Widget child, T action) => LongPressDraggable(
|
Widget _buildDraggable(Widget child, T action) => LongPressDraggable(
|
||||||
|
feedback: MediaQueryDataProvider(
|
||||||
|
child: draggableFeedbackBuilder!(action),
|
||||||
|
),
|
||||||
data: action,
|
data: action,
|
||||||
|
dragAnchorStrategy: (draggable, context, position) {
|
||||||
|
return childDragAnchorStrategy(draggable, context, position) + Offset(0, OverlayButton.getSize(context));
|
||||||
|
},
|
||||||
maxSimultaneousDrags: 1,
|
maxSimultaneousDrags: 1,
|
||||||
onDragStarted: () => _setDraggedQuickAction(action),
|
onDragStarted: () => _setDraggedQuickAction(action),
|
||||||
// `onDragEnd` is only called when the widget is mounted,
|
// `onDragEnd` is only called when the widget is mounted,
|
||||||
// so we rely on `onDraggableCanceled` and `onDragCompleted` instead
|
// so we rely on `onDraggableCanceled` and `onDragCompleted` instead
|
||||||
onDraggableCanceled: (velocity, offset) => _setDraggedQuickAction(null),
|
onDraggableCanceled: (velocity, offset) => _setDraggedQuickAction(null),
|
||||||
onDragCompleted: () => _setDraggedQuickAction(null),
|
onDragCompleted: () => _setDraggedQuickAction(null),
|
||||||
feedback: MediaQueryDataProvider(
|
|
||||||
child: draggableFeedbackBuilder!(action),
|
|
||||||
),
|
|
||||||
childWhenDragging: child,
|
childWhenDragging: child,
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue