Porgress use dynamic color

This commit is contained in:
LollipopKit
2021-11-01 15:26:29 +08:00
parent 1cd69c8f44
commit e7d87b40b8
11 changed files with 40 additions and 31 deletions

View File

@@ -29,7 +29,7 @@ class TcpStatus {
passive = json["passive"].toInt(); passive = json["passive"].toInt();
fail = json["fail"].toInt(); fail = json["fail"].toInt();
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{}; final Map<String, dynamic> data = <String, dynamic>{};
data["maxConn"] = maxConn; data["maxConn"] = maxConn;

View File

@@ -114,7 +114,9 @@ class ServerProvider extends BusyProvider {
final client = _servers[idx].client; final client = _servers[idx].client;
final connected = await client.isConnected(); final connected = await client.isConnected();
final state = _servers[idx].connectionState; final state = _servers[idx].connectionState;
if (!connected || state == ServerConnectionState.failed || state == ServerConnectionState.disconnected) { if (!connected ||
state == ServerConnectionState.failed ||
state == ServerConnectionState.disconnected) {
_servers[idx].connectionState = ServerConnectionState.connecting; _servers[idx].connectionState = ServerConnectionState.connecting;
notifyListeners(); notifyListeners();
final time1 = DateTime.now(); final time1 = DateTime.now();

View File

@@ -2,8 +2,9 @@
class BuildData { class BuildData {
static const String name = "ToolBox"; static const String name = "ToolBox";
static const int build = 44; static const int build = 50;
static const String engine = "Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 18116933e7 (2 weeks ago) • 2021-10-15 10:46:35 -0700\nEngine • revision d3ea636dc5\nTools • Dart 2.14.4\n"; static const String engine =
static const String buildAt = "2021-10-29 13:31:42.064782"; "Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 18116933e7 (2 weeks ago) • 2021-10-15 10:46:35 -0700\nEngine • revision d3ea636dc5\nTools • Dart 2.14.4\n";
static const String buildAt = "2021-10-31 22:21:56.798068";
static const int modifications = 1; static const int modifications = 1;
} }

View File

@@ -18,3 +18,4 @@ class DynamicColor {
} }
final mainColor = DynamicColor(Colors.black87, Colors.white70); final mainColor = DynamicColor(Colors.black87, Colors.white70);
final progressColor = DynamicColor(Colors.grey.shade100, Colors.grey);

View File

@@ -1,4 +1,4 @@
import 'package:toolbox/data/model/server/linux_icon.dart'; import 'package:toolbox/data/model/server/linux_icon.dart';
final linuxIcons = LinuxIcons(['ubuntu', 'arch', 'centos', 'debian', 'fedora', final linuxIcons = LinuxIcons(
'opensuse', 'kali']); ['ubuntu', 'arch', 'centos', 'debian', 'fedora', 'opensuse', 'kali']);

View File

@@ -11,8 +11,7 @@ class SnippetStore extends PersistentStore {
} }
List<Snippet> fetch() { List<Snippet> fetch() {
return getSnippetList( return getSnippetList(json.decode(box.get('snippet', defaultValue: '[]')!));
json.decode(box.get('snippet', defaultValue: '[]')!));
} }
void delete(Snippet s) { void delete(Snippet s) {
@@ -30,4 +29,4 @@ class SnippetStore extends PersistentStore {
int index(Snippet s) => fetch().indexWhere((e) => e.name == s.name); int index(Snippet s) => fetch().indexWhere((e) => e.name == s.name);
bool have(Snippet s) => index(s) != -1; bool have(Snippet s) => index(s) != -1;
} }

View File

@@ -84,7 +84,8 @@ class _MyHomePageState extends State<MyHomePage>
leading: const Icon(Icons.vpn_key), leading: const Icon(Icons.vpn_key),
title: const Text('Private Key'), title: const Text('Private Key'),
onTap: () => onTap: () =>
AppRoute(const StoredPrivateKeysPage(), 'private key list').go(context), AppRoute(const StoredPrivateKeysPage(), 'private key list')
.go(context),
), ),
AboutListTile( AboutListTile(
icon: const Icon(Icons.text_snippet), icon: const Icon(Icons.text_snippet),
@@ -94,8 +95,7 @@ class _MyHomePageState extends State<MyHomePage>
applicationIcon: _buildIcon(), applicationIcon: _buildIcon(),
aboutBoxChildren: const [ aboutBoxChildren: const [
UrlText( UrlText(
text: '\nMade with ❤️ by $myGithub', text: '\nMade with ❤️ by $myGithub', replace: 'LollipopKit'),
replace: 'LollipopKit'),
UrlText( UrlText(
text: text:
'\nThanks $rainSunMeGithub for participating in the test.\n\nAll rights reserved.', '\nThanks $rainSunMeGithub for participating in the test.\n\nAll rights reserved.',

View File

@@ -56,7 +56,8 @@ class _ServerDetailPageState extends State<ServerDetailPage>
Widget _buildLinuxIcon(String sysVer) { Widget _buildLinuxIcon(String sysVer) {
final iconPath = linuxIcons.search(sysVer); final iconPath = linuxIcons.search(sysVer);
if (iconPath == null) return const SizedBox(); if (iconPath == null) return const SizedBox();
return SizedBox(height: _media.size.height * 0.15, child: Image.asset(iconPath)); return SizedBox(
height: _media.size.height * 0.15, child: Image.asset(iconPath));
} }
Widget _buildCPUView(ServerStatus ss) { Widget _buildCPUView(ServerStatus ss) {
@@ -144,7 +145,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
return LinearProgressIndicator( return LinearProgressIndicator(
value: percentWithinOne, value: percentWithinOne,
minHeight: 7, minHeight: 7,
backgroundColor: Colors.grey[100], backgroundColor: progressColor.resolve(context),
color: pColor.withOpacity(0.5 + percentWithinOne / 2), color: pColor.withOpacity(0.5 + percentWithinOne / 2),
); );
} }
@@ -177,7 +178,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
children: [ children: [
_buildMemExplain('Used', pColor), _buildMemExplain('Used', pColor),
_buildMemExplain('Cache', pColor.withAlpha(77)), _buildMemExplain('Cache', pColor.withAlpha(77)),
_buildMemExplain('Avail', Colors.grey.shade100) _buildMemExplain('Avail', progressColor.resolve(context))
], ],
), ),
const SizedBox( const SizedBox(
@@ -195,8 +196,10 @@ class _ServerDetailPageState extends State<ServerDetailPage>
width: width * (1 - used), width: width * (1 - used),
child: LinearProgressIndicator( child: LinearProgressIndicator(
// length == 2: failed to get mem list, now mem list = [100,0] which is initial value. // length == 2: failed to get mem list, now mem list = [100,0] which is initial value.
value: ss.memList.length == 2 ? 0 : ss.memList[4] / ss.memList[0], value: ss.memList.length == 2
backgroundColor: Colors.grey[100], ? 0
: ss.memList[4] / ss.memList[0],
backgroundColor: progressColor.resolve(context),
color: pColor.withAlpha(77), color: pColor.withAlpha(77),
), ),
) )
@@ -261,5 +264,12 @@ class _ServerDetailPageState extends State<ServerDetailPage>
)); ));
} }
static const ignorePath = ['/run', '/sys', '/dev/shm', '/snap', '/var/lib/docker']; static const ignorePath = [
'/run',
'/sys',
'/dev/shm',
'/snap',
'/var/lib/docker',
'/dev/tty'
];
} }

