Identify mobile chat peeks and expose switching and resize affordances
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/semantics.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import '../conversation/chat_pane_presentation.dart';
|
||||
import 'chat_peek_gesture.dart';
|
||||
import 'chat_peek_header.dart';
|
||||
import 'chat_workspace_controller.dart';
|
||||
|
||||
/// A phone presentation only: saved split axes and ratios are left untouched.
|
||||
@@ -86,29 +87,51 @@ class ChatMobilePaneViewport extends StatelessWidget {
|
||||
final String paneId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ClipRect(
|
||||
child: Semantics(
|
||||
key: ValueKey('chat-peek-$paneId'),
|
||||
identifier: peek ? 'chat-peek-$paneId' : null,
|
||||
container: peek,
|
||||
sortKey: peek ? const OrdinalSortKey(1) : null,
|
||||
label: peek ? 'Expand $label' : null,
|
||||
button: peek ? true : null,
|
||||
onTap: peek ? onActivate : null,
|
||||
child: ChatPeekGesture(
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) => ClipRect(
|
||||
child: Semantics(
|
||||
key: ValueKey('chat-peek-$paneId'),
|
||||
identifier: peek ? 'chat-peek-$paneId' : null,
|
||||
container: peek,
|
||||
sortKey: peek ? const OrdinalSortKey(1) : null,
|
||||
label: peek ? 'Expand $label' : null,
|
||||
button: peek ? true : null,
|
||||
onTap: peek ? onActivate : null,
|
||||
child: ExcludeFocus(
|
||||
excluding: peek,
|
||||
child: ExcludeSemantics(
|
||||
excluding: peek,
|
||||
child: RepaintBoundary(
|
||||
child: ChatPanePresentation(
|
||||
peek: peek,
|
||||
barReveal: barReveal,
|
||||
fixedChromeLayout: fixedChromeLayout,
|
||||
child: child,
|
||||
child: ChatPeekGesture(
|
||||
onTap: peek ? onActivate : null,
|
||||
child: Column(
|
||||
children: [
|
||||
Offstage(
|
||||
offstage: !peek || fixedChromeLayout,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: constraints.maxHeight),
|
||||
child: ClipRect(
|
||||
child: ExcludeSemantics(
|
||||
child: ChatPeekHeader(
|
||||
title: label,
|
||||
onActivate: onActivate,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ExcludeFocus(
|
||||
excluding: peek,
|
||||
child: ExcludeSemantics(
|
||||
excluding: peek,
|
||||
child: RepaintBoundary(
|
||||
child: ChatPanePresentation(
|
||||
peek: peek,
|
||||
barReveal: barReveal,
|
||||
fixedChromeLayout: fixedChromeLayout,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'dart:math' as math;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// A transparent touch target centred on the active chat's coloured bottom
|
||||
/// border. Height is bounded by the original 20% peek and a nonzero minimum.
|
||||
@@ -20,6 +22,7 @@ class ChatMobilePeekDivider extends StatefulWidget {
|
||||
|
||||
class _ChatMobilePeekDividerState extends State<ChatMobilePeekDivider> {
|
||||
double? _dragHeight;
|
||||
bool _focused = false;
|
||||
double get _maximum => widget.available * .2;
|
||||
double get _minimum => math.min(48.0, _maximum);
|
||||
void _change(double value) {
|
||||
@@ -42,6 +45,7 @@ class _ChatMobilePeekDividerState extends State<ChatMobilePeekDivider> {
|
||||
onIncrease: () => _step(16),
|
||||
onDecrease: () => _step(-16),
|
||||
child: Focus(
|
||||
onFocusChange: (focused) => setState(() => _focused = focused),
|
||||
onKeyEvent: (_, event) {
|
||||
if (event is! KeyDownEvent && event is! KeyRepeatEvent) {
|
||||
return KeyEventResult.ignored;
|
||||
@@ -66,7 +70,40 @@ class _ChatMobilePeekDividerState extends State<ChatMobilePeekDivider> {
|
||||
},
|
||||
onVerticalDragEnd: (_) => _dragHeight = null,
|
||||
onVerticalDragCancel: () => _dragHeight = null,
|
||||
child: const SizedBox.expand(),
|
||||
child: Tooltip(
|
||||
message: 'Drag to resize inactive chat',
|
||||
child: Center(
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: usesCupertinoHost(context)
|
||||
? CupertinoColors.secondarySystemBackground.resolveFrom(
|
||||
context,
|
||||
)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: _focused
|
||||
? Border.all(
|
||||
color: usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Icon(
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoIcons.minus
|
||||
: Icons.drag_handle,
|
||||
size: 18,
|
||||
color: usesCupertinoHost(context)
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// A named, explicit switch action above the inactive transcript. It occupies
|
||||
/// space rather than obscuring the small chat's readable content.
|
||||
class ChatPeekHeader extends StatelessWidget {
|
||||
const ChatPeekHeader({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.onActivate,
|
||||
});
|
||||
final String title;
|
||||
final VoidCallback onActivate;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final compact = constraints.maxHeight < 44;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final textStyle = cupertino
|
||||
? (compact
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
|
||||
: CupertinoTheme.of(context).textTheme.textStyle)
|
||||
: (compact
|
||||
? Theme.of(context).textTheme.labelMedium
|
||||
: Theme.of(context).textTheme.labelLarge);
|
||||
final foreground = cupertino
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurface;
|
||||
final background = cupertino
|
||||
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainer;
|
||||
final content = Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: textStyle?.copyWith(color: foreground),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text('Switch', style: textStyle?.copyWith(color: foreground)),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
cupertino ? CupertinoIcons.arrow_up : Icons.arrow_upward,
|
||||
color: foreground,
|
||||
size: 18,
|
||||
),
|
||||
],
|
||||
);
|
||||
return ColoredBox(
|
||||
color: background,
|
||||
child: Tooltip(
|
||||
message: 'Switch to $title',
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
minimumSize: const Size(0, 44),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
onPressed: onActivate,
|
||||
child: content,
|
||||
)
|
||||
: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size(0, 44),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
shape: const RoundedRectangleBorder(),
|
||||
),
|
||||
onPressed: onActivate,
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user