113063b040
Adds the Notebook design (TranscriptStyle.cells, ComposerStyle.cell), a white/charcoal IDE theme with light grey cells, hairlines and 5px corners. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
95 lines
3.3 KiB
Dart
95 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/adaptive/glass_bar.dart';
|
|
import '../../../ui/theme/app_design_tokens.dart';
|
|
import '../ui/transcript/notebook/notebook_cell_frame.dart';
|
|
import '../ui/transcript/notebook/notebook_gutter.dart';
|
|
import 'composer_focus_ring.dart';
|
|
|
|
/// The composer under a design whose composer is a notebook cell
|
|
/// ([ComposerStyle.cell], Notebook): the next, empty input cell, `In [ ]:`
|
|
/// in the gutter beside a light grey cell holding the field and its
|
|
/// controls. The cell's frame and bar take [accent] while the field has
|
|
/// focus; while a turn runs a thin moving line runs along its foot. It
|
|
/// floats over the transcript, so it stands on the page's own colour.
|
|
class ComposerCell extends StatelessWidget {
|
|
const ComposerCell({
|
|
super.key,
|
|
required this.focus,
|
|
required this.accent,
|
|
required this.running,
|
|
required this.child,
|
|
});
|
|
|
|
final FocusNode focus;
|
|
|
|
/// The chat's focus colour (the host's primary for a chat with none).
|
|
final Color accent;
|
|
|
|
/// Whether a turn is running.
|
|
final bool running;
|
|
final Widget child;
|
|
|
|
/// The cell's padding: the pill's edge gap and, past it, the same 3px
|
|
/// the usage ring keeps from the send button, so the ring never meets
|
|
/// the cell's hairline.
|
|
static const double _inset = GlassBarMetrics.fieldEdgeGap + 3;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final scheme = Theme.of(context).colorScheme;
|
|
final cell = ListenableBuilder(
|
|
listenable: focus,
|
|
child: Padding(padding: const EdgeInsets.all(_inset), child: child),
|
|
builder: (context, field) {
|
|
final focused = focus.hasFocus;
|
|
return NotebookCellFrame(
|
|
key: const Key('chat-composer-cell-frame'),
|
|
fill: scheme.surfaceContainerLow,
|
|
border: focused ? accent : scheme.outlineVariant,
|
|
bar: focused ? accent : scheme.outline,
|
|
padding: const EdgeInsetsDirectional.only(start: notebookCellBar),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
field!,
|
|
if (running)
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.only(
|
|
start: notebookCellTextInset - notebookCellBar,
|
|
end: notebookCellTextInset,
|
|
bottom: 1,
|
|
),
|
|
child: LinearProgressIndicator(
|
|
key: const Key('chat-composer-running-rule'),
|
|
minHeight: ComposerFocusRing.ringWidth,
|
|
color: accent,
|
|
backgroundColor: scheme.outlineVariant,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
return Material(
|
|
key: const Key('chat-composer-cell'),
|
|
// The page itself, so the cell reads as the next one on the sheet.
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(top: 4),
|
|
child: NotebookGutterRow(
|
|
label: notebookInLabel(null),
|
|
color: notebookInColor(scheme),
|
|
// The label on the field's first line: the cell's padding, then
|
|
// the field's own.
|
|
top: _inset + 16,
|
|
inline: false,
|
|
child: cell,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|