readd: serverTabPreferDiskAmount (#780)

Fixes #643
This commit is contained in:
lollipopkit🏳️‍⚧️
2025-06-08 11:15:54 +08:00
committed by GitHub
parent b5aec55106
commit 4b3953e0d2
42 changed files with 343 additions and 515 deletions

View File

@@ -85,29 +85,26 @@ ${ss.err?.message ?? 'null'}
Widget _buildDisk(ServerStatus ss, String id) {
final cardNoti = _getCardNoti(id);
return ListenableBuilder(
listenable: cardNoti,
builder: (_, __) {
final isSpeed = cardNoti.value.diskIO ?? !Stores.setting.serverTabPreferDiskAmount.fetch();
return cardNoti.listenVal((v) {
final isSpeed = v.diskIO ?? !Stores.setting.serverTabPreferDiskAmount.fetch();
final (r, w) = ss.diskIO.cachedAllSpeed;
final (r, w) = ss.diskIO.cachedAllSpeed;
return AnimatedSwitcher(
duration: const Duration(milliseconds: 377),
transitionBuilder: (Widget child, Animation<double> animation) {
return FadeTransition(opacity: animation, child: child);
return AnimatedSwitcher(
duration: const Duration(milliseconds: 377),
transitionBuilder: (child, animation) {
return FadeTransition(opacity: animation, child: child);
},
child: _buildIOData(
isSpeed ? '${l10n.read}:\n$r' : 'Total:\n${ss.diskUsage?.size.kb2Str}',
isSpeed ? '${l10n.write}:\n$w' : 'Used:\n${ss.diskUsage?.used.kb2Str}',
onTap: () {
cardNoti.value = v.copyWith(diskIO: !isSpeed);
},
child: _buildIOData(
isSpeed ? '${l10n.read}:\n$r' : 'Total:\n${ss.diskUsage?.size.kb2Str}',
isSpeed ? '${l10n.write}:\n$w' : 'Used:\n${ss.diskUsage?.used.kb2Str}',
onTap: () {
cardNoti.value = cardNoti.value.copyWith(diskIO: !isSpeed);
},
key: ValueKey(isSpeed),
),
);
},
);
key: ValueKey(isSpeed),
),
);
});
}
Widget _buildNet(ServerStatus ss, String id) {

View File

@@ -42,17 +42,14 @@ extension on _ServerPageState {
final title = _buildServerCardTitle(srv);
final List<Widget> children = [title, _buildNormalCard(srv.status, srv.spi)];
return ListenableBuilder(
listenable: _getCardNoti(id),
builder: (_, __) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: children,
);
},
);
return _getCardNoti(id).listenVal((_) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: children,
);
});
});
},
);

View File

@@ -319,9 +319,7 @@ class _ServerPageState extends State<ServerPage> with AutomaticKeepAliveClientMi
],
),
UIs.height13,
if (Stores.setting.moveServerFuncs.fetch() &&
// Discussion #146
!Stores.setting.serverTabUseOldUI.fetch())
if (Stores.setting.moveServerFuncs.fetch())
SizedBox(height: 27, child: ServerFuncBtns(spi: spi)),
],
);

View File

@@ -100,9 +100,7 @@ extension _Utils on _ServerPageState {
if (flip) {
return _ServerPageState._kCardHeightFlip;
}
if (Stores.setting.moveServerFuncs.fetch() &&
// Discussion #146
!Stores.setting.serverTabUseOldUI.fetch()) {
if (Stores.setting.moveServerFuncs.fetch()) {
return _ServerPageState._kCardHeightMoveOutFuncs;
}
return _ServerPageState._kCardHeightNormal;