mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-10 02:05:03 +01:00
opt.: custom diskIgnorePath
This commit is contained in:
@@ -27,14 +27,13 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late MediaQueryData _media;
|
||||
late S _s;
|
||||
bool _showDistLogo = true;
|
||||
final _setting = locator<SettingStore>();
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_media = MediaQuery.of(context);
|
||||
_s = S.of(context)!;
|
||||
_showDistLogo = locator<SettingStore>().showDistLogo.fetch()!;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -76,7 +75,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildLinuxIcon(String sysVer) {
|
||||
if (!_showDistLogo) return placeholder;
|
||||
if (!_setting.showDistLogo.fetch()!) return placeholder;
|
||||
final iconPath = sysVer.dist?.iconPath;
|
||||
if (iconPath == null) return placeholder;
|
||||
return ConstrainedBox(
|
||||
@@ -262,13 +261,13 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildDiskView(ServerStatus ss) {
|
||||
final clone = ss.disk.toList();
|
||||
for (var item in ss.disk) {
|
||||
if (_ignorePath.any((ele) => item.path.startsWith(ele))) {
|
||||
clone.remove(item);
|
||||
ss.disk.removeWhere((e) {
|
||||
for (final ingorePath in _setting.diskIgnorePath.fetch()!) {
|
||||
if (e.path.startsWith(ingorePath)) return true;
|
||||
}
|
||||
}
|
||||
final children = clone
|
||||
return false;
|
||||
});
|
||||
final children = ss.disk
|
||||
.map((disk) => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Column(
|
||||
@@ -344,14 +343,14 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildNetSpeedItem(NetSpeed ns, String device) {
|
||||
final width = (_media.size.width - 34 - 34) / 3;
|
||||
final width = (_media.size.width - 34 - 34) / 2.9;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: width,
|
||||
width: width / 1.2,
|
||||
child: Text(
|
||||
device,
|
||||
style: textSize11,
|
||||
@@ -364,7 +363,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
'${ns.speedIn(device: device)} | ${ns.totalIn(device: device)}',
|
||||
style: textSize11,
|
||||
textAlign: TextAlign.center,
|
||||
textScaleFactor: 0.9,
|
||||
textScaleFactor: 0.87,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
@@ -373,7 +372,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
'${ns.speedOut(device: device)} | ${ns.totalOut(device: device)}',
|
||||
style: textSize11,
|
||||
textAlign: TextAlign.right,
|
||||
textScaleFactor: 0.9,
|
||||
textScaleFactor: 0.87,
|
||||
),
|
||||
)
|
||||
],
|
||||
@@ -393,7 +392,10 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
Icon(Icons.arrow_downward, size: 17),
|
||||
],
|
||||
),
|
||||
const Padding(padding: EdgeInsets.symmetric(vertical: 3), child: Divider(height: 7),),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 3),
|
||||
child: Divider(height: 7),
|
||||
),
|
||||
];
|
||||
children.addAll(ss.temps.devices.map((key) => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@@ -415,6 +417,4 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
child: Column(children: children),
|
||||
));
|
||||
}
|
||||
|
||||
static const _ignorePath = ['udev', 'tmpfs', 'devtmpfs'];
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -135,6 +136,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
_buildDistLogoSwitch(),
|
||||
_buildUpdateInterval(),
|
||||
_buildMaxRetry(),
|
||||
_buildDiskIgnorePath(),
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
);
|
||||
}
|
||||
@@ -568,4 +570,30 @@ class _SettingPageState extends State<SettingPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDiskIgnorePath() {
|
||||
final paths = _setting.diskIgnorePath.fetch()!;
|
||||
return ListTile(
|
||||
title: Text(_s.diskIgnorePath),
|
||||
trailing: Text(_s.edit, style: textSize15,),
|
||||
onTap: () {
|
||||
showRoundDialog(context: context, child: Input(
|
||||
controller: TextEditingController(text: json.encode(paths)),
|
||||
label: 'JSON',
|
||||
type: TextInputType.visiblePassword,
|
||||
maxLines: 3,
|
||||
onSubmitted: (p0) {
|
||||
try {
|
||||
final list = List<String>.from(json.decode(p0));
|
||||
_setting.diskIgnorePath.put(list);
|
||||
context.pop();
|
||||
showSnackBar(context, Text(_s.success));
|
||||
} catch (e) {
|
||||
showSnackBar(context, Text(e.toString()));
|
||||
}
|
||||
},
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user