fix(home): 调整首页分类与卡片标签样式
This commit is contained in:
1 parent
7446431511
commit
4f6116896f
14 files changed
+251
-117
No files matched your search
@@ -7,3 +7,11 @@ String formatInteractionCount(int count) {
|
||||
if (count < 10000) return '$count';
|
||||
return '${(count / 10000).toStringAsFixed(1)}万';
|
||||
}
|
||||
|
||||
/// 播放量展示:以 w 为单位,整数不保留小数,非整数保留一位。
|
||||
String formatPlayCount(int count) {
|
||||
if (count < 10000) return '$count';
|
||||
final value = count / 10000;
|
||||
if (value == value.roundToDouble()) return '${value.toInt()}w';
|
||||
return '${value.toStringAsFixed(1)}w';
|
||||
}
|
||||
@@ -81,11 +81,16 @@ abstract final class AppDimens {
|
||||
static const double homeGridGap = 6;
|
||||
static const double homeGridRowGap = 18;
|
||||
static const double homeCardRadius = 6;
|
||||
static const double cardCoverRadius = 8;
|
||||
static const double homeCardPadding = 8;
|
||||
static const double cardTitleFont = 15;
|
||||
static const double cardTitleLineHeight = 1.3;
|
||||
static const double cardViewsFont = 11;
|
||||
static const double cardViewsIcon = 11;
|
||||
static const double cardGenreRibbonHeight = 20;
|
||||
static const double cardGenreRibbonRadius = 10;
|
||||
static const double cardGenreRibbonLeftInset = 8;
|
||||
static const double cardGenreRibbonMaxWidth = 86;
|
||||
static const double cardTagFont = 11;
|
||||
static const double cardTagHeight = 18;
|
||||
static const double cardTagRadius = 9;
|
||||
@@ -98,8 +103,8 @@ abstract final class AppDimens {
|
||||
static const double cardTitleTagGap = 6;
|
||||
static const double cardCoverAspectRatio = 5 / 6;
|
||||
static const double homeCardBodyExtent = 84;
|
||||
static const double homePrimaryTabFont = 15;
|
||||
static const double homePrimaryTabSelectedFont = 18;
|
||||
static const double homePrimaryTabFont = 16;
|
||||
static const double homePrimaryTabSelectedFont = 20;
|
||||
static const double homePrimaryRowHeight = 30;
|
||||
static const Duration homePrimaryTabAnimationDuration = Duration(
|
||||
milliseconds: 180,
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/app_colors.dart';
|
||||
import '../theme/app_dimens.dart';
|
||||
|
||||
const List<Color> _ribbonColors = [
|
||||
AppColors.badgeHot,
|
||||
AppColors.badgeNew,
|
||||
AppColors.badgeAnime,
|
||||
];
|
||||
|
||||
/// 封面右上角的斜边题材丝带。
|
||||
class DramaGenreRibbon extends StatelessWidget {
|
||||
const DramaGenreRibbon({
|
||||
super.key,
|
||||
required this.tags,
|
||||
required this.keyPrefix,
|
||||
});
|
||||
|
||||
final List<String> tags;
|
||||
final String keyPrefix;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final visible = tags
|
||||
.map((tag) => tag.trim())
|
||||
.where((tag) => tag.isNotEmpty)
|
||||
.take(3)
|
||||
.toList(growable: false);
|
||||
if (visible.isEmpty) return const SizedBox.shrink();
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final (index, tag) in visible.indexed) ...[
|
||||
if (index > 0) const SizedBox(height: 2),
|
||||
ClipPath(
|
||||
key: Key('drama-genre-ribbon-$keyPrefix-$index'),
|
||||
clipper: const _SlantedRibbonClipper(),
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: AppDimens.cardGenreRibbonMaxWidth,
|
||||
),
|
||||
height: AppDimens.cardGenreRibbonHeight,
|
||||
padding: const EdgeInsets.only(
|
||||
left:
|
||||
AppDimens.cardTagHorizontalPadding +
|
||||
AppDimens.cardGenreRibbonLeftInset,
|
||||
right: AppDimens.cardTagHorizontalPadding,
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
color: _ribbonColors[index % _ribbonColors.length],
|
||||
child: Text(
|
||||
tag,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
fontSize: AppDimens.cardBadgeFont,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SlantedRibbonClipper extends CustomClipper<Path> {
|
||||
const _SlantedRibbonClipper();
|
||||
|
||||
@override
|
||||
Path getClip(Size size) {
|
||||
return Path()
|
||||
..moveTo(AppDimens.cardGenreRibbonLeftInset, 0)
|
||||
..lineTo(size.width, 0)
|
||||
..lineTo(size.width, size.height)
|
||||
..lineTo(0, size.height)
|
||||
..close();
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldReclip(_SlantedRibbonClipper oldClipper) => false;
|
||||
}
|
||||
Reference in new issue
Block a user