part. fix velocidade na navegação entre telas

This commit is contained in:
J. A. Messias 2024-11-06 15:24:17 -03:00
parent 24c1c0ccb9
commit cf8d789c2b
4 changed files with 27 additions and 48 deletions

View File

@ -9,17 +9,17 @@ import '../../../shared/services/localization/localization_service.dart';
class MenuButtonWidget extends MenuEntry { class MenuButtonWidget extends MenuEntry {
const MenuButtonWidget({ const MenuButtonWidget({
super.key, super.key,
this.action, required this.action,
this.title, required this.title,
this.icon, required this.icon,
}); }) : super(action: action, title: title, icon: icon);
@override @override
final Function()? action; final Function() action;
@override @override
final String? title; final String title;
@override @override
final IconData? icon; final IconData icon;
@override @override
_MenuButtonWidgetState createState() => _MenuButtonWidgetState(); _MenuButtonWidgetState createState() => _MenuButtonWidgetState();
@ -39,19 +39,9 @@ class _MenuButtonWidgetState extends State<MenuButtonWidget> {
onTap: _isProcessing onTap: _isProcessing
? null ? null
: () async { : () async {
setState(() { setState(() { _isProcessing = true; });
_isProcessing = true; await widget.action.call();
}); setState(() { _isProcessing = false; });
await LocalizationService.processLocals(context).then((value) async {
if (value) {
await widget.action?.call();
} else {
DialogUnavailable.unavailableCredentials(context);
}
});
setState(() {
_isProcessing = false;
});
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0), padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0),

View File

@ -9,17 +9,17 @@ import '../../../shared/services/localization/localization_service.dart';
class MenuCardItem extends MenuEntry { class MenuCardItem extends MenuEntry {
const MenuCardItem({ const MenuCardItem({
super.key, super.key,
this.action, required this.action,
this.title, required this.title,
this.icon, required this.icon,
}); }) : super(action: action, title: title, icon: icon);
@override @override
final Function()? action; final Function() action;
@override @override
final String? title; final String title;
@override @override
final IconData? icon; final IconData icon;
@override @override
_MenuCardItemState createState() => _MenuCardItemState(); _MenuCardItemState createState() => _MenuCardItemState();
@ -39,19 +39,9 @@ class _MenuCardItemState extends State<MenuCardItem> {
onTap: _isProcessing onTap: _isProcessing
? null ? null
: () async { : () async {
setState(() { setState(() { _isProcessing = true; });
_isProcessing = true; await widget.action.call();
}); setState(() { _isProcessing = false; });
await LocalizationService.processLocals(context).then((value) async {
if (value) {
await widget.action?.call();
} else {
DialogUnavailable.unavailableCredentials(context);
}
});
setState(() {
_isProcessing = false;
});
}, },
child: Card( child: Card(
elevation: 0, elevation: 0,

View File

@ -3,12 +3,12 @@ import 'package:flutter/material.dart';
abstract class MenuEntry extends StatefulWidget { abstract class MenuEntry extends StatefulWidget {
const MenuEntry({ const MenuEntry({
super.key, super.key,
this.action, required this.action,
this.title, required this.title,
this.icon, required this.icon,
}); });
final Function()? action; final Function() action;
final String? title; final String title;
final IconData? icon; final IconData icon;
} }

View File

@ -562,7 +562,6 @@ class _MenuComponentWidgetState extends State<MenuComponentWidget> {
ptText: 'Sair da Conta', ptText: 'Sair da Conta',
), ),
), ),
MenuCardItem(icon: null, action: () {}, title: ''),
]; ];
}(); }();