Added options to copy to clipboard on log details

This commit is contained in:
Juan Gilsanz Polo 2024-06-17 13:28:12 +02:00
parent c5d2892ec2
commit 1dd23906c3
4 changed files with 68 additions and 52 deletions

View file

@ -791,5 +791,8 @@
"clientDisallowedSuccessfully": "Client disallowed successfully", "clientDisallowedSuccessfully": "Client disallowed successfully",
"changesNotSaved": "Changes could not be saved", "changesNotSaved": "Changes could not be saved",
"allowingClient": "Allowing client...", "allowingClient": "Allowing client...",
"disallowingClient": "Disallowing client..." "disallowingClient": "Disallowing client...",
"clientIpCopied": "Client IP copied to the clipboard",
"clientNameCopied": "Client name copied to the clipboard",
"dnsServerAddressCopied": "DNS server address copied to the clipboard"
} }

View file

@ -791,5 +791,8 @@
"clientDisallowedSuccessfully": "Cliente no permitido correctamente", "clientDisallowedSuccessfully": "Cliente no permitido correctamente",
"changesNotSaved": "Los cambios no han podido ser guardados", "changesNotSaved": "Los cambios no han podido ser guardados",
"allowingClient": "Permitiendo cliente...", "allowingClient": "Permitiendo cliente...",
"disallowingClient": "No permitiendo cliente..." "disallowingClient": "No permitiendo cliente...",
"clientIpCopied": "Dirección IP del cliente copiada al portapapeles",
"clientNameCopied": "Nombre del cliente copiado al portapapeles",
"dnsServerAddressCopied": "Dirección del servidor DNS copiada al portapapeles"
} }

View file

@ -1,5 +1,6 @@
// ignore_for_file: use_build_context_synchronously // ignore_for_file: use_build_context_synchronously
import 'package:adguard_home_manager/functions/copy_clipboard.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@ -275,10 +276,11 @@ class _Content extends StatelessWidget {
subtitle: convertTimestampLocalTimezone(log.time, 'HH:mm:ss') subtitle: convertTimestampLocalTimezone(log.time, 'HH:mm:ss')
), ),
SectionLabel(label: AppLocalizations.of(context)!.request), SectionLabel(label: AppLocalizations.of(context)!.request),
LogListTile( if (log.question.name != null) LogListTile(
icon: Icons.domain_rounded, icon: Icons.domain_rounded,
title: AppLocalizations.of(context)!.domain, title: AppLocalizations.of(context)!.domain,
subtitle: log.question.name subtitle: log.question.name,
onTap: () => copyToClipboard(value: log.question.name!, successMessage: AppLocalizations.of(context)!.domainCopiedClipboard),
), ),
LogListTile( LogListTile(
icon: Icons.category_rounded, icon: Icons.category_rounded,
@ -294,7 +296,8 @@ class _Content extends StatelessWidget {
if (log.upstream != null && log.upstream != '') LogListTile( if (log.upstream != null && log.upstream != '') LogListTile(
icon: Icons.dns_rounded, icon: Icons.dns_rounded,
title: AppLocalizations.of(context)!.dnsServer, title: AppLocalizations.of(context)!.dnsServer,
subtitle: log.upstream subtitle: log.upstream,
onTap: () => copyToClipboard(value: log.upstream!, successMessage: AppLocalizations.of(context)!.dnsServerAddressCopied)
), ),
LogListTile( LogListTile(
icon: Icons.timer_rounded, icon: Icons.timer_rounded,
@ -310,12 +313,14 @@ class _Content extends StatelessWidget {
LogListTile( LogListTile(
icon: Icons.smartphone_rounded, icon: Icons.smartphone_rounded,
title: AppLocalizations.of(context)!.deviceIp, title: AppLocalizations.of(context)!.deviceIp,
subtitle: log.client subtitle: log.client,
onTap: () => copyToClipboard(value: log.client, successMessage: AppLocalizations.of(context)!.clientIpCopied),
), ),
if (log.clientInfo != null && log.clientInfo!.name != '') LogListTile( if (log.clientInfo != null && log.clientInfo!.name != '') LogListTile(
icon: Icons.abc_rounded, icon: Icons.abc_rounded,
title: AppLocalizations.of(context)!.deviceName, title: AppLocalizations.of(context)!.deviceName,
subtitle: log.clientInfo!.name subtitle: log.clientInfo!.name,
onTap: () => copyToClipboard(value: log.clientInfo!.name, successMessage: AppLocalizations.of(context)!.clientNameCopied),
), ),
if (log.rules.isNotEmpty) ...[ if (log.rules.isNotEmpty) ...[
SectionLabel(label: AppLocalizations.of(context)!.rules), SectionLabel(label: AppLocalizations.of(context)!.rules),

View file

@ -6,63 +6,68 @@ class LogListTile extends StatelessWidget {
final String? subtitle; final String? subtitle;
final Widget? subtitleWidget; final Widget? subtitleWidget;
final Widget? trailing; final Widget? trailing;
final void Function()? onTap;
const LogListTile({ const LogListTile({
Key? key, super.key,
required this.icon, required this.icon,
required this.title, required this.title,
this.subtitle, this.subtitle,
this.subtitleWidget, this.subtitleWidget,
this.trailing, this.trailing,
}) : super(key: key); this.onTap,
});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return InkWell(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), onTap: onTap,
child: Row( child: Padding(
mainAxisAlignment: MainAxisAlignment.spaceBetween, padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
children: [ child: Row(
Flexible( mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: Row( children: [
children: [ Flexible(
Icon( child: Row(
icon, children: [
size: 24, Icon(
color: Theme.of(context).colorScheme.onSurfaceVariant, icon,
), size: 24,
const SizedBox(width: 16), color: Theme.of(context).colorScheme.onSurfaceVariant,
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Theme.of(context).colorScheme.onSurface
),
),
const SizedBox(height: 3),
subtitleWidget ?? Text(
subtitle!,
style: TextStyle(
fontSize: 14,
color: Theme.of(context).listTileTheme.textColor,
),
)
],
), ),
), const SizedBox(width: 16),
], Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Theme.of(context).colorScheme.onSurface
),
),
const SizedBox(height: 3),
subtitleWidget ?? Text(
subtitle!,
style: TextStyle(
fontSize: 14,
color: Theme.of(context).listTileTheme.textColor,
),
)
],
),
),
],
),
), ),
), if (trailing != null) ...[
if (trailing != null) ...[ const SizedBox(width: 16),
const SizedBox(width: 16), trailing!
trailing! ]
] ],
], ),
), ),
); );
} }