diff --git a/lib/models/logs.dart b/lib/models/logs.dart index 8ae4698..ed86fee 100644 --- a/lib/models/logs.dart +++ b/lib/models/logs.dart @@ -47,7 +47,7 @@ class Log { final String status; final DateTime time; final String upstream; - final List? answer; + final List answer; final int? filterId; final String? rule; final List? 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.from(json["answer"].map((x) => Answer.fromJson(x))), + answer: json["answer"] != null ? List.from(json["answer"].map((x) => Answer.fromJson(x))) : [], filterId: json["filterId"], rule: json["rule"], originalAnswer: json["original_answer"] == null ? null : List.from(json["original_answer"].map((x) => Answer.fromJson(x))), diff --git a/lib/screens/logs/log_details_modal.dart b/lib/screens/logs/log_details_modal.dart index ee828fb..d27b063 100644 --- a/lib/screens/logs/log_details_modal.dart +++ b/lib/screens/logs/log_details_modal.dart @@ -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() + ] ], ), ), diff --git a/lib/screens/logs/log_list_tile.dart b/lib/screens/logs/log_list_tile.dart index a365c95..d5e011f 100644 --- a/lib/screens/logs/log_list_tile.dart +++ b/lib/screens/logs/log_list_tile.dart @@ -18,45 +18,47 @@ 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( - children: [ - Icon( - icon, - size: 24, - ), - const SizedBox(width: 20), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - title, - style: const TextStyle( - fontSize: 18, - ), - ), - const SizedBox(height: 5), - subtitleWidget ?? SizedBox( - width: width-100, - child: Text( - subtitle!, - style: TextStyle( - fontSize: 14, - color: Theme.of(context).listTileTheme.iconColor, + Flexible( + child: Row( + children: [ + Icon( + icon, + size: 24, + ), + const SizedBox(width: 20), + Flexible( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: const TextStyle( + fontSize: 18, + ), ), - ), - ) - ], - ), - ], + const SizedBox(height: 5), + 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! + ] ], ), );