This commit is contained in:
lollipopkit
2023-09-13 14:28:02 +08:00
parent 6c84d2f52b
commit 278d5984b2
55 changed files with 528 additions and 481 deletions

View File

@@ -2,7 +2,9 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:toolbox/core/extension/context.dart';
import 'package:toolbox/core/extension/context/common.dart';
import 'package:toolbox/core/extension/context/dialog.dart';
import 'package:toolbox/core/extension/context/snackbar.dart';
import 'package:toolbox/data/model/sftp/req.dart';
import 'package:toolbox/data/provider/server.dart';
import 'package:toolbox/data/provider/sftp.dart';
@@ -47,7 +49,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
_path = LocalPath(widget.initDir!);
});
} else {
sftpDir.then((dir) {
Paths.sftp.then((dir) {
setState(() {
_path = LocalPath(dir);
});
@@ -165,12 +167,13 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
? const Icon(Icons.folder)
: const Icon(Icons.insert_drive_file),
title: Text(fileName),
subtitle: isDir ? null : Text(stat.size.convertBytes, style: grey),
subtitle:
isDir ? null : Text(stat.size.convertBytes, style: UIs.textGrey),
trailing: Text(
stat.modified
.toString()
.substring(0, stat.modified.toString().length - 4),
style: grey,
style: UIs.textGrey,
),
onLongPress: () {
if (!isDir) return;
@@ -242,7 +245,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
onTap: () async {
context.pop();
final stat = await file.stat();
if (stat.size > editorMaxSize) {
if (stat.size > Miscs.editorMaxSize) {
context.showRoundDialog(
title: Text(_s.attention),
child: Text(_s.fileTooLarge(fileName, stat.size, '1m')),

View File

@@ -4,7 +4,9 @@ import 'package:after_layout/after_layout.dart';
import 'package:dartssh2/dartssh2.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:toolbox/core/extension/context.dart';
import 'package:toolbox/core/extension/context/common.dart';
import 'package:toolbox/core/extension/context/dialog.dart';
import 'package:toolbox/core/extension/context/snackbar.dart';
import 'package:toolbox/core/extension/sftpfile.dart';
import 'package:toolbox/data/res/logger.dart';
import 'package:toolbox/data/res/misc.dart';
@@ -267,7 +269,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
Widget _buildFileView() {
if (_status.files == null) {
return centerLoading;
return UIs.centerLoading;
}
if (_status.files!.isEmpty) {
@@ -293,7 +295,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
final isDir = file.attr.isDirectory;
final trailing = Text(
'${getTime(file.attr.modifyTime)}\n${file.attr.mode?.str ?? ''}',
style: grey,
style: UIs.textGrey,
textAlign: TextAlign.right,
);
return RoundRectCard(ListTile(
@@ -304,7 +306,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
? null
: Text(
(file.attr.size ?? 0).convertBytes,
style: grey,
style: UIs.textGrey,
),
onTap: () {
if (isDir) {
@@ -362,11 +364,11 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
Future<void> _edit(BuildContext context, SftpName name) async {
final size = name.attr.size;
if (size == null || size > editorMaxSize) {
if (size == null || size > Miscs.editorMaxSize) {
context.showSnackBar(_s.fileTooLarge(
name.filename,
size ?? 0,
editorMaxSize,
Miscs.editorMaxSize,
));
return;
}
@@ -469,7 +471,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
}
_listDir();
},
child: Text(_s.delete, style: textRed),
child: Text(_s.delete, style: UIs.textRed),
),
],
);
@@ -510,7 +512,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
context.pop();
_listDir();
},
child: Text(_s.ok, style: textRed),
child: Text(_s.ok, style: UIs.textRed),
),
],
);
@@ -550,7 +552,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
context.pop();
_listDir();
},
child: Text(_s.ok, style: textRed),
child: Text(_s.ok, style: UIs.textRed),
),
],
);
@@ -588,7 +590,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
context.pop();
_listDir();
},
child: Text(_s.rename, style: textRed),
child: Text(_s.rename, style: UIs.textRed),
),
],
);
@@ -623,7 +625,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
}
Future<String> _getLocalPath(String remotePath) async {
return '${await sftpDir}$remotePath';
return '${await Paths.sftp}$remotePath';
}
/// Only return true if the path is changed

View File

@@ -1,8 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:provider/provider.dart';
import 'package:toolbox/core/extension/context/common.dart';
import 'package:toolbox/core/extension/datetime.dart';
import 'package:toolbox/core/extension/context.dart';
import 'package:toolbox/core/extension/context/dialog.dart';
import 'package:toolbox/core/route.dart';
import 'package:toolbox/locator.dart';
@@ -34,7 +35,7 @@ class _SftpMissionPageState extends State<SftpMissionPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(
title: Text(_s.mission, style: textSize18),
title: Text(_s.mission, style: UIs.textSize18),
),
body: _buildBody(),
);
@@ -134,12 +135,7 @@ class _SftpMissionPageState extends State<SftpMissionPage> {
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
subtitle: subtitle == null
? null
: Text(
subtitle,
style: grey,
),
subtitle: subtitle == null ? null : Text(subtitle, style: UIs.textGrey),
trailing: trailing,
),
);