Merge branch 'main' into floating-chats-global
# Conflicts: # app/lib/features/chat/workspace/chat_workspace.dart
This commit is contained in:
@@ -462,39 +462,59 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
||||
required Set<String> edges,
|
||||
Map<ChatPaneDirection, String>? moveTargets,
|
||||
FocusNode? focusParent,
|
||||
}) => KeyedSubtree(
|
||||
key: _views.putIfAbsent(pane.id, () => GlobalKey(debugLabel: pane.id)),
|
||||
child: FocusScope(
|
||||
parentNode: focusParent,
|
||||
node: _panes.putIfAbsent(
|
||||
pane.id,
|
||||
() => FocusScopeNode(debugLabel: pane.id),
|
||||
),
|
||||
onFocusChange: (focused) {
|
||||
if (focused && !mobile) widget.controller.activate(pane.id);
|
||||
},
|
||||
child: Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
// A press in the peek scrolls or taps; the tap alone activates.
|
||||
onPointerDown: peek ? null : (_) => widget.controller.activate(pane.id),
|
||||
child: Semantics(
|
||||
identifier: 'chat-pane-${pane.id}',
|
||||
container: true,
|
||||
sortKey: mobile ? const OrdinalSortKey(0) : null,
|
||||
child: ChatWorkspacePaneScope(
|
||||
topEdgeShared: edges.contains('top'),
|
||||
bottomEdgeShared: edges.contains('bottom'),
|
||||
leftEdgeShared: edges.contains('left'),
|
||||
rightEdgeShared: edges.contains('right'),
|
||||
movable: moveTargets != null,
|
||||
moveTargets: moveTargets ?? const {},
|
||||
child: Builder(
|
||||
builder: (paneContext) =>
|
||||
widget.paneBuilder(paneContext, pane, active),
|
||||
}) {
|
||||
var actionBarPointerDown = false;
|
||||
bool preservesStageForActionBar() =>
|
||||
_stage.stage != null && _stage.stage!.stageId != pane.id;
|
||||
return KeyedSubtree(
|
||||
key: _views.putIfAbsent(pane.id, () => GlobalKey(debugLabel: pane.id)),
|
||||
child: FocusScope(
|
||||
parentNode: focusParent,
|
||||
node: _panes.putIfAbsent(
|
||||
pane.id,
|
||||
() => FocusScopeNode(debugLabel: pane.id),
|
||||
),
|
||||
onFocusChange: (focused) {
|
||||
final inActionBar = ChatWorkspacePaneActionBar.contains(
|
||||
primaryFocus?.context,
|
||||
);
|
||||
if (focused &&
|
||||
!mobile &&
|
||||
(!inActionBar || !preservesStageForActionBar())) {
|
||||
widget.controller.activate(pane.id);
|
||||
}
|
||||
},
|
||||
child: Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
// A press in the peek scrolls or taps; the tap alone activates.
|
||||
onPointerDown: peek
|
||||
? null
|
||||
: (_) {
|
||||
if (!actionBarPointerDown || !preservesStageForActionBar()) {
|
||||
widget.controller.activate(pane.id);
|
||||
}
|
||||
},
|
||||
child: Semantics(
|
||||
identifier: 'chat-pane-${pane.id}',
|
||||
container: true,
|
||||
sortKey: mobile ? const OrdinalSortKey(0) : null,
|
||||
child: ChatWorkspacePaneScope(
|
||||
topEdgeShared: edges.contains('top'),
|
||||
bottomEdgeShared: edges.contains('bottom'),
|
||||
leftEdgeShared: edges.contains('left'),
|
||||
rightEdgeShared: edges.contains('right'),
|
||||
movable: moveTargets != null,
|
||||
moveTargets: moveTargets ?? const {},
|
||||
onActionBarPointerDown: () => actionBarPointerDown = true,
|
||||
onActionBarPointerUp: () => actionBarPointerDown = false,
|
||||
child: Builder(
|
||||
builder: (paneContext) =>
|
||||
widget.paneBuilder(paneContext, pane, active),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ class ChatWorkspacePaneScope extends InheritedWidget {
|
||||
required this.rightEdgeShared,
|
||||
this.movable = false,
|
||||
this.moveTargets = const {},
|
||||
this.onActionBarPointerDown,
|
||||
this.onActionBarPointerUp,
|
||||
required super.child,
|
||||
});
|
||||
|
||||
@@ -29,6 +31,10 @@ class ChatWorkspacePaneScope extends InheritedWidget {
|
||||
/// The pane id a move in each direction swaps with; an outer edge has none.
|
||||
final Map<ChatPaneDirection, String> moveTargets;
|
||||
|
||||
/// Lets a live pane's toolbar consume the pointer without selecting the pane.
|
||||
final VoidCallback? onActionBarPointerDown;
|
||||
final VoidCallback? onActionBarPointerUp;
|
||||
|
||||
static ChatWorkspacePaneScope? maybeOf(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<ChatWorkspacePaneScope>();
|
||||
|
||||
@@ -39,5 +45,31 @@ class ChatWorkspacePaneScope extends InheritedWidget {
|
||||
leftEdgeShared != oldWidget.leftEdgeShared ||
|
||||
rightEdgeShared != oldWidget.rightEdgeShared ||
|
||||
movable != oldWidget.movable ||
|
||||
!mapEquals(moveTargets, oldWidget.moveTargets);
|
||||
!mapEquals(moveTargets, oldWidget.moveTargets) ||
|
||||
onActionBarPointerDown != oldWidget.onActionBarPointerDown ||
|
||||
onActionBarPointerUp != oldWidget.onActionBarPointerUp;
|
||||
}
|
||||
|
||||
/// Marks a pane header/toolbar. Its controls remain interactive, but focusing
|
||||
/// or pressing them must not make a live side pane the staged chat.
|
||||
class ChatWorkspacePaneActionBar extends StatelessWidget {
|
||||
const ChatWorkspacePaneActionBar({super.key, required this.child});
|
||||
|
||||
final Widget child;
|
||||
|
||||
static bool contains(BuildContext? context) =>
|
||||
context?.findAncestorWidgetOfExactType<ChatWorkspacePaneActionBar>() !=
|
||||
null;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scope = ChatWorkspacePaneScope.maybeOf(context);
|
||||
return Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onPointerDown: (_) => scope?.onActionBarPointerDown?.call(),
|
||||
onPointerUp: (_) => scope?.onActionBarPointerUp?.call(),
|
||||
onPointerCancel: (_) => scope?.onActionBarPointerUp?.call(),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user