ente/lib/ui/tools/debug/log_file_viewer.dart

58 lines
1.2 KiB
Dart
Raw Normal View History

2021-08-09 14:35:17 +00:00
import 'dart:io';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:photos/ui/common/loading_widget.dart';
2021-08-09 14:35:17 +00:00
class LogFileViewer extends StatefulWidget {
final File file;
const LogFileViewer(this.file, {Key? key}) : super(key: key);
2021-08-09 14:35:17 +00:00
@override
2022-07-03 09:45:00 +00:00
State<LogFileViewer> createState() => _LogFileViewerState();
2021-08-09 14:35:17 +00:00
}
class _LogFileViewerState extends State<LogFileViewer> {
String? _logs;
2021-08-09 14:35:17 +00:00
@override
void initState() {
widget.file.readAsString().then((logs) {
setState(() {
_logs = logs;
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
2022-07-04 06:02:17 +00:00
title: const Text("Today's logs"),
2021-08-09 14:35:17 +00:00
),
body: _getBody(),
);
}
Widget _getBody() {
if (_logs == null) {
return const EnteLoadingWidget();
2021-08-09 14:35:17 +00:00
}
return Container(
2022-07-04 06:02:17 +00:00
padding: const EdgeInsets.only(left: 12, top: 8, right: 12),
2021-08-09 14:35:17 +00:00
child: SingleChildScrollView(
child: Text(
_logs!,
2022-07-04 06:02:17 +00:00
style: const TextStyle(
fontFeatures: [
2021-08-09 14:35:17 +00:00
FontFeature.tabularFigures(),
],
2021-08-09 14:55:34 +00:00
height: 1.2,
2021-08-09 14:35:17 +00:00
),
),
),
);
}
}