Files
ReelShort/lib/pages/mine/widgets/mine_stats_panel.dart
T

92 lines
2.4 KiB
Dart

// Author: fruit.com.cn
import 'package:flutter/material.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/theme/app_dimens.dart';
import '../../../l10n/app_localizations.dart';
class MineStatsPanel extends StatelessWidget {
const MineStatsPanel({
super.key,
required this.followingCount,
required this.watchRecordCount,
required this.coinBalance,
});
final int? followingCount;
final int? watchRecordCount;
final int? coinBalance;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Container(
key: const Key('mine-stats'),
padding: const EdgeInsets.all(AppDimens.minePanelPadding),
decoration: BoxDecoration(
color: AppColors.minePanelSurface,
borderRadius: BorderRadius.circular(AppDimens.mineGridRadius),
),
child: Row(
children: [
_stat(
key: const Key('mine-stat-following'),
value: followingCount,
label: l10n.followingCountLabel,
l10n: l10n,
),
_stat(
key: const Key('mine-stat-watch-records'),
value: watchRecordCount,
label: l10n.watchRecordsCountLabel,
l10n: l10n,
),
_stat(
key: const Key('mine-stat-coins'),
value: coinBalance,
label: l10n.coinBalance,
l10n: l10n,
),
],
),
);
}
Widget _stat({
required Key key,
required int? value,
required String label,
required AppLocalizations l10n,
}) {
return Expanded(
child: Column(
key: key,
children: [
Text(
value?.toString() ?? l10n.dataUnavailable,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.mineStatsValueFont,
fontWeight: FontWeight.w700,
),
),
const SizedBox(height: AppDimens.spaceXs),
Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: const TextStyle(
color: AppColors.textTertiary,
fontSize: AppDimens.mineStatsLabelFont,
),
),
],
),
);
}
}