Refine mobile pane animation and preserve native Back
This commit is contained in:
@@ -93,6 +93,7 @@ class ChatThreadView extends StatefulWidget {
|
||||
this.paneControls = const [],
|
||||
this.sidebarControl,
|
||||
this.showBackButton,
|
||||
this.useNativeBack = false,
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
@@ -103,6 +104,7 @@ class ChatThreadView extends StatefulWidget {
|
||||
final List<Widget> paneControls;
|
||||
final Widget? sidebarControl;
|
||||
final bool? showBackButton;
|
||||
final bool useNativeBack;
|
||||
|
||||
/// Sets the chat's shared colour (a palette name, null for none) from the
|
||||
/// information sheet; null leaves the sheet without the Colour choice.
|
||||
@@ -1199,7 +1201,9 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
showBack: canGoBack,
|
||||
// A pushed page keeps the platform's stock Back (pop this route); a
|
||||
// standalone conversation calls its owner.
|
||||
onBack: widget.showBackButton == true
|
||||
onBack: widget.useNativeBack
|
||||
? null
|
||||
: widget.showBackButton == true
|
||||
? widget.onBack
|
||||
: (inShellBar ? null : widget.onBack),
|
||||
// Each control is its own action, so each pops in (and sinks) on its
|
||||
|
||||
@@ -432,6 +432,7 @@ class _ChatScreenState extends State<ChatScreen> with _ChatScreenWorkspace {
|
||||
onNextChat: _nextAfter(selected) != null
|
||||
? () => _openNext(selected)
|
||||
: null,
|
||||
useNativeBack: _page.open,
|
||||
showBackButton: pane == null
|
||||
? null
|
||||
: _page.open || !showsListBesideDetail(context),
|
||||
|
||||
@@ -51,50 +51,53 @@ class ChatMobilePaneViewport extends StatelessWidget {
|
||||
super.key,
|
||||
required this.peek,
|
||||
required this.child,
|
||||
required this.height,
|
||||
required this.onActivate,
|
||||
required this.label,
|
||||
required this.paneId,
|
||||
});
|
||||
final bool peek;
|
||||
final double height;
|
||||
final Widget child;
|
||||
final VoidCallback onActivate;
|
||||
final String label;
|
||||
final String paneId;
|
||||
@override
|
||||
Widget build(BuildContext context) => ClipRect(
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
OverflowBox(
|
||||
alignment: Alignment.topCenter,
|
||||
minHeight: height,
|
||||
maxHeight: peek ? math.max(height, 300) : height,
|
||||
child: SizedBox(
|
||||
height: peek ? math.max(height, 300) : height,
|
||||
child: ExcludeFocus(
|
||||
excluding: peek,
|
||||
child: ExcludeSemantics(
|
||||
excluding: peek,
|
||||
child: IgnorePointer(ignoring: peek, child: child),
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final height = constraints.maxHeight;
|
||||
return ClipRect(
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
OverflowBox(
|
||||
alignment: Alignment.topCenter,
|
||||
minHeight: height,
|
||||
maxHeight: peek ? math.max(height, 300) : height,
|
||||
child: SizedBox(
|
||||
height: peek ? math.max(height, 300) : height,
|
||||
child: ExcludeFocus(
|
||||
excluding: peek,
|
||||
child: ExcludeSemantics(
|
||||
excluding: peek,
|
||||
child: IgnorePointer(ignoring: peek, child: child),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (peek)
|
||||
Semantics(
|
||||
key: ValueKey('chat-peek-$paneId'),
|
||||
identifier: 'chat-peek-$paneId',
|
||||
container: true,
|
||||
label: 'Expand $label',
|
||||
button: true,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: onActivate,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (peek)
|
||||
Semantics(
|
||||
key: ValueKey('chat-peek-$paneId'),
|
||||
identifier: 'chat-peek-$paneId',
|
||||
container: true,
|
||||
label: 'Expand $label',
|
||||
button: true,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: onActivate,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -172,12 +172,6 @@ class _ChatWorkspaceState extends State<ChatWorkspace> {
|
||||
peek: mobile?.peekId == pane.id,
|
||||
label: widget.paneTitle?.call(pane) ?? pane.sessionId,
|
||||
paneId: pane.id,
|
||||
height:
|
||||
(mobile?.rects[pane.id] ??
|
||||
(collapsed
|
||||
? Offset.zero & constraints.biggest
|
||||
: geometry.panes[pane.id]!))
|
||||
.height,
|
||||
onActivate: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
widget.controller.activate(pane.id);
|
||||
|
||||
Reference in New Issue
Block a user