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