Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvement #109

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import 'package:style/text/app_text_style.dart';
class VideoDurationSlider extends StatelessWidget {
final bool showSlider;
final Duration duration;
final void Function(PointerDownEvent event) onPointerDownOnSlider;
final void Function(PointerUpEvent event) onPointerUpOnSlider;
final void Function(Duration duration) onChangeStart;
final void Function(Duration duration) onChanged;
final void Function(Duration duration) onChangeEnd;
final Duration position;
Expand All @@ -22,8 +21,7 @@ class VideoDurationSlider extends StatelessWidget {
required this.position,
required this.onChangeEnd,
required this.onChanged,
required this.onPointerDownOnSlider,
required this.onPointerUpOnSlider,
required this.onChangeStart,
});

@override
Expand Down Expand Up @@ -64,28 +62,26 @@ class VideoDurationSlider extends StatelessWidget {
height: 30,
child: Material(
color: Colors.transparent,
child: Listener(
onPointerDown: onPointerDownOnSlider,
onPointerUp: onPointerUpOnSlider,
child: SliderTheme(
data: SliderTheme.of(context).copyWith(
trackHeight: 4,
trackShape: const RoundedRectSliderTrackShape(),
rangeTrackShape:
const RoundedRectRangeSliderTrackShape(),
thumbShape: SliderComponentShape.noThumb,
),
child: Slider(
value: position.inSeconds.toDouble(),
max: duration.inSeconds.toDouble(),
min: 0,
activeColor: appColorSchemeDark.primary,
inactiveColor: appColorSchemeDark.outline,
onChangeEnd: (value) => onChangeEnd
.call(Duration(seconds: value.toInt())),
onChanged: (double value) => onChanged
.call(Duration(seconds: value.toInt())),
),
child: SliderTheme(
data: SliderTheme.of(context).copyWith(
trackHeight: 4,
trackShape: const RoundedRectSliderTrackShape(),
rangeTrackShape:
const RoundedRectRangeSliderTrackShape(),
thumbShape: SliderComponentShape.noThumb,
),
child: Slider(
value: position.inSeconds.toDouble(),
max: duration.inSeconds.toDouble(),
min: 0,
activeColor: appColorSchemeDark.primary,
inactiveColor: appColorSchemeDark.outline,
onChangeStart: (value) => onChangeStart
.call(Duration(seconds: value.toInt())),
onChangeEnd: (value) => onChangeEnd
.call(Duration(seconds: value.toInt())),
onChanged: (double value) =>
onChanged.call(Duration(seconds: value.toInt())),
),
),
),
Expand Down
6 changes: 2 additions & 4 deletions app/lib/ui/flow/media_preview/media_preview_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,12 @@ class _MediaPreviewState extends ConsumerState<MediaPreview> {
duration: state.duration,
position: state.position,
onChangeEnd: (duration) {
_notifier.pointerOnSlider(false);
_videoPlayerController?.seekTo(duration);
},
onPointerDownOnSlider: (_) {
onChangeStart: (duration) {
_notifier.pointerOnSlider(true);
},
onPointerUpOnSlider: (_) {
_notifier.pointerOnSlider(false);
},
onChanged: (duration) {
_notifier.updateVideoPosition(position: duration, isManual: true);
},
Expand Down
Loading