391 lines
9.7 KiB
Dart
391 lines
9.7 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
part of 'home_feed_overlay.dart';
|
|
|
|
/// 顶部频道 tab:漫剧点击提示即将上线。
|
|
enum _FeedTab {
|
|
anime,
|
|
real,
|
|
recommend;
|
|
|
|
bool get comingSoon => this == _FeedTab.anime;
|
|
|
|
String get keyName => switch (this) {
|
|
_FeedTab.anime => 'anime',
|
|
_FeedTab.real => 'real',
|
|
_FeedTab.recommend => 'recommend',
|
|
};
|
|
|
|
String label(AppLocalizations l10n) => switch (this) {
|
|
_FeedTab.anime => l10n.feedTabAnime,
|
|
_FeedTab.real => l10n.feedTabReal,
|
|
_FeedTab.recommend => l10n.feedTabForYou,
|
|
};
|
|
}
|
|
|
|
class _TopIconButton extends StatelessWidget {
|
|
const _TopIconButton({
|
|
super.key,
|
|
required this.tooltip,
|
|
required this.icon,
|
|
required this.dimension,
|
|
required this.glyphSize,
|
|
required this.onPressed,
|
|
});
|
|
|
|
final String tooltip;
|
|
final IconData icon;
|
|
final double dimension;
|
|
final double glyphSize;
|
|
final VoidCallback onPressed;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox.square(
|
|
dimension: dimension,
|
|
child: IconButton(
|
|
tooltip: tooltip,
|
|
onPressed: onPressed,
|
|
padding: EdgeInsets.zero,
|
|
icon: Icon(
|
|
icon,
|
|
size: glyphSize,
|
|
color: Colors.white,
|
|
shadows: const [Shadow(blurRadius: 6, color: Colors.black)],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _FeedTabItem extends StatelessWidget {
|
|
const _FeedTabItem({
|
|
required this.tab,
|
|
required this.label,
|
|
required this.selected,
|
|
required this.fontSize,
|
|
required this.underlineWidth,
|
|
required this.underlineHeight,
|
|
required this.onTap,
|
|
});
|
|
|
|
final _FeedTab tab;
|
|
final String label;
|
|
final bool selected;
|
|
final double fontSize;
|
|
final double underlineWidth;
|
|
final double underlineHeight;
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
key: Key('home-feed-tab-${tab.keyName}'),
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: onTap,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
label,
|
|
maxLines: 1,
|
|
style: TextStyle(
|
|
color: selected ? Colors.white : Colors.white70,
|
|
fontSize: fontSize,
|
|
fontWeight: selected ? FontWeight.w800 : FontWeight.w600,
|
|
shadows: const [Shadow(blurRadius: 6, color: Colors.black)],
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Container(
|
|
width: underlineWidth,
|
|
height: underlineHeight,
|
|
decoration: BoxDecoration(
|
|
color: selected ? Colors.white : Colors.transparent,
|
|
borderRadius: BorderRadius.circular(1),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _FeedRailItem extends StatelessWidget {
|
|
const _FeedRailItem({
|
|
super.key,
|
|
required this.icon,
|
|
required this.label,
|
|
required this.iconSize,
|
|
required this.onTap,
|
|
this.count,
|
|
this.countKey,
|
|
this.selected = false,
|
|
});
|
|
|
|
final IconData icon;
|
|
final String label;
|
|
final double iconSize;
|
|
final VoidCallback onTap;
|
|
final int? count;
|
|
final Key? countKey;
|
|
final bool selected;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.only(bottom: 16),
|
|
child: Semantics(
|
|
button: true,
|
|
label: label,
|
|
child: GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: onTap,
|
|
child: SizedBox(
|
|
width: 48,
|
|
child: Column(
|
|
children: [
|
|
Icon(
|
|
icon,
|
|
size: iconSize,
|
|
color: selected ? AppColors.blue : Colors.white,
|
|
shadows: const [Shadow(blurRadius: 6, color: Colors.black)],
|
|
),
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
count == null ? label : formatInteractionCount(count!),
|
|
key: countKey,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 10,
|
|
shadows: [Shadow(blurRadius: 6, color: Colors.black)],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _FeedPill extends StatelessWidget {
|
|
const _FeedPill({
|
|
required this.height,
|
|
required this.background,
|
|
required this.child,
|
|
});
|
|
|
|
final double height;
|
|
final Color background;
|
|
final Widget child;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
height: height,
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
decoration: BoxDecoration(
|
|
color: background,
|
|
borderRadius: BorderRadius.circular(999),
|
|
),
|
|
child: Center(child: child),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _DanmakuPill extends StatelessWidget {
|
|
const _DanmakuPill({
|
|
required this.l10n,
|
|
required this.height,
|
|
required this.background,
|
|
required this.onTap,
|
|
});
|
|
|
|
final AppLocalizations l10n;
|
|
final double height;
|
|
final Color background;
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
key: const Key('home-feed-danmaku'),
|
|
onTap: onTap,
|
|
child: _FeedPill(
|
|
height: height,
|
|
background: background,
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Text(
|
|
'弹',
|
|
style: TextStyle(color: Colors.white, fontSize: 12),
|
|
),
|
|
const SizedBox(width: 6),
|
|
Flexible(
|
|
child: Text(
|
|
l10n.danmaku,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(color: Colors.white70, fontSize: 12),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _FullscreenPill extends StatelessWidget {
|
|
const _FullscreenPill({
|
|
required this.l10n,
|
|
required this.height,
|
|
required this.background,
|
|
required this.onTap,
|
|
});
|
|
|
|
final AppLocalizations l10n;
|
|
final double height;
|
|
final Color background;
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
key: const Key('home-feed-fullscreen'),
|
|
onTap: onTap,
|
|
child: _FeedPill(
|
|
height: height,
|
|
background: background,
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(Icons.fullscreen_rounded, color: Colors.white, size: 14),
|
|
const SizedBox(width: 4),
|
|
Flexible(
|
|
child: Text(
|
|
l10n.watchFullscreen,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(color: Colors.white, fontSize: 12),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _FeedProgressTrack extends StatelessWidget {
|
|
const _FeedProgressTrack({required this.controller, required this.height});
|
|
|
|
final ValueListenable<VideoPlayerValue>? controller;
|
|
final double height;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final source = controller;
|
|
if (source == null) return _track(0);
|
|
return ValueListenableBuilder<VideoPlayerValue>(
|
|
valueListenable: source,
|
|
builder: (context, value, _) {
|
|
final total = value.duration.inMilliseconds;
|
|
final fraction = total <= 0
|
|
? 0.0
|
|
: (value.position.inMilliseconds / total).clamp(0.0, 1.0);
|
|
return _track(fraction.toDouble());
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _track(double fraction) {
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) => SizedBox(
|
|
height: height,
|
|
child: Stack(
|
|
children: [
|
|
Container(
|
|
width: constraints.maxWidth,
|
|
height: height,
|
|
color: Colors.white24,
|
|
),
|
|
Container(
|
|
width: constraints.maxWidth * fraction,
|
|
height: height,
|
|
color: AppColors.blue,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _FeedMoreSheet extends StatelessWidget {
|
|
const _FeedMoreSheet({
|
|
required this.l10n,
|
|
required this.onDownload,
|
|
required this.onClear,
|
|
this.onPip,
|
|
});
|
|
|
|
final AppLocalizations l10n;
|
|
final VoidCallback onDownload;
|
|
final VoidCallback onClear;
|
|
final VoidCallback? onPip;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SafeArea(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
ListTile(
|
|
key: const Key('home-feed-download'),
|
|
leading: const Icon(
|
|
Icons.download_outlined,
|
|
color: AppColors.secondary,
|
|
),
|
|
title: Text(l10n.downloads),
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
onDownload();
|
|
},
|
|
),
|
|
if (onPip != null)
|
|
ListTile(
|
|
key: const Key('home-feed-pip'),
|
|
leading: const Icon(
|
|
Icons.picture_in_picture_alt_outlined,
|
|
color: AppColors.secondary,
|
|
),
|
|
title: Text(l10n.pictureInPicture),
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
onPip!();
|
|
},
|
|
),
|
|
ListTile(
|
|
key: const Key('home-feed-clear'),
|
|
leading: const Icon(
|
|
Icons.fullscreen_rounded,
|
|
color: AppColors.secondary,
|
|
),
|
|
title: Text(l10n.clearScreen),
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
onClear();
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|