7d2c3412a1
Adds the Paper design and generalises design tokens (transcript, composer, selected-row styles, reading type, panel fill, chat colour saturation). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
2.0 KiB
Dart
51 lines
2.0 KiB
Dart
import 'dart:math' as math;
|
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import '../../../ui/theme/app_design_tokens.dart';
|
|
import '../ui/transcript/chat_message_bubble.dart';
|
|
import '../ui/transcript/chat_turn_activity_view.dart';
|
|
|
|
/// The widest the conversation's reading column grows: transcript rows and
|
|
/// the floating composer share it, centred, so a wide window keeps a
|
|
/// comfortable line length instead of stretching messages edge to edge.
|
|
const double kChatReadingWidth = 760;
|
|
|
|
/// The reading column's width under the design at [context]:
|
|
/// [kChatReadingWidth], or, for a design that sets a reading measure
|
|
/// ([ReadingType.measure], Paper's ~70ch), that many reading characters plus
|
|
/// the rows' own side padding (16 each side, then the answer's inset), so
|
|
/// the text itself is that wide. It follows the operator's text scaling.
|
|
double chatReadingWidthOf(BuildContext context) {
|
|
final reading = AppDesignTokens.of(context).reading;
|
|
final measure = reading.measure;
|
|
if (measure == null) return kChatReadingWidth;
|
|
final size = MediaQuery.textScalerOf(
|
|
context,
|
|
).scale(chatMessageTextStyle(context)?.fontSize ?? 16);
|
|
return measure * size * reading.figureWidth +
|
|
2 * (16 + chatAgentContentInset);
|
|
}
|
|
|
|
/// The space on each side of the centred reading column in [width], for a
|
|
/// column [readingWidth] wide.
|
|
double chatReadingInset(
|
|
double width, [
|
|
double readingWidth = kChatReadingWidth,
|
|
]) => math.max(0, (width - readingWidth) / 2);
|
|
|
|
/// The strip left of the reading column that holds an answer's Copy button,
|
|
/// outside the answer itself.
|
|
const double kChatCopyGutterWidth = 48;
|
|
|
|
/// The copy gutter a transcript [width] wide gives each answer:
|
|
/// [kChatCopyGutterWidth] when the margin left of the centred reading column
|
|
/// fits it, else 0, and Copy stays in the answer's footer (phones, narrow
|
|
/// panes).
|
|
double chatCopyGutter(
|
|
double width, [
|
|
double readingWidth = kChatReadingWidth,
|
|
]) => chatReadingInset(width, readingWidth) >= kChatCopyGutterWidth
|
|
? kChatCopyGutterWidth
|
|
: 0;
|