mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-05 00:13:12 +00:00
Merge pull request 'feat: Implement copying to clipboard for snapshot id of backups' (#325) from snapshot-id into master
Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy.org.app/pulls/325 Reviewed-by: Inex Code <inex.code@selfprivacy.org>
This commit is contained in:
commit
fd13828ec3
|
@ -21,11 +21,12 @@ class NavigationService {
|
|||
);
|
||||
}
|
||||
|
||||
void showSnackBar(final String text) {
|
||||
void showSnackBar(final String text, {final SnackBarBehavior? behavior}) {
|
||||
final ScaffoldMessengerState state = scaffoldMessengerKey.currentState!;
|
||||
final SnackBar snack = SnackBar(
|
||||
content: Text(text),
|
||||
duration: const Duration(seconds: 2),
|
||||
behavior: behavior,
|
||||
);
|
||||
state.showSnackBar(snack);
|
||||
}
|
||||
|
|
30
lib/ui/pages/backups/snapshot_id_list_tile.dart
Normal file
30
lib/ui/pages/backups/snapshot_id_list_tile.dart
Normal file
|
@ -0,0 +1,30 @@
|
|||
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';
|
||||
|
||||
class SnapshotIdListTile extends StatelessWidget {
|
||||
const SnapshotIdListTile({
|
||||
required this.snapshotId,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String snapshotId;
|
||||
|
||||
@override
|
||||
Widget build(final BuildContext context) => ListTile(
|
||||
onLongPress: () {
|
||||
Clipboard.setData(ClipboardData(text: snapshotId));
|
||||
getIt<NavigationService>().showSnackBar(
|
||||
'basis.copied_to_clipboard'.tr(),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
);
|
||||
},
|
||||
leading: Icon(
|
||||
Icons.numbers_outlined,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
title: Text('backup.snapshot_id_title'.tr()),
|
||||
subtitle: Text(snapshotId),
|
||||
);
|
||||
}
|
|
@ -11,6 +11,7 @@ import 'package:selfprivacy/logic/models/service.dart';
|
|||
import 'package:selfprivacy/ui/components/buttons/brand_button.dart';
|
||||
import 'package:selfprivacy/ui/components/cards/outlined_card.dart';
|
||||
import 'package:selfprivacy/ui/components/info_box/info_box.dart';
|
||||
import 'package:selfprivacy/ui/pages/backups/snapshot_id_list_tile.dart';
|
||||
|
||||
class SnapshotModal extends StatefulWidget {
|
||||
const SnapshotModal({
|
||||
|
@ -51,7 +52,9 @@ class _SnapshotModalState extends State<SnapshotModal> {
|
|||
.state
|
||||
.getServiceById(widget.snapshot.serviceId);
|
||||
|
||||
return ListView(
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
body: ListView(
|
||||
controller: widget.scrollController,
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
|
@ -95,18 +98,7 @@ class _SnapshotModalState extends State<SnapshotModal> {
|
|||
'${MaterialLocalizations.of(context).formatShortDate(widget.snapshot.time)} ${TimeOfDay.fromDateTime(widget.snapshot.time).format(context)}',
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Icons.numbers_outlined,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
title: Text(
|
||||
'backup.snapshot_id_title'.tr(),
|
||||
),
|
||||
subtitle: Text(
|
||||
widget.snapshot.id,
|
||||
),
|
||||
),
|
||||
SnapshotIdListTile(snapshotId: widget.snapshot.id),
|
||||
if (service != null)
|
||||
Column(
|
||||
children: [
|
||||
|
@ -170,6 +162,7 @@ class _SnapshotModalState extends State<SnapshotModal> {
|
|||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue