From f0a8941b592d5dfb9f5d1e0e48667fe7c5961bb5 Mon Sep 17 00:00:00 2001 From: LollipopKit <2036293523@qq.com> Date: Mon, 1 Nov 2021 22:19:32 +0800 Subject: [PATCH] Optimized net speed view --- lib/view/page/server/detail.dart | 53 +++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/lib/view/page/server/detail.dart b/lib/view/page/server/detail.dart index 7fcd04a6..3cac2027 100644 --- a/lib/view/page/server/detail.dart +++ b/lib/view/page/server/detail.dart @@ -8,6 +8,9 @@ import 'package:toolbox/data/res/color.dart'; import 'package:toolbox/data/res/icon/linux_icons.dart'; import 'package:toolbox/view/widget/round_rect_card.dart'; +const style11 = TextStyle(fontSize: 11); +const style13 = TextStyle(fontSize: 13); + class ServerDetailPage extends StatefulWidget { const ServerDetailPage(this.id, {Key? key}) : super(key: key); @@ -158,8 +161,12 @@ class _ServerDetailPageState extends State child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(ss.sysVer), - Text(ss.uptime), + Text(ss.sysVer, style: style11, textScaleFactor: 1.0), + Text( + ss.uptime, + style: style11, + textScaleFactor: 1.0, + ), ], ), )); @@ -221,7 +228,7 @@ class _ServerDetailPageState extends State width: 11, ), const SizedBox(width: 4), - Text(type, style: const TextStyle(fontSize: 10), textScaleFactor: 1.0) + Text(type, style: style11, textScaleFactor: 1.0) ], ); } @@ -250,12 +257,10 @@ class _ServerDetailPageState extends State children: [ Text( '${disk.usedPercent}% of ${disk.size}', - style: const TextStyle(fontSize: 11), + style: style11, textScaleFactor: 1.0, ), - Text(disk.mountPath, - style: const TextStyle(fontSize: 11), - textScaleFactor: 1.0) + Text(disk.mountPath, style: style11, textScaleFactor: 1.0) ], ), _buildProgress(disk.usedPercent.toDouble()) @@ -267,7 +272,39 @@ class _ServerDetailPageState extends State } Widget _buildNetView(NetSpeed ns) { - return Text(ns.speedIn() + '' + ns.speedOut()); + return RoundRectCard(Padding( + padding: const EdgeInsets.symmetric(vertical: 7), + child: Column( + children: ns.devices.map((e) => _buildNetSpeedItem(ns, e)).toList(), + ), + )); + } + + Widget _buildNetSpeedItem(NetSpeed ns, String device) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 3), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + SizedBox( + width: _media.size.width / 4, + child: Text(device, style: style11, textScaleFactor: 1.0)), + SizedBox( + width: _media.size.width / 4, + child: Text(ns.speedIn(device: device), + style: style11, + textAlign: TextAlign.center, + textScaleFactor: 1.0), + ), + SizedBox( + width: _media.size.width / 4, + child: Text(ns.speedOut(device: device), + style: style11, + textAlign: TextAlign.right, + textScaleFactor: 1.0)) + ], + ), + ); } static const ignorePath = [