Added answers section logs

This commit is contained in:
Juan Gilsanz Polo 2022-10-22 02:39:29 +02:00
parent 80019eaa13
commit 82870ded63
3 changed files with 70 additions and 35 deletions

View file

@ -47,7 +47,7 @@ class Log {
final String status;
final DateTime time;
final String upstream;
final List<Answer>? answer;
final List<Answer> answer;
final int? filterId;
final String? rule;
final List<Answer>? originalAnswer;
@ -65,7 +65,7 @@ class Log {
required this.status,
required this.time,
required this.upstream,
this.answer,
required this.answer,
this.filterId,
this.rule,
this.originalAnswer,
@ -84,7 +84,7 @@ class Log {
status: json["status"],
time: DateTime.parse(json["time"]),
upstream: json["upstream"],
answer: json["answer"] == null ? null : List<Answer>.from(json["answer"].map((x) => Answer.fromJson(x))),
answer: json["answer"] != null ? List<Answer>.from(json["answer"].map((x) => Answer.fromJson(x))) : [],
filterId: json["filterId"],
rule: json["rule"],
originalAnswer: json["original_answer"] == null ? null : List<Answer>.from(json["original_answer"].map((x) => Answer.fromJson(x))),

View file

@ -179,6 +179,39 @@ class LogDetailsModal extends StatelessWidget {
title: AppLocalizations.of(context)!.deviceName,
subtitle: log.clientInfo!.name
),
if (log.answer.isNotEmpty) ...[
Padding(
padding: const EdgeInsets.all(20),
child: Text(
AppLocalizations.of(context)!.answer,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryColor
),
),
),
...log.answer.map((a) => LogListTile(
icon: Icons.download_rounded,
title: a.value,
subtitle: "TTL: ${a.ttl.toString()}",
trailing: Container(
padding: const EdgeInsets.all(5),
decoration: BoxDecoration(
color: Theme.of(context).listTileTheme.iconColor,
borderRadius: BorderRadius.circular(10)
),
child: Text(
a.type,
style: const TextStyle(
fontSize: 12,
color: Colors.white,
fontWeight: FontWeight.w500
),
),
)
)).toList()
]
],
),
),

View file

@ -18,21 +18,21 @@ class LogListTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
final width = MediaQuery.of(context).size.width;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
Flexible(
child: Row(
children: [
Icon(
icon,
size: 24,
),
const SizedBox(width: 20),
Column(
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
@ -42,21 +42,23 @@ class LogListTile extends StatelessWidget {
),
),
const SizedBox(height: 5),
subtitleWidget ?? SizedBox(
width: width-100,
child: Text(
subtitleWidget ?? Text(
subtitle!,
style: TextStyle(
fontSize: 14,
color: Theme.of(context).listTileTheme.iconColor,
),
),
)
],
),
),
],
),
if (trailing != null) trailing!
),
if (trailing != null) ...[
const SizedBox(width: 10),
trailing!
]
],
),
);