mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 07:44:26 +01:00
fix & opt.
This commit is contained in:
@@ -3,7 +3,6 @@ import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/route.dart';
|
||||
import 'package:toolbox/data/provider/private_key.dart';
|
||||
import 'package:toolbox/data/res/font_style.dart';
|
||||
import 'package:toolbox/data/res/padding.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/view/page/private_key/edit.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
@@ -32,36 +31,31 @@ class _PrivateKeyListState extends State<StoredPrivateKeysPage> {
|
||||
),
|
||||
body: Consumer<PrivateKeyProvider>(
|
||||
builder: (_, key, __) {
|
||||
return key.infos.isNotEmpty
|
||||
? ListView.builder(
|
||||
padding: const EdgeInsets.all(13),
|
||||
itemCount: key.infos.length,
|
||||
itemExtent: 57,
|
||||
itemBuilder: (context, idx) {
|
||||
return RoundRectCard(Padding(
|
||||
padding: roundRectCardPadding,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
key.infos[idx].id,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => AppRoute(
|
||||
PrivateKeyEditPage(info: key.infos[idx]),
|
||||
'private key edit page')
|
||||
.go(context),
|
||||
child: Text(_s.edit),
|
||||
)
|
||||
],
|
||||
),
|
||||
));
|
||||
})
|
||||
: Center(
|
||||
child: Text(_s.noSavedPrivateKey),
|
||||
);
|
||||
if (key.infos.isEmpty) {
|
||||
return Center(
|
||||
child: Text(_s.noSavedPrivateKey),
|
||||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(13),
|
||||
itemCount: key.infos.length,
|
||||
itemBuilder: (context, idx) {
|
||||
return RoundRectCard(
|
||||
ListTile(
|
||||
title: Text(
|
||||
key.infos[idx].id,
|
||||
),
|
||||
trailing: TextButton(
|
||||
onPressed: () => AppRoute(
|
||||
PrivateKeyEditPage(info: key.infos[idx]),
|
||||
'private key edit page')
|
||||
.go(context),
|
||||
child: Text(_s.edit),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
|
||||
@@ -23,6 +23,10 @@ class ServerDetailPage extends StatefulWidget {
|
||||
_ServerDetailPageState createState() => _ServerDetailPageState();
|
||||
}
|
||||
|
||||
const width13 = SizedBox(
|
||||
width: 13,
|
||||
);
|
||||
|
||||
class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late MediaQueryData _media;
|
||||
@@ -92,45 +96,44 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildCPUView(ServerStatus ss) {
|
||||
final tempWidget = ss.cpu2Status.temp.isEmpty
|
||||
? const SizedBox()
|
||||
: Text(
|
||||
ss.cpu2Status.temp,
|
||||
style: textSize13Grey,
|
||||
);
|
||||
return RoundRectCard(
|
||||
Padding(
|
||||
padding: roundRectCardPadding,
|
||||
child: SizedBox(
|
||||
height: 12 * ss.cpu2Status.coresCount + 63,
|
||||
child: Column(children: [
|
||||
SizedBox(
|
||||
height: _media.size.height * 0.02,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'${ss.cpu2Status.usedPercent(coreIdx: 0).toInt()}%',
|
||||
style: textSize27,
|
||||
textScaleFactor: 1.0,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
_buildDetailPercent(ss.cpu2Status.user, 'user'),
|
||||
SizedBox(
|
||||
width: _media.size.width * 0.03,
|
||||
),
|
||||
_buildDetailPercent(ss.cpu2Status.sys, 'sys'),
|
||||
SizedBox(
|
||||
width: _media.size.width * 0.03,
|
||||
),
|
||||
_buildDetailPercent(ss.cpu2Status.iowait, 'io'),
|
||||
SizedBox(
|
||||
width: _media.size.width * 0.03,
|
||||
),
|
||||
_buildDetailPercent(ss.cpu2Status.idle, 'idle')
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
_buildCPUProgress(ss)
|
||||
]),
|
||||
),
|
||||
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'${ss.cpu2Status.usedPercent(coreIdx: 0).toInt()}%',
|
||||
style: textSize27,
|
||||
textScaleFactor: 1.0,
|
||||
),
|
||||
tempWidget
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
_buildDetailPercent(ss.cpu2Status.user, 'user'),
|
||||
width13,
|
||||
_buildDetailPercent(ss.cpu2Status.sys, 'sys'),
|
||||
width13,
|
||||
_buildDetailPercent(ss.cpu2Status.iowait, 'io'),
|
||||
width13,
|
||||
_buildDetailPercent(ss.cpu2Status.idle, 'idle')
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
_buildCPUProgress(ss)
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -180,13 +183,13 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
value: percentWithinOne,
|
||||
minHeight: 7,
|
||||
backgroundColor: progressColor.resolve(context),
|
||||
color: pColor.withOpacity(0.5 + percentWithinOne / 2),
|
||||
color: pColor,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUpTimeAndSys(ServerStatus ss) {
|
||||
return RoundRectCard(Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 13, horizontal: 17),
|
||||
padding: roundRectCardPadding,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -208,40 +211,35 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
|
||||
return RoundRectCard(Padding(
|
||||
padding: roundRectCardPadding,
|
||||
child: SizedBox(
|
||||
height: 70,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text('${used.toStringAsFixed(0)}%', style: textSize27),
|
||||
const SizedBox(width: 7),
|
||||
Text('of ${(ss.memory.total * 1024).convertBytes}',
|
||||
style: textSize13Grey)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
_buildDetailPercent(free, 'free'),
|
||||
SizedBox(
|
||||
width: _media.size.width * 0.03,
|
||||
),
|
||||
_buildDetailPercent(avail, 'avail'),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 11,
|
||||
),
|
||||
_buildProgress(used)
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text('${used.toStringAsFixed(0)}%', style: textSize27),
|
||||
const SizedBox(width: 7),
|
||||
Text('of ${(ss.memory.total * 1024).convertBytes}',
|
||||
style: textSize13Grey)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
_buildDetailPercent(free, 'free'),
|
||||
width13,
|
||||
_buildDetailPercent(avail, 'avail'),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 11,
|
||||
),
|
||||
_buildProgress(used)
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
@@ -253,17 +251,11 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
clone.remove(item);
|
||||
}
|
||||
}
|
||||
return RoundRectCard(SizedBox(
|
||||
height: 27 * clone.length + 25,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 13, horizontal: 17),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: clone.length,
|
||||
itemBuilder: (_, idx) {
|
||||
final disk = clone[idx];
|
||||
return Padding(
|
||||
final children = clone
|
||||
.map((disk) => Padding(
|
||||
padding: const EdgeInsets.all(3),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@@ -280,8 +272,14 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
_buildProgress(disk.usedPercent.toDouble())
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
))
|
||||
.toList();
|
||||
return RoundRectCard(Padding(
|
||||
padding: roundRectCardPadding,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: children,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -304,7 +302,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
return RoundRectCard(Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 7, horizontal: 17),
|
||||
padding: roundRectCardPadding,
|
||||
child: Column(
|
||||
children: children,
|
||||
),
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:toolbox/data/provider/server.dart';
|
||||
import 'package:toolbox/data/res/build_data.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
import 'package:toolbox/data/res/font_style.dart';
|
||||
import 'package:toolbox/data/res/padding.dart';
|
||||
import 'package:toolbox/data/res/tab.dart';
|
||||
import 'package:toolbox/data/store/setting.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
@@ -99,7 +98,6 @@ class _SettingPageState extends State<SettingPage> {
|
||||
display = _s.versionUnknownUpdate(BuildData.build);
|
||||
}
|
||||
return ListTile(
|
||||
contentPadding: roundRectCardPadding,
|
||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||
title: Text(
|
||||
display,
|
||||
@@ -114,8 +112,6 @@ class _SettingPageState extends State<SettingPage> {
|
||||
|
||||
Widget _buildUpdateInterval() {
|
||||
return ExpansionTile(
|
||||
tilePadding: roundRectCardPadding,
|
||||
childrenPadding: roundRectCardPadding,
|
||||
textColor: priColor,
|
||||
title: Text(
|
||||
_s.updateServerStatusInterval,
|
||||
@@ -166,8 +162,6 @@ class _SettingPageState extends State<SettingPage> {
|
||||
Widget _buildAppColorPreview() {
|
||||
return ExpansionTile(
|
||||
textColor: priColor,
|
||||
tilePadding: roundRectCardPadding,
|
||||
childrenPadding: roundRectCardPadding,
|
||||
trailing: ClipOval(
|
||||
child: Container(
|
||||
color: priColor,
|
||||
@@ -205,8 +199,6 @@ class _SettingPageState extends State<SettingPage> {
|
||||
Widget _buildLaunchPage() {
|
||||
return ExpansionTile(
|
||||
textColor: priColor,
|
||||
tilePadding: roundRectCardPadding,
|
||||
childrenPadding: roundRectCardPadding,
|
||||
title: Text(
|
||||
_s.launchPage,
|
||||
style: textSize13,
|
||||
|
||||
@@ -75,6 +75,7 @@ class _SFTPDownloadingPageState extends State<SFTPDownloadingPage> {
|
||||
Widget _buildItem(SftpDownloadStatus status) {
|
||||
if (status.error != null) {
|
||||
showSnackBar(context, Text(status.error.toString()));
|
||||
status.error = null;
|
||||
}
|
||||
switch (status.status) {
|
||||
case SftpWorkerStatus.finished:
|
||||
|
||||
@@ -2,24 +2,25 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/extension/numx.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
import 'package:toolbox/core/route.dart';
|
||||
import 'package:toolbox/core/utils.dart';
|
||||
import 'package:toolbox/data/model/server/server.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/model/sftp/absolute_path.dart';
|
||||
import 'package:toolbox/data/model/sftp/download_worker.dart';
|
||||
import 'package:toolbox/data/model/sftp/browser_status.dart';
|
||||
import 'package:toolbox/data/provider/server.dart';
|
||||
import 'package:toolbox/data/provider/sftp_download.dart';
|
||||
import 'package:toolbox/data/res/path.dart';
|
||||
import 'package:toolbox/data/store/private_key.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
import 'package:toolbox/view/page/sftp/downloading.dart';
|
||||
import 'package:toolbox/view/widget/fade_in.dart';
|
||||
import 'package:toolbox/view/widget/two_line_text.dart';
|
||||
|
||||
import '../../../core/extension/numx.dart';
|
||||
import '../../../core/extension/stringx.dart';
|
||||
import '../../../core/route.dart';
|
||||
import '../../../core/utils.dart';
|
||||
import '../../../data/model/server/server.dart';
|
||||
import '../../../data/model/server/server_private_info.dart';
|
||||
import '../../../data/model/sftp/absolute_path.dart';
|
||||
import '../../../data/model/sftp/browser_status.dart';
|
||||
import '../../../data/model/sftp/download_item.dart';
|
||||
import '../../../data/provider/server.dart';
|
||||
import '../../../data/provider/sftp_download.dart';
|
||||
import '../../../data/res/path.dart';
|
||||
import '../../../data/store/private_key.dart';
|
||||
import '../../../generated/l10n.dart';
|
||||
import '../../../locator.dart';
|
||||
import '../../widget/fade_in.dart';
|
||||
import '../../widget/two_line_text.dart';
|
||||
import 'downloading.dart';
|
||||
|
||||
class SFTPPage extends StatefulWidget {
|
||||
final ServerPrivateInfo spi;
|
||||
@@ -62,38 +63,19 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
title: TwoLineText(up: 'SFTP', down: widget.spi.name),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: (() => showRoundDialog(
|
||||
context,
|
||||
_s.choose,
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.folder),
|
||||
title: Text(_s.createFolder),
|
||||
onTap: () => mkdir(context)),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.insert_drive_file),
|
||||
title: Text(_s.createFile),
|
||||
onTap: () => newFile(context)),
|
||||
],
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.close))
|
||||
],
|
||||
)),
|
||||
icon: const Icon(Icons.add),
|
||||
)
|
||||
icon: const Icon(Icons.downloading),
|
||||
onPressed: () =>
|
||||
AppRoute(const SFTPDownloadingPage(), 'sftp downloading')
|
||||
.go(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: _buildFileView(),
|
||||
bottomNavigationBar: _buildPath(),
|
||||
bottomNavigationBar: _buildBottom(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPath() {
|
||||
Widget _buildBottom() {
|
||||
return SafeArea(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(11, 7, 11, 11),
|
||||
@@ -112,6 +94,31 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
},
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: (() => showRoundDialog(
|
||||
context,
|
||||
_s.choose,
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.folder),
|
||||
title: Text(_s.createFolder),
|
||||
onTap: () => mkdir(context)),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.insert_drive_file),
|
||||
title: Text(_s.createFile),
|
||||
onTap: () => newFile(context)),
|
||||
],
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.close))
|
||||
],
|
||||
)),
|
||||
icon: const Icon(Icons.add),
|
||||
),
|
||||
IconButton(
|
||||
padding: const EdgeInsets.all(0),
|
||||
onPressed: () async {
|
||||
@@ -307,25 +314,6 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.goSftpDlPage,
|
||||
const SizedBox(),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
AppRoute(const SFTPDownloadingPage(), 'sftp downloading')
|
||||
.go(context);
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
child: Text(_s.download),
|
||||
)
|
||||
|
||||
@@ -2,9 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/route.dart';
|
||||
import 'package:toolbox/data/provider/snippet.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
import 'package:toolbox/data/res/font_style.dart';
|
||||
import 'package:toolbox/data/res/padding.dart';
|
||||
import 'package:toolbox/generated/l10n.dart';
|
||||
import 'package:toolbox/view/page/snippet/edit.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
@@ -17,8 +15,6 @@ class SnippetListPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SnippetListPageState extends State<SnippetListPage> {
|
||||
final _textStyle = TextStyle(color: primaryColor);
|
||||
|
||||
late S _s;
|
||||
|
||||
@override
|
||||
@@ -54,30 +50,18 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(13),
|
||||
itemCount: key.snippets.length,
|
||||
itemExtent: 57,
|
||||
itemBuilder: (context, idx) {
|
||||
return RoundRectCard(
|
||||
Padding(
|
||||
padding: roundRectCardPadding,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
key.snippets[idx].name,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => AppRoute(
|
||||
SnippetEditPage(snippet: key.snippets[idx]),
|
||||
'snippet edit page')
|
||||
.go(context),
|
||||
child: Text(
|
||||
_s.edit,
|
||||
style: _textStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
ListTile(
|
||||
title: Text(
|
||||
key.snippets[idx].name,
|
||||
),
|
||||
trailing: TextButton(
|
||||
onPressed: () => AppRoute(
|
||||
SnippetEditPage(snippet: key.snippets[idx]),
|
||||
'snippet edit page')
|
||||
.go(context),
|
||||
child: Text(_s.edit),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user