From e3e5570e4ed9a63549068f49f29aebf5c0b41bee Mon Sep 17 00:00:00 2001 From: def Date: Thu, 28 Dec 2023 15:19:16 +0200 Subject: [PATCH] feat: Add the button to copy password on the new user creation screen (#409) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://git.selfprivacy.org/SelfPrivacy/selfprivacy.org.app/issues/299 Co-authored-by: dettlaff Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy.org.app/pulls/409 Reviewed-by: NaiJi ✨ Reviewed-by: Inex Code Co-authored-by: def Co-committed-by: def --- lib/ui/pages/users/new_user.dart | 38 +++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/lib/ui/pages/users/new_user.dart b/lib/ui/pages/users/new_user.dart index 9212307a..2315bdb1 100644 --- a/lib/ui/pages/users/new_user.dart +++ b/lib/ui/pages/users/new_user.dart @@ -71,12 +71,38 @@ class NewUserPage extends StatelessWidget { labelText: 'basis.password'.tr(), suffixIcon: Padding( padding: const EdgeInsets.only(right: 8), - child: IconButton( - icon: Icon( - BrandIcons.refresh, - color: Theme.of(context).colorScheme.secondary, - ), - onPressed: context.read().genNewPassword, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + icon: Icon( + Icons.copy, + size: 24.0, + color: Theme.of(context).colorScheme.secondary, + ), + onPressed: () { + final String currentPassword = context + .read() + .password + .state + .value; + PlatformAdapter.setClipboard(currentPassword); + getIt().showSnackBar( + 'basis.copied_to_clipboard'.tr(), + behavior: SnackBarBehavior.floating, + ); + }, + ), + IconButton( + icon: Icon( + Icons.refresh, + size: 24.0, + color: Theme.of(context).colorScheme.secondary, + ), + onPressed: + context.read().genNewPassword, + ), + ], ), ), ),