feat: 增加播放器双击点赞与飘心
This commit is contained in:
1 parent
e2cc409e5a
commit
4140c4eb50
6 files changed
+207
No files matched your search
@@ -14,6 +14,7 @@ import '../../../core/theme/app_colors.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'home_feed_recommend_panel.dart';
|
||||
import 'loading_progress_track.dart';
|
||||
import 'player_double_tap_hearts.dart';
|
||||
import 'seek_progress_bar.dart';
|
||||
|
||||
part 'home_feed_overlay_parts.dart';
|
||||
@@ -54,6 +55,7 @@ class HomeFeedOverlay extends StatefulWidget {
|
||||
required this.onBoostStart,
|
||||
required this.onBoostEnd,
|
||||
required this.onMore,
|
||||
this.onDoubleTapLike,
|
||||
this.likeCount,
|
||||
this.favoriteCount,
|
||||
this.commentCount,
|
||||
@@ -91,6 +93,7 @@ class HomeFeedOverlay extends StatefulWidget {
|
||||
final VoidCallback onBoostStart;
|
||||
final VoidCallback onBoostEnd;
|
||||
final VoidCallback onMore;
|
||||
final ValueChanged<Offset>? onDoubleTapLike;
|
||||
final VoidCallback? onScrubStart;
|
||||
final ValueChanged<bool>? onScrubEnd;
|
||||
final ValueChanged<bool>? onScrubVisibilityChanged;
|
||||
@@ -106,6 +109,9 @@ class HomeFeedOverlay extends StatefulWidget {
|
||||
class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
||||
bool _scrubbing = false;
|
||||
bool _wasVisibleBeforeScrub = true;
|
||||
Offset? _doubleTapPosition;
|
||||
int _nextHeartBurstId = 0;
|
||||
final List<({int id, Offset position})> _heartBursts = [];
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant HomeFeedOverlay oldWidget) {
|
||||
@@ -130,6 +136,9 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
||||
key: const Key('home-feed-gesture'),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: _handleSurfaceTap,
|
||||
onDoubleTapDown: (details) =>
|
||||
_doubleTapPosition = details.localPosition,
|
||||
onDoubleTap: _handleDoubleTap,
|
||||
onLongPressStart: (details) =>
|
||||
_handleLongPressStart(details, constraints.maxWidth),
|
||||
onLongPressEnd: (_) => widget.onBoostEnd(),
|
||||
@@ -193,6 +202,25 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
||||
onSeek: widget.onSeek,
|
||||
),
|
||||
),
|
||||
if (_heartBursts.isNotEmpty)
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
for (final burst in _heartBursts)
|
||||
Positioned(
|
||||
left: burst.position.dx,
|
||||
top: burst.position.dy - 10,
|
||||
child: PlayerDoubleTapHeartBurst(
|
||||
key: ValueKey(burst.id),
|
||||
onCompleted: () => _removeHeartBurst(burst.id),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -218,6 +246,19 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
||||
widget.onTogglePlay();
|
||||
}
|
||||
|
||||
void _handleDoubleTap() {
|
||||
final position = _doubleTapPosition;
|
||||
if (position == null) return;
|
||||
final id = _nextHeartBurstId++;
|
||||
setState(() => _heartBursts.add((id: id, position: position)));
|
||||
widget.onDoubleTapLike?.call(position);
|
||||
}
|
||||
|
||||
void _removeHeartBurst(int id) {
|
||||
if (!mounted) return;
|
||||
setState(() => _heartBursts.removeWhere((burst) => burst.id == id));
|
||||
}
|
||||
|
||||
void _handleLongPressStart(LongPressStartDetails details, double width) {
|
||||
final third = width / 3;
|
||||
final dx = details.localPosition.dx;
|
||||
|
||||
Reference in new issue
Block a user