fix(flutter): 收紧播放页底部与互动栏
This commit is contained in:
1 parent
7b4a792c12
commit
cf93d8d794
10 files changed
+167
-240
No files matched your search
@@ -73,6 +73,30 @@ class _SpeedEntry extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _PipButton extends StatelessWidget {
|
||||
const _PipButton({super.key, required this.tooltip, required this.onPressed});
|
||||
|
||||
final String tooltip;
|
||||
final VoidCallback onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox.square(
|
||||
dimension: 30,
|
||||
child: IconButton(
|
||||
tooltip: tooltip,
|
||||
padding: EdgeInsets.zero,
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: const Color(0x80000000),
|
||||
foregroundColor: AppColors.onPrimary,
|
||||
),
|
||||
onPressed: onPressed,
|
||||
icon: const Icon(Icons.picture_in_picture_alt_rounded, size: 17),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Rail extends StatelessWidget {
|
||||
const _Rail({
|
||||
required this.l10n,
|
||||
@@ -85,7 +109,6 @@ class _Rail extends StatelessWidget {
|
||||
required this.onComments,
|
||||
required this.onSave,
|
||||
required this.onShare,
|
||||
required this.compact,
|
||||
});
|
||||
|
||||
final AppLocalizations l10n;
|
||||
@@ -98,7 +121,6 @@ class _Rail extends StatelessWidget {
|
||||
final VoidCallback onComments;
|
||||
final VoidCallback onSave;
|
||||
final VoidCallback onShare;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -111,29 +133,28 @@ class _Rail extends StatelessWidget {
|
||||
label: favoriteCount?.toString() ?? l10n.favorite,
|
||||
active: saved,
|
||||
onTap: onSave,
|
||||
compact: compact,
|
||||
),
|
||||
const SizedBox(height: _railGap),
|
||||
_RailButton(
|
||||
key: const Key('player-rail-comments'),
|
||||
icon: Icons.chat_bubble_outline_rounded,
|
||||
label: commentCount?.toString() ?? l10n.comments,
|
||||
onTap: onComments,
|
||||
compact: compact,
|
||||
),
|
||||
const SizedBox(height: _railGap),
|
||||
_RailButton(
|
||||
key: const Key('player-rail-like'),
|
||||
icon: liked ? Icons.favorite_rounded : Icons.favorite_border_rounded,
|
||||
label: likeCount?.toString() ?? l10n.like,
|
||||
active: liked,
|
||||
onTap: onLike,
|
||||
compact: compact,
|
||||
),
|
||||
const SizedBox(height: _railGap),
|
||||
_RailButton(
|
||||
key: const Key('player-rail-share'),
|
||||
icon: Icons.ios_share_rounded,
|
||||
label: l10n.share,
|
||||
onTap: onShare,
|
||||
compact: compact,
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -146,46 +167,41 @@ class _RailButton extends StatelessWidget {
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.onTap,
|
||||
required this.compact,
|
||||
this.active = false,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final VoidCallback onTap;
|
||||
final bool compact;
|
||||
final bool active;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: compact ? 3 : _railGap),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox.square(
|
||||
dimension: _railButtonSize,
|
||||
child: IconButton(
|
||||
onPressed: onTap,
|
||||
padding: EdgeInsets.zero,
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: const Color(0x80000000),
|
||||
foregroundColor: active ? AppColors.blue : AppColors.onPrimary,
|
||||
),
|
||||
icon: Icon(icon, size: 18),
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox.square(
|
||||
dimension: _railButtonSize,
|
||||
child: IconButton(
|
||||
onPressed: onTap,
|
||||
padding: EdgeInsets.zero,
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: const Color(0x80000000),
|
||||
foregroundColor: active ? AppColors.blue : AppColors.onPrimary,
|
||||
),
|
||||
icon: Icon(icon, size: 24),
|
||||
),
|
||||
SizedBox(height: compact ? 1 : 3),
|
||||
Text(
|
||||
label,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
color: AppColors.onPrimary,
|
||||
fontSize: compact ? 8 : 9,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
label,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(
|
||||
color: AppColors.onPrimary,
|
||||
fontSize: 11,
|
||||
height: 1,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -196,12 +212,14 @@ class _EpisodeSynopsis extends StatefulWidget {
|
||||
required this.l10n,
|
||||
required this.episodeNumber,
|
||||
required this.synopsis,
|
||||
required this.authorNote,
|
||||
required this.textScale,
|
||||
});
|
||||
|
||||
final AppLocalizations l10n;
|
||||
final int episodeNumber;
|
||||
final String synopsis;
|
||||
final String authorNote;
|
||||
final double textScale;
|
||||
|
||||
@override
|
||||
@@ -213,92 +231,64 @@ class _EpisodeSynopsisState extends State<_EpisodeSynopsis> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final canExpand = widget.synopsis.trim().length > 28;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
key: const Key('player-synopsis-toggle'),
|
||||
onTap: () => setState(() => _expanded = !_expanded),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.l10n.episodeLabel(widget.episodeNumber),
|
||||
key: const Key('player-episode-label'),
|
||||
style: TextStyle(
|
||||
color: AppColors.blue,
|
||||
fontSize: 11 * widget.textScale,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 6),
|
||||
child: Text('|', style: TextStyle(color: Colors.white38)),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.synopsis,
|
||||
key: const Key('player-synopsis'),
|
||||
maxLines: _expanded ? 4 : 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 11 * widget.textScale,
|
||||
height: 1.45,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.l10n.episodeLabel(widget.episodeNumber),
|
||||
key: const Key('player-episode-label'),
|
||||
style: TextStyle(
|
||||
color: AppColors.blue,
|
||||
fontSize: 11 * widget.textScale,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 6),
|
||||
child: Text('|', style: TextStyle(color: Colors.white38)),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.synopsis,
|
||||
key: const Key('player-synopsis'),
|
||||
maxLines: _expanded ? 3 : 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 11 * widget.textScale,
|
||||
height: 1.35,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
_expanded
|
||||
? Icons.keyboard_arrow_up_rounded
|
||||
: Icons.keyboard_arrow_down_rounded,
|
||||
color: Colors.white54,
|
||||
size: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_expanded && widget.authorNote.isNotEmpty) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
widget.authorNote,
|
||||
key: const Key('player-author-note'),
|
||||
style: const TextStyle(color: Colors.white54, fontSize: 10),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
if (canExpand)
|
||||
GestureDetector(
|
||||
key: const Key('player-synopsis-toggle'),
|
||||
onTap: () => setState(() => _expanded = !_expanded),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
child: Text(
|
||||
_expanded ? widget.l10n.showLess : widget.l10n.showMore,
|
||||
style: const TextStyle(
|
||||
color: Colors.white54,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PlayerTimeLabel extends StatelessWidget {
|
||||
const _PlayerTimeLabel({super.key, required this.controller});
|
||||
|
||||
final VideoPlayerController? controller;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final source = controller;
|
||||
if (source == null) return _label(Duration.zero, Duration.zero);
|
||||
return ValueListenableBuilder<VideoPlayerValue>(
|
||||
valueListenable: source,
|
||||
builder: (context, value, _) => _label(value.position, value.duration),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _label(Duration position, Duration duration) => Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text(
|
||||
'${_format(position)} / ${_format(duration)}',
|
||||
style: const TextStyle(
|
||||
color: Colors.white60,
|
||||
fontSize: 9,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
String _format(Duration value) {
|
||||
final minutes = value.inMinutes.remainder(60).toString().padLeft(2, '0');
|
||||
final seconds = value.inSeconds.remainder(60).toString().padLeft(2, '0');
|
||||
return '$minutes:$seconds';
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user