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;
|
double dragUpDelta = 0.0;
|
||||||
|
|
||||||
final controller = TextEditingController();
|
final controller = TextEditingController();
|
||||||
late final timerController = RestarableTimerController(
|
late final timerController = RestartableTimerController(
|
||||||
ref.read(photoViewSettingsProvider).timer, const Duration(milliseconds: 32), onTimeout: () {
|
ref.read(photoViewSettingsProvider).timer, const Duration(milliseconds: 32), onTimeout: () {
|
||||||
if (widget.pageController.page == widget.itemCount - 1) {
|
if (widget.pageController.page == widget.itemCount - 1) {
|
||||||
widget.pageController.animateToPage(0, duration: const Duration(milliseconds: 250), curve: Curves.easeInOut);
|
widget.pageController.animateToPage(0, duration: const Duration(milliseconds: 250), curve: Curves.easeInOut);
|
||||||
|
|
@ -146,6 +146,7 @@ class _PhotoViewerControllsState extends ConsumerState<PhotoViewerControls> with
|
||||||
return PopScope(
|
return PopScope(
|
||||||
onPopInvokedWithResult: (didPop, result) async => await WakelockPlus.disable(),
|
onPopInvokedWithResult: (didPop, result) async => await WakelockPlus.disable(),
|
||||||
child: InputHandler(
|
child: InputHandler(
|
||||||
|
autoFocus: false,
|
||||||
onKeyEvent: (node, event) => _onKey(event) ? KeyEventResult.handled : KeyEventResult.ignored,
|
onKeyEvent: (node, event) => _onKey(event) ? KeyEventResult.handled : KeyEventResult.ignored,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ class VideoPlayerNextWrapper extends ConsumerStatefulWidget {
|
||||||
class _VideoPlayerNextWrapperState extends ConsumerState<VideoPlayerNextWrapper> {
|
class _VideoPlayerNextWrapperState extends ConsumerState<VideoPlayerNextWrapper> {
|
||||||
bool show = false;
|
bool show = false;
|
||||||
bool showOverwrite = false;
|
bool showOverwrite = false;
|
||||||
late RestarableTimerController timerController =
|
late RestartableTimerController timerController =
|
||||||
RestarableTimerController(const Duration(seconds: 30), const Duration(milliseconds: 33), onTimeout: onTimeOut);
|
RestartableTimerController(const Duration(seconds: 30), const Duration(milliseconds: 33), onTimeout: onTimeOut);
|
||||||
|
|
||||||
void onTimeOut() {
|
void onTimeOut() {
|
||||||
timerController.cancel();
|
timerController.cancel();
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,20 @@ class InputHandler extends StatefulWidget {
|
||||||
class _InputHandlerState extends State<InputHandler> {
|
class _InputHandlerState extends State<InputHandler> {
|
||||||
final focusNode = FocusNode();
|
final focusNode = FocusNode();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
//Focus on start
|
||||||
|
focusNode.requestFocus();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Focus(
|
return Focus(
|
||||||
autofocus: widget.autoFocus,
|
autofocus: widget.autoFocus,
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
onFocusChange: (value) {
|
onFocusChange: (value) {
|
||||||
if (!focusNode.hasFocus) {
|
if (!focusNode.hasFocus && widget.autoFocus) {
|
||||||
focusNode.requestFocus();
|
focusNode.requestFocus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
import 'dart:developer';
|
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/screens/shared/outlined_text_field.dart';
|
||||||
import 'package:fladder/util/localization_helper.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) {
|
String timePickerString(BuildContext context, Duration? duration) {
|
||||||
if (duration == null) return context.localized.never;
|
if (duration == null) return context.localized.never;
|
||||||
|
|
@ -113,8 +115,10 @@ class SimpleDurationPicker extends ConsumerWidget {
|
||||||
final parsedValue = int.parse(value);
|
final parsedValue = int.parse(value);
|
||||||
if (parsedValue >= 60) {
|
if (parsedValue >= 60) {
|
||||||
secondsTextController.text = (parsedValue % 60).toString().padLeft(2, '0');
|
secondsTextController.text = (parsedValue % 60).toString().padLeft(2, '0');
|
||||||
minuteTextController.text =
|
minuteTextController.text = (int.parse(minuteTextController.text) + parsedValue / 60)
|
||||||
(int.parse(minuteTextController.text) + parsedValue / 60).floor().toString().padLeft(2, '0');
|
.floor()
|
||||||
|
.toString()
|
||||||
|
.padLeft(2, '0');
|
||||||
}
|
}
|
||||||
onChanged(
|
onChanged(
|
||||||
Duration(
|
Duration(
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import 'package:square_progress_indicator/square_progress_indicator.dart';
|
||||||
|
|
||||||
import 'package:fladder/util/simple_duration_picker.dart';
|
import 'package:fladder/util/simple_duration_picker.dart';
|
||||||
|
|
||||||
class RestarableTimerController {
|
class RestartableTimerController {
|
||||||
late Duration _steps = const Duration(milliseconds: 32);
|
late Duration _steps = const Duration(milliseconds: 32);
|
||||||
RestartableTimer? _timer;
|
RestartableTimer? _timer;
|
||||||
late Duration _duration = const Duration(seconds: 1);
|
late Duration _duration = const Duration(seconds: 1);
|
||||||
|
|
@ -25,7 +25,7 @@ class RestarableTimerController {
|
||||||
final StreamController<Duration> _timeLeftController = StreamController<Duration>.broadcast();
|
final StreamController<Duration> _timeLeftController = StreamController<Duration>.broadcast();
|
||||||
final StreamController<bool> _isActiveController = StreamController<bool>.broadcast();
|
final StreamController<bool> _isActiveController = StreamController<bool>.broadcast();
|
||||||
|
|
||||||
RestarableTimerController(Duration duration, Duration steps, {Function()? onTimeout}) {
|
RestartableTimerController(Duration duration, Duration steps, {Function()? onTimeout}) {
|
||||||
_steps = steps;
|
_steps = steps;
|
||||||
_duration = duration;
|
_duration = duration;
|
||||||
_onTimeout = onTimeout;
|
_onTimeout = onTimeout;
|
||||||
|
|
@ -85,7 +85,7 @@ class RestarableTimerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProgressFloatingButton extends ConsumerStatefulWidget {
|
class ProgressFloatingButton extends ConsumerStatefulWidget {
|
||||||
final RestarableTimerController? controller;
|
final RestartableTimerController? controller;
|
||||||
final Function()? onTimeOut;
|
final Function()? onTimeOut;
|
||||||
final Function(Duration? newDuration)? onLongPress;
|
final Function(Duration? newDuration)? onLongPress;
|
||||||
const ProgressFloatingButton({this.controller, this.onTimeOut, this.onLongPress, super.key});
|
const ProgressFloatingButton({this.controller, this.onTimeOut, this.onLongPress, super.key});
|
||||||
|
|
@ -95,7 +95,7 @@ class ProgressFloatingButton extends ConsumerStatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ProgressFloatingButtonState extends ConsumerState<ProgressFloatingButton> {
|
class _ProgressFloatingButtonState extends ConsumerState<ProgressFloatingButton> {
|
||||||
late RestarableTimerController timer;
|
late RestartableTimerController timer;
|
||||||
late Duration timeLeft = timer._duration;
|
late Duration timeLeft = timer._duration;
|
||||||
late bool isActive = false;
|
late bool isActive = false;
|
||||||
|
|
||||||
|
|
@ -105,7 +105,7 @@ class _ProgressFloatingButtonState extends ConsumerState<ProgressFloatingButton>
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
timer = widget.controller ??
|
timer = widget.controller ??
|
||||||
RestarableTimerController(
|
RestartableTimerController(
|
||||||
const Duration(seconds: 1),
|
const Duration(seconds: 1),
|
||||||
const Duration(milliseconds: 32),
|
const Duration(milliseconds: 32),
|
||||||
onTimeout: widget.onTimeOut ?? () {},
|
onTimeout: widget.onTimeOut ?? () {},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue