mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
fix: duration-picker not working (#134)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
59a5fa6ac6
commit
35e74258d9
5 changed files with 26 additions and 14 deletions
|
|
@ -56,7 +56,7 @@ class _PhotoViewerControllsState extends ConsumerState<PhotoViewerControls> 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<PhotoViewerControls> 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: [
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ class VideoPlayerNextWrapper extends ConsumerStatefulWidget {
|
|||
class _VideoPlayerNextWrapperState extends ConsumerState<VideoPlayerNextWrapper> {
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -18,13 +18,20 @@ class InputHandler extends StatefulWidget {
|
|||
class _InputHandlerState extends State<InputHandler> {
|
||||
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();
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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<Duration> _timeLeftController = StreamController<Duration>.broadcast();
|
||||
final StreamController<bool> _isActiveController = StreamController<bool>.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<ProgressFloatingButton> {
|
||||
late RestarableTimerController timer;
|
||||
late RestartableTimerController timer;
|
||||
late Duration timeLeft = timer._duration;
|
||||
late bool isActive = false;
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ class _ProgressFloatingButtonState extends ConsumerState<ProgressFloatingButton>
|
|||
void initState() {
|
||||
super.initState();
|
||||
timer = widget.controller ??
|
||||
RestarableTimerController(
|
||||
RestartableTimerController(
|
||||
const Duration(seconds: 1),
|
||||
const Duration(milliseconds: 32),
|
||||
onTimeout: widget.onTimeOut ?? () {},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue