refactored broad range of the application, split files, modularized calendar and file views, centralized bottom sheets and clipboard handling, and implemented unit test coverage
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../utils/clipboard_helper.dart';
|
||||
|
||||
class JsonViewer extends StatelessWidget {
|
||||
final String title;
|
||||
@@ -19,30 +20,26 @@ class JsonViewer extends StatelessWidget {
|
||||
child: Text(format(data)),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
static final _encoder = const JsonEncoder.withIndent(' ');
|
||||
|
||||
static String format(Map<String, dynamic> jsonInput) => _encoder.convert(jsonInput);
|
||||
|
||||
static void asDialog(BuildContext context, Map<String, dynamic> dataMap) {
|
||||
showDialog(context: context, builder: (context) => AlertDialog(
|
||||
showDialog(context: context, builder: (dialogCtx) => AlertDialog(
|
||||
scrollable: true,
|
||||
title: const Row(children: [Icon(Icons.bug_report_outlined), Text('Rohdaten')]),
|
||||
content: Text(JsonViewer.format(dataMap)),
|
||||
actions: [
|
||||
TextButton(onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: JsonViewer.format(dataMap))).then((value) {
|
||||
if (!context.mounted) return;
|
||||
showDialog(context: context, builder: (context) => const AlertDialog(content: Text('Formatiertes JSON wurde erfolgreich in deiner Zwischenlage abgelegt.')));
|
||||
});
|
||||
}, child: const Text('Kopieren')),
|
||||
TextButton(onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: dataMap.toString())).then((value) {
|
||||
if (!context.mounted) return;
|
||||
showDialog(context: context, builder: (context) => const AlertDialog(content: Text('Unformatiertes JSON wurde erfolgreich in deiner Zwischenablage abgelegt.')));
|
||||
});
|
||||
}, child: const Text('Inline Kopieren')),
|
||||
TextButton(onPressed: () => Navigator.of(context).pop(), child: const Text('Schließen'))
|
||||
TextButton(
|
||||
onPressed: () => copyToClipboard(dialogCtx, JsonViewer.format(dataMap), successMessage: 'Formatiertes JSON kopiert'),
|
||||
child: const Text('Kopieren'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => copyToClipboard(dialogCtx, dataMap.toString(), successMessage: 'Inline JSON kopiert'),
|
||||
child: const Text('Inline Kopieren'),
|
||||
),
|
||||
TextButton(onPressed: () => Navigator.of(dialogCtx).pop(), child: const Text('Schließen'))
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user