refactor: 重构弹窗组件支持自定义图标组件
This commit is contained in:
@@ -4,6 +4,7 @@ import '../../../../l10n/app_localizations.dart';
|
||||
import '../../../../core/logging/logger.dart';
|
||||
import '../../../../shared/theme/design_tokens.dart';
|
||||
import '../../../../shared/widgets/app_modal_dialog.dart';
|
||||
import '../../../../shared/widgets/gua_icon.dart';
|
||||
import '../../../../shared/widgets/toast/toast.dart';
|
||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import '../../data/models/profile_settings.dart';
|
||||
@@ -40,7 +41,6 @@ class SettingsScreen extends StatefulWidget {
|
||||
class _SettingsScreenState extends State<SettingsScreen> {
|
||||
final Logger _logger = getLogger('features.settings.settings_screen');
|
||||
late ProfileSettingsV1 _settings;
|
||||
bool _isLoggingOut = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -114,7 +114,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
),
|
||||
const SizedBox(height: AppSpacing.xl),
|
||||
FilledButton(
|
||||
onPressed: _isLoggingOut ? null : _confirmLogout,
|
||||
onPressed: _confirmLogout,
|
||||
style: FilledButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: colors.error,
|
||||
@@ -208,7 +208,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
return AppModalDialog(
|
||||
title: l10n.settingsLogoutDialogTitle,
|
||||
message: l10n.settingsLogoutDialogBody,
|
||||
icon: Icons.logout_rounded,
|
||||
iconWidget: const GuaIcon(),
|
||||
actions: [
|
||||
AppModalDialogAction(
|
||||
label: l10n.settingsCancel,
|
||||
@@ -228,21 +228,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_isLoggingOut = true;
|
||||
});
|
||||
try {
|
||||
await widget.onLogout();
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoggingOut = false;
|
||||
});
|
||||
}
|
||||
await widget.onLogout();
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user