Files
sendico/frontend/pweb/lib/pages/settings/profile/account/name/actions.dart
2025-12-22 21:09:58 +03:00

48 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:pweb/pages/settings/profile/account/name/state.dart';
class AccountNameActions extends StatelessWidget {
const AccountNameActions({
super.key,
required this.state,
});
final AccountNameState state;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
if (state.isEditing) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: Icon(Icons.check, color: theme.colorScheme.primary),
onPressed: state.isBusy
? null
: () async {
final wasSaved = await state.save();
if (!context.mounted || wasSaved || state.errorText.isEmpty) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(state.errorText)),
);
},
),
IconButton(
icon: Icon(Icons.close, color: theme.colorScheme.error),
onPressed: state.isBusy ? null : state.cancelEditing,
),
],
);
}
return IconButton(
icon: Icon(Icons.edit, color: theme.colorScheme.primary),
onPressed: state.isBusy ? null : state.startEditing,
);
}
}