diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n.dart b/.dart_tool/flutter_gen/gen_l10n/l10n.dart index 6526deb2..2344f10f 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n.dart @@ -1118,6 +1118,12 @@ abstract class S { /// **'Password'** String get pwd; + /// No description provided for @read. + /// + /// In en, this message translates to: + /// **'Read'** + String get read; + /// No description provided for @reboot. /// /// In en, this message translates to: @@ -1567,6 +1573,12 @@ abstract class S { /// In en, this message translates to: /// **'Will take effect immediately'** String get willTakEeffectImmediately; + + /// No description provided for @write. + /// + /// In en, this message translates to: + /// **'Write'** + String get write; } class _SDelegate extends LocalizationsDelegate { diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart index 8f6e5259..b654c2c3 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_de.dart @@ -538,6 +538,9 @@ class SDe extends S { @override String get pwd => 'Passwort'; + @override + String get read => 'Lesen'; + @override String get reboot => 'Neustart'; @@ -778,4 +781,7 @@ class SDe extends S { @override String get willTakEeffectImmediately => 'Wird sofort angewendet'; + + @override + String get write => 'Schreiben'; } diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart index 421844d4..0e5b36e4 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_en.dart @@ -538,6 +538,9 @@ class SEn extends S { @override String get pwd => 'Password'; + @override + String get read => 'Read'; + @override String get reboot => 'Reboot'; @@ -778,4 +781,7 @@ class SEn extends S { @override String get willTakEeffectImmediately => 'Will take effect immediately'; + + @override + String get write => 'Write'; } diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart index 7518da6f..701d12b0 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_id.dart @@ -538,6 +538,9 @@ class SId extends S { @override String get pwd => 'Kata sandi'; + @override + String get read => 'Baca'; + @override String get reboot => 'Reboot'; @@ -778,4 +781,7 @@ class SId extends S { @override String get willTakEeffectImmediately => 'Akan segera berlaku'; + + @override + String get write => 'Tulis'; } diff --git a/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart b/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart index c602c9ec..6f120538 100644 --- a/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart +++ b/.dart_tool/flutter_gen/gen_l10n/l10n_zh.dart @@ -538,6 +538,9 @@ class SZh extends S { @override String get pwd => '密码'; + @override + String get read => '读'; + @override String get reboot => '重启'; @@ -778,6 +781,9 @@ class SZh extends S { @override String get willTakEeffectImmediately => '更改将会立即生效'; + + @override + String get write => '写'; } /// The translations for Chinese, as used in Taiwan (`zh_TW`). @@ -1318,6 +1324,9 @@ class SZhTw extends SZh { @override String get pwd => '密碼'; + @override + String get read => '读'; + @override String get reboot => '重启'; @@ -1558,4 +1567,7 @@ class SZhTw extends SZh { @override String get willTakEeffectImmediately => '更改將會立即生效'; + + @override + String get write => '写'; } diff --git a/lib/data/model/app/net_view.dart b/lib/data/model/app/net_view.dart index ba25fda8..3c2e9b3a 100644 --- a/lib/data/model/app/net_view.dart +++ b/lib/data/model/app/net_view.dart @@ -35,22 +35,22 @@ enum NetViewType { } } - NetViewData build(ServerStatus ss) { + (String, String) build(ServerStatus ss) { switch (this) { case NetViewType.conn: - return NetViewData( - 'Conn:\n${ss.tcp.maxConn}', - 'Fail:\n${ss.tcp.fail}', + return ( + '${l10n.conn}:\n${ss.tcp.maxConn}', + '${l10n.failed}:\n${ss.tcp.fail}', ); case NetViewType.speed: - return NetViewData( - 'In:\n${ss.netSpeed.speedIn(all: true)}', - 'Out:\n${ss.netSpeed.speedOut(all: true)}', + return ( + '↓:\n${ss.netSpeed.speedIn(all: true)}', + '↑:\n${ss.netSpeed.speedOut(all: true)}', ); case NetViewType.traffic: - return NetViewData( - 'In:\n${ss.netSpeed.sizeIn(all: true)}', - 'Out:\n${ss.netSpeed.sizeOut(all: true)}', + return ( + '↓:\n${ss.netSpeed.sizeIn(all: true)}', + '↑:\n${ss.netSpeed.sizeOut(all: true)}', ); } } @@ -77,10 +77,3 @@ enum NetViewType { } } } - -class NetViewData { - final String up; - final String down; - - NetViewData(this.up, this.down); -} diff --git a/lib/data/model/server/disk.dart b/lib/data/model/server/disk.dart index 6e475e9c..f4940f00 100644 --- a/lib/data/model/server/disk.dart +++ b/lib/data/model/server/disk.dart @@ -84,8 +84,10 @@ class DiskIO extends TimeSeq { final vals = item.split(Miscs.blankReg); if (vals.length < 10) continue; try { + final dev = vals[2]; + if (dev.startsWith('loop')) continue; items.add(DiskIOPiece( - dev: vals[2], + dev: dev, sectorsRead: int.parse(vals[5]), sectorsWrite: int.parse(vals[9]), time: time, diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 11c8b6df..7c378ca6 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -170,6 +170,7 @@ "process": "Prozess", "pushToken": "Push Token", "pwd": "Passwort", + "read": "Lesen", "reboot": "Neustart", "remotePath": "Entfernte Pfade", "rename": "Umbenennen", @@ -244,5 +245,6 @@ "waitConnection": "Bitte warte, bis die Verbindung hergestellt wurde.", "watchNotPaired": "Keine gekoppelte Apple Watch", "whenOpenApp": "Beim Öffnen der App", - "willTakEeffectImmediately": "Wird sofort angewendet" + "willTakEeffectImmediately": "Wird sofort angewendet", + "write": "Schreiben" } \ No newline at end of file diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 5cd5a48d..db3d627d 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -170,6 +170,7 @@ "process": "Process", "pushToken": "Push token", "pwd": "Password", + "read": "Read", "reboot": "Reboot", "remotePath": "Remote path", "rename": "Rename", @@ -244,5 +245,6 @@ "waitConnection": "Please wait for the connection to be established.", "watchNotPaired": "No paired Apple Watch", "whenOpenApp": "When opening the app", - "willTakEeffectImmediately": "Will take effect immediately" + "willTakEeffectImmediately": "Will take effect immediately", + "write": "Write" } \ No newline at end of file diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 560d82d8..a44572fc 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -170,6 +170,7 @@ "process": "Proses", "pushToken": "Dorong token", "pwd": "Kata sandi", + "read": "Baca", "reboot": "Reboot", "remotePath": "Jalur jarak jauh", "rename": "Ganti nama", @@ -244,5 +245,6 @@ "waitConnection": "Harap tunggu koneksi akan dibuat.", "watchNotPaired": "Tidak ada Apple Watch yang dipasangkan", "whenOpenApp": "Saat membuka aplikasi", - "willTakEeffectImmediately": "Akan segera berlaku" + "willTakEeffectImmediately": "Akan segera berlaku", + "write": "Tulis" } \ No newline at end of file diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 6f750da5..9ac1b2ff 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -170,6 +170,7 @@ "process": "进程", "pushToken": "消息推送 Token", "pwd": "密码", + "read": "读", "reboot": "重启", "remotePath": "远端路径", "rename": "重命名", @@ -244,5 +245,6 @@ "waitConnection": "请等待连接建立", "watchNotPaired": "没有已配对的 Apple Watch", "whenOpenApp": "当打开 App 时", - "willTakEeffectImmediately": "更改将会立即生效" + "willTakEeffectImmediately": "更改将会立即生效", + "write": "写" } \ No newline at end of file diff --git a/lib/l10n/app_zh_tw.arb b/lib/l10n/app_zh_tw.arb index b7054a59..eeda2c68 100644 --- a/lib/l10n/app_zh_tw.arb +++ b/lib/l10n/app_zh_tw.arb @@ -170,6 +170,7 @@ "process": "進程", "pushToken": "消息推送 Token", "pwd": "密碼", + "read": "读", "reboot": "重启", "remotePath": "遠端路徑", "rename": "重命名", @@ -244,5 +245,6 @@ "waitConnection": "請等待連接建立", "watchNotPaired": "沒有已配對的 Apple Watch", "whenOpenApp": "當打開 App 時", - "willTakEeffectImmediately": "更改將會立即生效" + "willTakEeffectImmediately": "更改將會立即生效", + "write": "写" } \ No newline at end of file diff --git a/lib/view/page/full_screen.dart b/lib/view/page/full_screen.dart index f4182d79..7777de75 100644 --- a/lib/view/page/full_screen.dart +++ b/lib/view/page/full_screen.dart @@ -295,10 +295,10 @@ class _FullScreenPageState extends State with AfterLayoutMixin { return ValueListenableBuilder( valueListenable: Stores.setting.netViewType.listenable(), builder: (_, val, __) { - final data = val.build(ss); + final (a, b) = val.build(ss); return AnimatedSwitcher( duration: const Duration(milliseconds: 177), - child: _buildIOData(data.up, data.down), + child: _buildIOData(a, b), ); }, ); diff --git a/lib/view/page/server/detail.dart b/lib/view/page/server/detail.dart index 3b78b0bb..c100fcd1 100644 --- a/lib/view/page/server/detail.dart +++ b/lib/view/page/server/detail.dart @@ -331,7 +331,7 @@ class _ServerDetailPageState extends State final text = () { final use = '${disk.used} / ${disk.size}'; if (read == null || write == null) return use; - return '$use\nR $read | W $write'; + return '$use\n${l10n.read} $read | ${l10n.write} $write'; }(); return ListTile( title: Text( diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index f718b585..ee74a7c6 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -42,6 +42,9 @@ class _ServerPageState extends State final _netViewType = {}; + /// If true, display IO speed + final _diskViewSpeed = {}; + String? _tag; bool _useDoubleColumn = false; @@ -302,7 +305,6 @@ class _ServerPageState extends State } List _buildNormalCard(ServerStatus ss, ServerPrivateInfo spi) { - final rootDisk = findRootDisk(ss.disk); return [ UIs.height13, Padding( @@ -313,10 +315,7 @@ class _ServerPageState extends State _wrapWithSizedbox(_buildPercentCircle(ss.cpu.usedPercent())), _wrapWithSizedbox(_buildPercentCircle(ss.mem.usedPercent * 100)), _wrapWithSizedbox(_buildNet(ss, spi.id)), - _wrapWithSizedbox(_buildIOData( - 'Total:\n${rootDisk?.size}', - 'Used:\n${rootDisk?.usedPercent}%', - )), + _wrapWithSizedbox(_buildDisk(ss, spi.id)), ], ), ), @@ -421,28 +420,53 @@ class _ServerPageState extends State ); } - Widget _buildNet(ServerStatus ss, String id) { - final type = _netViewType[id] ?? Stores.setting.netViewType.fetch(); - final data = type.build(ss); + Widget _buildDisk(ServerStatus ss, String id) { + final rootDisk = findRootDisk(ss.disk); + final isSpeed = _diskViewSpeed[id] ?? true; + + final (r, w) = ss.diskIO.getAllSpeed(); + return AnimatedSwitcher( duration: const Duration(milliseconds: 377), transitionBuilder: (Widget child, Animation animation) { return FadeTransition(opacity: animation, child: child); }, child: _buildIOData( - data.up, - data.down, + 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), + ), + ); + } + + Widget _buildNet(ServerStatus ss, String id) { + final type = _netViewType[id] ?? Stores.setting.netViewType.fetch(); + final (a, b) = type.build(ss); + return AnimatedSwitcher( + duration: const Duration(milliseconds: 377), + transitionBuilder: (Widget child, Animation animation) { + return FadeTransition(opacity: animation, child: child); + }, + child: _buildIOData( + a, + b, onTap: () { setState(() { _netViewType[id] = type.next; }); }, - key: ValueKey(type) + key: ValueKey(type), ), ); } - Widget _buildIOData(String up, String down, {void Function()? onTap, Key? key}) { + Widget _buildIOData(String up, String down, + {void Function()? onTap, Key? key}) { final child = Column( children: [ const SizedBox(height: 5),