mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
opt.: use new routes
This commit is contained in:
@@ -110,8 +110,15 @@ class AppRoute {
|
||||
return AppRoute(SSHVirtKeySettingPage(key: key), 'ssh_virt_key_setting');
|
||||
}
|
||||
|
||||
static AppRoute localStorage({Key? key}) {
|
||||
return AppRoute(LocalStoragePage(key: key), 'local_storage');
|
||||
static AppRoute localStorage(
|
||||
{Key? key, bool isPickFile = false, String? initDir}) {
|
||||
return AppRoute(
|
||||
LocalStoragePage(
|
||||
key: key,
|
||||
isPickFile: isPickFile,
|
||||
initDir: initDir,
|
||||
),
|
||||
'local_storage');
|
||||
}
|
||||
|
||||
static AppRoute sftpMission({Key? key}) {
|
||||
|
||||
@@ -11,7 +11,6 @@ import '../../data/model/server/snippet.dart';
|
||||
import '../../data/provider/snippet.dart';
|
||||
import '../../data/res/ui.dart';
|
||||
import '../../locator.dart';
|
||||
import '../../view/page/snippet/edit.dart';
|
||||
import '../../view/widget/picker.dart';
|
||||
import '../persistant_store.dart';
|
||||
import '../route.dart';
|
||||
@@ -146,7 +145,7 @@ void showSnippetDialog(
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
AppRoute(const SnippetEditPage(), 'edit snippet').go(context);
|
||||
AppRoute.snippetEdit().go(context);
|
||||
},
|
||||
child: Text(s.add),
|
||||
)
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/extension/navigator.dart';
|
||||
import 'package:toolbox/core/route.dart';
|
||||
import 'package:toolbox/data/model/docker/image.dart';
|
||||
import 'package:toolbox/view/page/ssh_term.dart';
|
||||
import 'package:toolbox/view/widget/input_field.dart';
|
||||
|
||||
import '../../core/utils/ui.dart';
|
||||
@@ -457,21 +456,15 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
context.pop();
|
||||
break;
|
||||
case DockerMenuType.logs:
|
||||
AppRoute(
|
||||
SSHPage(
|
||||
AppRoute.ssh(
|
||||
spi: widget.spi,
|
||||
initCmd: 'docker logs -f --tail 100 ${dItem.containerId}',
|
||||
),
|
||||
'Docker logs',
|
||||
).go(context);
|
||||
break;
|
||||
case DockerMenuType.terminal:
|
||||
AppRoute(
|
||||
SSHPage(
|
||||
AppRoute.ssh(
|
||||
spi: widget.spi,
|
||||
initCmd: 'docker exec -it ${dItem.containerId} sh',
|
||||
),
|
||||
'Docker terminal',
|
||||
).go(context);
|
||||
break;
|
||||
// case DockerMenuType.stats:
|
||||
|
||||
@@ -22,8 +22,6 @@ import '../../data/model/server/server.dart';
|
||||
import '../../data/model/server/server_private_info.dart';
|
||||
import '../../data/model/server/server_status.dart';
|
||||
import '../../data/res/color.dart';
|
||||
import 'server/edit.dart';
|
||||
import 'setting/entry.dart';
|
||||
|
||||
class FullScreenPage extends StatefulWidget {
|
||||
const FullScreenPage({Key? key}) : super(key: key);
|
||||
@@ -117,10 +115,7 @@ class _FullScreenPageState extends State<FullScreenPage> with AfterLayoutMixin {
|
||||
|
||||
Widget _buildSettingBtn() {
|
||||
return IconButton(
|
||||
onPressed: () => AppRoute(
|
||||
const SettingPage(),
|
||||
'Setting',
|
||||
).go(context),
|
||||
onPressed: () => AppRoute.setting().go(context),
|
||||
icon: const Icon(Icons.settings, color: Colors.grey));
|
||||
}
|
||||
|
||||
@@ -129,10 +124,7 @@ class _FullScreenPageState extends State<FullScreenPage> with AfterLayoutMixin {
|
||||
if (pro.serverOrder.isEmpty) {
|
||||
return Center(
|
||||
child: TextButton(
|
||||
onPressed: () => AppRoute(
|
||||
const ServerEditPage(),
|
||||
'Add server info page',
|
||||
).go(context),
|
||||
onPressed: () => AppRoute.serverEdit().go(context),
|
||||
child: Text(
|
||||
_s.addAServer,
|
||||
style: const TextStyle(fontSize: 27),
|
||||
|
||||
@@ -22,12 +22,6 @@ import '../../data/store/setting.dart';
|
||||
import '../../locator.dart';
|
||||
import '../widget/custom_appbar.dart';
|
||||
import '../widget/url_text.dart';
|
||||
import 'backup.dart';
|
||||
import 'convert.dart';
|
||||
import 'debug.dart';
|
||||
import 'private_key/list.dart';
|
||||
import 'setting/entry.dart';
|
||||
import 'storage/local.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({Key? key}) : super(key: key);
|
||||
@@ -136,10 +130,7 @@ class _HomePageState extends State<HomePage>
|
||||
IconButton(
|
||||
icon: const Icon(Icons.developer_mode, size: 23),
|
||||
tooltip: _s.debug,
|
||||
onPressed: () => AppRoute(
|
||||
const DebugPage(),
|
||||
'Debug Page',
|
||||
).go(context),
|
||||
onPressed: () => AppRoute.debug().go(context),
|
||||
),
|
||||
];
|
||||
if (isDesktop && _selectIndex.value == AppTab.server.index) {
|
||||
@@ -238,42 +229,27 @@ class _HomePageState extends State<HomePage>
|
||||
ListTile(
|
||||
leading: const Icon(Icons.settings),
|
||||
title: Text(_s.setting),
|
||||
onTap: () => AppRoute(
|
||||
const SettingPage(),
|
||||
'Setting',
|
||||
).go(context),
|
||||
onTap: () => AppRoute.setting().go(context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.vpn_key),
|
||||
title: Text(_s.privateKey),
|
||||
onTap: () => AppRoute(
|
||||
const PrivateKeysListPage(),
|
||||
'private key list',
|
||||
).go(context),
|
||||
onTap: () => AppRoute.keyList().go(context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.download),
|
||||
title: Text(_s.download),
|
||||
onTap: () => AppRoute(
|
||||
const LocalStoragePage(),
|
||||
'sftp local page',
|
||||
).go(context),
|
||||
onTap: () => AppRoute.localStorage().go(context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.import_export),
|
||||
title: Text(_s.backup),
|
||||
onTap: () => AppRoute(
|
||||
BackupPage(),
|
||||
'backup page',
|
||||
).go(context),
|
||||
onTap: () => AppRoute.backup().go(context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.code),
|
||||
title: Text(_s.convert),
|
||||
onTap: () => AppRoute(
|
||||
const ConvertPage(),
|
||||
'convert page',
|
||||
).go(context),
|
||||
onTap: () => AppRoute.convert().go(context),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.text_snippet),
|
||||
|
||||
@@ -15,7 +15,6 @@ import '../../../data/model/server/private_key_info.dart';
|
||||
import '../../../data/provider/private_key.dart';
|
||||
import '../../../data/res/ui.dart';
|
||||
import '../../widget/custom_appbar.dart';
|
||||
import 'edit.dart';
|
||||
import '../../../view/widget/round_rect_card.dart';
|
||||
|
||||
class PrivateKeysListPage extends StatefulWidget {
|
||||
@@ -44,10 +43,7 @@ class _PrivateKeyListState extends State<PrivateKeysListPage>
|
||||
body: _buildBody(),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.add),
|
||||
onPressed: () => AppRoute(
|
||||
const PrivateKeyEditPage(),
|
||||
'private key edit page',
|
||||
).go(context),
|
||||
onPressed: () => AppRoute.keyEdit().go(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -68,10 +64,8 @@ class _PrivateKeyListState extends State<PrivateKeysListPage>
|
||||
ListTile(
|
||||
title: Text(key.pkis[idx].id),
|
||||
trailing: TextButton(
|
||||
onPressed: () => AppRoute(
|
||||
PrivateKeyEditPage(pki: key.pkis[idx]),
|
||||
'private key edit page',
|
||||
).go(context),
|
||||
onPressed: () =>
|
||||
AppRoute.keyEdit(pki: key.pkis[idx]).go(context),
|
||||
child: Text(_s.edit),
|
||||
),
|
||||
),
|
||||
@@ -102,10 +96,7 @@ class _PrivateKeyListState extends State<PrivateKeysListPage>
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
AppRoute(
|
||||
PrivateKeyEditPage(pki: sysPk),
|
||||
'private key edit page',
|
||||
).go(context);
|
||||
AppRoute.keyEdit(pki: sysPk).go(context);
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
|
||||
@@ -17,7 +17,6 @@ import '../../../data/store/private_key.dart';
|
||||
import '../../../locator.dart';
|
||||
import '../../widget/custom_appbar.dart';
|
||||
import '../../widget/tag.dart';
|
||||
import '../private_key/edit.dart';
|
||||
|
||||
class ServerEditPage extends StatefulWidget {
|
||||
const ServerEditPage({Key? key, this.spi}) : super(key: key);
|
||||
@@ -231,10 +230,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
contentPadding: EdgeInsets.zero,
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () => AppRoute(
|
||||
const PrivateKeyEditPage(),
|
||||
'private key edit page',
|
||||
).go(context),
|
||||
onPressed: () => AppRoute.keyEdit().go(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -23,7 +23,6 @@ import '../../../locator.dart';
|
||||
import '../../widget/round_rect_card.dart';
|
||||
import '../../widget/server_func_btns.dart';
|
||||
import '../../widget/tag.dart';
|
||||
import 'edit.dart';
|
||||
|
||||
class ServerPage extends StatefulWidget {
|
||||
const ServerPage({Key? key}) : super(key: key);
|
||||
@@ -63,10 +62,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
return Scaffold(
|
||||
body: _buildBody(),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => AppRoute(
|
||||
const ServerEditPage(),
|
||||
'Add server info page',
|
||||
).go(context),
|
||||
onPressed: () => AppRoute.serverEdit().go(context),
|
||||
tooltip: _s.addAServer,
|
||||
heroTag: 'server',
|
||||
child: const Icon(Icons.add),
|
||||
|
||||
@@ -13,7 +13,6 @@ import 'package:toolbox/core/extension/stringx.dart';
|
||||
import 'package:toolbox/core/persistant_store.dart';
|
||||
import 'package:toolbox/core/route.dart';
|
||||
import 'package:toolbox/data/model/app/net_view.dart';
|
||||
import 'package:toolbox/view/page/setting/virt_key.dart';
|
||||
import 'package:toolbox/view/widget/input_field.dart';
|
||||
import 'package:toolbox/view/widget/value_notifier.dart';
|
||||
|
||||
@@ -814,10 +813,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
return ListTile(
|
||||
title: Text(_s.editVirtKeys),
|
||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||
onTap: () => AppRoute(
|
||||
const SSHVirtKeySettingPage(),
|
||||
'ssh virt key edit',
|
||||
).go(context),
|
||||
onTap: () => AppRoute.sshVirtKeySetting().go(context),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import '../../../locator.dart';
|
||||
import '../../widget/tag.dart';
|
||||
import '/core/route.dart';
|
||||
import '/data/provider/snippet.dart';
|
||||
import 'edit.dart';
|
||||
import '/view/widget/round_rect_card.dart';
|
||||
|
||||
class SnippetListPage extends StatefulWidget {
|
||||
@@ -46,10 +45,7 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
floatingActionButton: FloatingActionButton(
|
||||
heroTag: 'snippet',
|
||||
child: const Icon(Icons.add),
|
||||
onPressed: () => AppRoute(
|
||||
const SnippetEditPage(),
|
||||
'snippet edit page',
|
||||
).go(context),
|
||||
onPressed: () => AppRoute.snippetEdit().go(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -121,10 +117,8 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => AppRoute(
|
||||
SnippetEditPage(snippet: snippet),
|
||||
'snippet edit page',
|
||||
).go(context),
|
||||
onPressed: () =>
|
||||
AppRoute.snippetEdit(snippet: snippet).go(context),
|
||||
icon: const Icon(Icons.edit),
|
||||
),
|
||||
IconButton(
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:toolbox/data/provider/server.dart';
|
||||
import 'package:toolbox/data/provider/sftp.dart';
|
||||
import 'package:toolbox/data/res/misc.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
import 'package:toolbox/view/page/editor.dart';
|
||||
import 'package:toolbox/view/widget/input_field.dart';
|
||||
import 'package:toolbox/view/widget/picker.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
@@ -23,13 +22,15 @@ import '../../../data/res/path.dart';
|
||||
import '../../../data/res/ui.dart';
|
||||
import '../../widget/custom_appbar.dart';
|
||||
import '../../widget/fade_in.dart';
|
||||
import 'sftp_mission.dart';
|
||||
|
||||
class LocalStoragePage extends StatefulWidget {
|
||||
final bool isPickFile;
|
||||
final String? initDir;
|
||||
const LocalStoragePage({Key? key, this.isPickFile = false, this.initDir})
|
||||
: super(key: key);
|
||||
const LocalStoragePage({
|
||||
Key? key,
|
||||
required this.isPickFile,
|
||||
this.initDir,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LocalStoragePage> createState() => _LocalStoragePageState();
|
||||
@@ -78,10 +79,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.downloading),
|
||||
onPressed: () => AppRoute(
|
||||
const SftpMissionPage(),
|
||||
'sftp downloading',
|
||||
).go(context),
|
||||
onPressed: () => AppRoute.sftpMission().go(context),
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -256,11 +254,8 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
);
|
||||
return;
|
||||
}
|
||||
final result = await AppRoute(
|
||||
EditorPage(
|
||||
final result = await AppRoute.editor(
|
||||
path: file.absolute.path,
|
||||
),
|
||||
'sftp dled editor',
|
||||
).go<String>(context);
|
||||
final f = File(file.absolute.path);
|
||||
if (result != null) {
|
||||
|
||||
@@ -9,8 +9,6 @@ import 'package:toolbox/core/extension/navigator.dart';
|
||||
import 'package:toolbox/core/extension/sftpfile.dart';
|
||||
import 'package:toolbox/data/res/misc.dart';
|
||||
import 'package:toolbox/data/store/history.dart';
|
||||
import 'package:toolbox/view/page/editor.dart';
|
||||
import 'package:toolbox/view/page/storage/local.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
|
||||
import '../../../core/extension/numx.dart';
|
||||
@@ -31,7 +29,6 @@ import '../../widget/custom_appbar.dart';
|
||||
import '../../widget/fade_in.dart';
|
||||
import '../../widget/input_field.dart';
|
||||
import '../../widget/two_line_text.dart';
|
||||
import 'sftp_mission.dart';
|
||||
|
||||
class SftpPage extends StatefulWidget {
|
||||
final ServerPrivateInfo spi;
|
||||
@@ -92,10 +89,7 @@ class _SftpPageState extends State<SftpPage> {
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.downloading),
|
||||
onPressed: () => AppRoute(
|
||||
const SftpMissionPage(),
|
||||
'sftp downloading',
|
||||
).go(context),
|
||||
onPressed: () => AppRoute.sftpMission().go(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -176,11 +170,7 @@ class _SftpPageState extends State<SftpPage> {
|
||||
final path = await () async {
|
||||
switch (idx) {
|
||||
case 0:
|
||||
return await AppRoute(
|
||||
const LocalStoragePage(
|
||||
isPickFile: true,
|
||||
),
|
||||
'sftp dled pick')
|
||||
return await AppRoute.localStorage(isPickFile: true)
|
||||
.go<String>(context);
|
||||
case 1:
|
||||
return await pickOneFile();
|
||||
@@ -390,10 +380,7 @@ class _SftpPageState extends State<SftpPage> {
|
||||
await completer.future;
|
||||
context.pop();
|
||||
|
||||
final result = await AppRoute(
|
||||
EditorPage(path: localPath),
|
||||
'SFTP edit',
|
||||
).go<String>(context);
|
||||
final result = await AppRoute.editor(path: localPath).go<String>(context);
|
||||
if (result != null) {
|
||||
_sftp.add(SftpReq(req.spi, remotePath, localPath, SftpReqType.upload));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:toolbox/core/extension/datetime.dart';
|
||||
import 'package:toolbox/core/extension/navigator.dart';
|
||||
import 'package:toolbox/core/route.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
import 'package:toolbox/view/page/storage/local.dart';
|
||||
|
||||
import '../../../core/extension/numx.dart';
|
||||
import '../../../core/utils/misc.dart';
|
||||
@@ -77,10 +76,7 @@ class _SftpMissionPageState extends State<SftpMissionPage> {
|
||||
onPressed: () {
|
||||
final idx = status.req.localPath.lastIndexOf('/');
|
||||
final dir = status.req.localPath.substring(0, idx);
|
||||
AppRoute(
|
||||
LocalStoragePage(initDir: dir),
|
||||
'sftp local',
|
||||
).go(context);
|
||||
AppRoute.localStorage(initDir: dir).go(context);
|
||||
},
|
||||
icon: const Icon(Icons.file_open)),
|
||||
IconButton(
|
||||
|
||||
@@ -14,7 +14,6 @@ import '../../data/model/server/server_private_info.dart';
|
||||
import '../../data/model/server/snippet.dart';
|
||||
import '../../data/provider/snippet.dart';
|
||||
import '../../locator.dart';
|
||||
import '../page/process.dart';
|
||||
import 'tag.dart';
|
||||
|
||||
class ServerFuncBtns extends StatelessWidget {
|
||||
@@ -84,7 +83,7 @@ class ServerFuncBtns extends StatelessWidget {
|
||||
);
|
||||
break;
|
||||
case ServerTabMenuType.process:
|
||||
AppRoute(ProcessPage(spi: spi), 'process page').checkGo(
|
||||
AppRoute.process(spi: spi).checkGo(
|
||||
context: context,
|
||||
check: () => _checkClient(context, spi.id),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user