View File

@@ -105,8 +105,8 @@ class _ServerPageState extends State<ServerPage>
child: InkWell( child: InkWell(
child: Padding( child: Padding(
padding: const EdgeInsets.all(13), padding: const EdgeInsets.all(13),
child: _buildRealServerCard( child:
si.status, si.info.name, si.connectionState), _buildRealServerCard(si.status, si.info.name, si.connectionState),
), ),
onTap: () => onTap: () =>
AppRoute(ServerDetailPage(si.client.id!), 'server detail page') AppRoute(ServerDetailPage(si.client.id!), 'server detail page')

View File

@@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class SnappetEditPage extends StatefulWidget { class SnappetEditPage extends StatefulWidget {
const SnappetEditPage({ Key? key }) : super(key: key); const SnappetEditPage({Key? key}) : super(key: key);
@override @override
_SnappetEditPageState createState() => _SnappetEditPageState(); _SnappetEditPageState createState() => _SnappetEditPageState();
@@ -10,8 +10,6 @@ class SnappetEditPage extends StatefulWidget {
class _SnappetEditPageState extends State<SnappetEditPage> { class _SnappetEditPageState extends State<SnappetEditPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container();
);
} }
} }

View File

@@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class SnappetListPage extends StatefulWidget { class SnappetListPage extends StatefulWidget {
const SnappetListPage({ Key? key }) : super(key: key); const SnappetListPage({Key? key}) : super(key: key);
@override @override
_SnappetListPageState createState() => _SnappetListPageState(); _SnappetListPageState createState() => _SnappetListPageState();
@@ -10,8 +10,6 @@ class SnappetListPage extends StatefulWidget {
class _SnappetListPageState extends State<SnappetListPage> { class _SnappetListPageState extends State<SnappetListPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container();
);
} }
} }