2022-09-30 01:23:28 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-10-17 01:37:11 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
2022-09-30 01:23:28 +02:00
|
|
|
|
|
|
|
import 'package:adguard_home_manager/models/app_log.dart';
|
|
|
|
|
|
|
|
class AppLogDetailsModal extends StatefulWidget {
|
|
|
|
final AppLog log;
|
|
|
|
|
|
|
|
const AppLogDetailsModal({
|
|
|
|
Key? key,
|
|
|
|
required this.log
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<AppLogDetailsModal> createState() => _AppLogDetailsModalState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AppLogDetailsModalState extends State<AppLogDetailsModal> {
|
|
|
|
String valueToShow = 'message';
|
|
|
|
|
|
|
|
String generateBody() {
|
|
|
|
switch (valueToShow) {
|
|
|
|
case 'message':
|
|
|
|
return widget.log.message;
|
|
|
|
|
|
|
|
case 'statusCode':
|
|
|
|
return widget.log.statusCode != null
|
|
|
|
? widget.log.statusCode.toString()
|
|
|
|
: "[NO STAUS CODE]";
|
|
|
|
|
|
|
|
case 'body':
|
|
|
|
return widget.log.resBody != null
|
|
|
|
? widget.log.resBody.toString()
|
|
|
|
: "[NO RESPONSE BODY]";
|
|
|
|
|
|
|
|
default:
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AlertDialog(
|
2022-10-17 01:37:11 +02:00
|
|
|
title: Column(
|
|
|
|
children: [
|
2022-11-05 02:35:35 +01:00
|
|
|
Icon(
|
2022-10-17 01:37:11 +02:00
|
|
|
Icons.description_rounded,
|
2022-11-05 02:35:35 +01:00
|
|
|
size: 24,
|
|
|
|
color: Theme.of(context).listTileTheme.iconColor,
|
2022-10-17 01:37:11 +02:00
|
|
|
),
|
2022-11-05 02:35:35 +01:00
|
|
|
const SizedBox(height: 16),
|
2022-10-17 01:37:11 +02:00
|
|
|
Text(
|
|
|
|
AppLocalizations.of(context)!.logDetails,
|
|
|
|
textAlign: TextAlign.center,
|
2022-11-05 02:35:35 +01:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 24,
|
|
|
|
color: Theme.of(context).colorScheme.onSurface
|
2022-10-17 01:37:11 +02:00
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2022-09-30 01:23:28 +02:00
|
|
|
scrollable: true,
|
|
|
|
content: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
2022-10-17 01:37:11 +02:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
2022-09-30 01:23:28 +02:00
|
|
|
children: [
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Material(
|
|
|
|
borderRadius: const BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(15),
|
|
|
|
bottomLeft: Radius.circular(15)
|
|
|
|
),
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
borderRadius: const BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(15),
|
|
|
|
bottomLeft: Radius.circular(15)
|
|
|
|
),
|
|
|
|
onTap: () => setState(() => valueToShow = 'message'),
|
|
|
|
child: AnimatedContainer(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
curve: Curves.easeInOut,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: const BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(15),
|
|
|
|
bottomLeft: Radius.circular(15)
|
|
|
|
),
|
|
|
|
border: Border.all(
|
2023-01-25 20:51:23 +01:00
|
|
|
color: Theme.of(context).colorScheme.primary
|
2022-09-30 01:23:28 +02:00
|
|
|
),
|
|
|
|
color: valueToShow == 'message'
|
2023-01-25 20:51:23 +01:00
|
|
|
? Theme.of(context).colorScheme.primary
|
|
|
|
: Theme.of(context).colorScheme.primary.withOpacity(0.05)
|
2022-09-30 01:23:28 +02:00
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
"Message",
|
|
|
|
style: TextStyle(
|
|
|
|
color: valueToShow == 'message'
|
|
|
|
? Colors.white
|
|
|
|
: null
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () => setState(() => valueToShow = 'statusCode'),
|
|
|
|
child: AnimatedContainer(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
curve: Curves.easeInOut,
|
|
|
|
decoration: BoxDecoration(
|
2022-10-17 01:37:11 +02:00
|
|
|
border: Border(
|
|
|
|
top: BorderSide(
|
2023-01-25 20:51:23 +01:00
|
|
|
color: Theme.of(context).colorScheme.primary
|
2022-10-17 01:37:11 +02:00
|
|
|
),
|
|
|
|
bottom: BorderSide(
|
2023-01-25 20:51:23 +01:00
|
|
|
color: Theme.of(context).colorScheme.primary
|
2022-10-17 01:37:11 +02:00
|
|
|
),
|
2022-09-30 01:23:28 +02:00
|
|
|
),
|
|
|
|
color: valueToShow == 'statusCode'
|
2023-01-25 20:51:23 +01:00
|
|
|
? Theme.of(context).colorScheme.primary
|
|
|
|
: Theme.of(context).colorScheme.primary.withOpacity(0.05)
|
2022-09-30 01:23:28 +02:00
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
"Status code",
|
|
|
|
style: TextStyle(
|
|
|
|
color: valueToShow == 'statusCode'
|
|
|
|
? Colors.white
|
|
|
|
: null
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Material(
|
|
|
|
borderRadius: const BorderRadius.only(
|
|
|
|
topRight: Radius.circular(15),
|
|
|
|
bottomRight: Radius.circular(15)
|
|
|
|
),
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
borderRadius: const BorderRadius.only(
|
|
|
|
topRight: Radius.circular(15),
|
|
|
|
bottomRight: Radius.circular(15)
|
|
|
|
),
|
|
|
|
onTap: () => setState(() => valueToShow = 'body'),
|
|
|
|
child: AnimatedContainer(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
curve: Curves.easeInOut,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: const BorderRadius.only(
|
|
|
|
topRight: Radius.circular(15),
|
|
|
|
bottomRight: Radius.circular(15)
|
|
|
|
),
|
|
|
|
border: Border.all(
|
2023-01-25 20:51:23 +01:00
|
|
|
color: Theme.of(context).colorScheme.primary
|
2022-09-30 01:23:28 +02:00
|
|
|
),
|
|
|
|
color: valueToShow == 'body'
|
2023-01-25 20:51:23 +01:00
|
|
|
? Theme.of(context).colorScheme.primary
|
|
|
|
: Theme.of(context).colorScheme.primary.withOpacity(0.05)
|
2022-09-30 01:23:28 +02:00
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
"Body",
|
|
|
|
style: TextStyle(
|
|
|
|
color: valueToShow == 'body'
|
|
|
|
? Colors.white
|
|
|
|
: null
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
Text(generateBody())
|
|
|
|
],
|
|
|
|
),
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
|
|
|
onPressed: () => Navigator.pop(context),
|
|
|
|
child: const Text("Close")
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|