refactor(account): 收敛账号页组件结构
This commit is contained in:
1 parent
da095115d4
commit
6fce24d9ec
5 files changed
+308
-247
No files matched your search
@@ -69,84 +69,101 @@ class _AccountDeactivatePageState extends State<AccountDeactivatePage> {
|
||||
}
|
||||
|
||||
Widget _body(AppLocalizations l10n) {
|
||||
final errorColor = Theme.of(context).colorScheme.error;
|
||||
return ListView(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 28),
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: errorColor.withValues(alpha: 0.10),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: errorColor.withValues(alpha: 0.35)),
|
||||
),
|
||||
child: Text(
|
||||
l10n.accountDeactivateWarning,
|
||||
style: TextStyle(color: errorColor, height: 1.5),
|
||||
),
|
||||
),
|
||||
if (_logic.scheduledAt != null) ...[
|
||||
const SizedBox(height: 14),
|
||||
Container(
|
||||
key: const Key('account-deactivate-scheduled'),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.card,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Text(
|
||||
l10n.accountScheduledFor(
|
||||
formatLocalizedDateTime(context, _logic.scheduledAt!),
|
||||
),
|
||||
),
|
||||
),
|
||||
] else ...[
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
key: const Key('account-deactivate-reason'),
|
||||
controller: _reason,
|
||||
maxLength: AccountDeactivateLogic.maxReasonLength,
|
||||
maxLines: 4,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.accountDeactivateReason,
|
||||
hintText: l10n.accountDeactivateReasonHint,
|
||||
),
|
||||
),
|
||||
if (_logic.error != null)
|
||||
Text(
|
||||
_message(l10n, _logic.error, l10n.accountDeactivateFailed),
|
||||
style: TextStyle(color: errorColor, fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
FilledButton(
|
||||
key: const Key('account-deactivate-submit'),
|
||||
onPressed: _logic.requesting ? null : _confirm,
|
||||
child: _logic.requesting
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: Text(l10n.accountRequestDeactivate),
|
||||
),
|
||||
],
|
||||
_warning(l10n),
|
||||
const SizedBox(height: 14),
|
||||
OutlinedButton(
|
||||
key: const Key('account-deactivate-cancel'),
|
||||
onPressed: _logic.cancelling ? null : _cancel,
|
||||
child: Text(l10n.accountCancelDeactivation),
|
||||
),
|
||||
if (_logic.actionMessage != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
_message(l10n, _logic.actionMessage, l10n.accountCancelFailed),
|
||||
style: TextStyle(color: errorColor, fontSize: 12),
|
||||
),
|
||||
],
|
||||
if (_logic.scheduledAt != null)
|
||||
_scheduledPanel(l10n)
|
||||
else
|
||||
_requestPanel(l10n),
|
||||
const SizedBox(height: 14),
|
||||
_cancelPanel(l10n),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _warning(AppLocalizations l10n) {
|
||||
final errorColor = Theme.of(context).colorScheme.error;
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: errorColor.withValues(alpha: 0.10),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: errorColor.withValues(alpha: 0.35)),
|
||||
),
|
||||
child: Text(
|
||||
l10n.accountDeactivateWarning,
|
||||
style: TextStyle(color: errorColor, height: 1.5),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _scheduledPanel(AppLocalizations l10n) => Container(
|
||||
key: const Key('account-deactivate-scheduled'),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.card,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Text(
|
||||
l10n.accountScheduledFor(
|
||||
formatLocalizedDateTime(context, _logic.scheduledAt!),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _requestPanel(AppLocalizations l10n) => Column(
|
||||
children: [
|
||||
TextField(
|
||||
key: const Key('account-deactivate-reason'),
|
||||
controller: _reason,
|
||||
maxLength: AccountDeactivateLogic.maxReasonLength,
|
||||
maxLines: 4,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.accountDeactivateReason,
|
||||
hintText: l10n.accountDeactivateReasonHint,
|
||||
),
|
||||
),
|
||||
if (_logic.error != null)
|
||||
_errorText(_message(l10n, _logic.error, l10n.accountDeactivateFailed)),
|
||||
const SizedBox(height: 12),
|
||||
FilledButton(
|
||||
key: const Key('account-deactivate-submit'),
|
||||
onPressed: _logic.requesting ? null : _confirm,
|
||||
child: _logic.requesting
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: Text(l10n.accountRequestDeactivate),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Widget _cancelPanel(AppLocalizations l10n) => Column(
|
||||
children: [
|
||||
OutlinedButton(
|
||||
key: const Key('account-deactivate-cancel'),
|
||||
onPressed: _logic.cancelling ? null : _cancel,
|
||||
child: Text(l10n.accountCancelDeactivation),
|
||||
),
|
||||
if (_logic.actionMessage != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
_errorText(
|
||||
_message(l10n, _logic.actionMessage, l10n.accountCancelFailed),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
Widget _errorText(String value) => Text(
|
||||
value,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error, fontSize: 12),
|
||||
);
|
||||
|
||||
Future<void> _confirm() async {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final confirmed = await showDialog<bool>(
|
||||
|
||||
Reference in new issue
Block a user