fix navbar freezing fix
This commit is contained in:
@@ -4,6 +4,7 @@ import 'dart:convert';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mileograph_flutter/components/calculator/calculator.dart';
|
||||
import 'package:mileograph_flutter/components/pages/traction.dart';
|
||||
|
||||
@@ -10,6 +10,7 @@ class NewEntryPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _NewEntryPageState extends State<NewEntryPage> {
|
||||
late final NavigationGuardCallback _exitGuard;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
DateTime _selectedDate = DateTime.now();
|
||||
TimeOfDay _selectedTime = TimeOfDay.now();
|
||||
@@ -40,7 +41,8 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
NavigationGuard.register(_handleExitIntent);
|
||||
_exitGuard = _handleExitIntent;
|
||||
NavigationGuard.register(_exitGuard);
|
||||
// legacy single-draft auto-save listeners removed in favor of explicit multi-draft flow
|
||||
Future.microtask(() {
|
||||
if (!mounted) return;
|
||||
@@ -58,7 +60,7 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
NavigationGuard.unregister(_handleExitIntent);
|
||||
NavigationGuard.unregister(_exitGuard);
|
||||
_startController.dispose();
|
||||
_endController.dispose();
|
||||
_headcodeController.dispose();
|
||||
@@ -586,7 +588,12 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
||||
if (didPop) return;
|
||||
final allow = await _handleExitIntent();
|
||||
if (allow && context.mounted) {
|
||||
Navigator.of(context).maybePop();
|
||||
final router = GoRouter.of(context);
|
||||
if (router.canPop()) {
|
||||
context.pop();
|
||||
} else {
|
||||
context.go('/');
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
@@ -597,7 +604,12 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
||||
onPressed: () async {
|
||||
if (!await _handleExitIntent()) return;
|
||||
if (!context.mounted) return;
|
||||
Navigator.of(context).maybePop();
|
||||
final router = GoRouter.of(context);
|
||||
if (router.canPop()) {
|
||||
context.pop();
|
||||
} else {
|
||||
context.go('/');
|
||||
}
|
||||
},
|
||||
),
|
||||
title: const Text('Edit entry'),
|
||||
|
||||
Reference in New Issue
Block a user