feat. & opt.

switch for distribution logo
opt. for server detail page
This commit is contained in:
lollipopkit
2023-01-27 21:46:52 +08:00
parent 7c6649f941
commit b6ab4b7fde
19 changed files with 146 additions and 107 deletions

View File

@@ -76,7 +76,7 @@ android {
}
profile {
applicationIdSuffix '.profile'
applicationIdSuffix '.debug'
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -1,11 +1,12 @@
PODS:
- countly_flutter (22.02.0):
- countly_flutter (22.09.0):
- Flutter
- Flutter (1.0.0)
- flutter_native_splash (0.0.1):
- Flutter
- path_provider_ios (0.0.1):
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- r_upgrade (0.0.1):
- Flutter
- share_plus (0.0.1):
@@ -17,7 +18,7 @@ DEPENDENCIES:
- countly_flutter (from `.symlinks/plugins/countly_flutter/ios`)
- Flutter (from `Flutter`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
- r_upgrade (from `.symlinks/plugins/r_upgrade/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
@@ -29,8 +30,8 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
path_provider_ios:
:path: ".symlinks/plugins/path_provider_ios/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/ios"
r_upgrade:
:path: ".symlinks/plugins/r_upgrade/ios"
share_plus:
@@ -39,13 +40,13 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/url_launcher_ios/ios"
SPEC CHECKSUMS:
countly_flutter: c1c0f790841565e956256c4d2e11aee73c517da5
countly_flutter: 135f1a4930f8e26ba223a14201d3f265ea7b4c83
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
r_upgrade: 44d715c61914cce3d01ea225abffe894fd51c114
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de
url_launcher_ios: ae1517e5e344f5544fb090b079e11f399dfbe4d2
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

View File

@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
@@ -199,6 +199,7 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
@@ -213,6 +214,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);

View File

@@ -48,5 +48,7 @@
</array>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>

File diff suppressed because one or more lines are too long

View File

@@ -8,7 +8,6 @@ enum Dist {
wrt,
armbian,
arch,
/// Rocky Linux
rocky;
String? get iconPath {

View File

@@ -2,9 +2,9 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 176;
static const int build = 183;
static const String engine =
"Flutter 3.3.9 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision b8f7f1f986 (7 weeks ago) • 2022-11-23 06:43:51 +0900\nEngine • revision 8f2221fbef\nTools • Dart 2.18.5 • DevTools 2.15.0\n";
static const String buildAt = "2023-01-09 13:53:02.523811";
static const int modifications = 0;
"Flutter 3.7.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision b06b8b2710 (4 days ago) • 2023-01-23 16:55:55 -0800\nEngine • revision b24591ed32\nTools • Dart 2.19.0 • DevTools 2.20.1\n";
static const String buildAt = "2023-01-27 21:38:08.181334";
static const int modifications = 19;
}

View File

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

View File

@@ -3,5 +3,7 @@ import 'package:flutter/material.dart';
const textSize18 = TextStyle(fontSize: 18);
const textSize11 = TextStyle(fontSize: 11);
const textSize13 = TextStyle(fontSize: 13);
const textSize13Grey = TextStyle(color: Colors.grey, fontSize: 13);
const textSize27 = TextStyle(fontSize: 27);
const grey = TextStyle(color: Colors.grey);

View File

@@ -4,10 +4,18 @@ import 'package:toolbox/core/persistant_store.dart';
class SettingStore extends PersistentStore {
StoreProperty<int> get primaryColor =>
property('primaryColor', defaultValue: Colors.deepPurpleAccent.value);
StoreProperty<int> get serverStatusUpdateInterval =>
property('serverStatusUpdateInterval', defaultValue: 5);
/// Lanch page idx
StoreProperty<int> get launchPage => property('launchPage', defaultValue: 0);
/// Version of store db
StoreProperty<int> get storeVersion =>
property('storeVersion', defaultValue: 0);
/// Show logo on server detail page
StoreProperty<bool> get showDistLogo =>
property('showDistLogo', defaultValue: true);
}

View File

@@ -175,6 +175,8 @@ class MessageLookup extends MessageLookupByLibrary {
"noUpdateAvailable":
MessageLookupByLibrary.simpleMessage("No update available"),
"ok": MessageLookupByLibrary.simpleMessage("OK"),
"onServerDetailPage":
MessageLookupByLibrary.simpleMessage("On server detail page"),
"open": MessageLookupByLibrary.simpleMessage("Open"),
"path": MessageLookupByLibrary.simpleMessage("Path"),
"ping": MessageLookupByLibrary.simpleMessage("Ping"),
@@ -221,6 +223,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("No download task."),
"sftpSSHConnected":
MessageLookupByLibrary.simpleMessage("SFTP Connected"),
"showDistLogo":
MessageLookupByLibrary.simpleMessage("Show distribution logo"),
"snippet": MessageLookupByLibrary.simpleMessage("Snippet"),
"spentTime": m11,
"start": MessageLookupByLibrary.simpleMessage("Start"),

View File

@@ -154,6 +154,7 @@ class MessageLookup extends MessageLookupByLibrary {
"noServerAvailable": MessageLookupByLibrary.simpleMessage("没有可用的服务器。"),
"noUpdateAvailable": MessageLookupByLibrary.simpleMessage("没有可用更新"),
"ok": MessageLookupByLibrary.simpleMessage(""),
"onServerDetailPage": MessageLookupByLibrary.simpleMessage("在服务器详情页"),
"open": MessageLookupByLibrary.simpleMessage("打开"),
"path": MessageLookupByLibrary.simpleMessage("路径"),
"ping": MessageLookupByLibrary.simpleMessage("Ping"),
@@ -192,6 +193,7 @@ class MessageLookup extends MessageLookupByLibrary {
"sftpNoDownloadTask": MessageLookupByLibrary.simpleMessage("没有下载任务"),
"sftpSSHConnected":
MessageLookupByLibrary.simpleMessage("SFTP 已连接,即将开始下载..."),
"showDistLogo": MessageLookupByLibrary.simpleMessage("显示发行版 Logo"),
"snippet": MessageLookupByLibrary.simpleMessage("代码片段"),
"spentTime": m11,
"start": MessageLookupByLibrary.simpleMessage("开始"),

View File

@@ -1500,6 +1500,26 @@ class S {
args: [],
);
}
/// `Show distribution logo`
String get showDistLogo {
return Intl.message(
'Show distribution logo',
name: 'showDistLogo',
desc: '',
args: [],
);
}
/// `On server detail page`
String get onServerDetailPage {
return Intl.message(
'On server detail page',
name: 'onServerDetailPage',
desc: '',
args: [],
);
}
}
class AppLocalizationDelegate extends LocalizationsDelegate<S> {

View File

@@ -143,5 +143,7 @@
"imagesList": "Images list",
"dockerImagesFmt": "{count} images",
"path": "Path",
"goto": "Go to"
"goto": "Go to",
"showDistLogo": "Show distribution logo",
"onServerDetailPage": "On server detail page"
}

View File

@@ -143,5 +143,7 @@
"imagesList": "镜像列表",
"dockerImagesFmt": "共 {count} 个镜像",
"path": "路径",
"goto": "前往"
"goto": "前往",
"showDistLogo": "显示发行版 Logo",
"onServerDetailPage": "在服务器详情页"
}

View File

@@ -9,7 +9,9 @@ import 'package:toolbox/data/provider/server.dart';
import 'package:toolbox/data/res/color.dart';
import 'package:toolbox/data/res/font_style.dart';
import 'package:toolbox/data/res/padding.dart';
import 'package:toolbox/data/store/setting.dart';
import 'package:toolbox/generated/l10n.dart';
import 'package:toolbox/locator.dart';
import 'package:toolbox/view/widget/round_rect_card.dart';
class ServerDetailPage extends StatefulWidget {
@@ -25,12 +27,16 @@ class _ServerDetailPageState extends State<ServerDetailPage>
with SingleTickerProviderStateMixin {
late MediaQueryData _media;
late S _s;
late Color pColor;
bool _showDistLogo = true;
@override
void didChangeDependencies() {
super.didChangeDependencies();
_media = MediaQuery.of(context);
_s = S.of(context);
_showDistLogo = locator<SettingStore>().showDistLogo.fetch()!;
pColor = primaryColor;
}
@override
@@ -52,24 +58,26 @@ class _ServerDetailPageState extends State<ServerDetailPage>
body: ListView(
padding: const EdgeInsets.all(13),
children: [
SizedBox(height: _media.size.height * 0.01),
_buildLinuxIcon(si.status.sysVer),
SizedBox(height: _media.size.height * 0.03),
...(_buildLinuxIcon(si.status.sysVer) ?? []),
_buildUpTimeAndSys(si.status),
_buildCPUView(si.status),
_buildDiskView(si.status),
_buildMemView(si.status),
_buildDiskView(si.status),
_buildNetView(si.status.netSpeed),
// avoid the hieght of navigation bar
SizedBox(height: _media.padding.bottom),
],
),
);
}
Widget _buildLinuxIcon(String sysVer) {
List<Widget>? _buildLinuxIcon(String sysVer) {
if (!_showDistLogo) return null;
final iconPath = sysVer.dist?.iconPath;
if (iconPath == null) return const SizedBox();
return ConstrainedBox(
if (iconPath == null) return null;
return [
SizedBox(height: _media.size.height * 0.03),
ConstrainedBox(
constraints: BoxConstraints(
maxHeight: _media.size.height * 0.13,
maxWidth: _media.size.width * 0.6,
@@ -78,7 +86,9 @@ class _ServerDetailPageState extends State<ServerDetailPage>
iconPath,
fit: BoxFit.contain,
),
);
),
SizedBox(height: _media.size.height * 0.03),
];
}
Widget _buildCPUView(ServerStatus ss) {
@@ -86,7 +96,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
Padding(
padding: roundRectCardPadding,
child: SizedBox(
height: 12 * ss.cpu2Status.coresCount + 67,
height: 12 * ss.cpu2Status.coresCount + 63,
child: Column(children: [
SizedBox(
height: _media.size.height * 0.02,
@@ -96,24 +106,24 @@ class _ServerDetailPageState extends State<ServerDetailPage>
children: [
Text(
'${ss.cpu2Status.usedPercent(coreIdx: 0).toInt()}%',
style: const TextStyle(fontSize: 27),
style: textSize27,
textScaleFactor: 1.0,
),
Row(
children: [
_buildCPUTimePercent(ss.cpu2Status.user, 'user'),
_buildDetailPercent(ss.cpu2Status.user, 'user'),
SizedBox(
width: _media.size.width * 0.03,
),
_buildCPUTimePercent(ss.cpu2Status.sys, 'sys'),
_buildDetailPercent(ss.cpu2Status.sys, 'sys'),
SizedBox(
width: _media.size.width * 0.03,
),
_buildCPUTimePercent(ss.cpu2Status.iowait, 'io'),
_buildDetailPercent(ss.cpu2Status.iowait, 'io'),
SizedBox(
width: _media.size.width * 0.03,
),
_buildCPUTimePercent(ss.cpu2Status.idle, 'idle')
_buildDetailPercent(ss.cpu2Status.idle, 'idle')
],
)
],
@@ -125,7 +135,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
);
}
Widget _buildCPUTimePercent(double percent, String timeType) {
Widget _buildDetailPercent(double percent, String timeType) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
@@ -150,7 +160,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
height: 12.0 * ss.cpu2Status.coresCount,
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.symmetric(vertical: 17),
padding: const EdgeInsets.only(top: 13),
itemBuilder: (ctx, idx) {
if (idx == 0) return const SizedBox();
return Padding(
@@ -165,7 +175,6 @@ class _ServerDetailPageState extends State<ServerDetailPage>
Widget _buildProgress(double percent) {
if (percent > 100) percent = 100;
final pColor = primaryColor;
final percentWithinOne = percent / 100;
return LinearProgressIndicator(
value: percentWithinOne,
@@ -193,14 +202,14 @@ class _ServerDetailPageState extends State<ServerDetailPage>
}
Widget _buildMemView(ServerStatus ss) {
final pColor = primaryColor;
final used = ss.memory.used / ss.memory.total;
final width = _media.size.width - 17 * 2 - 17 * 2;
const mb = 1024;
final used = ss.memory.used / ss.memory.total * 100;
final free = ss.memory.free / ss.memory.total * 100;
final avail = ss.memory.avail / ss.memory.total * 100;
return RoundRectCard(Padding(
padding: roundRectCardPadding,
child: SizedBox(
height: 47,
height: 70,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
@@ -208,64 +217,35 @@ class _ServerDetailPageState extends State<ServerDetailPage>
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildMemExplain((ss.memory.used * mb).convertBytes, pColor),
_buildMemExplain(
(ss.memory.cache * mb).convertBytes, pColor.withAlpha(77)),
_buildMemExplain(
((ss.memory.total - ss.memory.used) * mb).convertBytes,
progressColor.resolve(context),
)
Row(
children: [
Text('${used.toStringAsFixed(0)}%', style: textSize27),
const SizedBox(width: 7),
Text('of ${(ss.memory.total * 1024).convertBytes}',
style: textSize13Grey)
],
),
const SizedBox(
height: 7,
),
Row(
children: [
_buildDetailPercent(free, 'free'),
SizedBox(
width: width * used,
child: LinearProgressIndicator(
value: 1,
color: pColor,
)),
SizedBox(
width: width * (1 - used),
child: LinearProgressIndicator(
// memory.total == 1: failed to get mem, now mem = [emptyMemory] which is initial value.
value: ss.memory.total == 1
? 0
: ss.memory.cache / (ss.memory.total - ss.memory.used),
backgroundColor: progressColor.resolve(context),
color: pColor.withAlpha(77),
width: _media.size.width * 0.03,
),
)
_buildDetailPercent(avail, 'avail'),
],
)
),
],
),
const SizedBox(
height: 11,
),
_buildProgress(used)
],
),
),
));
}
Widget _buildMemExplain(String value, Color color) {
return Row(
children: [
Container(
color: color,
height: 11,
width: 11,
),
const SizedBox(width: 4),
Text(
value,
style: textSize11,
textScaleFactor: 1.0,
textAlign: TextAlign.center,
)
],
);
}
Widget _buildDiskView(ServerStatus ss) {
final clone = ss.disk.toList();
for (var item in ss.disk) {

View File

@@ -23,7 +23,7 @@ class SettingPage extends StatefulWidget {
}
class _SettingPageState extends State<SettingPage> {
late SettingStore _store;
late SettingStore _setting;
late int _selectedColorValue;
late int _launchPageIdx;
late Color priColor;
@@ -47,9 +47,9 @@ class _SettingPageState extends State<SettingPage> {
void initState() {
super.initState();
_serverProvider = locator<ServerProvider>();
_store = locator<SettingStore>();
_launchPageIdx = _store.launchPage.fetch()!;
_intervalValue = _store.serverStatusUpdateInterval.fetch()!.toDouble();
_setting = locator<SettingStore>();
_launchPageIdx = _setting.launchPage.fetch()!;
_intervalValue = _setting.serverStatusUpdateInterval.fetch()!.toDouble();
}
@override
@@ -64,12 +64,27 @@ class _SettingPageState extends State<SettingPage> {
_buildAppColorPreview(),
_buildUpdateInterval(),
_buildCheckUpdate(),
_buildLaunchPage()
_buildLaunchPage(),
_buildDistLogoSwitch(),
].map((e) => RoundRectCard(e)).toList(),
),
);
}
Widget _buildDistLogoSwitch() {
return ListTile(
title: Text(
_s.showDistLogo,
style: textSize13,
),
subtitle: Text(
_s.onServerDetailPage,
style: textSize13Grey,
),
trailing: buildSwitch(context, _setting.showDistLogo),
);
}
Widget _buildCheckUpdate() {
return Consumer<AppProvider>(
builder: (_, app, __) {
@@ -109,7 +124,7 @@ class _SettingPageState extends State<SettingPage> {
),
subtitle: Text(
_s.willTakEeffectImmediately,
style: const TextStyle(color: Colors.grey, fontSize: 13),
style: textSize13Grey,
),
trailing: Text('${_intervalValue.toInt()} ${_s.second}'),
children: [
@@ -125,7 +140,7 @@ class _SettingPageState extends State<SettingPage> {
});
},
onChangeEnd: (val) {
_store.serverStatusUpdateInterval.put(val.toInt());
_setting.serverStatusUpdateInterval.put(val.toInt());
_serverProvider.startAutoRefresh();
},
label: '${_intervalValue.toInt()} ${_s.second}',
@@ -181,7 +196,7 @@ class _SettingPageState extends State<SettingPage> {
return IconButton(
icon: const Icon(Icons.save),
onPressed: (() {
_store.primaryColor.put(_selectedColorValue);
_setting.primaryColor.put(_selectedColorValue);
setState(() {});
}),
);
@@ -228,7 +243,7 @@ class _SettingPageState extends State<SettingPage> {
onChanged: (int? value) {
setState(() {
_launchPageIdx = value!;
_store.launchPage.put(value);
_setting.launchPage.put(value);
});
},
);