#48 display all support devices temperature
This commit is contained in:
@@ -55,9 +55,7 @@ class BackupPage extends StatelessWidget {
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 107,
|
||||
),
|
||||
const SizedBox(height: 107),
|
||||
_buildCard(s.restore, Icons.download, media, () async {
|
||||
final path = await pickOneFile();
|
||||
if (path == null) {
|
||||
@@ -72,12 +70,12 @@ class BackupPage extends StatelessWidget {
|
||||
final text = await file.readAsString();
|
||||
_import(text, context, s);
|
||||
}),
|
||||
const SizedBox(height: 17),
|
||||
height13,
|
||||
const SizedBox(
|
||||
width: 37,
|
||||
child: Divider(),
|
||||
),
|
||||
const SizedBox(height: 17),
|
||||
height13,
|
||||
_buildCard(
|
||||
s.backup,
|
||||
Icons.file_upload,
|
||||
@@ -122,7 +120,7 @@ class BackupPage extends StatelessWidget {
|
||||
icon,
|
||||
color: textColor,
|
||||
),
|
||||
const SizedBox(width: 7),
|
||||
width7,
|
||||
Text(text, style: TextStyle(color: textColor)),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/data/res/ui.dart';
|
||||
|
||||
import '../../core/utils/ui.dart';
|
||||
import '../widget/input_field.dart';
|
||||
@@ -48,7 +49,7 @@ class _ConvertPageState extends State<ConvertPage>
|
||||
controller: ScrollController(),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 13),
|
||||
height13,
|
||||
_buildInputTop(),
|
||||
_buildMiddleBtns(),
|
||||
_buildResult(),
|
||||
|
||||
@@ -277,7 +277,7 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
|
||||
Widget _buildImages() {
|
||||
if (_docker.images == null) {
|
||||
return const SizedBox();
|
||||
return placeholder;
|
||||
}
|
||||
final items = _docker.images!
|
||||
.map(
|
||||
@@ -336,7 +336,7 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
}
|
||||
|
||||
Widget _buildLoading() {
|
||||
if (!_docker.isBusy) return const SizedBox();
|
||||
if (!_docker.isBusy) return placeholder;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(17),
|
||||
child: Column(
|
||||
@@ -344,7 +344,7 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
const SizedBox(height: 17),
|
||||
height13,
|
||||
Text(_docker.runLog ?? '...'),
|
||||
],
|
||||
),
|
||||
@@ -353,7 +353,7 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
|
||||
Widget _buildEditHost() {
|
||||
if (_docker.items!.isNotEmpty || _docker.images!.isNotEmpty) {
|
||||
return const SizedBox();
|
||||
return placeholder;
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(17, 17, 17, 0),
|
||||
|
||||
@@ -53,7 +53,7 @@ class _PingPageState extends State<PingPage>
|
||||
padding: const EdgeInsets.symmetric(horizontal: 7),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 13),
|
||||
height13,
|
||||
Input(
|
||||
controller: _textEditingController,
|
||||
hint: s.inputDomainHere,
|
||||
|
||||
@@ -133,7 +133,7 @@ class _PkgManagePageState extends State<PkgManagePage>
|
||||
|
||||
Widget _buildFAB(PkgProvider pkg) {
|
||||
if (pkg.isBusy || (pkg.upgradeable?.isEmpty ?? true)) {
|
||||
return const SizedBox();
|
||||
return placeholder;
|
||||
}
|
||||
return FloatingActionButton(
|
||||
onPressed: () {
|
||||
|
||||
@@ -42,13 +42,13 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
late PrivateKeyProvider _provider;
|
||||
late S _s;
|
||||
|
||||
Widget _loading = const SizedBox();
|
||||
Widget _loading = placeholder;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_provider = locator<PrivateKeyProvider>();
|
||||
_loading = const SizedBox();
|
||||
_loading = placeholder;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -79,7 +79,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
context.pop();
|
||||
},
|
||||
icon: const Icon(Icons.delete))
|
||||
: const SizedBox()
|
||||
: placeholder
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
rethrow;
|
||||
} finally {
|
||||
setState(() {
|
||||
_loading = const SizedBox();
|
||||
_loading = placeholder;
|
||||
});
|
||||
}
|
||||
if (widget.info != null) {
|
||||
|
||||
@@ -60,47 +60,38 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(13),
|
||||
children: [
|
||||
...(_buildLinuxIcon(si.status.sysVer) ?? []),
|
||||
_buildLinuxIcon(si.status.sysVer),
|
||||
_buildUpTimeAndSys(si.status),
|
||||
_buildCPUView(si.status),
|
||||
_buildMemView(si.status),
|
||||
_buildSwapView(si.status),
|
||||
_buildDiskView(si.status),
|
||||
_buildNetView(si.status.netSpeed),
|
||||
// avoid the hieght of navigation bar
|
||||
_buildTemperature(si.status),
|
||||
// height of navigation bar
|
||||
SizedBox(height: _media.padding.bottom),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget>? _buildLinuxIcon(String sysVer) {
|
||||
if (!_showDistLogo) return null;
|
||||
Widget _buildLinuxIcon(String sysVer) {
|
||||
if (!_showDistLogo) return placeholder;
|
||||
final iconPath = sysVer.dist?.iconPath;
|
||||
if (iconPath == null) return null;
|
||||
return [
|
||||
SizedBox(height: _media.size.height * 0.03),
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: _media.size.height * 0.13,
|
||||
maxWidth: _media.size.width * 0.6,
|
||||
),
|
||||
child: Image.asset(
|
||||
iconPath,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
if (iconPath == null) return placeholder;
|
||||
return ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: _media.size.height * 0.13,
|
||||
maxWidth: _media.size.width * 0.6,
|
||||
),
|
||||
SizedBox(height: _media.size.height * 0.03),
|
||||
];
|
||||
child: Image.asset(
|
||||
iconPath,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCPUView(ServerStatus ss) {
|
||||
final tempWidget = ss.cpu.temp.isEmpty
|
||||
? const SizedBox()
|
||||
: Text(
|
||||
ss.cpu.temp,
|
||||
style: textSize13Grey,
|
||||
);
|
||||
return RoundRectCard(
|
||||
Padding(
|
||||
padding: roundRectCardPadding,
|
||||
@@ -108,16 +99,10 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'${ss.cpu.usedPercent(coreIdx: 0).toInt()}%',
|
||||
style: textSize27,
|
||||
textScaleFactor: 1.0,
|
||||
),
|
||||
width7,
|
||||
tempWidget
|
||||
],
|
||||
Text(
|
||||
'${ss.cpu.usedPercent(coreIdx: 0).toInt()}%',
|
||||
style: textSize27,
|
||||
textScaleFactor: 1.0,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
@@ -244,7 +229,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildSwapView(ServerStatus ss) {
|
||||
if (ss.swap.total == 0) return const SizedBox();
|
||||
if (ss.swap.total == 0) return placeholder;
|
||||
final used = ss.swap.usedPercent * 100;
|
||||
final cached = ss.swap.cached / ss.swap.total * 100;
|
||||
return RoundRectCard(
|
||||
@@ -396,5 +381,40 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTemperature(ServerStatus ss) {
|
||||
if (ss.temps.isEmpty) {
|
||||
return placeholder;
|
||||
}
|
||||
final List<Widget> children = [
|
||||
const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Icon(Icons.device_hub, size: 17),
|
||||
Icon(Icons.arrow_downward, size: 17),
|
||||
],
|
||||
),
|
||||
const Padding(padding: EdgeInsets.symmetric(vertical: 3), child: Divider(height: 7),),
|
||||
];
|
||||
children.addAll(ss.temps.devices.map((key) => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
key,
|
||||
style: textSize11,
|
||||
textScaleFactor: 1.0,
|
||||
),
|
||||
Text(
|
||||
'${ss.temps.get(key)}°C',
|
||||
style: textSize11,
|
||||
textScaleFactor: 1.0,
|
||||
),
|
||||
],
|
||||
)));
|
||||
return RoundRectCard(Padding(
|
||||
padding: roundRectCardPadding,
|
||||
child: Column(children: children),
|
||||
));
|
||||
}
|
||||
|
||||
static const _ignorePath = ['udev', 'tmpfs', 'devtmpfs'];
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
return AppBar(
|
||||
title: Text(_s.edit, style: textSize18),
|
||||
actions: [
|
||||
widget.spi != null ? delBtn : const SizedBox(),
|
||||
widget.spi != null ? delBtn : placeholder,
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -165,8 +165,8 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
hint: _s.pwd,
|
||||
onSubmitted: (_) => {},
|
||||
)
|
||||
: const SizedBox(),
|
||||
usePublicKey ? _buildKeyAuth() : const SizedBox()
|
||||
: placeholder,
|
||||
usePublicKey ? _buildKeyAuth() : placeholder
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -108,20 +108,20 @@ class _ServerPageState extends State<ServerPage>
|
||||
|
||||
Widget _buildEachServerCard(Server? si) {
|
||||
if (si == null) {
|
||||
return const SizedBox();
|
||||
return placeholder;
|
||||
}
|
||||
return RoundRectCard(
|
||||
GestureDetector(
|
||||
child: Padding(
|
||||
return GestureDetector(
|
||||
key: Key(si.spi.id),
|
||||
onTap: () => AppRoute(
|
||||
ServerDetailPage(si.spi.id),
|
||||
'server detail page',
|
||||
).go(context),
|
||||
child: RoundRectCard(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(13),
|
||||
child: _buildRealServerCard(si.status, si.state, si.spi),
|
||||
),
|
||||
onTap: () => AppRoute(
|
||||
ServerDetailPage(si.spi.id),
|
||||
'server detail page',
|
||||
).go(context),
|
||||
),
|
||||
key: Key(si.spi.id),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -136,9 +136,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildServerCardTitle(ss, cs, spi),
|
||||
const SizedBox(
|
||||
height: 17,
|
||||
),
|
||||
height13,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
@@ -149,7 +147,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
'Total:\n${rootDisk.size}', 'Used:\n${rootDisk.usedPercent}%')
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 13),
|
||||
height13,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
@@ -169,9 +167,6 @@ class _ServerPageState extends State<ServerPage>
|
||||
ServerState cs,
|
||||
ServerPrivateInfo spi,
|
||||
) {
|
||||
final topRightStr =
|
||||
getTopRightStr(cs, ss.cpu.temp, ss.uptime, ss.failedInfo);
|
||||
final hasError = cs == ServerState.failed && ss.failedInfo != null;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 7),
|
||||
child: Row(
|
||||
@@ -194,32 +189,8 @@ class _ServerPageState extends State<ServerPage>
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
hasError
|
||||
? GestureDetector(
|
||||
onTap: () => showRoundDialog(
|
||||
context: context,
|
||||
title: Text(_s.error),
|
||||
child: Text(ss.failedInfo ?? _s.unknownError),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => copy2Clipboard(
|
||||
ss.failedInfo ?? _s.unknownError),
|
||||
child: Text(_s.copy),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
_s.viewErr,
|
||||
style: textSize12Grey,
|
||||
textScaleFactor: 1.0,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
topRightStr,
|
||||
style: textSize12Grey,
|
||||
textScaleFactor: 1.0,
|
||||
),
|
||||
const SizedBox(width: 9),
|
||||
_buildTopRightText(ss, cs),
|
||||
width7,
|
||||
_buildSSHBtn(spi),
|
||||
_buildMoreBtn(spi),
|
||||
],
|
||||
@@ -229,6 +200,41 @@ class _ServerPageState extends State<ServerPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTopRightText(ServerStatus ss, ServerState cs) {
|
||||
final topRightStr = getTopRightStr(
|
||||
cs,
|
||||
ss.temps.first,
|
||||
ss.uptime,
|
||||
ss.failedInfo,
|
||||
);
|
||||
final hasError = cs == ServerState.failed && ss.failedInfo != null;
|
||||
return hasError
|
||||
? GestureDetector(
|
||||
onTap: () => showRoundDialog(
|
||||
context: context,
|
||||
title: Text(_s.error),
|
||||
child: Text(ss.failedInfo ?? _s.unknownError),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
copy2Clipboard(ss.failedInfo ?? _s.unknownError),
|
||||
child: Text(_s.copy),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
_s.viewErr,
|
||||
style: textSize12Grey,
|
||||
textScaleFactor: 1.0,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
topRightStr,
|
||||
style: textSize12Grey,
|
||||
textScaleFactor: 1.0,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSSHBtn(ServerPrivateInfo spi) {
|
||||
return GestureDetector(
|
||||
child: const Icon(
|
||||
@@ -311,24 +317,18 @@ class _ServerPageState extends State<ServerPage>
|
||||
}
|
||||
|
||||
String getTopRightStr(
|
||||
ServerState cs, String temp, String upTime, String? failedInfo) {
|
||||
ServerState cs,
|
||||
double? temp,
|
||||
String upTime,
|
||||
String? failedInfo,
|
||||
) {
|
||||
switch (cs) {
|
||||
case ServerState.disconnected:
|
||||
return _s.disconnected;
|
||||
case ServerState.connected:
|
||||
if (temp == '') {
|
||||
if (upTime == '') {
|
||||
return _s.serverTabLoading;
|
||||
} else {
|
||||
return upTime;
|
||||
}
|
||||
} else {
|
||||
if (upTime == '') {
|
||||
return temp;
|
||||
} else {
|
||||
return '$temp | $upTime';
|
||||
}
|
||||
}
|
||||
final tempStr = temp == null ? '' : '${temp.toStringAsFixed(1)}°C';
|
||||
final items = [tempStr, upTime];
|
||||
return items.where((element) => element.isNotEmpty).join(' | ');
|
||||
case ServerState.connecting:
|
||||
return _s.serverTabConnecting;
|
||||
case ServerState.failed:
|
||||
|
||||
@@ -317,7 +317,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
.toList();
|
||||
return ListTile(
|
||||
title: Text(
|
||||
_s.termTheme,
|
||||
_s.theme,
|
||||
),
|
||||
onTap: () {
|
||||
termThemeKey.currentState?.showButtonMenu();
|
||||
@@ -465,7 +465,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
Widget _buildFont() {
|
||||
final fontName = getFileName(_setting.fontPath.fetch());
|
||||
return ListTile(
|
||||
title: Text(_s.choose),
|
||||
title: Text(_s.font),
|
||||
trailing: Text(
|
||||
fontName ?? _s.notSelected,
|
||||
style: textSize15,
|
||||
|
||||
@@ -266,7 +266,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
title: Text(_s.download),
|
||||
onTap: () => download(context, file),
|
||||
)
|
||||
: const SizedBox()
|
||||
: placeholder
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
|
||||
@@ -54,7 +54,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
},
|
||||
tooltip: _s.delete,
|
||||
icon: const Icon(Icons.delete))
|
||||
: const SizedBox()
|
||||
: placeholder
|
||||
],
|
||||
),
|
||||
body: _buildBody(),
|
||||
|
||||
Reference in New Issue
Block a user