mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
66 lines
1.6 KiB
Dart
66 lines
1.6 KiB
Dart
import 'package:fl_lib/fl_lib.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:toolbox/core/extension/context/locale.dart';
|
|
import 'package:toolbox/core/route.dart';
|
|
import 'package:toolbox/data/model/server/server_private_info.dart';
|
|
|
|
class IPerfPage extends StatefulWidget {
|
|
final ServerPrivateInfo spi;
|
|
const IPerfPage({super.key, required this.spi});
|
|
|
|
@override
|
|
State<IPerfPage> createState() => _IPerfPageState();
|
|
}
|
|
|
|
class _IPerfPageState extends State<IPerfPage> {
|
|
final _hostCtrl = TextEditingController();
|
|
final _portCtrl = TextEditingController();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: const CustomAppBar(
|
|
title: Text('iperf'),
|
|
),
|
|
body: _buildBody(),
|
|
floatingActionButton: _buildFAB(),
|
|
);
|
|
}
|
|
|
|
Widget _buildFAB() {
|
|
return FloatingActionButton(
|
|
heroTag: 'iperf',
|
|
child: const Icon(Icons.send),
|
|
onPressed: () {
|
|
if (_hostCtrl.text.isEmpty || _portCtrl.text.isEmpty) {
|
|
context.showSnackBar(l10n.fieldMustNotEmpty);
|
|
return;
|
|
}
|
|
AppRoutes.ssh(
|
|
spi: widget.spi,
|
|
initCmd: 'iperf -c ${_hostCtrl.text} -p ${_portCtrl.text}',
|
|
).go(context);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _buildBody() {
|
|
return ListView(
|
|
padding: const EdgeInsets.symmetric(horizontal: 17),
|
|
children: [
|
|
Input(
|
|
controller: _hostCtrl,
|
|
label: l10n.host,
|
|
icon: Icons.computer,
|
|
),
|
|
Input(
|
|
controller: _portCtrl,
|
|
label: l10n.port,
|
|
type: TextInputType.number,
|
|
icon: Icons.numbers,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|