Skip to content

Commit

Permalink
new: setting of preferDiskAmount
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit committed Nov 19, 2023
1 parent 5660c0e commit 691471d
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions lib/view/page/server/tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:toolbox/data/model/app/shell_func.dart';
import 'package:toolbox/data/model/server/try_limiter.dart';
import 'package:toolbox/data/res/provider.dart';
import 'package:toolbox/data/res/store.dart';
import 'package:toolbox/view/widget/value_notifier.dart';

import '../../../core/route.dart';
import '../../../data/model/app/net_view.dart';
Expand Down Expand Up @@ -430,26 +431,32 @@ class _ServerPageState extends State<ServerPage>
}

Widget _buildDisk(ServerStatus ss, String id) {
final rootDisk = findRootDisk(ss.disk);
final isSpeed = _diskViewSpeed[id] ?? !Stores.setting.serverTabPreferDiskAmount.fetch();

final (r, w) = ss.diskIO.getAllSpeed();

return AnimatedSwitcher(
duration: const Duration(milliseconds: 377),
transitionBuilder: (Widget child, Animation<double> animation) {
return FadeTransition(opacity: animation, child: child);
return ValueBuilder(
listenable: Stores.setting.serverTabPreferDiskAmount.listenable(),
build: () {
final rootDisk = findRootDisk(ss.disk);
final isSpeed = _diskViewSpeed[id] ??
!Stores.setting.serverTabPreferDiskAmount.fetch();

final (r, w) = ss.diskIO.getAllSpeed();

return AnimatedSwitcher(
duration: const Duration(milliseconds: 377),
transitionBuilder: (Widget child, Animation<double> animation) {
return FadeTransition(opacity: animation, child: child);
},
child: _buildIOData(
isSpeed ? '${l10n.read}:\n$r' : 'Total:\n${rootDisk?.size}',
isSpeed ? '${l10n.write}:\n$w' : 'Used:\n${rootDisk?.usedPercent}%',
onTap: () {
setState(() {
_diskViewSpeed[id] = !isSpeed;
});
},
key: ValueKey(isSpeed),
),
);
},
child: _buildIOData(
isSpeed ? '${l10n.read}:\n$r' : 'Total:\n${rootDisk?.size}',
isSpeed ? '${l10n.write}:\n$w' : 'Used:\n${rootDisk?.usedPercent}%',
onTap: () {
setState(() {
_diskViewSpeed[id] = !isSpeed;
});
},
key: ValueKey(isSpeed),
),
);
}

Expand Down

0 comments on commit 691471d

Please sign in to comment.