show user medal

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-03-22 15:01:30 +08:00
parent fc7fc18b14
commit 2bebf200df
151 changed files with 1435 additions and 1321 deletions

View File

@@ -1,6 +1,12 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/style.dart';
import 'package:PiliPlus/models_new/live/live_medal_wall/uinfo_medal.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
const _kFontSize = 10.0;
const _kStrutStyle = StrutStyle(height: 1, leading: 0, fontSize: _kFontSize);
const _kPadding = EdgeInsets.symmetric(horizontal: 8, vertical: 3);
class MedalWidget extends StatelessWidget {
const MedalWidget({
super.key,
@@ -8,36 +14,47 @@ class MedalWidget extends StatelessWidget {
required this.level,
required this.backgroundColor,
required this.nameColor,
required this.levelColor,
this.fontSize = _kFontSize,
this.strutStyle = _kStrutStyle,
this.padding = _kPadding,
});
MedalWidget.fromMedalInfo({
super.key,
required UinfoMedal medal,
this.fontSize = _kFontSize,
this.strutStyle = _kStrutStyle,
this.padding = _kPadding,
}) : medalName = medal.name!,
level = medal.level!,
backgroundColor = Utils.parseMedalColor(medal.v2MedalColorStart!),
nameColor = Utils.parseColor(medal.v2MedalColorText!);
final String medalName;
final int level;
final Color backgroundColor;
final Color nameColor;
final Color levelColor;
final double fontSize;
final StrutStyle strutStyle;
final EdgeInsets padding;
@override
Widget build(BuildContext context) {
return Container(
padding: const .symmetric(horizontal: 8, vertical: 3),
padding: padding,
decoration: BoxDecoration(
borderRadius: StyleString.mdRadius,
borderRadius: Style.mdRadius,
color: backgroundColor,
),
child: Text.rich(
strutStyle: const StrutStyle(
height: 1,
leading: 0,
fontSize: 10,
),
strutStyle: strutStyle,
TextSpan(
children: [
TextSpan(
text: medalName,
style: TextStyle(
height: 1,
fontSize: 10,
fontSize: fontSize,
color: nameColor,
),
),
@@ -45,9 +62,9 @@ class MedalWidget extends StatelessWidget {
text: ' $level',
style: TextStyle(
height: 1,
fontSize: 10,
fontSize: fontSize,
color: nameColor,
fontWeight: .bold,
color: levelColor,
),
),
],