Compare commits

..

No commits in common. "a2e70f7dffda2a669fb6018fbdbc39fd87d7deae" and "7f0200885cd73b84f6f95429b31109d97c9956d6" have entirely different histories.

View File

@ -1,6 +1,5 @@
import 'dart:convert';
import 'dart:io';
import 'dart:ui';
import 'package:dartssh2/dartssh2.dart';
import 'package:flutter/material.dart';
@ -22,21 +21,6 @@ import 'authentik_api.dart' as authentik;
import 'package:app_links/app_links.dart';
void main() {
final errorNotifier = ValueNotifier<String?>(null);
// Fehler-Handler registrieren
PlatformDispatcher.instance.onError = (error, stack) {
final timeStr = DateTime.now().toIso8601String();
final errorMessage = 'Time: $timeStr\nError: $error\nStack: $stack';
if (errorNotifier.value == null) {
errorNotifier.value = errorMessage;
} else {
errorNotifier.value = errorNotifier.value! + '\n\n' + errorMessage;
}
return true;
};
runApp(
MultiProvider(
providers: [
@ -44,7 +28,7 @@ void main() {
create: (context) => AuthentikUserSettingsChangeDialogState(),
), // Do something (navigation, ...)
],
child: MyApp(errorNotifier: errorNotifier),
child: const MyApp(),
),
);
}
@ -73,9 +57,7 @@ String encodePublicKey(OpenSSHEd25519KeyPair keyPair, {String comment = ''}) {
}
class MyApp extends StatelessWidget {
final ValueNotifier<String?> errorNotifier;
const MyApp({super.key, required this.errorNotifier});
const MyApp({super.key});
@override
Widget build(BuildContext context) {
@ -84,23 +66,15 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.yellow),
),
home: MyHomePage(
title: 'LeineLab e.V. Key App',
errorNotifier: errorNotifier,
),
home: const MyHomePage(title: 'LeineLab e.V. Key App'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({
super.key,
required this.title,
required this.errorNotifier,
});
const MyHomePage({super.key, required this.title});
final String title;
final ValueNotifier<String?> errorNotifier;
@override
State<MyHomePage> createState() => _MyHomePageState();
@ -428,64 +402,6 @@ class _MyHomePageState extends State<MyHomePage> {
),
);
final bodyComponentLogs = Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.all(20),
child: Card(
child: Padding(
padding: EdgeInsets.all(20),
child: ValueListenableBuilder<String?>(
valueListenable: widget.errorNotifier,
builder: (context, error, child) {
if (error != null) {
return Text(
"Error: $error",
style: TextStyle(color: Colors.red, fontSize: 15),
);
}
return Text("No exceptions captured yet.");
},
),
),
),
),
],
),
),
);
final actionButtonLogs = FloatingActionButton(
onPressed: () {
// Copy the logs to the clipboard
final error = widget.errorNotifier.value;
if (error != null) {
SystemChannels.platform.invokeMethod<void>(
'Clipboard.setData',
<String, dynamic>{'text': error},
);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("Logs copied to clipboard."),
duration: const Duration(seconds: 3),
),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("No logs to copy."),
duration: const Duration(seconds: 3),
),
);
}
},
tooltip: 'Copy Logs',
child: const Icon(Icons.copy),
);
final actionButtonInfo = FloatingActionButton(
onPressed: () => obtainKeyPair(regenerate: true),
tooltip: 'Regenerate Key',
@ -503,10 +419,6 @@ class _MyHomePageState extends State<MyHomePage> {
// Info page
bodyComponent = bodyComponentInfo;
actionButton = actionButtonInfo;
} else if (navIndex == 2) {
// Logs page
bodyComponent = bodyComponentLogs;
actionButton = actionButtonLogs;
} else {
throw Exception('Unknown navIndex: $navIndex');
}
@ -544,15 +456,6 @@ class _MyHomePageState extends State<MyHomePage> {
Navigator.pop(context);
},
),
ListTile(
title: const Text('Logs'),
onTap: () {
setState(() {
navIndex = 2;
});
Navigator.pop(context);
},
),
],
),
),