new: more battery data & fix: auto reload

This commit is contained in:
lollipopkit
2023-12-20 17:26:04 +08:00
parent 7283c968ae
commit 4a93b326db
26 changed files with 247 additions and 147 deletions

View File

@@ -33,7 +33,7 @@ class BackupPage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(
title: Text(l10n.backupAndRestore, style: UIs.textSize18),
title: Text(l10n.backupAndRestore, style: UIs.text18),
),
body: _buildBody(context),
);

View File

@@ -349,7 +349,7 @@ class _DockerManagePageState extends State<DockerManagePage> {
title: Text(item.image),
subtitle: Text(
'${item.name} - ${item.status}',
style: UIs.textSize13Grey,
style: UIs.text13Grey,
),
trailing: _buildMoreBtn(item),
);

View File

@@ -245,7 +245,7 @@ class _FullScreenPageState extends State<FullScreenPage> with AfterLayoutMixin {
);
return Text(
topRightStr,
style: UIs.textSize11Grey,
style: UIs.text11Grey,
);
}

View File

@@ -200,7 +200,7 @@ class _HomePageState extends State<HomePage>
child: Text(
'${BuildData.name}\n$_versionStr',
textAlign: TextAlign.center,
style: UIs.textSize15,
style: UIs.text15,
),
),
const SizedBox(height: 37),

View File

@@ -131,7 +131,7 @@ class _PingPageState extends State<PingPage>
),
subtitle: Text(
_buildPingSummary(result, unknown, ms),
style: UIs.textSize11,
style: UIs.text11,
),
trailing: Text(
'${l10n.pingAvg}${result.statistic?.avg?.toStringAsFixed(2) ?? l10n.unknown} $ms',

View File

@@ -113,7 +113,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
)
];
return CustomAppBar(
title: Text(l10n.edit, style: UIs.textSize18),
title: Text(l10n.edit, style: UIs.text18),
actions: widget.pki == null ? null : actions,
);
}

View File

