feat(auth): 登录异常改为居中弹窗
This commit is contained in:
1 parent
9b78e43702
commit
b0002abf82
14 files changed
+436
-10
No files matched your search
@@ -0,0 +1,67 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import '../theme/app_colors.dart';
|
||||
|
||||
const Key _dialogKey = Key('centered-error-dialog');
|
||||
const Key _confirmKey = Key('centered-error-confirm');
|
||||
const double _dialogRadius = 16;
|
||||
const double _titleHorizontalInset = 24;
|
||||
const double _titleTopInset = 24;
|
||||
const double _contentHorizontalInset = 24;
|
||||
const double _contentTopInset = 12;
|
||||
const double _contentBottomInset = 8;
|
||||
const double _actionsHorizontalInset = 16;
|
||||
const double _actionsBottomInset = 12;
|
||||
const EdgeInsets _titlePadding = EdgeInsets.fromLTRB(
|
||||
_titleHorizontalInset,
|
||||
_titleTopInset,
|
||||
_titleHorizontalInset,
|
||||
0,
|
||||
);
|
||||
const EdgeInsets _contentPadding = EdgeInsets.fromLTRB(
|
||||
_contentHorizontalInset,
|
||||
_contentTopInset,
|
||||
_contentHorizontalInset,
|
||||
_contentBottomInset,
|
||||
);
|
||||
const EdgeInsets _actionsPadding = EdgeInsets.fromLTRB(
|
||||
_actionsHorizontalInset,
|
||||
0,
|
||||
_actionsHorizontalInset,
|
||||
_actionsBottomInset,
|
||||
);
|
||||
|
||||
/// Shows a reusable error dialog centered on the screen.
|
||||
Future<void> showCenteredErrorDialog(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
required String message,
|
||||
}) async {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
key: _dialogKey,
|
||||
backgroundColor: AppColors.card,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(_dialogRadius),
|
||||
),
|
||||
titlePadding: _titlePadding,
|
||||
contentPadding: _contentPadding,
|
||||
title: Text(title),
|
||||
content: Text(message),
|
||||
actionsPadding: _actionsPadding,
|
||||
actions: [
|
||||
TextButton(
|
||||
key: _confirmKey,
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: Text(l10n.authErrorConfirm),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user