Terminal design: no composer prompt glyph; usage ring follows the square send button
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1314,10 +1314,6 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
|||||||
// Let a long folder name wrap when the attach and primary controls
|
// Let a long folder name wrap when the attach and primary controls
|
||||||
// leave little horizontal room.
|
// leave little horizontal room.
|
||||||
hintMaxLines: 2,
|
hintMaxLines: 2,
|
||||||
// A terminal design's prompt glyph leads the field, as a CLI's
|
|
||||||
// input line does.
|
|
||||||
prefixIcon: _promptGlyph(context),
|
|
||||||
prefixIconConstraints: const BoxConstraints(),
|
|
||||||
// The pill draws the field's surface; the field adds no border.
|
// The pill draws the field's surface; the field adds no border.
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
isDense: true,
|
isDense: true,
|
||||||
@@ -1326,26 +1322,6 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The prompt glyph before the field under a terminal design; null under
|
|
||||||
/// the Default design.
|
|
||||||
Widget? _promptGlyph(BuildContext context) {
|
|
||||||
final tokens = AppDesignTokens.of(context);
|
|
||||||
if (!tokens.terminal) return null;
|
|
||||||
return ExcludeSemantics(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsetsDirectional.only(start: 4, end: 10),
|
|
||||||
child: Text(
|
|
||||||
tokens.promptGlyph,
|
|
||||||
key: const Key('chat-composer-prompt-glyph'),
|
|
||||||
style: TextStyle(
|
|
||||||
color: chatFocusRingColor(context, widget.chatColor),
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The single primary control: Send (or Run command for a `!` draft). A
|
/// The single primary control: Send (or Run command for a `!` draft). A
|
||||||
/// prompt sent while a turn runs takes the server's queued-prompt path; the
|
/// prompt sent while a turn runs takes the server's queued-prompt path; the
|
||||||
/// running turn is stopped by Escape twice, `/stop`, or the More menu.
|
/// running turn is stopped by Escape twice, `/stop`, or the More menu.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:math' as math;
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
import '../domain/chat_account_usage.dart';
|
import '../domain/chat_account_usage.dart';
|
||||||
import '../domain/chat_usage_ring.dart';
|
import '../domain/chat_usage_ring.dart';
|
||||||
|
|
||||||
@@ -125,6 +126,8 @@ class _ChatSendUsageRingState extends State<ChatSendUsageRing> {
|
|||||||
},
|
},
|
||||||
track: scheme.outlineVariant.withValues(alpha: .35),
|
track: scheme.outlineVariant.withValues(alpha: .35),
|
||||||
circle: chatSendButtonDiameter(context),
|
circle: chatSendButtonDiameter(context),
|
||||||
|
// A design with square-ish corners frames its square send button.
|
||||||
|
cornerRadius: AppDesignTokens.of(context).radius,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,6 +151,7 @@ class ChatUsageRingPainter extends CustomPainter {
|
|||||||
required this.color,
|
required this.color,
|
||||||
required this.track,
|
required this.track,
|
||||||
required this.circle,
|
required this.circle,
|
||||||
|
this.cornerRadius,
|
||||||
});
|
});
|
||||||
|
|
||||||
final double fraction;
|
final double fraction;
|
||||||
@@ -155,6 +159,10 @@ class ChatUsageRingPainter extends CustomPainter {
|
|||||||
final Color track;
|
final Color track;
|
||||||
final double circle;
|
final double circle;
|
||||||
|
|
||||||
|
/// The button's corner radius under a design that squares it; null for the
|
||||||
|
/// round button. The ring then follows a rounded square instead.
|
||||||
|
final double? cornerRadius;
|
||||||
|
|
||||||
static const double stroke = 2;
|
static const double stroke = 2;
|
||||||
static const double gap = 1;
|
static const double gap = 1;
|
||||||
|
|
||||||
@@ -171,6 +179,11 @@ class ChatUsageRingPainter extends CustomPainter {
|
|||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = stroke
|
..strokeWidth = stroke
|
||||||
..isAntiAlias = true;
|
..isAntiAlias = true;
|
||||||
|
final corner = cornerRadius;
|
||||||
|
if (corner != null) {
|
||||||
|
_paintSquare(canvas, size, corner, paint);
|
||||||
|
return;
|
||||||
|
}
|
||||||
canvas.drawCircle(rect.center, radius, paint..color = track);
|
canvas.drawCircle(rect.center, radius, paint..color = track);
|
||||||
if (fraction <= 0) return;
|
if (fraction <= 0) return;
|
||||||
canvas.drawArc(
|
canvas.drawArc(
|
||||||
@@ -184,8 +197,43 @@ class ChatUsageRingPainter extends CustomPainter {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The rounded-square ring: the track all round and the used part
|
||||||
|
/// clockwise from the top centre.
|
||||||
|
void _paintSquare(Canvas canvas, Size size, double corner, Paint paint) {
|
||||||
|
final half = radius;
|
||||||
|
final rect = Rect.fromCenter(
|
||||||
|
center: size.center(Offset.zero),
|
||||||
|
width: half * 2,
|
||||||
|
height: half * 2,
|
||||||
|
);
|
||||||
|
final r = Radius.circular(corner + gap + stroke / 2);
|
||||||
|
final c = rect.center;
|
||||||
|
// Built clockwise from the top centre, so the used length starts there.
|
||||||
|
final path = Path()
|
||||||
|
..moveTo(c.dx, rect.top)
|
||||||
|
..lineTo(rect.right - r.x, rect.top)
|
||||||
|
..arcToPoint(Offset(rect.right, rect.top + r.y), radius: r)
|
||||||
|
..lineTo(rect.right, rect.bottom - r.y)
|
||||||
|
..arcToPoint(Offset(rect.right - r.x, rect.bottom), radius: r)
|
||||||
|
..lineTo(rect.left + r.x, rect.bottom)
|
||||||
|
..arcToPoint(Offset(rect.left, rect.bottom - r.y), radius: r)
|
||||||
|
..lineTo(rect.left, rect.top + r.y)
|
||||||
|
..arcToPoint(Offset(rect.left + r.x, rect.top), radius: r)
|
||||||
|
..close();
|
||||||
|
canvas.drawPath(path, paint..color = track);
|
||||||
|
if (fraction <= 0) return;
|
||||||
|
final metric = path.computeMetrics().first;
|
||||||
|
canvas.drawPath(
|
||||||
|
metric.extractPath(0, metric.length * fraction.clamp(0, 1)),
|
||||||
|
paint
|
||||||
|
..color = color
|
||||||
|
..strokeCap = fraction >= 1 ? StrokeCap.butt : StrokeCap.square,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldRepaint(ChatUsageRingPainter old) =>
|
bool shouldRepaint(ChatUsageRingPainter old) =>
|
||||||
|
old.cornerRadius != cornerRadius ||
|
||||||
old.fraction != fraction ||
|
old.fraction != fraction ||
|
||||||
old.color != color ||
|
old.color != color ||
|
||||||
old.track != track ||
|
old.track != track ||
|
||||||
|
|||||||
Reference in New Issue
Block a user