opt: stat组件传参

This commit is contained in:
guozhigq
2024-09-11 20:25:40 +08:00
parent e3b7aed888
commit a5e2414a75
12 changed files with 73 additions and 48 deletions

View File

@ -6,7 +6,7 @@ class StatDanMu extends StatelessWidget {
final dynamic danmu;
final String? size;
const StatDanMu({Key? key, this.theme, this.danmu, this.size})
const StatDanMu({Key? key, this.theme = 'gray', this.danmu, this.size})
: super(key: key);
@override
@ -17,21 +17,46 @@ class StatDanMu extends StatelessWidget {
'black': Theme.of(context).colorScheme.onSurface.withOpacity(0.8),
};
Color color = colorObject[theme]!;
return StatIconText(
icon: Icons.subtitles_outlined,
text: Utils.numFormat(danmu!),
color: color,
size: size,
);
}
}
class StatIconText extends StatelessWidget {
final IconData icon;
final String text;
final Color color;
final String? size;
const StatIconText({
Key? key,
required this.icon,
required this.text,
required this.color,
this.size,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
children: [
Icon(
Icons.subtitles_outlined,
icon,
size: 14,
color: color,
),
const SizedBox(width: 2),
Text(
Utils.numFormat(danmu!),
text,
style: TextStyle(
fontSize: size == 'medium' ? 12 : 11,
color: color,
),
)
),
],
);
}