mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
@@ -60,7 +60,7 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<ContainerProvider>(
|
||||
builder: (_, ___, __) {
|
||||
builder: (_, _, _) {
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
centerTitle: true,
|
||||
|
||||
@@ -15,14 +15,10 @@ class PingPage extends StatefulWidget {
|
||||
@override
|
||||
State<PingPage> createState() => _PingPageState();
|
||||
|
||||
static const route = AppRouteNoArg(
|
||||
page: PingPage.new,
|
||||
path: '/ping',
|
||||
);
|
||||
static const route = AppRouteNoArg(page: PingPage.new, path: '/ping');
|
||||
}
|
||||
|
||||
class _PingPageState extends State<PingPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
class _PingPageState extends State<PingPage> with AutomaticKeepAliveClientMixin {
|
||||
late TextEditingController _textEditingController;
|
||||
final _results = ValueNotifier(<PingResult>[]);
|
||||
bool get isInit => _results.value.isEmpty;
|
||||
@@ -43,13 +39,7 @@ class _PingPageState extends State<PingPage>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Scaffold(
|
||||
body: ListenableBuilder(
|
||||
listenable: _results,
|
||||
builder: (_, __) => _buildBody(),
|
||||
),
|
||||
floatingActionButton: _buildFAB(),
|
||||
);
|
||||
return Scaffold(body: _results.listenVal(_buildBody), floatingActionButton: _buildFAB());
|
||||
}
|
||||
|
||||
Widget _buildFAB() {
|
||||
@@ -81,26 +71,21 @@ class _PingPageState extends State<PingPage>
|
||||
context.showRoundDialog(
|
||||
title: libL10n.error,
|
||||
child: Text(e.toString()),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Pfs.copy(e.toString()),
|
||||
child: Text(libL10n.copy),
|
||||
),
|
||||
],
|
||||
actions: [TextButton(onPressed: () => Pfs.copy(e.toString()), child: Text(libL10n.copy))],
|
||||
);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
Widget _buildBody(List<PingResult> results) {
|
||||
if (isInit) {
|
||||
return Center(child: Text(libL10n.empty));
|
||||
}
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(11),
|
||||
controller: ScrollController(),
|
||||
itemCount: _results.value.length,
|
||||
itemBuilder: (_, index) => _buildResultItem(_results.value[index]),
|
||||
itemCount: results.length,
|
||||
itemBuilder: (_, index) => _buildResultItem(results[index]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -112,22 +97,12 @@ class _PingPageState extends State<PingPage>
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 7, horizontal: 17),
|
||||
title: Text(
|
||||
result.serverName,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: UIs.primaryColor,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
_buildPingSummary(result, unknown, ms),
|
||||
style: UIs.text11,
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: UIs.primaryColor),
|
||||
),
|
||||
subtitle: Text(_buildPingSummary(result, unknown, ms), style: UIs.text11),
|
||||
trailing: Text(
|
||||
'${l10n.pingAvg}${result.statistic?.avg?.toStringAsFixed(2) ?? l10n.unknown} $ms',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: UIs.primaryColor,
|
||||
),
|
||||
style: TextStyle(fontSize: 14, color: UIs.primaryColor),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -165,20 +140,22 @@ class _PingPageState extends State<PingPage>
|
||||
return;
|
||||
}
|
||||
|
||||
await Future.wait(ServerProvider.servers.values.map((v) async {
|
||||
final e = v.value;
|
||||
if (e.client == null) {
|
||||
return;
|
||||
}
|
||||
final result = await e.client!.run('ping -c 3 $target').string;
|
||||
_results.value.add(PingResult.parse(e.spi.name, result));
|
||||
// [ValueNotifier] only notify when value is changed
|
||||
// But we just add a element to list without changing the list itself
|
||||
// So we need to notify manually
|
||||
//
|
||||
// ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member
|
||||
_results.notifyListeners();
|
||||
}));
|
||||
await Future.wait(
|
||||
ServerProvider.servers.values.map((v) async {
|
||||
final e = v.value;
|
||||
if (e.client == null) {
|
||||
return;
|
||||
}
|
||||
final result = await e.client!.run('ping -c 3 $target').string;
|
||||
_results.value.add(PingResult.parse(e.spi.name, result));
|
||||
// [ValueNotifier] only notify when value is changed
|
||||
// But we just add a element to list without changing the list itself
|
||||
// So we need to notify manually
|
||||
//
|
||||
// ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member
|
||||
_results.notifyListeners();
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -20,10 +20,7 @@ class ServerEditPage extends StatefulWidget {
|
||||
|
||||
const ServerEditPage({super.key, this.args});
|
||||
|
||||
static const route = AppRoute<bool, SpiRequiredArgs>(
|
||||
page: ServerEditPage.new,
|
||||
path: '/servers/edit',
|
||||
);
|
||||
static const route = AppRoute<bool, SpiRequiredArgs>(page: ServerEditPage.new, path: '/servers/edit');
|
||||
|
||||
@override
|
||||
State<ServerEditPage> createState() => _ServerEditPageState();
|
||||
@@ -118,15 +115,9 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
}
|
||||
|
||||
Widget _buildForm() {
|
||||
final topItems = [
|
||||
_buildWriteScriptTip(),
|
||||
if (isMobile) _buildQrScan(),
|
||||
];
|
||||
final topItems = [_buildWriteScriptTip(), if (isMobile) _buildQrScan()];
|
||||
final children = [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: topItems.joinWith(UIs.width13).toList(),
|
||||
),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: topItems.joinWith(UIs.width13).toList()),
|
||||
Input(
|
||||
autoFocus: true,
|
||||
controller: _nameController,
|
||||
@@ -173,10 +164,9 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
TagTile(tags: _tags, allTags: ServerProvider.tags.value).cardx,
|
||||
ListTile(
|
||||
title: Text(l10n.autoConnect),
|
||||
trailing: ListenableBuilder(
|
||||
listenable: _autoConnect,
|
||||
builder: (_, __) => Switch(
|
||||
value: _autoConnect.value,
|
||||
trailing: _autoConnect.listenVal(
|
||||
(val) => Switch(
|
||||
value: val,
|
||||
onChanged: (val) {
|
||||
_autoConnect.value = val;
|
||||
},
|
||||
@@ -193,10 +183,9 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
Widget _buildAuth() {
|
||||
final switch_ = ListTile(
|
||||
title: Text(l10n.keyAuth),
|
||||
trailing: ListenableBuilder(
|
||||
listenable: _keyIdx,
|
||||
builder: (_, __) => Switch(
|
||||
value: _keyIdx.value != null,
|
||||
trailing: _keyIdx.listenVal(
|
||||
(v) => Switch(
|
||||
value: v != null,
|
||||
onChanged: (val) {
|
||||
if (val) {
|
||||
_keyIdx.value = -1;
|
||||
@@ -209,14 +198,13 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
);
|
||||
|
||||
/// Put [switch_] out of [ValueBuilder] to avoid rebuild
|
||||
return ListenableBuilder(
|
||||
listenable: _keyIdx,
|
||||
builder: (_, __) {
|
||||
final children = <Widget>[switch_];
|
||||
if (_keyIdx.value != null) {
|
||||
children.add(_buildKeyAuth());
|
||||
} else {
|
||||
children.add(Input(
|
||||
return _keyIdx.listenVal((v) {
|
||||
final children = <Widget>[switch_];
|
||||
if (v != null) {
|
||||
children.add(_buildKeyAuth());
|
||||
} else {
|
||||
children.add(
|
||||
Input(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
type: TextInputType.text,
|
||||
@@ -225,52 +213,43 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
hint: l10n.pwd,
|
||||
suggestion: false,
|
||||
onSubmitted: (_) => _onSave(),
|
||||
));
|
||||
}
|
||||
return Column(children: children);
|
||||
},
|
||||
);
|
||||
),
|
||||
);
|
||||
}
|
||||
return Column(children: children);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildKeyAuth() {
|
||||
return PrivateKeyProvider.pkis.listenVal(
|
||||
(pkis) {
|
||||
final tiles = List<Widget>.generate(pkis.length, (index) {
|
||||
final e = pkis[index];
|
||||
return ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 10, right: 15),
|
||||
leading: Radio<int>(
|
||||
value: index,
|
||||
groupValue: _keyIdx.value,
|
||||
onChanged: (value) => _keyIdx.value = value,
|
||||
),
|
||||
title: Text(e.id, textAlign: TextAlign.start),
|
||||
subtitle: Text(
|
||||
e.type ?? l10n.unknown,
|
||||
textAlign: TextAlign.start,
|
||||
style: UIs.textGrey,
|
||||
),
|
||||
trailing: Btn.icon(
|
||||
icon: const Icon(Icons.edit),
|
||||
onTap: () => PrivateKeyEditPage.route.go(
|
||||
context,
|
||||
args: PrivateKeyEditPageArgs(pki: e),
|
||||
),
|
||||
),
|
||||
onTap: () => _keyIdx.value = index,
|
||||
);
|
||||
});
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(libL10n.add),
|
||||
contentPadding: const EdgeInsets.only(left: 23, right: 23),
|
||||
trailing: const Icon(Icons.add),
|
||||
onTap: () => PrivateKeyEditPage.route.go(context),
|
||||
return PrivateKeyProvider.pkis.listenVal((pkis) {
|
||||
final tiles = List<Widget>.generate(pkis.length, (index) {
|
||||
final e = pkis[index];
|
||||
return ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 10, right: 15),
|
||||
leading: Radio<int>(
|
||||
value: index,
|
||||
groupValue: _keyIdx.value,
|
||||
onChanged: (value) => _keyIdx.value = value,
|
||||
),
|
||||
title: Text(e.id, textAlign: TextAlign.start),
|
||||
subtitle: Text(e.type ?? l10n.unknown, textAlign: TextAlign.start, style: UIs.textGrey),
|
||||
trailing: Btn.icon(
|
||||
icon: const Icon(Icons.edit),
|
||||
onTap: () => PrivateKeyEditPage.route.go(context, args: PrivateKeyEditPageArgs(pki: e)),
|
||||
),
|
||||
onTap: () => _keyIdx.value = index,
|
||||
);
|
||||
return _keyIdx.listenVal((_) => Column(children: tiles)).cardx;
|
||||
},
|
||||
);
|
||||
});
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(libL10n.add),
|
||||
contentPadding: const EdgeInsets.only(left: 23, right: 23),
|
||||
trailing: const Icon(Icons.add),
|
||||
onTap: () => PrivateKeyEditPage.route.go(context),
|
||||
),
|
||||
);
|
||||
return _keyIdx.listenVal((_) => Column(children: tiles)).cardx;
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildEnvs() {
|
||||
@@ -282,10 +261,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
title: Text(l10n.envVars),
|
||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||
onTap: () async {
|
||||
final res = await KvEditor.route.go(
|
||||
context,
|
||||
KvEditorArgs(data: spi?.envs ?? {}),
|
||||
);
|
||||
final res = await KvEditor.route.go(context, KvEditorArgs(data: spi?.envs ?? {}));
|
||||
if (res == null) return;
|
||||
_env.value = res;
|
||||
},
|
||||
@@ -385,10 +361,9 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
ListTile(
|
||||
leading: const Icon(MingCute.certificate_line),
|
||||
title: TipText('PVE ${l10n.ignoreCert}', l10n.pveIgnoreCertTip),
|
||||
trailing: ListenableBuilder(
|
||||
listenable: _pveIgnoreCert,
|
||||
builder: (_, __) => Switch(
|
||||
value: _pveIgnoreCert.value,
|
||||
trailing: _pveIgnoreCert.listenVal(
|
||||
(v) => Switch(
|
||||
value: v,
|
||||
onChanged: (val) {
|
||||
_pveIgnoreCert.value = val;
|
||||
},
|
||||
@@ -404,17 +379,15 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CenterGreyTitle(l10n.customCmd),
|
||||
_customCmds.listenVal(
|
||||
(vals) {
|
||||
return ListTile(
|
||||
leading: const Icon(BoxIcons.bxs_file_json),
|
||||
title: const Text('JSON'),
|
||||
subtitle: vals.isEmpty ? null : Text(vals.keys.join(','), style: UIs.textGrey),
|
||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||
onTap: _onTapCustomItem,
|
||||
);
|
||||
},
|
||||
).cardx,
|
||||
_customCmds.listenVal((vals) {
|
||||
return ListTile(
|
||||
leading: const Icon(BoxIcons.bxs_file_json),
|
||||
title: const Text('JSON'),
|
||||
subtitle: vals.isEmpty ? null : Text(vals.keys.join(','), style: UIs.textGrey),
|
||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||
onTap: _onTapCustomItem,
|
||||
);
|
||||
}).cardx,
|
||||
ListTile(
|
||||
leading: const Icon(MingCute.doc_line),
|
||||
title: Text(libL10n.doc),
|
||||
@@ -464,10 +437,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
}
|
||||
|
||||
Widget _buildFAB() {
|
||||
return FloatingActionButton(
|
||||
onPressed: _onSave,
|
||||
child: const Icon(Icons.save),
|
||||
);
|
||||
return FloatingActionButton(onPressed: _onSave, child: const Icon(Icons.save));
|
||||
}
|
||||
|
||||
Widget _buildJumpServer() {
|
||||
@@ -477,36 +447,31 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
.where((e) => e.spi.jumpId == null)
|
||||
.where((e) => e.spi.id != spi?.id)
|
||||
.toList();
|
||||
final choice = _jumpServer.listenVal(
|
||||
(val) {
|
||||
final srv = srvs.firstWhereOrNull((e) => e.id == _jumpServer.value);
|
||||
return Choice<Server>(
|
||||
multiple: false,
|
||||
clearable: true,
|
||||
value: srv != null ? [srv] : [],
|
||||
builder: (state, _) => Wrap(
|
||||
children: List<Widget>.generate(
|
||||
srvs.length,
|
||||
(index) {
|
||||
final item = srvs[index];
|
||||
return ChoiceChipX<Server>(
|
||||
label: item.spi.name,
|
||||
state: state,
|
||||
value: item,
|
||||
onSelected: (srv, on) {
|
||||
if (on) {
|
||||
_jumpServer.value = srv.spi.id;
|
||||
} else {
|
||||
_jumpServer.value = null;
|
||||
}
|
||||
},
|
||||
);
|
||||
final choice = _jumpServer.listenVal((val) {
|
||||
final srv = srvs.firstWhereOrNull((e) => e.id == _jumpServer.value);
|
||||
return Choice<Server>(
|
||||
multiple: false,
|
||||
clearable: true,
|
||||
value: srv != null ? [srv] : [],
|
||||
builder: (state, _) => Wrap(
|
||||
children: List<Widget>.generate(srvs.length, (index) {
|
||||
final item = srvs[index];
|
||||
return ChoiceChipX<Server>(
|
||||
label: item.spi.name,
|
||||
state: state,
|
||||
value: item,
|
||||
onSelected: (srv, on) {
|
||||
if (on) {
|
||||
_jumpServer.value = srv.spi.id;
|
||||
} else {
|
||||
_jumpServer.value = null;
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
return ExpandTile(
|
||||
leading: const Icon(Icons.map),
|
||||
initiallyExpanded: _jumpServer.value != null,
|
||||
@@ -537,10 +502,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
text: libL10n.import,
|
||||
icon: const Icon(Icons.qr_code, color: Colors.grey),
|
||||
onTap: () async {
|
||||
final ret = await BarcodeScannerPage.route.go(
|
||||
context,
|
||||
args: const BarcodeScannerPageArgs(),
|
||||
);
|
||||
final ret = await BarcodeScannerPage.route.go(context, args: const BarcodeScannerPageArgs());
|
||||
final code = ret?.text;
|
||||
if (code == null) return;
|
||||
try {
|
||||
@@ -560,9 +522,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
onPressed: () {
|
||||
context.showRoundDialog(
|
||||
title: libL10n.attention,
|
||||
child: Text(libL10n.askContinue(
|
||||
'${libL10n.delete} ${l10n.server}(${spi!.name})',
|
||||
)),
|
||||
child: Text(libL10n.askContinue('${libL10n.delete} ${l10n.server}(${spi!.name})')),
|
||||
actions: Btn.ok(
|
||||
onTap: () async {
|
||||
context.pop();
|
||||
@@ -587,10 +547,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
|
||||
extension on _ServerEditPageState {
|
||||
void _onTapCustomItem() async {
|
||||
final res = await KvEditor.route.go(
|
||||
context,
|
||||
KvEditorArgs(data: _customCmds.value),
|
||||
);
|
||||
final res = await KvEditor.route.go(context, KvEditorArgs(data: _customCmds.value));
|
||||
if (res == null) return;
|
||||
_customCmds.value = res;
|
||||
}
|
||||
@@ -602,21 +559,12 @@ extension on _ServerEditPageState {
|
||||
}
|
||||
|
||||
if (_keyIdx.value == null && _passwordController.text.isEmpty) {
|
||||
final cancel = await context.showRoundDialog<bool>(
|
||||
final ok = await context.showRoundDialog<bool>(
|
||||
title: libL10n.attention,
|
||||
child: Text(libL10n.askContinue(l10n.useNoPwd)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(false),
|
||||
child: Text(libL10n.ok),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => context.pop(true),
|
||||
child: Text(libL10n.cancel),
|
||||
)
|
||||
],
|
||||
actions: Btnx.cancelRedOk,
|
||||
);
|
||||
if (cancel != false) return;
|
||||
if (ok != true) return;
|
||||
}
|
||||
|
||||
// If [_pubKeyIndex] is -1, it means that the user has not selected
|
||||
@@ -644,11 +592,7 @@ extension on _ServerEditPageState {
|
||||
final wolEmpty = _wolMacCtrl.text.isEmpty && _wolIpCtrl.text.isEmpty && _wolPwdCtrl.text.isEmpty;
|
||||
final wol = wolEmpty
|
||||
? null
|
||||
: WakeOnLanCfg(
|
||||
mac: _wolMacCtrl.text,
|
||||
ip: _wolIpCtrl.text,
|
||||
pwd: _wolPwdCtrl.text.selfNotEmptyOrNull,
|
||||
);
|
||||
: WakeOnLanCfg(mac: _wolMacCtrl.text, ip: _wolIpCtrl.text, pwd: _wolPwdCtrl.text.selfNotEmptyOrNull);
|
||||
if (wol != null) {
|
||||
final wolValidation = wol.validate();
|
||||
if (!wolValidation.$2) {
|
||||
@@ -696,9 +640,7 @@ extension on _ServerEditPageState {
|
||||
if (spi.keyId == null) {
|
||||
_passwordController.text = spi.pwd ?? '';
|
||||
} else {
|
||||
_keyIdx.value = PrivateKeyProvider.pkis.value.indexWhere(
|
||||
(e) => e.id == spi.keyId,
|
||||
);
|
||||
_keyIdx.value = PrivateKeyProvider.pkis.value.indexWhere((e) => e.id == spi.keyId);
|
||||
}
|
||||
|
||||
/// List in dart is passed by pointer, so you need to copy it here
|
||||
|
||||
@@ -85,29 +85,26 @@ ${ss.err?.message ?? 'null'}
|
||||
|
||||
Widget _buildDisk(ServerStatus ss, String id) {
|
||||
final cardNoti = _getCardNoti(id);
|
||||
return ListenableBuilder(
|
||||
listenable: cardNoti,
|
||||
builder: (_, __) {
|
||||
final isSpeed = cardNoti.value.diskIO ?? !Stores.setting.serverTabPreferDiskAmount.fetch();
|
||||
return cardNoti.listenVal((v) {
|
||||
final isSpeed = v.diskIO ?? !Stores.setting.serverTabPreferDiskAmount.fetch();
|
||||
|
||||
final (r, w) = ss.diskIO.cachedAllSpeed;
|
||||
final (r, w) = ss.diskIO.cachedAllSpeed;
|
||||
|
||||
return AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 377),
|
||||
transitionBuilder: (Widget child, Animation<double> animation) {
|
||||
return FadeTransition(opacity: animation, child: child);
|
||||
return AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 377),
|
||||
transitionBuilder: (child, animation) {
|
||||
return FadeTransition(opacity: animation, child: child);
|
||||
},
|
||||
child: _buildIOData(
|
||||
isSpeed ? '${l10n.read}:\n$r' : 'Total:\n${ss.diskUsage?.size.kb2Str}',
|
||||
isSpeed ? '${l10n.write}:\n$w' : 'Used:\n${ss.diskUsage?.used.kb2Str}',
|
||||
onTap: () {
|
||||
cardNoti.value = v.copyWith(diskIO: !isSpeed);
|
||||
},
|
||||
child: _buildIOData(
|
||||
isSpeed ? '${l10n.read}:\n$r' : 'Total:\n${ss.diskUsage?.size.kb2Str}',
|
||||
isSpeed ? '${l10n.write}:\n$w' : 'Used:\n${ss.diskUsage?.used.kb2Str}',
|
||||
onTap: () {
|
||||
cardNoti.value = cardNoti.value.copyWith(diskIO: !isSpeed);
|
||||
},
|
||||
key: ValueKey(isSpeed),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
key: ValueKey(isSpeed),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildNet(ServerStatus ss, String id) {
|
||||
|
||||
@@ -42,17 +42,14 @@ extension on _ServerPageState {
|
||||
final title = _buildServerCardTitle(srv);
|
||||
final List<Widget> children = [title, _buildNormalCard(srv.status, srv.spi)];
|
||||
|
||||
return ListenableBuilder(
|
||||
listenable: _getCardNoti(id),
|
||||
builder: (_, __) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: children,
|
||||
);
|
||||
},
|
||||
);
|
||||
return _getCardNoti(id).listenVal((_) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: children,
|
||||
);
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@@ -319,9 +319,7 @@ class _ServerPageState extends State<ServerPage> with AutomaticKeepAliveClientMi
|
||||
],
|
||||
),
|
||||
UIs.height13,
|
||||
if (Stores.setting.moveServerFuncs.fetch() &&
|
||||
// Discussion #146
|
||||
!Stores.setting.serverTabUseOldUI.fetch())
|
||||
if (Stores.setting.moveServerFuncs.fetch())
|
||||
SizedBox(height: 27, child: ServerFuncBtns(spi: spi)),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -100,9 +100,7 @@ extension _Utils on _ServerPageState {
|
||||
if (flip) {
|
||||
return _ServerPageState._kCardHeightFlip;
|
||||
}
|
||||
if (Stores.setting.moveServerFuncs.fetch() &&
|
||||
// Discussion #146
|
||||
!Stores.setting.serverTabUseOldUI.fetch()) {
|
||||
if (Stores.setting.moveServerFuncs.fetch()) {
|
||||
return _ServerPageState._kCardHeightMoveOutFuncs;
|
||||
}
|
||||
return _ServerPageState._kCardHeightNormal;
|
||||
|
||||
@@ -173,6 +173,7 @@ extension _Server on _AppSettingsPageState {
|
||||
title: Text(l10n.more),
|
||||
initiallyExpanded: false,
|
||||
children: [
|
||||
_buildServerTabPreferDiskAmount(),
|
||||
_buildRememberPwdInMem(),
|
||||
_buildTextScaler(),
|
||||
_buildKeepStatusWhenErr(),
|
||||
@@ -298,4 +299,11 @@ extension _Server on _AppSettingsPageState {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildServerTabPreferDiskAmount() {
|
||||
return ListTile(
|
||||
title: Text(l10n.preferDiskAmount),
|
||||
trailing: StoreSwitch(prop: Stores.setting.serverTabPreferDiskAmount),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ abstract final class PlatformPublicSettings {
|
||||
title: Text(libL10n.bioAuth),
|
||||
subtitle: const Text('...', style: UIs.textGrey),
|
||||
),
|
||||
error: (e, __) => ListTile(
|
||||
error: (e, _) => ListTile(
|
||||
title: Text(libL10n.bioAuth),
|
||||
subtitle: Text('${libL10n.fail}: $e', style: UIs.textGrey),
|
||||
),
|
||||
|
||||
@@ -189,7 +189,7 @@ class SSHPageState extends State<SSHPage>
|
||||
if (hasBg) {
|
||||
children.add(
|
||||
Positioned.fill(
|
||||
child: Image.file(file, fit: BoxFit.cover, errorBuilder: (_, __, ___) => const SizedBox()),
|
||||
child: Image.file(file, fit: BoxFit.cover, errorBuilder: (_, _, _) => const SizedBox()),
|
||||
),
|
||||
);
|
||||
if (blur > 0) {
|
||||
@@ -247,8 +247,8 @@ class SSHPageState extends State<SSHPage>
|
||||
height: _virtKeysHeight + _media.padding.bottom,
|
||||
child: ChangeNotifierProvider(
|
||||
create: (_) => _keyboard,
|
||||
builder: (_, __) => Consumer<VirtKeyProvider>(
|
||||
builder: (_, __, ___) {
|
||||
builder: (_, _) => Consumer<VirtKeyProvider>(
|
||||
builder: (_, _, _) {
|
||||
return _buildVirtualKey();
|
||||
},
|
||||
),
|
||||
|
||||
@@ -186,7 +186,7 @@ final class _TabBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 5),
|
||||
itemCount: names.length,
|
||||
itemBuilder: (_, idx) => _buildItem(idx),
|
||||
separatorBuilder: (_, __) => Padding(
|
||||
separatorBuilder: (_, _) => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 17),
|
||||
child: Container(
|
||||
color: const Color.fromARGB(61, 158, 158, 158),
|
||||
|
||||
@@ -26,28 +26,18 @@ final class SftpPageArgs {
|
||||
final bool isSelect;
|
||||
final String? initPath;
|
||||
|
||||
const SftpPageArgs({
|
||||
required this.spi,
|
||||
this.isSelect = false,
|
||||
this.initPath,
|
||||
});
|
||||
const SftpPageArgs({required this.spi, this.isSelect = false, this.initPath});
|
||||
}
|
||||
|
||||
class SftpPage extends StatefulWidget {
|
||||
final SftpPageArgs args;
|
||||
|
||||
const SftpPage({
|
||||
super.key,
|
||||
required this.args,
|
||||
});
|
||||
const SftpPage({super.key, required this.args});
|
||||
|
||||
@override
|
||||
State<SftpPage> createState() => _SftpPageState();
|
||||
|
||||
static const route = AppRouteArg<String, SftpPageArgs>(
|
||||
page: SftpPage.new,
|
||||
path: '/sftp',
|
||||
);
|
||||
static const route = AppRouteArg<String, SftpPageArgs>(page: SftpPage.new, path: '/sftp');
|
||||
}
|
||||
|
||||
class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
@@ -64,20 +54,14 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final children = [
|
||||
Btn.icon(
|
||||
icon: const Icon(Icons.downloading),
|
||||
onTap: () => SftpMissionPage.route.go(context),
|
||||
),
|
||||
Btn.icon(icon: const Icon(Icons.downloading), onTap: () => SftpMissionPage.route.go(context)),
|
||||
_buildSortMenu(),
|
||||
_buildSearchBtn(),
|
||||
];
|
||||
if (isDesktop) children.add(_buildRefreshBtn());
|
||||
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
title: Text(widget.args.spi.name),
|
||||
actions: children,
|
||||
),
|
||||
appBar: CustomAppBar(title: Text(widget.args.spi.name), actions: children),
|
||||
body: _buildFileView(),
|
||||
bottomNavigationBar: _buildBottom(),
|
||||
);
|
||||
@@ -105,56 +89,45 @@ extension _UI on _SftpPageState {
|
||||
(_SortType.size, l10n.size),
|
||||
(_SortType.time, l10n.time),
|
||||
];
|
||||
return _sortOption.listenVal(
|
||||
(value) {
|
||||
return PopupMenuButton<_SortType>(
|
||||
icon: const Icon(Icons.sort),
|
||||
itemBuilder: (context) {
|
||||
return options.map((r) {
|
||||
final (type, name) = r;
|
||||
final selected = type == value.sortBy;
|
||||
final title = selected ? "$name (${value.reversed ? '-' : '+'})" : name;
|
||||
return PopupMenuItem(
|
||||
value: type,
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: selected ? UIs.primaryColor : null,
|
||||
fontWeight: selected ? FontWeight.bold : null,
|
||||
),
|
||||
return _sortOption.listenVal((value) {
|
||||
return PopupMenuButton<_SortType>(
|
||||
icon: const Icon(Icons.sort),
|
||||
itemBuilder: (context) {
|
||||
return options.map((r) {
|
||||
final (type, name) = r;
|
||||
final selected = type == value.sortBy;
|
||||
final title = selected ? "$name (${value.reversed ? '-' : '+'})" : name;
|
||||
return PopupMenuItem(
|
||||
value: type,
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: selected ? UIs.primaryColor : null,
|
||||
fontWeight: selected ? FontWeight.bold : null,
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
onSelected: (sortBy) {
|
||||
final old = _sortOption.value;
|
||||
if (old.sortBy == sortBy) {
|
||||
_sortOption.value = old.copyWith(reversed: !old.reversed);
|
||||
} else {
|
||||
_sortOption.value = old.copyWith(sortBy: sortBy);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
onSelected: (sortBy) {
|
||||
final old = _sortOption.value;
|
||||
if (old.sortBy == sortBy) {
|
||||
_sortOption.value = old.copyWith(reversed: !old.reversed);
|
||||
} else {
|
||||
_sortOption.value = old.copyWith(sortBy: sortBy);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildBottom() {
|
||||
final children = widget.args.isSelect
|
||||
? [
|
||||
IconButton(
|
||||
onPressed: () => context.pop(_status.path.path),
|
||||
icon: const Icon(Icons.done),
|
||||
),
|
||||
IconButton(onPressed: () => context.pop(_status.path.path), icon: const Icon(Icons.done)),
|
||||
_buildSearchBtn(),
|
||||
]
|
||||
: [
|
||||
_buildBackBtn(),
|
||||
_buildHomeBtn(),
|
||||
_buildAddBtn(),
|
||||
_buildGotoBtn(),
|
||||
_buildUploadBtn(),
|
||||
];
|
||||
: [_buildBackBtn(), _buildHomeBtn(), _buildAddBtn(), _buildGotoBtn(), _buildUploadBtn()];
|
||||
return SafeArea(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(11, 7, 11, 11),
|
||||
@@ -162,10 +135,7 @@ extension _UI on _SftpPageState {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
OmitStartText(_status.path.path),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: children,
|
||||
)
|
||||
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: children),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -182,10 +152,7 @@ extension _UI on _SftpPageState {
|
||||
child: ValBuilder(
|
||||
listenable: _sortOption,
|
||||
builder: (sortOption) {
|
||||
final files = sortOption.sortBy.sort(
|
||||
_status.files,
|
||||
reversed: sortOption.reversed,
|
||||
);
|
||||
final files = sortOption.sortBy.sort(_status.files, reversed: sortOption.reversed);
|
||||
return ListView.builder(
|
||||
itemCount: files.length,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 3),
|
||||
@@ -209,12 +176,7 @@ extension _UI on _SftpPageState {
|
||||
leading: Icon(isDir ? Icons.folder_outlined : Icons.insert_drive_file),
|
||||
title: Text(file.filename),
|
||||
trailing: trailing,
|
||||
subtitle: isDir
|
||||
? null
|
||||
: Text(
|
||||
(file.attr.size ?? 0).bytes2Str,
|
||||
style: UIs.textGrey,
|
||||
),
|
||||
subtitle: isDir ? null : Text((file.attr.size ?? 0).bytes2Str, style: UIs.textGrey),
|
||||
onTap: () {
|
||||
beforeTap?.call();
|
||||
if (isDir) {
|
||||
@@ -236,16 +198,8 @@ extension _UI on _SftpPageState {
|
||||
extension _Actions on _SftpPageState {
|
||||
void _onItemPress(SftpName file, bool notDir) {
|
||||
final children = [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.delete),
|
||||
title: Text(libL10n.delete),
|
||||
onTap: () => _delete(file),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.abc),
|
||||
title: Text(libL10n.rename),
|
||||
onTap: () => _rename(file),
|
||||
),
|
||||
ListTile(leading: const Icon(Icons.delete), title: Text(libL10n.delete), onTap: () => _delete(file)),
|
||||
ListTile(leading: const Icon(Icons.abc), title: Text(libL10n.rename), onTap: () => _rename(file)),
|
||||
ListTile(
|
||||
leading: const Icon(MingCute.copy_line),
|
||||
title: Text(l10n.copyPath),
|
||||
@@ -270,21 +224,19 @@ extension _Actions on _SftpPageState {
|
||||
|
||||
final permStr = newPerm.perm;
|
||||
if (ok == true && permStr != perm.perm) {
|
||||
await context.showLoadingDialog(fn: () async {
|
||||
await _client.run('chmod $permStr "${_getRemotePath(file)}"');
|
||||
await _listDir();
|
||||
});
|
||||
await context.showLoadingDialog(
|
||||
fn: () async {
|
||||
await _client.run('chmod $permStr "${_getRemotePath(file)}"');
|
||||
await _listDir();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
];
|
||||
if (notDir) {
|
||||
children.addAll([
|
||||
ListTile(
|
||||
leading: const Icon(Icons.edit),
|
||||
title: Text(libL10n.edit),
|
||||
onTap: () => _edit(file),
|
||||
),
|
||||
ListTile(leading: const Icon(Icons.edit), title: Text(libL10n.edit), onTap: () => _edit(file)),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.download),
|
||||
title: Text(libL10n.download),
|
||||
@@ -300,10 +252,7 @@ extension _Actions on _SftpPageState {
|
||||
]);
|
||||
}
|
||||
context.showRoundDialog(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: children,
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: children),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -323,27 +272,16 @@ extension _Actions on _SftpPageState {
|
||||
|
||||
final size = name.attr.size;
|
||||
if (size == null || size > Miscs.editorMaxSize) {
|
||||
context.showSnackBar(l10n.fileTooLarge(
|
||||
name.filename,
|
||||
size ?? 0,
|
||||
Miscs.editorMaxSize,
|
||||
));
|
||||
context.showSnackBar(l10n.fileTooLarge(name.filename, size ?? 0, Miscs.editorMaxSize));
|
||||
return;
|
||||
}
|
||||
|
||||
final remotePath = _getRemotePath(name);
|
||||
final localPath = _getLocalPath(remotePath);
|
||||
final completer = Completer();
|
||||
final req = SftpReq(
|
||||
widget.args.spi,
|
||||
remotePath,
|
||||
localPath,
|
||||
SftpReqType.download,
|
||||
);
|
||||
final req = SftpReq(widget.args.spi, remotePath, localPath, SftpReqType.download);
|
||||
SftpProvider.add(req, completer: completer);
|
||||
final (suc, err) = await context.showLoadingDialog(
|
||||
fn: () => completer.future,
|
||||
);
|
||||
final (suc, err) = await context.showLoadingDialog(fn: () => completer.future);
|
||||
if (suc == null || err != null) return;
|
||||
|
||||
await EditorPage.route.go(
|
||||
@@ -351,12 +289,7 @@ extension _Actions on _SftpPageState {
|
||||
args: EditorPageArgs(
|
||||
path: localPath,
|
||||
onSave: (_) {
|
||||
SftpProvider.add(SftpReq(
|
||||
req.spi,
|
||||
remotePath,
|
||||
localPath,
|
||||
SftpReqType.upload,
|
||||
));
|
||||
SftpProvider.add(SftpReq(req.spi, remotePath, localPath, SftpReqType.upload));
|
||||
context.showSnackBar(l10n.added2List);
|
||||
},
|
||||
closeAfterSave: SettingStore.instance.closeAfterSave.fetch(),
|
||||
@@ -371,28 +304,20 @@ extension _Actions on _SftpPageState {
|
||||
title: libL10n.attention,
|
||||
child: Text('${l10n.dl2Local(name.filename)}\n${l10n.keepForeground}'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(libL10n.cancel),
|
||||
),
|
||||
TextButton(onPressed: () => context.pop(), child: Text(libL10n.cancel)),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
context.pop();
|
||||
final remotePath = _getRemotePath(name);
|
||||
|
||||
SftpProvider.add(
|
||||
SftpReq(
|
||||
widget.args.spi,
|
||||
remotePath,
|
||||
_getLocalPath(remotePath),
|
||||
SftpReqType.download,
|
||||
),
|
||||
SftpReq(widget.args.spi, remotePath, _getLocalPath(remotePath), SftpReqType.download),
|
||||
);
|
||||
|
||||
context.pop();
|
||||
},
|
||||
child: Text(libL10n.download),
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -416,9 +341,7 @@ extension _Actions on _SftpPageState {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(text),
|
||||
),
|
||||
ListTile(title: Text(text)),
|
||||
if (!useRmr)
|
||||
StatefulBuilder(
|
||||
builder: (_, setState) {
|
||||
@@ -436,10 +359,7 @@ extension _Actions on _SftpPageState {
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(libL10n.cancel),
|
||||
),
|
||||
TextButton(onPressed: () => context.pop(), child: Text(libL10n.cancel)),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
context.pop();
|
||||
@@ -474,10 +394,7 @@ extension _Actions on _SftpPageState {
|
||||
void onSubmitted() async {
|
||||
final text = textController.text.trim();
|
||||
if (text.isEmpty) {
|
||||
context.showRoundDialog(
|
||||
child: Text(libL10n.empty),
|
||||
actions: Btnx.oks,
|
||||
);
|
||||
context.showRoundDialog(child: Text(libL10n.empty), actions: Btnx.oks);
|
||||
return;
|
||||
}
|
||||
context.pop();
|
||||
@@ -504,10 +421,7 @@ extension _Actions on _SftpPageState {
|
||||
suggestion: true,
|
||||
onSubmitted: (_) => onSubmitted(),
|
||||
),
|
||||
actions: Btn.ok(
|
||||
onTap: onSubmitted,
|
||||
red: true,
|
||||
).toList,
|
||||
actions: Btn.ok(onTap: onSubmitted, red: true).toList,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -518,11 +432,7 @@ extension _Actions on _SftpPageState {
|
||||
void onSubmitted() async {
|
||||
final text = textController.text.trim();
|
||||
if (text.isEmpty) {
|
||||
context.showRoundDialog(
|
||||
title: libL10n.attention,
|
||||
child: Text(libL10n.empty),
|
||||
actions: Btnx.oks,
|
||||
);
|
||||
context.showRoundDialog(title: libL10n.attention, child: Text(libL10n.empty), actions: Btnx.oks);
|
||||
return;
|
||||
}
|
||||
context.pop();
|
||||
@@ -560,11 +470,7 @@ extension _Actions on _SftpPageState {
|
||||
void onSubmitted() async {
|
||||
final text = textController.text.trim();
|
||||
if (text.isEmpty) {
|
||||
context.showRoundDialog(
|
||||
title: libL10n.attention,
|
||||
child: Text(libL10n.empty),
|
||||
actions: Btnx.oks,
|
||||
);
|
||||
context.showRoundDialog(title: libL10n.attention, child: Text(libL10n.empty), actions: Btnx.oks);
|
||||
return;
|
||||
}
|
||||
context.pop();
|
||||
@@ -685,10 +591,7 @@ extension _Actions on _SftpPageState {
|
||||
}
|
||||
|
||||
Widget _buildBackBtn() {
|
||||
return Btn.icon(
|
||||
onTap: _backward,
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
);
|
||||
return Btn.icon(onTap: _backward, icon: const Icon(Icons.arrow_back));
|
||||
}
|
||||
|
||||
Widget _buildSearchBtn() {
|
||||
@@ -718,26 +621,16 @@ extension _Actions on _SftpPageState {
|
||||
return Btn.icon(
|
||||
onTap: () async {
|
||||
final idx = await context.showRoundDialog(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Btn.tile(
|
||||
icon: const Icon(Icons.open_in_new),
|
||||
text: l10n.system,
|
||||
onTap: () => context.pop(1),
|
||||
),
|
||||
Btn.tile(
|
||||
icon: const Icon(Icons.folder),
|
||||
text: l10n.inner,
|
||||
onTap: () => context.pop(0),
|
||||
),
|
||||
],
|
||||
));
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Btn.tile(icon: const Icon(Icons.open_in_new), text: l10n.system, onTap: () => context.pop(1)),
|
||||
Btn.tile(icon: const Icon(Icons.folder), text: l10n.inner, onTap: () => context.pop(0)),
|
||||
],
|
||||
),
|
||||
);
|
||||
final path = switch (idx) {
|
||||
0 => await LocalFilePage.route.go(
|
||||
context,
|
||||
args: const LocalFilePageArgs(isPickFile: true),
|
||||
),
|
||||
0 => await LocalFilePage.route.go(context, args: const LocalFilePageArgs(isPickFile: true)),
|
||||
1 => await Pfs.pickFilePath(),
|
||||
_ => null,
|
||||
};
|
||||
@@ -747,9 +640,7 @@ extension _Actions on _SftpPageState {
|
||||
final fileName = path.split(Platform.pathSeparator).lastOrNull;
|
||||
final remotePath = '$remoteDir/$fileName';
|
||||
Loggers.app.info('SFTP upload local: $path, remote: $remotePath');
|
||||
SftpProvider.add(
|
||||
SftpReq(widget.args.spi, remotePath, path, SftpReqType.upload),
|
||||
);
|
||||
SftpProvider.add(SftpReq(widget.args.spi, remotePath, path, SftpReqType.upload));
|
||||
},
|
||||
icon: const Icon(Icons.upload_file),
|
||||
);
|
||||
@@ -761,16 +652,8 @@ extension _Actions on _SftpPageState {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Btn.tile(
|
||||
icon: const Icon(Icons.folder),
|
||||
text: libL10n.folder,
|
||||
onTap: _mkdir,
|
||||
),
|
||||
Btn.tile(
|
||||
icon: const Icon(Icons.insert_drive_file),
|
||||
text: libL10n.file,
|
||||
onTap: _newFile,
|
||||
),
|
||||
Btn.tile(icon: const Icon(Icons.folder), text: libL10n.folder, onTap: _mkdir),
|
||||
Btn.tile(icon: const Icon(Icons.insert_drive_file), text: libL10n.file, onTap: _newFile),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -788,11 +671,9 @@ extension _Actions on _SftpPageState {
|
||||
if (!Stores.setting.recordHistory.fetch()) {
|
||||
return [];
|
||||
}
|
||||
return Stores.history.sftpGoPath.all.cast<String>().where(
|
||||
(element) => element.contains(val.text),
|
||||
);
|
||||
return Stores.history.sftpGoPath.all.cast<String>().where((e) => e.contains(val.text));
|
||||
},
|
||||
fieldViewBuilder: (_, controller, node, __) {
|
||||
fieldViewBuilder: (_, controller, node, _) {
|
||||
return Input(
|
||||
autoFocus: true,
|
||||
icon: Icons.abc,
|
||||
@@ -821,10 +702,7 @@ extension _Actions on _SftpPageState {
|
||||
}
|
||||
|
||||
Widget _buildRefreshBtn() {
|
||||
return Btn.icon(
|
||||
onTap: _listDir,
|
||||
icon: const Icon(Icons.refresh),
|
||||
);
|
||||
return Btn.icon(onTap: _listDir, icon: const Icon(Icons.refresh));
|
||||
}
|
||||
|
||||
Widget _buildHomeBtn() {
|
||||
@@ -913,8 +791,7 @@ String _getTime(int? unixMill) {
|
||||
enum _SortType {
|
||||
name,
|
||||
time,
|
||||
size,
|
||||
;
|
||||
size;
|
||||
|
||||
List<SftpName> sort(List<SftpName> files, {bool reversed = false}) {
|
||||
var comparator = ChainComparator<SftpName>.create();
|
||||
@@ -933,24 +810,10 @@ enum _SortType {
|
||||
);
|
||||
break;
|
||||
case _SortType.time:
|
||||
files.sort(
|
||||
comparator
|
||||
.thenCompareBy<num>(
|
||||
(x) => x.attr.modifyTime ?? 0,
|
||||
reversed: reversed,
|
||||
)
|
||||
.compare,
|
||||
);
|
||||
files.sort(comparator.thenCompareBy<num>((x) => x.attr.modifyTime ?? 0, reversed: reversed).compare);
|
||||
break;
|
||||
case _SortType.size:
|
||||
files.sort(
|
||||
comparator
|
||||
.thenCompareBy<num>(
|
||||
(x) => x.attr.size ?? 0,
|
||||
reversed: reversed,
|
||||
)
|
||||
.compare,
|
||||
);
|
||||
files.sort(comparator.thenCompareBy<num>((x) => x.attr.size ?? 0, reversed: reversed).compare);
|
||||
break;
|
||||
}
|
||||
return files;
|
||||
@@ -963,13 +826,7 @@ class _SortOption {
|
||||
|
||||
_SortOption({this.sortBy = _SortType.name, this.reversed = false});
|
||||
|
||||
_SortOption copyWith({
|
||||
_SortType? sortBy,
|
||||
bool? reversed,
|
||||
}) {
|
||||
return _SortOption(
|
||||
sortBy: sortBy ?? this.sortBy,
|
||||
reversed: reversed ?? this.reversed,
|
||||
);
|
||||
_SortOption copyWith({_SortType? sortBy, bool? reversed}) {
|
||||
return _SortOption(sortBy: sortBy ?? this.sortBy, reversed: reversed ?? this.reversed);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user