2026-09-18 23:32:36 +08:00
|
|
|
// 应用标志组件:绘制与应用程序图标(tools/gen-icon.py)一致的原创标记。
|
2026-09-18 16:50:12 +08:00
|
|
|
//
|
2026-09-18 23:32:36 +08:00
|
|
|
// 设计构成「环序 / Cycle-Step」——全部由基础几何元素组合而成,
|
|
|
|
|
// 不参考、不复刻任何既有品牌图形:
|
|
|
|
|
// 1. 深蓝渐变圆角方形底板:在浅色 / 深色背景下都保持清晰;
|
|
|
|
|
// 2. 顶部带缺口的圆环:一圈 = 一个循环 = 360°,缺口指示 0° 起点;
|
|
|
|
|
// 3. 阶梯折线:动作按时间顺序推进的“步进”语义(即时序图本身);
|
|
|
|
|
// 4. 缺口内的白色原点(0° / 12 点钟)与折线末端的绿色节点(链尾)。
|
|
|
|
|
//
|
|
|
|
|
// 架构位置:纯 UI 装饰组件,不持有业务状态;颜色为品牌固定值,
|
|
|
|
|
// 因此不随主题变化(shouldRepaint 恒为 false)。
|
2026-09-18 16:50:12 +08:00
|
|
|
import 'dart:math' as math;
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
2026-09-18 23:32:36 +08:00
|
|
|
/// 应用标志:原创「环序」标记,可在工具栏与启动画面复用。
|
2026-09-18 16:50:12 +08:00
|
|
|
class AppLogo extends StatelessWidget {
|
2026-09-18 23:32:36 +08:00
|
|
|
/// 创建应用标志;[size] 为正方形边长,默认 30。
|
2026-09-18 16:50:12 +08:00
|
|
|
const AppLogo({super.key, this.size = 30});
|
|
|
|
|
|
2026-09-18 23:32:36 +08:00
|
|
|
/// 标志边长(逻辑像素)。
|
2026-09-18 16:50:12 +08:00
|
|
|
final double size;
|
|
|
|
|
|
2026-09-18 23:32:36 +08:00
|
|
|
/// 使用 [_LogoPainter] 在方形画布上绘制标志。
|
2026-09-18 16:50:12 +08:00
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return CustomPaint(
|
|
|
|
|
size: Size.square(size),
|
2026-09-18 23:32:36 +08:00
|
|
|
painter: _LogoPainter(),
|
2026-09-18 16:50:12 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-18 23:32:36 +08:00
|
|
|
/// 标志绘制器:底板 → 缺口圆环 → 原点 → 阶梯折线 → 末端节点。
|
2026-09-18 16:50:12 +08:00
|
|
|
class _LogoPainter extends CustomPainter {
|
2026-09-18 23:32:36 +08:00
|
|
|
/// 底板渐变起始色(深蓝)。
|
|
|
|
|
static const Color _tileTop = Color(0xFF18213D);
|
|
|
|
|
/// 底板渐变结束色(更深的蓝)。
|
|
|
|
|
static const Color _tileBot = Color(0xFF0C1226);
|
|
|
|
|
/// 圆环颜色(与主题强调色一致)。
|
|
|
|
|
static const Color _ring = Color(0xFF4CC9F0);
|
|
|
|
|
/// 阶梯折线颜色(与主题警告色一致,表示顺序推进)。
|
|
|
|
|
static const Color _step = Color(0xFFFFD166);
|
|
|
|
|
/// 0° 原点颜色。
|
|
|
|
|
static const Color _origin = Color(0xFFFFFFFF);
|
|
|
|
|
/// 折线末端节点颜色(与主题成功色一致,表示链尾)。
|
|
|
|
|
static const Color _end = Color(0xFF34D399);
|
2026-09-18 16:50:12 +08:00
|
|
|
|
2026-09-18 23:32:36 +08:00
|
|
|
/// 缺口圆环的角度半宽(度):缺口总宽 68°。
|
|
|
|
|
static const double _gapHalfDeg = 34;
|
2026-09-18 16:50:12 +08:00
|
|
|
|
2026-09-18 23:32:36 +08:00
|
|
|
/// 按上述构成绘制标志。
|
2026-09-18 16:50:12 +08:00
|
|
|
@override
|
|
|
|
|
void paint(Canvas canvas, Size size) {
|
|
|
|
|
final double s = size.shortestSide;
|
|
|
|
|
final Offset c = Offset(size.width / 2, size.height / 2);
|
2026-09-18 23:32:36 +08:00
|
|
|
|
|
|
|
|
// 1) 圆角方形底板 + 顶部到底部的深蓝渐变。
|
2026-09-18 16:50:12 +08:00
|
|
|
final RRect badge = RRect.fromRectAndRadius(
|
|
|
|
|
Rect.fromLTWH(0, 0, s, s),
|
2026-09-18 23:32:36 +08:00
|
|
|
Radius.circular(s * 0.27),
|
|
|
|
|
);
|
|
|
|
|
canvas.drawRRect(
|
|
|
|
|
badge,
|
|
|
|
|
Paint()
|
|
|
|
|
..shader = const LinearGradient(
|
|
|
|
|
begin: Alignment.topCenter,
|
|
|
|
|
end: Alignment.bottomCenter,
|
|
|
|
|
colors: <Color>[_tileTop, _tileBot],
|
|
|
|
|
).createShader(Rect.fromLTWH(0, 0, s, s)),
|
2026-09-18 16:50:12 +08:00
|
|
|
);
|
|
|
|
|
canvas.drawRRect(
|
|
|
|
|
badge,
|
|
|
|
|
Paint()
|
|
|
|
|
..style = PaintingStyle.stroke
|
2026-09-18 23:32:36 +08:00
|
|
|
..strokeWidth = s * 0.018
|
|
|
|
|
..color = Colors.white.withValues(alpha: 0.14),
|
2026-09-18 16:50:12 +08:00
|
|
|
);
|
|
|
|
|
|
2026-09-18 23:32:36 +08:00
|
|
|
// 2) 顶部带缺口的圆环:从 +34° 顺时针扫过 292°。
|
|
|
|
|
final double ringR = s * 0.293;
|
|
|
|
|
final double ringW = s * 0.062;
|
|
|
|
|
const double gapHalf = _gapHalfDeg * math.pi / 180;
|
|
|
|
|
canvas.drawArc(
|
|
|
|
|
Rect.fromCircle(center: c, radius: ringR),
|
|
|
|
|
-math.pi / 2 + gapHalf,
|
|
|
|
|
2 * math.pi - 2 * gapHalf,
|
|
|
|
|
false,
|
|
|
|
|
Paint()
|
|
|
|
|
..style = PaintingStyle.stroke
|
|
|
|
|
..strokeWidth = ringW
|
|
|
|
|
..strokeCap = StrokeCap.round
|
|
|
|
|
..color = _ring,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 3) 0° 原点:位于 12 点钟方向、落在圆环缺口内。
|
|
|
|
|
canvas.drawCircle(Offset(c.dx, c.dy - ringR), s * 0.042, Paint()..color = _origin);
|
2026-09-18 16:50:12 +08:00
|
|
|
|
2026-09-18 23:32:36 +08:00
|
|
|
// 4) 阶梯折线:横向 → 纵向 → 横向,表示动作顺序推进。
|
|
|
|
|
final Offset p1 = c + Offset(-s * 0.146, s * 0.088);
|
|
|
|
|
final Offset p2 = c + Offset(-s * 0.010, s * 0.088);
|
|
|
|
|
final Offset p3 = c + Offset(-s * 0.010, -s * 0.059);
|
|
|
|
|
final Offset p4 = c + Offset(s * 0.166, -s * 0.059);
|
|
|
|
|
canvas.drawPath(
|
|
|
|
|
Path()
|
|
|
|
|
..moveTo(p1.dx, p1.dy)
|
|
|
|
|
..lineTo(p2.dx, p2.dy)
|
|
|
|
|
..lineTo(p3.dx, p3.dy)
|
|
|
|
|
..lineTo(p4.dx, p4.dy),
|
|
|
|
|
Paint()
|
|
|
|
|
..style = PaintingStyle.stroke
|
|
|
|
|
..strokeWidth = s * 0.057
|
|
|
|
|
..strokeCap = StrokeCap.round
|
|
|
|
|
..strokeJoin = StrokeJoin.round
|
|
|
|
|
..color = _step,
|
|
|
|
|
);
|
2026-09-18 16:50:12 +08:00
|
|
|
|
2026-09-18 23:32:36 +08:00
|
|
|
// 5) 折线末端节点:链尾动作。
|
|
|
|
|
canvas.drawCircle(p4, s * 0.037, Paint()..color = _end);
|
2026-09-18 16:50:12 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-18 23:32:36 +08:00
|
|
|
/// 标志为固定品牌配色,与主题无关,因此无需重绘。
|
2026-09-18 16:50:12 +08:00
|
|
|
@override
|
2026-09-18 23:32:36 +08:00
|
|
|
bool shouldRepaint(covariant _LogoPainter old) => false;
|
2026-09-18 16:50:12 +08:00
|
|
|
}
|