117 lines
3.1 KiB
Dart
117 lines
3.1 KiB
Dart
// Author: fruit.com.cn
|
|
// 职责:首页推荐流加载骨架、页面保活与静态文案,保持原有行为。
|
|
part of 'recommend_page.dart';
|
|
|
|
const double _posterWidth = 132;
|
|
const double _posterHeight = 176;
|
|
const double _posterRadius = AppDimens.coverRadius;
|
|
const double _copyLeft = 14;
|
|
const double _copyRight = 72;
|
|
const double _copyBottom = 42;
|
|
const double _titleWidth = 190;
|
|
const double _titleHeight = 18;
|
|
const double _subtitleWidth = 140;
|
|
const double _subtitleHeight = 12;
|
|
const double _descriptionWidth = 220;
|
|
const double _descriptionHeight = 10;
|
|
const double _titleGap = 10;
|
|
const double _subtitleGap = 8;
|
|
const double _lineRadius = 6;
|
|
|
|
class _RecommendFeedSkeleton extends StatelessWidget {
|
|
const _RecommendFeedSkeleton();
|
|
|
|
@override
|
|
Widget build(BuildContext context) => const ColoredBox(
|
|
key: Key('recommend-feed-skeleton'),
|
|
color: AppColors.mediaBlack,
|
|
child: Stack(
|
|
children: [
|
|
Center(
|
|
child: SizedBox(
|
|
width: _posterWidth,
|
|
height: _posterHeight,
|
|
child: DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
color: AppColors.skeletonMedia,
|
|
borderRadius: BorderRadius.all(Radius.circular(_posterRadius)),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
left: _copyLeft,
|
|
right: _copyRight,
|
|
bottom: _copyBottom,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_SkeletonLine(width: _titleWidth, height: _titleHeight),
|
|
SizedBox(height: _titleGap),
|
|
_SkeletonLine(width: _subtitleWidth, height: _subtitleHeight),
|
|
SizedBox(height: _subtitleGap),
|
|
_SkeletonLine(
|
|
width: _descriptionWidth,
|
|
height: _descriptionHeight,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
class _SkeletonLine extends StatelessWidget {
|
|
const _SkeletonLine({required this.width, required this.height});
|
|
|
|
final double width;
|
|
final double height;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Container(
|
|
width: width,
|
|
height: height,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.skeletonMedia,
|
|
borderRadius: BorderRadius.circular(_lineRadius),
|
|
),
|
|
);
|
|
}
|
|
|
|
class _KeepAliveTab extends StatefulWidget {
|
|
const _KeepAliveTab({super.key, required this.child});
|
|
|
|
final Widget child;
|
|
|
|
@override
|
|
State<_KeepAliveTab> createState() => _KeepAliveTabState();
|
|
}
|
|
|
|
class _KeepAliveTabState extends State<_KeepAliveTab>
|
|
with AutomaticKeepAliveClientMixin<_KeepAliveTab> {
|
|
@override
|
|
bool get wantKeepAlive => true;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
super.build(context);
|
|
return widget.child;
|
|
}
|
|
}
|
|
|
|
(String, String) _sectionCopy(
|
|
AppLocalizations l10n,
|
|
RecommendSectionKind section,
|
|
) => switch (section) {
|
|
RecommendSectionKind.hits => (l10n.weeklyHitsTitle, l10n.weeklyHitsSubtitle),
|
|
RecommendSectionKind.newReleases => (
|
|
l10n.weeklyNewTitle,
|
|
l10n.weeklyNewSubtitle,
|
|
),
|
|
RecommendSectionKind.costume => (
|
|
l10n.costumeAwardsTitle,
|
|
l10n.costumeAwardsSubtitle,
|
|
),
|
|
};
|