mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
fix
This commit is contained in:
@@ -121,7 +121,7 @@ Future<void> loadFontFile(String? localPath) async {
|
||||
void showSnippetDialog(
|
||||
BuildContext context,
|
||||
S s,
|
||||
Function(Snippet s) onSelected,
|
||||
void Function(Snippet s) onSelected,
|
||||
) {
|
||||
final provider = locator<SnippetProvider>();
|
||||
if (provider.snippets.isEmpty) {
|
||||
|
||||
@@ -68,19 +68,20 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
}
|
||||
|
||||
PreferredSizeWidget _buildAppBar() {
|
||||
return AppBar(
|
||||
title: Text(_s.edit, style: textSize18),
|
||||
actions: [
|
||||
widget.info != null
|
||||
? IconButton(
|
||||
final actions = widget.info == null
|
||||
? null
|
||||
: [
|
||||
IconButton(
|
||||
tooltip: _s.delete,
|
||||
onPressed: () {
|
||||
_provider.delInfo(widget.info!);
|
||||
context.pop();
|
||||
},
|
||||
icon: const Icon(Icons.delete))
|
||||
: nil
|
||||
],
|
||||
];
|
||||
return AppBar(
|
||||
title: Text(_s.edit, style: textSize18),
|
||||
actions: actions,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'package:after_layout/after_layout.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:nil/nil.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/extension/navigator.dart';
|
||||
import 'package:toolbox/view/widget/input_field.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
|
||||
import '../../../core/route.dart';
|
||||
import '../../../core/utils/ui.dart';
|
||||
@@ -97,90 +97,91 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
},
|
||||
icon: const Icon(Icons.delete),
|
||||
);
|
||||
final actions = widget.spi != null ? [delBtn] : null;
|
||||
return AppBar(
|
||||
title: Text(_s.edit, style: textSize18),
|
||||
actions: [
|
||||
widget.spi != null ? delBtn : nil,
|
||||
],
|
||||
actions: actions,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildForm() {
|
||||
final children = [
|
||||
Input(
|
||||
controller: _nameController,
|
||||
type: TextInputType.text,
|
||||
node: _nameFocus,
|
||||
onSubmitted: (_) => _focusScope.requestFocus(_ipFocus),
|
||||
hint: _s.exampleName,
|
||||
label: _s.name,
|
||||
icon: Icons.info,
|
||||
),
|
||||
Input(
|
||||
controller: _ipController,
|
||||
type: TextInputType.text,
|
||||
onSubmitted: (_) => _focusScope.requestFocus(_portFocus),
|
||||
node: _ipFocus,
|
||||
label: _s.host,
|
||||
icon: Icons.storage,
|
||||
hint: 'example.com',
|
||||
),
|
||||
Input(
|
||||
controller: _portController,
|
||||
type: TextInputType.number,
|
||||
node: _portFocus,
|
||||
onSubmitted: (_) => _focusScope.requestFocus(_usernameFocus),
|
||||
label: _s.port,
|
||||
icon: Icons.format_list_numbered,
|
||||
hint: '22',
|
||||
),
|
||||
Input(
|
||||
controller: _usernameController,
|
||||
type: TextInputType.text,
|
||||
node: _usernameFocus,
|
||||
label: _s.user,
|
||||
icon: Icons.account_box,
|
||||
hint: 'root',
|
||||
),
|
||||
TagEditor(
|
||||
tags: _tags,
|
||||
onChanged: (p0) => setState(() {
|
||||
_tags = p0;
|
||||
}),
|
||||
s: _s,
|
||||
tagSuggestions: [..._serverProvider.tags],
|
||||
onRenameTag: _serverProvider.renameTag,
|
||||
),
|
||||
width7,
|
||||
Row(
|
||||
children: [
|
||||
width13,
|
||||
Text(_s.keyAuth),
|
||||
width13,
|
||||
Switch(
|
||||
value: usePublicKey,
|
||||
onChanged: (val) => setState(() => usePublicKey = val),
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
if (usePublicKey) {
|
||||
children.add(_buildKeyAuth());
|
||||
} else {
|
||||
children.add(Input(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
type: TextInputType.text,
|
||||
label: _s.pwd,
|
||||
icon: Icons.password,
|
||||
hint: _s.pwd,
|
||||
onSubmitted: (_) => {},
|
||||
));
|
||||
}
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(17),
|
||||
padding: const EdgeInsets.fromLTRB(17, 17, 17, 47),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Input(
|
||||
controller: _nameController,
|
||||
type: TextInputType.text,
|
||||
node: _nameFocus,
|
||||
onSubmitted: (_) => _focusScope.requestFocus(_ipFocus),
|
||||
hint: _s.exampleName,
|
||||
label: _s.name,
|
||||
icon: Icons.info,
|
||||
),
|
||||
Input(
|
||||
controller: _ipController,
|
||||
type: TextInputType.text,
|
||||
onSubmitted: (_) => _focusScope.requestFocus(_portFocus),
|
||||
node: _ipFocus,
|
||||
label: _s.host,
|
||||
icon: Icons.storage,
|
||||
hint: 'example.com',
|
||||
),
|
||||
Input(
|
||||
controller: _portController,
|
||||
type: TextInputType.number,
|
||||
node: _portFocus,
|
||||
onSubmitted: (_) => _focusScope.requestFocus(_usernameFocus),
|
||||
label: _s.port,
|
||||
icon: Icons.format_list_numbered,
|
||||
hint: '22',
|
||||
),
|
||||
Input(
|
||||
controller: _usernameController,
|
||||
type: TextInputType.text,
|
||||
node: _usernameFocus,
|
||||
label: _s.user,
|
||||
icon: Icons.account_box,
|
||||
hint: 'root',
|
||||
),
|
||||
TagEditor(
|
||||
tags: _tags,
|
||||
onChanged: (p0) => setState(() {
|
||||
_tags = p0;
|
||||
}),
|
||||
s: _s,
|
||||
tagSuggestions: [..._serverProvider.tags],
|
||||
onRenameTag: _serverProvider.renameTag,
|
||||
),
|
||||
width7,
|
||||
Row(
|
||||
children: [
|
||||
width13,
|
||||
Text(_s.keyAuth),
|
||||
width13,
|
||||
Switch(
|
||||
value: usePublicKey,
|
||||
onChanged: (val) => setState(() => usePublicKey = val),
|
||||
),
|
||||
],
|
||||
),
|
||||
!usePublicKey
|
||||
? Input(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
type: TextInputType.text,
|
||||
label: _s.pwd,
|
||||
icon: Icons.password,
|
||||
hint: _s.pwd,
|
||||
onSubmitted: (_) => {},
|
||||
)
|
||||
: nil,
|
||||
usePublicKey ? _buildKeyAuth() : nil
|
||||
],
|
||||
children: children,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -215,11 +216,12 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
),
|
||||
),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17),
|
||||
child: Column(
|
||||
children: tiles,
|
||||
),
|
||||
return RoundRectCard(
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17),
|
||||
child: Column(
|
||||
children: tiles,
|
||||
)),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'dart:typed_data';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:nil/nil.dart';
|
||||
import 'package:toolbox/core/extension/navigator.dart';
|
||||
import 'package:toolbox/core/extension/sftpfile.dart';
|
||||
import 'package:toolbox/data/res/misc.dart';
|
||||
@@ -119,7 +118,6 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Divider(),
|
||||
(_status.path?.path ?? _s.loadingFiles).omitStartStr(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
@@ -299,36 +297,37 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
}
|
||||
|
||||
void _onItemPress(BuildContext context, SftpName file, bool notDir) {
|
||||
final children = [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.delete),
|
||||
title: Text(_s.delete),
|
||||
onTap: () => _delete(context, file),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.abc),
|
||||
title: Text(_s.rename),
|
||||
onTap: () => _rename(context, file),
|
||||
),
|
||||
];
|
||||
if (notDir) {
|
||||
children.addAll([
|
||||
ListTile(
|
||||
leading: const Icon(Icons.edit),
|
||||
title: Text(_s.edit),
|
||||
onTap: () => _edit(context, file),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.download),
|
||||
title: Text(_s.download),
|
||||
onTap: () => _download(context, file),
|
||||
),
|
||||
]);
|
||||
}
|
||||
showRoundDialog(
|
||||
context: context,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
notDir
|
||||
? ListTile(
|
||||
leading: const Icon(Icons.edit),
|
||||
title: Text(_s.edit),
|
||||
onTap: () => _edit(context, file),
|
||||
)
|
||||
: nil,
|
||||
ListTile(
|
||||
leading: const Icon(Icons.delete),
|
||||
title: Text(_s.delete),
|
||||
onTap: () => _delete(context, file),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.abc),
|
||||
title: Text(_s.rename),
|
||||
onTap: () => _rename(context, file),
|
||||
),
|
||||
notDir
|
||||
? ListTile(
|
||||
leading: const Icon(Icons.download),
|
||||
title: Text(_s.download),
|
||||
onTap: () => _download(context, file),
|
||||
)
|
||||
: nil,
|
||||
],
|
||||
children: children,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -131,6 +131,10 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
if (widget.snippet != null) {
|
||||
_nameController.text = widget.snippet!.name;
|
||||
_scriptController.text = widget.snippet!.script;
|
||||
if (widget.snippet!.tags != null) {
|
||||
_tags = widget.snippet!.tags!;
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user