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();
fail = json["fail"].toInt();
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data["maxConn"] = maxConn;

View File

@@ -114,7 +114,9 @@ class ServerProvider extends BusyProvider {
final client = _servers[idx].client;
final connected = await client.isConnected();
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;
notifyListeners();
final time1 = DateTime.now();

View File

@@ -2,8 +2,9 @@
class BuildData {
static const String name = "ToolBox";
static const int build = 44;
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 buildAt = "2021-10-29 13:31:42.064782";
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 buildAt = "2021-10-31 22:21:56.798068";
static const int modifications = 1;
}

View File

@@ -18,3 +18,4 @@ class DynamicColor {
}
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';
final linuxIcons = LinuxIcons(['ubuntu', 'arch', 'centos', 'debian', 'fedora',
'opensuse', 'kali']);
final linuxIcons = LinuxIcons(
['ubuntu', 'arch', 'centos', 'debian', 'fedora', 'opensuse', 'kali']);

View File

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

View File

@@ -84,7 +84,8 @@ class _MyHomePageState extends State<MyHomePage>
leading: const Icon(Icons.vpn_key),
title: const Text('Private Key'),
onTap: () =>
AppRoute(const StoredPrivateKeysPage(), 'private key list').go(context),
AppRoute(const StoredPrivateKeysPage(), 'private key list')
.go(context),
),
AboutListTile(
icon: const Icon(Icons.text_snippet),
@@ -94,8 +95,7 @@ class _MyHomePageState extends State<MyHomePage>
applicationIcon: _buildIcon(),
aboutBoxChildren: const [
UrlText(
text: '\nMade with ❤️ by $myGithub',
replace: 'LollipopKit'),
text: '\nMade with ❤️ by $myGithub', replace: 'LollipopKit'),
UrlText(
text:
'\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) {
final iconPath = linuxIcons.search(sysVer);
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) {
@@ -144,7 +145,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
return LinearProgressIndicator(
value: percentWithinOne,
minHeight: 7,
backgroundColor: Colors.grey[100],
backgroundColor: progressColor.resolve(context),
color: pColor.withOpacity(0.5 + percentWithinOne / 2),
);
}
@@ -177,7 +178,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
children: [
_buildMemExplain('Used', pColor),
_buildMemExplain('Cache', pColor.withAlpha(77)),
_buildMemExplain('Avail', Colors.grey.shade100)
_buildMemExplain('Avail', progressColor.resolve(context))
],
),
const SizedBox(
@@ -195,8 +196,10 @@ class _ServerDetailPageState extends State<ServerDetailPage>
width: width * (1 - used),
child: LinearProgressIndicator(
// 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],
backgroundColor: Colors.grey[100],
value: ss.memList.length == 2
? 0
: ss.memList[4] / ss.memList[0],
backgroundColor: progressColor.resolve(context),
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: Padding(
padding: const EdgeInsets.all(13),
child: _buildRealServerCard(
si.status, si.info.name, si.connectionState),
child:
_buildRealServerCard(si.status, si.info.name, si.connectionState),
),
onTap: () =>
AppRoute(ServerDetailPage(si.client.id!), 'server detail page')

View File

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

View File

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