@@ -30,7 +30,7 @@ class _PrivateKeyListState extends State<PrivateKeysListPage>
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(
title: Text(l10n.privateKey, style: UIs.textSize18),
title: Text(l10n.privateKey, style: UIs.text18),
),
body: _buildBody(),
floatingActionButton: FloatingActionButton(

View File

@@ -6,6 +6,7 @@ import 'package:toolbox/core/extension/context/locale.dart';
import 'package:toolbox/core/extension/order.dart';
import 'package:toolbox/core/extension/status_cmd_type.dart';
import 'package:toolbox/core/extension/widget.dart';
import 'package:toolbox/data/model/server/battery.dart';
import 'package:toolbox/data/model/server/cpu.dart';
import 'package:toolbox/data/model/server/disk.dart';
import 'package:toolbox/data/model/server/net_speed.dart';
@@ -53,6 +54,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
_buildDiskView,
_buildNetView,
_buildTemperature,
_buildBatteries,
],
);
@@ -89,7 +91,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
final buildFuncs = !Stores.setting.moveOutServerTabFuncBtns.fetch();
return Scaffold(
appBar: CustomAppBar(
title: Text(si.spi.name, style: UIs.textSize18),
title: Text(si.spi.name, style: UIs.text18),
actions: [
IconButton(
icon: const Icon(Icons.edit),
@@ -135,8 +137,8 @@ class _ServerDetailPageState extends State<ServerDetailPage>
(e) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(e.key.i18n, style: UIs.textSize13),
Text(e.value, style: UIs.textSize13Grey)
Text(e.key.i18n, style: UIs.text13),
Text(e.value, style: UIs.text13Grey)
],
).padding(const EdgeInsets.symmetric(vertical: 2)),
)
@@ -168,7 +170,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
child: _buildAnimatedText(
ValueKey(percent),
'$percent%',
UIs.textSize27,
UIs.text27,
),
),
childrenPadding: const EdgeInsets.symmetric(vertical: 13),
@@ -248,12 +250,12 @@ class _ServerDetailPageState extends State<ServerDetailPage>
_buildAnimatedText(
ValueKey(usedStr),
'$usedStr%',
UIs.textSize27,
UIs.text27,
),
UIs.width7,
Text(
'of ${(ss.mem.total * 1024).convertBytes}',
style: UIs.textSize13Grey,
style: UIs.text13Grey,
)
],
),
@@ -290,11 +292,11 @@ class _ServerDetailPageState extends State<ServerDetailPage>
children: [
Row(
children: [
Text('${used.toStringAsFixed(0)}%', style: UIs.textSize27),
Text('${used.toStringAsFixed(0)}%', style: UIs.text27),
UIs.width7,
Text(
'of ${(ss.swap.total * 1024).convertBytes} ',
style: UIs.textSize13Grey,
style: UIs.text13Grey,
)
],
),
@@ -330,7 +332,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
children.addAll(processes.map((e) => _buildGpuProcessItem(e)));
}
return ListTile(
title: Text(item.name, style: UIs.textSize13),
title: Text(item.name, style: UIs.text13),
subtitle: Text(
'${item.power} - ${item.temp} °C\n${mem.used} / ${mem.total} ${mem.unit} - ${item.fanSpeed} RPM',
style: UIs.text12Grey,
@@ -483,7 +485,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
backgroundColor: DynamicColors.progress.resolve(context),
color: primaryColor,
),
Text('${disk.usedPercent}%', style: UIs.textSize13Grey)
Text('${disk.usedPercent}%', style: UIs.text13Grey)
],
),
)
@@ -498,7 +500,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
children.add(Center(
child: Text(
l10n.noInterface,
style: UIs.textSize13Grey,
style: UIs.text13Grey,
),
));
} else {
@@ -531,7 +533,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
UIs.width7,
Text(
_netSortType.name,
style: UIs.textSize13Grey,
style: UIs.text13Grey,
),
],
),
@@ -576,7 +578,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
child: Text(
'${ns.speedOut(device: device)}\n${ns.speedIn(device: device)}',
textAlign: TextAlign.end,
style: UIs.textSize13Grey,
style: UIs.text13Grey,
),
)
],
@@ -607,8 +609,43 @@ class _ServerDetailPageState extends State<ServerDetailPage>
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(key, style: UIs.textSize15),
Text('${val?.toStringAsFixed(1)}°C', style: UIs.textSize13Grey),
Text(key, style: UIs.text15),
Text('${val?.toStringAsFixed(1)}°C', style: UIs.text13Grey),
],
),
);
}
Widget _buildBatteries(ServerStatus ss) {
if (ss.batteries.isEmpty) {
return UIs.placeholder;
}
return CardX(
child: ExpandTile(
title: Text(l10n.battery),
leading: const Icon(Icons.battery_charging_full, size: 17),
childrenPadding: const EdgeInsets.only(bottom: 7),
children: ss.batteries.map(_buildBatteryItem).toList(),
),
);
}
Widget _buildBatteryItem(Battery battery) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 5),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('${battery.name}', style: UIs.text15),
Text('${battery.status.name} - ${battery.cycle} - ${battery.powerNow}', style: UIs.text13Grey),
],
),
Text('${battery.percent?.toStringAsFixed(0)}%',
style: UIs.text13Grey),
],
),
);

View File

