mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-03-31 18:56:21 +00:00
refactor(ui): some tweaks to reset_password_link_dialog
This commit is contained in:
parent
8a2c56d24c
commit
c6abf9712a
2 changed files with 33 additions and 46 deletions
lib
logic/cubit/forms/user
ui/pages/users/reset_password
|
@ -78,6 +78,7 @@ class ResetPasswordState extends Equatable {
|
|||
});
|
||||
|
||||
final Uri? passwordResetLink;
|
||||
bool get isLinkValid => passwordResetLink != null;
|
||||
final bool isLoading;
|
||||
final String passwordResetMessage;
|
||||
final String errorMessage;
|
||||
|
|
|
@ -25,7 +25,6 @@ class ResetPasswordLinkDialog extends StatelessWidget {
|
|||
: 'users.creating_password_reset_link'.tr();
|
||||
|
||||
late final Widget content;
|
||||
late final List<Widget> actions;
|
||||
|
||||
if (state.errorMessage.isNotEmpty) {
|
||||
content = Text(
|
||||
|
@ -36,31 +35,11 @@ class ResetPasswordLinkDialog extends StatelessWidget {
|
|||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
);
|
||||
actions = <Widget>[
|
||||
TextButton(
|
||||
key: const ValueKey('close_button'),
|
||||
child: Text(
|
||||
'basis.close'.tr(),
|
||||
),
|
||||
onPressed: () {
|
||||
context.router.maybePop();
|
||||
},
|
||||
),
|
||||
];
|
||||
} else if (state.isLoading) {
|
||||
content = const SizedBox(
|
||||
height: 52, child: Center(child: CircularProgressIndicator()));
|
||||
actions = <Widget>[
|
||||
TextButton(
|
||||
key: const ValueKey('close_button'),
|
||||
child: Text(
|
||||
'basis.close'.tr(),
|
||||
),
|
||||
onPressed: () {
|
||||
context.router.maybePop();
|
||||
},
|
||||
),
|
||||
];
|
||||
height: 52,
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
} else {
|
||||
content = ListTile(
|
||||
onTap: () {
|
||||
|
@ -81,27 +60,6 @@ class ResetPasswordLinkDialog extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
);
|
||||
actions = <Widget>[
|
||||
TextButton(
|
||||
child: Text('basis.copy'.tr()),
|
||||
onPressed: () {
|
||||
PlatformAdapter.setClipboard(
|
||||
state.passwordResetLink.toString());
|
||||
getIt<NavigationService>().showSnackBar(
|
||||
'basis.copied_to_clipboard'.tr(),
|
||||
);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
key: const ValueKey('close_button'),
|
||||
child: Text(
|
||||
'basis.close'.tr(),
|
||||
),
|
||||
onPressed: () {
|
||||
context.router.maybePop();
|
||||
},
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
return AlertDialog(
|
||||
|
@ -112,8 +70,36 @@ class ResetPasswordLinkDialog extends StatelessWidget {
|
|||
duration: const Duration(milliseconds: 300),
|
||||
child: content,
|
||||
),
|
||||
actions: actions,
|
||||
actions: [
|
||||
if (state.isLinkValid)
|
||||
TextButton(
|
||||
child: Text('basis.copy'.tr()),
|
||||
onPressed: () {
|
||||
PlatformAdapter.setClipboard(
|
||||
state.passwordResetLink.toString());
|
||||
getIt<NavigationService>().showSnackBar(
|
||||
'basis.copied_to_clipboard'.tr(),
|
||||
);
|
||||
},
|
||||
),
|
||||
const _CloseButton(),
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
class _CloseButton extends StatelessWidget {
|
||||
const _CloseButton() : super(key: const ValueKey('close_button'));
|
||||
|
||||
@override
|
||||
Widget build(final BuildContext context) => TextButton(
|
||||
key: const ValueKey('close_button'),
|
||||
child: Text(
|
||||
'basis.close'.tr(),
|
||||
),
|
||||
onPressed: () {
|
||||
context.router.maybePop();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue