Completed basic functionality

This commit is contained in:
MaticIvesic committed 2026-02-02 20:52:17 +01:00
1 parent 922f26310a
commit 78f2dfa742
55 files changed
+1399 -101

No files matched your search

+87
View File
@@ -0,0 +1,87 @@
import 'package:flutter/material.dart';
import 'package:QuickSSH/classes/ServerCommand.dart';
import 'package:QuickSSH/services/SSHService.dart';
import 'package:flutter/services.dart';
class ServerStatusTile extends StatelessWidget {
final ServerCommand command;
final VoidCallback onEdit;
const ServerStatusTile({
super.key,
required this.command,
required this.onEdit,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context).colorScheme;
return Card(
clipBehavior: Clip.antiAlias,
color: theme.primaryContainer,
child: InkWell(
splashColor: const Color.fromARGB(
47,
255,
255,
255,
), // Custom ripple color!
highlightColor: Colors.transparent,
onDoubleTap: () {
HapticFeedback.heavyImpact();
_handleCommandTap(context, command);
},
onLongPress: () {
HapticFeedback.heavyImpact();
onEdit();
},
child: IgnorePointer(
child: ListTile(
title: Text(
command.name,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: theme.onSurface,
),
),
subtitle: Text(
"${command.username}@${command.ip}",
style: TextStyle(color: theme.onSurfaceVariant),
),
),
),
),
);
}
void _handleCommandTap(BuildContext context, ServerCommand cmd) async {
// Show a "Loading" snackbar
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
behavior: SnackBarBehavior.floating,
content: Text("Connecting to ${cmd.ip} as ${cmd.username}..."),
duration: Duration(seconds: 2),
backgroundColor: const Color.fromARGB(255, 56, 159, 243),
),
);
// Run the SSH command
String output = await SSHService.execute(cmd);
// Show the final result from the server
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
behavior: SnackBarBehavior.floating,
content: Text(output.isEmpty ? "Command executed (no output)" : output),
backgroundColor: output.contains("Error") ? Colors.red : Colors.green,
),
);
}
}