@@ -109,7 +109,7 @@ class _ServerEditPageState extends State<ServerEditPage> {
PreferredSizeWidget _buildAppBar() {
return CustomAppBar(
title: Text(l10n.edit, style: UIs.textSize18),
title: Text(l10n.edit, style: UIs.text18),
actions: widget.spi != null
? [
IconButton(

View File

@@ -358,7 +358,7 @@ class _ServerPageState extends State<ServerPage>
children: [
Text(
spi.name,
style: UIs.textSize13Bold,
style: UIs.text13Bold,
),
const Icon(
Icons.keyboard_arrow_right,
@@ -390,13 +390,13 @@ class _ServerPageState extends State<ServerPage>
onTap: () => _showFailReason(ss),
child: Text(
l10n.viewErr,
style: UIs.textSize13Grey,
style: UIs.text13Grey,
),
);
}
return Text(
topRightStr,
style: UIs.textSize13Grey,
style: UIs.text13Grey,
);
}
@@ -500,25 +500,20 @@ class _ServerPageState extends State<ServerPage>
if (percent <= 0) percent = 0.01;
if (percent >= 100) percent = 99.9;
return Stack(
alignment: Alignment.center,
children: [
Center(
child: CircleChart(
progressColor: primaryColor,
progressNumber: percent,
maxNumber: 100,
width: 57,
height: 57,
animationDuration: const Duration(milliseconds: 777),
),
CircleChart(
progressColor: primaryColor,
progressNumber: percent,
maxNumber: 100,
width: 57,
height: 57,
animationDuration: const Duration(milliseconds: 777),
),
Positioned.fill(
child: Center(
child: Text(
'${percent.toStringAsFixed(1)}%',
textAlign: TextAlign.center,
style: UIs.textSize13,
),
),
Text(
'${percent.toStringAsFixed(1)}%',
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 12.7),
),
],
);

View File

@@ -151,7 +151,8 @@ class _SettingPageState extends State<SettingPage> {
_buildSFTP(),
_buildTitle(l10n.editor),
_buildEditor(),
/// Fullscreen Mode is designed for old mobile phone which can be
/// Fullscreen Mode is designed for old mobile phone which can be
/// used as a status screen, so it's only available on mobile phone.
if (!isDesktop) _buildTitle(l10n.fullScreen),
if (!isDesktop) _buildFullScreen(),
@@ -301,7 +302,7 @@ class _SettingPageState extends State<SettingPage> {
},
child: Text(
'${_updateInterval.value} ${l10n.second}',
style: UIs.textSize15,
style: UIs.text15,
),
),
),
@@ -455,7 +456,7 @@ class _SettingPageState extends State<SettingPage> {
},
child: Text(
'${_maxRetryCount.value} ${l10n.times}',
style: UIs.textSize15,
style: UIs.text15,
),
),
listenable: _maxRetryCount,
@@ -504,7 +505,7 @@ class _SettingPageState extends State<SettingPage> {
},
child: Text(
_buildThemeModeStr(_nightMode.value),
style: UIs.textSize15,
style: UIs.text15,
),
),
),
@@ -532,7 +533,7 @@ class _SettingPageState extends State<SettingPage> {
title: Text(l10n.font),
trailing: Text(
fontName ?? l10n.notSelected,
style: UIs.textSize15,
style: UIs.text15,
),
onTap: () {
context.showRoundDialog(
@@ -583,7 +584,7 @@ class _SettingPageState extends State<SettingPage> {
title: Text(l10n.fontSize),
trailing: Text(
_termFontSize.value.toString(),
style: UIs.textSize15,
style: UIs.text15,
),
onTap: () => _showFontSizeDialog(_termFontSize, _setting.termFontSize),
),
@@ -655,7 +656,7 @@ class _SettingPageState extends State<SettingPage> {
},
child: Text(
l10n.languageName,
style: UIs.textSize15,
style: UIs.text15,
),
),
),
@@ -693,7 +694,7 @@ class _SettingPageState extends State<SettingPage> {
},
child: Text(
_editorTheme.value,
style: UIs.textSize15,
style: UIs.text15,
),
),
),
@@ -726,7 +727,7 @@ class _SettingPageState extends State<SettingPage> {
},
child: Text(
_editorDarkTheme.value,
style: UIs.textSize15,
style: UIs.text15,
),
),
),
@@ -780,7 +781,7 @@ class _SettingPageState extends State<SettingPage> {
},
child: Text(
degrees[_rotateQuarter.value],
style: UIs.textSize15,
style: UIs.text15,
),
),
),
@@ -828,7 +829,7 @@ class _SettingPageState extends State<SettingPage> {
},
child: Text(
names[_keyboardType.value],
style: UIs.textSize15,
style: UIs.text15,
),
),
),
@@ -884,7 +885,7 @@ class _SettingPageState extends State<SettingPage> {
},
child: Text(
_netViewType.value.toStr,
style: UIs.textSize15,
style: UIs.text15,
),
),
),
@@ -946,7 +947,7 @@ class _SettingPageState extends State<SettingPage> {
listenable: _textScaler,
build: () => Text(
_textScaler.value.toString(),
style: UIs.textSize15,
style: UIs.text15,
),
),
onTap: () => context.showRoundDialog(
@@ -984,7 +985,7 @@ class _SettingPageState extends State<SettingPage> {
Widget _buildServerFuncBtns() {
return ListTile(
title: Text(l10n.location),
subtitle: Text(l10n.moveOutServerFuncBtnsHelp, style: UIs.textSize13Grey),
subtitle: Text(l10n.moveOutServerFuncBtnsHelp, style: UIs.text13Grey),
trailing: StoreSwitch(prop: _setting.moveOutServerTabFuncBtns),
);
}
@@ -1018,7 +1019,7 @@ class _SettingPageState extends State<SettingPage> {
title: Text(l10n.fontSize),
trailing: Text(
_editorFontSize.value.toString(),
style: UIs.textSize15,
style: UIs.text15,
),
onTap: () =>
_showFontSizeDialog(_editorFontSize, _setting.editorFontSize),

View File

@@ -6,7 +6,7 @@ import 'package:toolbox/data/res/ui.dart';
import 'package:toolbox/view/widget/future_widget.dart';
import 'package:toolbox/view/widget/store_switch.dart';
class PlatformPublicSettings {
abstract final class PlatformPublicSettings {
static Widget buildBioAuth() {
return FutureWidget<bool>(
future: BioAuth.isAvail,

View File

@@ -42,7 +42,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(
title: Text(l10n.edit, style: UIs.textSize18),
title: Text(l10n.edit, style: UIs.text18),
actions: _buildAppBarActions(),
),
body: _buildBody(),

View File

@@ -161,22 +161,22 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
Widget _buildAddBtn() {
return IconButton(
onPressed: () => context.showRoundDialog(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: const Icon(Icons.folder),
title: Text(l10n.createFolder),
onTap: _mkdir,
),
ListTile(
leading: const Icon(Icons.insert_drive_file),
title: Text(l10n.createFile),
onTap: _newFile,
),
],
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: const Icon(Icons.folder),
title: Text(l10n.createFolder),
onTap: _mkdir,
),
),
ListTile(
leading: const Icon(Icons.insert_drive_file),
title: Text(l10n.createFile),
onTap: _newFile,
),
],
),
),
icon: const Icon(Icons.add),
);
}

View File

@@ -27,7 +27,7 @@ class _SftpMissionPageState extends State<SftpMissionPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(
title: Text(l10n.mission, style: UIs.textSize18),
title: Text(l10n.mission, style: UIs.text18),
),
body: _buildBody(),
);

View File

@@ -29,7 +29,7 @@ class TagBtn extends StatelessWidget {
Text(
content,
textAlign: TextAlign.center,
style: isEnable ? UIs.textSize13 : UIs.textSize13Grey,
style: isEnable ? UIs.text13 : UIs.text13Grey,
),
onTap: onTap,
);
@@ -106,7 +106,7 @@ class _TagEditorState extends State<TagEditor> {
Text(
'#$tag',
textAlign: TextAlign.center,
style: isAdd ? UIs.textSize13Grey : UIs.textSize13,
style: isAdd ? UIs.text13Grey : UIs.text13,
),
const SizedBox(width: 4.0),
Icon(

View File

@@ -14,12 +14,12 @@ class TwoLineText extends StatelessWidget {
children: [
Text(
up,
style: UIs.textSize15,
style: UIs.text15,
overflow: TextOverflow.ellipsis,
),
Text(
down,
style: UIs.textSize11,
style: UIs.text11,
overflow: TextOverflow.ellipsis,
)
],