chore: Added a small animation to skip button

This commit is contained in:
PartyDonut 2024-11-29 13:30:46 +01:00
parent a06591084b
commit 9442a5bd41
2 changed files with 36 additions and 26 deletions

View file

@ -2,9 +2,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:fladder/models/items/media_segments_model.dart';
import 'package:fladder/providers/video_player_provider.dart';
import 'package:fladder/screens/shared/animated_fade_size.dart';
import 'package:fladder/screens/video_player/components/video_player_chapters.dart';
import 'package:fladder/screens/video_player/components/video_player_queue.dart';
import 'package:fladder/util/localization_helper.dart';
class ChapterButton extends ConsumerWidget {
final Duration position;
@ -61,28 +64,36 @@ class OpenQueueButton extends ConsumerWidget {
}
class SkipSegmentButton extends ConsumerWidget {
final String label;
final MediaSegment? segment;
final bool isOverlayVisible;
final Function() pressedSkip;
const SkipSegmentButton({required this.label, required this.isOverlayVisible, required this.pressedSkip, super.key});
const SkipSegmentButton(
{required this.segment, required this.isOverlayVisible, required this.pressedSkip, super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return AnimatedOpacity(
opacity: isOverlayVisible ? 0.85 : 0,
duration: const Duration(milliseconds: 500),
child: ElevatedButton(
onPressed: pressedSkip,
style: ElevatedButton.styleFrom(shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5))),
child: Padding(
padding: const EdgeInsets.all(8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [Text(label), const Icon(Icons.skip_next_rounded)],
),
),
),
return AnimatedFadeSize(
child: segment != null
? AnimatedOpacity(
opacity: isOverlayVisible ? 1 : 0.15,
duration: const Duration(milliseconds: 500),
child: ElevatedButton(
onPressed: pressedSkip,
style: ElevatedButton.styleFrom(shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5))),
child: Padding(
padding: const EdgeInsets.all(8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(context.localized.skipButtonLabel(segment!.type.label(context))),
const Icon(Icons.skip_next_rounded)
],
),
),
),
)
: const SizedBox.shrink(key: Key("Other")),
);
}
}

View file

@ -159,18 +159,17 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
bool forceShow = segment?.forceShow(position) ?? false;
return Stack(
children: [
if (segment != null)
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(32),
child: SkipSegmentButton(
label: context.localized.skipButtonLabel(segment.type.label(context).toLowerCase()),
isOverlayVisible: forceShow ? true : showOverlay,
pressedSkip: () => skipToSegmentEnd(segment),
),
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(32),
child: SkipSegmentButton(
segment: segment,
isOverlayVisible: forceShow ? true : showOverlay,
pressedSkip: () => skipToSegmentEnd(segment),
),
),
),
],
);
},