diff --git a/lib/screens/photo_viewer/photo_viewer_controls.dart b/lib/screens/photo_viewer/photo_viewer_controls.dart index 8543227..92b060e 100644 --- a/lib/screens/photo_viewer/photo_viewer_controls.dart +++ b/lib/screens/photo_viewer/photo_viewer_controls.dart @@ -56,7 +56,7 @@ class _PhotoViewerControllsState extends ConsumerState with double dragUpDelta = 0.0; final controller = TextEditingController(); - late final timerController = RestarableTimerController( + late final timerController = RestartableTimerController( ref.read(photoViewSettingsProvider).timer, const Duration(milliseconds: 32), onTimeout: () { if (widget.pageController.page == widget.itemCount - 1) { widget.pageController.animateToPage(0, duration: const Duration(milliseconds: 250), curve: Curves.easeInOut); @@ -146,6 +146,7 @@ class _PhotoViewerControllsState extends ConsumerState with return PopScope( onPopInvokedWithResult: (didPop, result) async => await WakelockPlus.disable(), child: InputHandler( + autoFocus: false, onKeyEvent: (node, event) => _onKey(event) ? KeyEventResult.handled : KeyEventResult.ignored, child: Stack( children: [ diff --git a/lib/screens/video_player/components/video_player_next_wrapper.dart b/lib/screens/video_player/components/video_player_next_wrapper.dart index e92c992..e9951b8 100644 --- a/lib/screens/video_player/components/video_player_next_wrapper.dart +++ b/lib/screens/video_player/components/video_player_next_wrapper.dart @@ -38,8 +38,8 @@ class VideoPlayerNextWrapper extends ConsumerStatefulWidget { class _VideoPlayerNextWrapperState extends ConsumerState { bool show = false; bool showOverwrite = false; - late RestarableTimerController timerController = - RestarableTimerController(const Duration(seconds: 30), const Duration(milliseconds: 33), onTimeout: onTimeOut); + late RestartableTimerController timerController = + RestartableTimerController(const Duration(seconds: 30), const Duration(milliseconds: 33), onTimeout: onTimeOut); void onTimeOut() { timerController.cancel(); diff --git a/lib/util/input_handler.dart b/lib/util/input_handler.dart index 161ca73..60d4b2b 100644 --- a/lib/util/input_handler.dart +++ b/lib/util/input_handler.dart @@ -18,13 +18,20 @@ class InputHandler extends StatefulWidget { class _InputHandlerState extends State { final focusNode = FocusNode(); + @override + void initState() { + super.initState(); + //Focus on start + focusNode.requestFocus(); + } + @override Widget build(BuildContext context) { return Focus( autofocus: widget.autoFocus, focusNode: focusNode, onFocusChange: (value) { - if (!focusNode.hasFocus) { + if (!focusNode.hasFocus && widget.autoFocus) { focusNode.requestFocus(); } }, diff --git a/lib/util/simple_duration_picker.dart b/lib/util/simple_duration_picker.dart index d40f1ed..8995e86 100644 --- a/lib/util/simple_duration_picker.dart +++ b/lib/util/simple_duration_picker.dart @@ -1,10 +1,12 @@ import 'dart:developer'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +import 'package:flutter_riverpod/flutter_riverpod.dart'; + import 'package:fladder/screens/shared/outlined_text_field.dart'; import 'package:fladder/util/localization_helper.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; String timePickerString(BuildContext context, Duration? duration) { if (duration == null) return context.localized.never; @@ -113,8 +115,10 @@ class SimpleDurationPicker extends ConsumerWidget { final parsedValue = int.parse(value); if (parsedValue >= 60) { secondsTextController.text = (parsedValue % 60).toString().padLeft(2, '0'); - minuteTextController.text = - (int.parse(minuteTextController.text) + parsedValue / 60).floor().toString().padLeft(2, '0'); + minuteTextController.text = (int.parse(minuteTextController.text) + parsedValue / 60) + .floor() + .toString() + .padLeft(2, '0'); } onChanged( Duration( diff --git a/lib/widgets/shared/progress_floating_button.dart b/lib/widgets/shared/progress_floating_button.dart index 3284d30..d449e7e 100644 --- a/lib/widgets/shared/progress_floating_button.dart +++ b/lib/widgets/shared/progress_floating_button.dart @@ -10,7 +10,7 @@ import 'package:square_progress_indicator/square_progress_indicator.dart'; import 'package:fladder/util/simple_duration_picker.dart'; -class RestarableTimerController { +class RestartableTimerController { late Duration _steps = const Duration(milliseconds: 32); RestartableTimer? _timer; late Duration _duration = const Duration(seconds: 1); @@ -25,7 +25,7 @@ class RestarableTimerController { final StreamController _timeLeftController = StreamController.broadcast(); final StreamController _isActiveController = StreamController.broadcast(); - RestarableTimerController(Duration duration, Duration steps, {Function()? onTimeout}) { + RestartableTimerController(Duration duration, Duration steps, {Function()? onTimeout}) { _steps = steps; _duration = duration; _onTimeout = onTimeout; @@ -85,7 +85,7 @@ class RestarableTimerController { } class ProgressFloatingButton extends ConsumerStatefulWidget { - final RestarableTimerController? controller; + final RestartableTimerController? controller; final Function()? onTimeOut; final Function(Duration? newDuration)? onLongPress; const ProgressFloatingButton({this.controller, this.onTimeOut, this.onLongPress, super.key}); @@ -95,7 +95,7 @@ class ProgressFloatingButton extends ConsumerStatefulWidget { } class _ProgressFloatingButtonState extends ConsumerState { - late RestarableTimerController timer; + late RestartableTimerController timer; late Duration timeLeft = timer._duration; late bool isActive = false; @@ -105,7 +105,7 @@ class _ProgressFloatingButtonState extends ConsumerState void initState() { super.initState(); timer = widget.controller ?? - RestarableTimerController( + RestartableTimerController( const Duration(seconds: 1), const Duration(milliseconds: 32), onTimeout: widget.onTimeOut ?? () {},