mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-02 14:14:23 +00:00
feat: Add copy-to-clipboard for email on user page
- Implement setClipboard adapter and encapsulate platform dependency on clipboard service
This commit is contained in:
parent
fd13828ec3
commit
3c548e5aa9
|
@ -1,7 +1,7 @@
|
|||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:selfprivacy/logic/models/message.dart';
|
||||
import 'package:selfprivacy/utils/platform_adapter.dart';
|
||||
|
||||
class LogListItem extends StatelessWidget {
|
||||
const LogListItem({
|
||||
|
@ -71,7 +71,7 @@ class _RestApiRequestMessageItem extends StatelessWidget {
|
|||
if (message.text != null)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: message.text ?? ''));
|
||||
PlatformAdapter.setClipboard(message.text ?? '');
|
||||
},
|
||||
child: Text('console_page.copy'.tr()),
|
||||
),
|
||||
|
@ -121,7 +121,7 @@ class _RestApiResponseMessageItem extends StatelessWidget {
|
|||
if (message.text != null)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: message.text ?? ''));
|
||||
PlatformAdapter.setClipboard(message.text ?? '');
|
||||
},
|
||||
child: Text('console_page.copy'.tr()),
|
||||
),
|
||||
|
@ -195,7 +195,7 @@ class _GraphQlResponseMessageItem extends StatelessWidget {
|
|||
if (message.text != null)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: message.text ?? ''));
|
||||
PlatformAdapter.setClipboard(message.text ?? '');
|
||||
},
|
||||
child: Text('console_page.copy'.tr()),
|
||||
),
|
||||
|
@ -264,7 +264,7 @@ class _GraphQlRequestMessageItem extends StatelessWidget {
|
|||
if (message.text != null)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: message.text ?? ''));
|
||||
PlatformAdapter.setClipboard(message.text ?? '');
|
||||
},
|
||||
child: Text('console_page.copy'.tr()),
|
||||
),
|
||||
|
|
|
@ -2,11 +2,11 @@ import 'dart:async';
|
|||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_jobs/server_jobs_cubit.dart';
|
||||
import 'package:selfprivacy/ui/components/info_box/info_box.dart';
|
||||
import 'package:selfprivacy/utils/platform_adapter.dart';
|
||||
|
||||
class CopyEncryptionKeyModal extends StatefulWidget {
|
||||
const CopyEncryptionKeyModal({
|
||||
|
@ -144,11 +144,7 @@ class _CopyEncryptionKeyModalState extends State<CopyEncryptionKeyModal> {
|
|||
},
|
||||
);
|
||||
});
|
||||
Clipboard.setData(
|
||||
ClipboardData(
|
||||
text: encryptionKey,
|
||||
),
|
||||
);
|
||||
PlatformAdapter.setClipboard(encryptionKey);
|
||||
},
|
||||
icon: const Icon(Icons.copy_all_outlined),
|
||||
label: Text(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:selfprivacy/config/get_it_config.dart';
|
||||
import 'package:selfprivacy/utils/platform_adapter.dart';
|
||||
|
||||
class SnapshotIdListTile extends StatelessWidget {
|
||||
const SnapshotIdListTile({
|
||||
|
@ -14,7 +14,7 @@ class SnapshotIdListTile extends StatelessWidget {
|
|||
@override
|
||||
Widget build(final BuildContext context) => ListTile(
|
||||
onLongPress: () {
|
||||
Clipboard.setData(ClipboardData(text: snapshotId));
|
||||
PlatformAdapter.setClipboard(snapshotId);
|
||||
getIt<NavigationService>().showSnackBar(
|
||||
'basis.copied_to_clipboard'.tr(),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
|
|
|
@ -143,17 +143,27 @@ class _UserLogins extends StatelessWidget {
|
|||
final String domainName;
|
||||
|
||||
@override
|
||||
Widget build(final BuildContext context) => FilledCard(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTileOnSurfaceVariant(
|
||||
title: '${user.login}@$domainName',
|
||||
subtitle: 'users.email_login'.tr(),
|
||||
leadingIcon: Icons.alternate_email_outlined,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
Widget build(final BuildContext context) {
|
||||
final email = '${user.login}@$domainName';
|
||||
return FilledCard(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTileOnSurfaceVariant(
|
||||
onTap: () {
|
||||
PlatformAdapter.setClipboard(email);
|
||||
getIt<NavigationService>().showSnackBar(
|
||||
'basis.copied_to_clipboard'.tr(),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
);
|
||||
},
|
||||
title: email,
|
||||
subtitle: 'users.email_login'.tr(),
|
||||
leadingIcon: Icons.alternate_email_outlined,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SshKeysCard extends StatelessWidget {
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:cubit_form/cubit_form.dart';
|
|||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:selfprivacy/config/brand_theme.dart';
|
||||
import 'package:selfprivacy/config/get_it_config.dart';
|
||||
import 'package:selfprivacy/logic/cubit/forms/user/ssh_form_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
||||
|
@ -22,6 +23,7 @@ import 'package:selfprivacy/ui/components/list_tiles/list_tile_on_surface_varian
|
|||
import 'package:selfprivacy/ui/components/not_ready_card/not_ready_card.dart';
|
||||
import 'package:selfprivacy/ui/router/router.dart';
|
||||
import 'package:selfprivacy/utils/breakpoints.dart';
|
||||
import 'package:selfprivacy/utils/platform_adapter.dart';
|
||||
import 'package:selfprivacy/utils/ui_helpers.dart';
|
||||
|
||||
part 'empty.dart';
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:io';
|
|||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// SelfPrivacy wrapper for Platform information provider.
|
||||
class PlatformAdapter {
|
||||
|
@ -56,4 +57,8 @@ class PlatformAdapter {
|
|||
|
||||
return 'Unidentified';
|
||||
}
|
||||
|
||||
static void setClipboard(final String clipboardData) {
|
||||
Clipboard.setData(ClipboardData(text: clipboardData));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue