Files
blumia aee560172c feat: port the client to Flutter (0.3.0)
Replace the MyGo/Go app with a Flutter client that keeps the feature set:

- servers: saved servers, passwordless and password login, HTTP/SOCKS5
  proxy via dart:io, self-signed certificates and pinning, tokens in
  flutter_secure_storage (Keystore)
- sessions: list with live events, search, new/rename/archive/delete,
  instance sheet
- chat: streaming Markdown (flutter_markdown), reasoning and tool rows,
  image previews, context usage ring and sheet, model/agent switching,
  fork/revert, attachments (file_picker), permissions
- Android 7.0 (API 24)+, plain http:// works in release (Dart dials
  sockets directly)
- build: China mirrors for Gradle/NDK, Aliyun Maven repositories, and the
  Gradle distribution pre-seeded; release signed with the test keystore

Read-aloud is dropped as requested. Version 0.3.0.
2026-11-18 19:08:06 +08:00

56 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
/// The composer's context usage ring, colored by the official thresholds.
class UsageRing extends StatelessWidget {
final double pct; // 0..100
final double size;
final Color accent;
const UsageRing({super.key, required this.pct, this.size = 18, required this.accent});
Color get _color {
if (pct >= 90) return Colors.red.shade600;
if (pct >= 75) return Colors.orange.shade700;
return Colors.green.shade600;
}
@override
Widget build(BuildContext context) {
return SizedBox(
width: size,
height: size,
child: CustomPaint(
painter: _RingPainter(pct: pct.clamp(0, 100), color: _color, bg: accent.withValues(alpha: 0.2)),
),
);
}
}
class _RingPainter extends CustomPainter {
final double pct;
final Color color;
final Color bg;
_RingPainter({required this.pct, required this.color, required this.bg});
@override
void paint(Canvas canvas, Size size) {
final stroke = size.width * 0.14;
final rect = Offset.zero & size;
final paint = Paint()
..style = PaintingStyle.stroke
..strokeWidth = stroke
..color = bg;
canvas.drawArc(rect.deflate(stroke / 2), 0, 3.14159 * 2, false, paint);
final sweep = 3.14159 * 2 * (pct / 100);
final fg = Paint()
..style = PaintingStyle.stroke
..strokeWidth = stroke
..strokeCap = StrokeCap.round
..color = color;
canvas.drawArc(rect.deflate(stroke / 2), -3.14159 / 2, sweep, false, fg);
}
@override
bool shouldRepaint(_RingPainter old) =>
old.pct != pct || old.color != color || old.bg != bg;
}