2024-01-15 18:50:33 +02:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2023-04-03 23:43:46 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2023-11-09 18:19:53 +02:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
2023-04-03 23:43:46 +02:00
|
|
|
import 'package:immich_mobile/shared/models/logger_message.model.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
2024-01-15 18:50:33 +02:00
|
|
|
@RoutePage()
|
2023-04-03 23:43:46 +02:00
|
|
|
class AppLogDetailPage extends HookConsumerWidget {
|
|
|
|
const AppLogDetailPage({super.key, required this.logMessage});
|
|
|
|
|
|
|
|
final LoggerMessage logMessage;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2023-11-09 18:19:53 +02:00
|
|
|
var isDarkTheme = context.isDarkTheme;
|
2023-04-03 23:43:46 +02:00
|
|
|
|
2024-02-24 05:38:57 +02:00
|
|
|
buildTextWithCopyButton(String header, String text) {
|
2023-04-03 23:43:46 +02:00
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(bottom: 8.0),
|
|
|
|
child: Text(
|
2024-02-24 05:38:57 +02:00
|
|
|
header,
|
2023-04-03 23:43:46 +02:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.0,
|
2023-11-09 18:19:53 +02:00
|
|
|
color: context.primaryColor,
|
2023-04-03 23:43:46 +02:00
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
IconButton(
|
|
|
|
onPressed: () {
|
2024-02-24 05:38:57 +02:00
|
|
|
Clipboard.setData(ClipboardData(text: text)).then((_) {
|
2023-04-03 23:43:46 +02:00
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
2023-11-29 06:17:29 +02:00
|
|
|
SnackBar(
|
|
|
|
content: Text(
|
|
|
|
"Copied to clipboard",
|
|
|
|
style: context.textTheme.bodyLarge?.copyWith(
|
|
|
|
color: context.primaryColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2023-04-03 23:43:46 +02:00
|
|
|
);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
icon: Icon(
|
|
|
|
Icons.copy,
|
|
|
|
size: 16.0,
|
2023-11-09 18:19:53 +02:00
|
|
|
color: context.primaryColor,
|
2023-04-03 23:43:46 +02:00
|
|
|
),
|
2023-08-19 00:52:40 +02:00
|
|
|
),
|
2023-04-03 23:43:46 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
2023-11-09 18:19:53 +02:00
|
|
|
color: isDarkTheme ? Colors.grey[900] : Colors.grey[200],
|
2023-04-03 23:43:46 +02:00
|
|
|
borderRadius: BorderRadius.circular(15.0),
|
|
|
|
),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: SelectableText(
|
2024-02-24 05:38:57 +02:00
|
|
|
text,
|
2023-04-03 23:43:46 +02:00
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 12.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontFamily: "Inconsolata",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
buildLogContext1(String context1) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(bottom: 8.0),
|
|
|
|
child: Text(
|
|
|
|
"FROM",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.0,
|
2023-11-09 18:19:53 +02:00
|
|
|
color: context.primaryColor,
|
2023-04-03 23:43:46 +02:00
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
2023-11-09 18:19:53 +02:00
|
|
|
color: isDarkTheme ? Colors.grey[900] : Colors.grey[200],
|
2023-04-03 23:43:46 +02:00
|
|
|
borderRadius: BorderRadius.circular(15.0),
|
|
|
|
),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: SelectableText(
|
|
|
|
context1.toString(),
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 12.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontFamily: "Inconsolata",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: const Text("Log Detail"),
|
|
|
|
),
|
|
|
|
body: SafeArea(
|
|
|
|
child: ListView(
|
|
|
|
children: [
|
2024-02-24 05:38:57 +02:00
|
|
|
buildTextWithCopyButton("MESSAGE", logMessage.message),
|
|
|
|
if (logMessage.details != null)
|
|
|
|
buildTextWithCopyButton("DETAILS", logMessage.details.toString()),
|
2023-04-03 23:43:46 +02:00
|
|
|
if (logMessage.context1 != null)
|
|
|
|
buildLogContext1(logMessage.context1.toString()),
|
|
|
|
if (logMessage.context2 != null)
|
2024-02-24 05:38:57 +02:00
|
|
|
buildTextWithCopyButton(
|
|
|
|
"STACK TRACE",
|
|
|
|
logMessage.context2.toString(),
|
|
|
|
),
|
2023-04-03 23:43:46 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|