a642bf16a2
design/ 同步自最新设计导出,新增 ui_kits/tablet/ 平板分栏布局;todo/ 录入 18 个并行实施任务。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
46 lines
1.7 KiB
Dart
46 lines
1.7 KiB
Dart
// status_pill.dart — 状态胶囊(色点 + 文字)。不用 emoji。
|
|
// 对应 React UI Kit 的 .pill / 徽章。
|
|
import 'package:flutter/material.dart';
|
|
import '../pangolin_theme.dart';
|
|
|
|
enum PangolinStatus { connected, connecting, error, neutral, pro }
|
|
|
|
class StatusPill extends StatelessWidget {
|
|
const StatusPill({super.key, required this.label, this.status = PangolinStatus.neutral});
|
|
final String label;
|
|
final PangolinStatus status;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final c = context.pangolin;
|
|
late final Color bg, fg, dot;
|
|
bool showDot = true;
|
|
switch (status) {
|
|
case PangolinStatus.connected:
|
|
bg = c.successSubtle; fg = c.success; dot = c.success; break;
|
|
case PangolinStatus.connecting:
|
|
bg = c.warningSubtle; fg = c.warning; dot = c.warning; break;
|
|
case PangolinStatus.error:
|
|
bg = c.dangerSubtle; fg = c.danger; dot = c.danger; break;
|
|
case PangolinStatus.pro:
|
|
bg = c.accent; fg = c.fgOnAccent; dot = c.fgOnAccent; showDot = false; break;
|
|
case PangolinStatus.neutral:
|
|
bg = c.bgSubtle; fg = c.fg2; dot = c.fg3; break;
|
|
}
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
decoration: BoxDecoration(color: bg, borderRadius: BorderRadius.circular(PangolinRadius.full)),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (showDot) ...[
|
|
Container(width: 7, height: 7, decoration: BoxDecoration(color: dot, shape: BoxShape.circle)),
|
|
const SizedBox(width: 7),
|
|
],
|
|
Text(label, style: PangolinText.caption.copyWith(color: fg, fontWeight: FontWeight.w600)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|