mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 13:08:42 +00:00
fix #115
This commit is contained in:
parent
d8155765a6
commit
cbe2619a06
1 changed files with 65 additions and 46 deletions
|
|
@ -4,13 +4,30 @@ import 'package:path_provider/path_provider.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:twonly/src/utils/misc.dart';
|
||||
|
||||
class DiagnosticsView extends StatelessWidget {
|
||||
class DiagnosticsView extends StatefulWidget {
|
||||
const DiagnosticsView({super.key});
|
||||
|
||||
@override
|
||||
State<DiagnosticsView> createState() => _DiagnosticsViewState();
|
||||
}
|
||||
|
||||
class _DiagnosticsViewState extends State<DiagnosticsView> {
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
||||
void _scrollToBottom() {
|
||||
// Assuming the button is at the bottom of the scroll view
|
||||
_scrollController.animateTo(
|
||||
_scrollController.position.maxScrollExtent, // Scroll to the bottom
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: FutureBuilder<String>(
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Diagnostics')),
|
||||
body: FutureBuilder<String>(
|
||||
future: _loadLogFile(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
|
|
@ -20,54 +37,56 @@ class DiagnosticsView extends StatelessWidget {
|
|||
} else {
|
||||
final logText = snapshot.data ?? '';
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Diagnostics')),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Text(logText),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
controller: _scrollController,
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: logText));
|
||||
child: Text(logText),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: logText));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Log copied to clipboard!')),
|
||||
);
|
||||
},
|
||||
child: const Text('Copy All Text'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: _scrollToBottom,
|
||||
child: const Text('Scroll to Bottom'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (await deleteLogFile()) {
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Log copied to clipboard!')),
|
||||
content: Text('Log file deleted!')),
|
||||
);
|
||||
},
|
||||
child: const Text('Copy All Text'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (await deleteLogFile()) {
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Log file deleted!')),
|
||||
);
|
||||
} else {
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Log file does not exist.')),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text('Delete Log File'),
|
||||
),
|
||||
],
|
||||
),
|
||||
} else {
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Log file does not exist.')),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text('Delete Log File'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue