From f480c49f1fdea42db234e651702a4c70e1b13d1b Mon Sep 17 00:00:00 2001 From: Junyuan Feng Date: Fri, 31 Dec 2021 17:55:07 +0800 Subject: [PATCH] scroll server connection failed info --- lib/view/page/server/tab.dart | 26 +++++++++++++++++++------- lib/view/page/setting.dart | 7 +++++-- pubspec.lock | 14 ++++++++++++++ pubspec.yaml | 1 + 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index 05dae129..0e825bc7 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -3,6 +3,7 @@ import 'package:circle_chart/circle_chart.dart'; import 'package:flutter/material.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; import 'package:get_it/get_it.dart'; +import 'package:marquee/marquee.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:toolbox/core/route.dart'; @@ -128,6 +129,12 @@ class _ServerPageState extends State final rootDisk = ss.disk.firstWhere((element) => element.mountLocation == '/'); + final topRightStr = + getTopRightStr(cs, ss.cpu2Status.temp, ss.uptime, ss.failedInfo); + final hasError = cs == ServerConnectionState.failed; + final style = TextStyle( + color: _theme.textTheme.bodyText1!.color!.withAlpha(100), fontSize: 11); + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -139,13 +146,18 @@ class _ServerPageState extends State style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 12), textScaleFactor: 1.0, ), - Text( - getTopRightStr( - cs, ss.cpu2Status.temp, ss.uptime, ss.failedInfo), - textScaleFactor: 1.0, - style: TextStyle( - color: _theme.textTheme.bodyText1!.color!.withAlpha(100), - fontSize: 11)) + hasError + ? ConstrainedBox( + constraints: BoxConstraints( + maxWidth: _media.size.width * 0.57, maxHeight: 17), + child: Marquee( + accelerationDuration: const Duration(seconds: 3), + accelerationCurve: Curves.linear, + decelerationDuration: const Duration(seconds: 3), + decelerationCurve: Curves.linear, + text: topRightStr, textScaleFactor: 1.0, style: style), + ) + : Text(topRightStr, style: style, textScaleFactor: 1.0), ], ), const SizedBox( diff --git a/lib/view/page/setting.dart b/lib/view/page/setting.dart index a617c8f6..7f32d237 100644 --- a/lib/view/page/setting.dart +++ b/lib/view/page/setting.dart @@ -113,8 +113,11 @@ class _SettingPageState extends State { height: 3, ), _intervalValue == 0.0 - ? const Text('You set to 0, will not update automatically.\nYou can pull to refresh manually.', - style: TextStyle(color: Colors.grey), textAlign: TextAlign.center,) + ? const Text( + 'You set to 0, will not update automatically.\nYou can pull to refresh manually.', + style: TextStyle(color: Colors.grey), + textAlign: TextAlign.center, + ) : const SizedBox(), const SizedBox( height: 13, diff --git a/pubspec.lock b/pubspec.lock index cd0905ff..43cd05aa 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -117,6 +117,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.0" + fading_edge_scrollview: + dependency: transitive + description: + name: fading_edge_scrollview + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" fake_async: dependency: transitive description: @@ -258,6 +265,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.2" + marquee: + dependency: "direct main" + description: + name: marquee + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 3fe4f2b8..702ebc77 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -53,6 +53,7 @@ dependencies: clipboard: ^0.1.3 r_upgrade: ^0.3.6 pull_to_refresh: ^2.0.0 + marquee: ^2.2.0 dev_dependencies: