refactor: SSHClientX.exec

This commit is contained in:
lollipopkit🏳️‍⚧️
2024-08-15 11:27:22 +08:00
parent 267b0b0a69
commit 195ddd2bcc
16 changed files with 155 additions and 221 deletions

View File

@@ -156,9 +156,8 @@ class BackupPage extends StatelessWidget {
trailing: ListenableBuilder(
listenable: webdavLoading,
builder: (_, __) {
if (webdavLoading.value) {
return UIs.centerSizedLoadingSmall;
}
if (webdavLoading.value) return SizedLoading.centerSmall;
return Row(
mainAxisSize: MainAxisSize.min,
children: [

View File

@@ -199,7 +199,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
return;
}
FocusScope.of(context).unfocus();
_loading.value = UIs.centerSizedLoading;
_loading.value = SizedLoading.centerMedium;
try {
final decrypted = await Computer.shared.start(decyptPem, [key, pwd]);
final pki = PrivateKeyInfo(id: name, key: decrypted);

View File

@@ -606,7 +606,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
_tags.value = spi.tags?.toSet() ?? {};
_altUrlController.text = spi.alterUrl ?? '';
_autoConnect.value = spi.autoConnect ?? true;
_autoConnect.value = spi.autoConnect;
_jumpServer.value = spi.jumpId;
final custom = spi.custom;

View File

@@ -64,24 +64,22 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
}
Widget _buildSortMenu() {
final options = [
(_SortType.name, libL10n.name),
(_SortType.size, l10n.size),
(_SortType.time, l10n.time),
];
return ValBuilder(
listenable: _sortOption,
builder: (value) {
return PopupMenuButton<_SortType>(
icon: const Icon(Icons.sort),
itemBuilder: (context) {
final currentSelectedOption = _sortOption.value;
final options = [
(_SortType.name, libL10n.name),
(_SortType.size, l10n.size),
(_SortType.time, l10n.time),
];
return options.map((r) {
final (type, name) = r;
final selected = type == currentSelectedOption.sortBy;
final title = selected
? "$name (${currentSelectedOption.reversed ? '-' : '+'})"
: name;
final selected = type == value.sortBy;
final title =
selected ? "$name (${value.reversed ? '-' : '+'})" : name;
return PopupMenuItem(
value: type,
child: Text(
@@ -607,7 +605,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
/// Issue #97
/// In order to compatible with the Synology NAS
/// which not has '.' and '..' in listdir
if (fs.isNotEmpty && fs.firstOrNull?.filename == '.') {
if (fs.firstOrNull?.filename == '.') {
fs.removeAt(0);
}

View File

@@ -54,9 +54,9 @@ final class _SystemdPageState extends State<SystemdPage> {
(isBusy) => AnimatedContainer(
duration: Durations.medium1,
curve: Curves.fastEaseInToSlowEaseOut,
height: isBusy ? 50 : 0,
height: isBusy ? 30 : 0,
child: isBusy
? UIs.centerSizedLoadingSmall.paddingOnly(bottom: 7)
? SizedLoading.centerSmall.paddingOnly(bottom: 7)
: const SizedBox.shrink(),
),
),
@@ -71,8 +71,7 @@ final class _SystemdPageState extends State<SystemdPage> {
(units) {
if (units.isEmpty) {
return SliverToBoxAdapter(
child: ListTile(title: Text(libL10n.empty))
.cardx
child: CenterGreyTitle(libL10n.empty)
.paddingSymmetric(horizontal: 13),
);
}
@@ -103,7 +102,7 @@ final class _SystemdPageState extends State<SystemdPage> {
return PopupMenu(
items: unit.availableFuncs.map(_buildUnitFuncBtn).toList(),
onSelected: (val) async {
final cmd = unit.getCmd(func: val, isRoot: _pro.isRoot.value);
final cmd = unit.getCmd(func: val, isRoot: _pro.isRoot);
final sure = await context.showRoundDialog(
title: libL10n.attention,
child: SimpleMarkdown(data: '```shell\n$cmd\n```'),