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:
@@ -3,6 +3,7 @@ import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
import '../domain/chat_account_usage.dart';
|
||||
import '../domain/chat_usage_ring.dart';
|
||||
|
||||
@@ -125,6 +126,8 @@ class _ChatSendUsageRingState extends State<ChatSendUsageRing> {
|
||||
},
|
||||
track: scheme.outlineVariant.withValues(alpha: .35),
|
||||
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.track,
|
||||
required this.circle,
|
||||
this.cornerRadius,
|
||||
});
|
||||
|
||||
final double fraction;
|
||||
@@ -155,6 +159,10 @@ class ChatUsageRingPainter extends CustomPainter {
|
||||
final Color track;
|
||||
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 gap = 1;
|
||||
|
||||
@@ -171,6 +179,11 @@ class ChatUsageRingPainter extends CustomPainter {
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = stroke
|
||||
..isAntiAlias = true;
|
||||
final corner = cornerRadius;
|
||||
if (corner != null) {
|
||||
_paintSquare(canvas, size, corner, paint);
|
||||
return;
|
||||
}
|
||||
canvas.drawCircle(rect.center, radius, paint..color = track);
|
||||
if (fraction <= 0) return;
|
||||
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
|
||||
bool shouldRepaint(ChatUsageRingPainter old) =>
|
||||
old.cornerRadius != cornerRadius ||
|
||||
old.fraction != fraction ||
|
||||
old.color != color ||
|
||||
old.track != track ||
|
||||
|
||||
Reference in New Issue
Block a user