Skip to content

Commit

Permalink
opt.: speed up docker page
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit committed Jun 1, 2024
1 parent 8953f63 commit d1f14be
Show file tree
Hide file tree
Showing 17 changed files with 132 additions and 131 deletions.
File renamed without changes.
36 changes: 18 additions & 18 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 918;
CURRENT_PROJECT_VERSION = 923;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
Expand All @@ -700,7 +700,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.918;
MARKETING_VERSION = 1.0.923;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down Expand Up @@ -826,7 +826,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 918;
CURRENT_PROJECT_VERSION = 923;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
Expand All @@ -836,7 +836,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.918;
MARKETING_VERSION = 1.0.923;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand All @@ -854,7 +854,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 918;
CURRENT_PROJECT_VERSION = 923;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
Expand All @@ -864,7 +864,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.918;
MARKETING_VERSION = 1.0.923;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand All @@ -885,7 +885,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 918;
CURRENT_PROJECT_VERSION = 923;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -898,7 +898,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.918;
MARKETING_VERSION = 1.0.923;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
Expand All @@ -924,7 +924,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 918;
CURRENT_PROJECT_VERSION = 923;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -937,7 +937,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.918;
MARKETING_VERSION = 1.0.923;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -960,7 +960,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 918;
CURRENT_PROJECT_VERSION = 923;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -973,7 +973,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.918;
MARKETING_VERSION = 1.0.923;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -996,7 +996,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 918;
CURRENT_PROJECT_VERSION = 923;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_PREVIEWS = YES;
Expand All @@ -1008,7 +1008,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.918;
MARKETING_VERSION = 1.0.923;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
Expand Down Expand Up @@ -1037,7 +1037,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 918;
CURRENT_PROJECT_VERSION = 923;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_PREVIEWS = YES;
Expand All @@ -1049,7 +1049,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.918;
MARKETING_VERSION = 1.0.923;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
PRODUCT_NAME = ServerBox;
Expand All @@ -1075,7 +1075,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 918;
CURRENT_PROJECT_VERSION = 923;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_PREVIEWS = YES;
Expand All @@ -1087,7 +1087,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.918;
MARKETING_VERSION = 1.0.923;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
PRODUCT_NAME = ServerBox;
Expand Down
17 changes: 1 addition & 16 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class MyApp extends StatelessWidget {
title: BuildData.name,
themeMode: themeMode,
theme: light,
darkTheme: tMode < 3 ? dark : _getAmoledTheme(dark),
darkTheme: tMode < 3 ? dark : dark.toAmoled,
home: _buildAppContent(ctx),
);
}
Expand All @@ -88,18 +88,3 @@ class MyApp extends StatelessWidget {
void _setup(BuildContext context) async {
SystemUIs.setTransparentNavigationBar(context);
}

ThemeData _getAmoledTheme(ThemeData darkTheme) => darkTheme.copyWith(
scaffoldBackgroundColor: Colors.black,
dialogBackgroundColor: Colors.black,
drawerTheme: const DrawerThemeData(backgroundColor: Colors.black),
appBarTheme: const AppBarTheme(backgroundColor: Colors.black),
dialogTheme: const DialogTheme(backgroundColor: Colors.black),
bottomSheetTheme:
const BottomSheetThemeData(backgroundColor: Colors.black),
listTileTheme: const ListTileThemeData(tileColor: Colors.transparent),
cardTheme: const CardTheme(color: Colors.black12),
navigationBarTheme:
const NavigationBarThemeData(backgroundColor: Colors.black),
popupMenuTheme: const PopupMenuThemeData(color: Colors.black),
);
4 changes: 3 additions & 1 deletion lib/core/extension/ssh_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ extension SSHClientX on SSHClient {
isRequestingPwd = true;
final user = Miscs.pwdRequestWithUserReg.firstMatch(data)?.group(1);
if (context == null) return;
final pwd = await context.showPwdDialog(title: user, id: id);
final pwd = context.mounted
? await context.showPwdDialog(title: user, id: id)
: null;
if (pwd == null || pwd.isEmpty) {
session.kill(SSHSignal.TERM);
} else {
Expand Down
7 changes: 4 additions & 3 deletions lib/core/utils/sync/icloud.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:icloud_storage/icloud_storage.dart';
import 'package:logging/logging.dart';
import 'package:toolbox/data/model/app/backup.dart';
import 'package:toolbox/data/model/app/sync.dart';
import 'package:toolbox/data/res/misc.dart';

import '../../../data/model/app/error.dart';

Expand Down Expand Up @@ -198,14 +199,14 @@ abstract final class ICloud {
}

static Future<void> sync() async {
final result = await download(relativePath: Paths.bakName);
final result = await download(relativePath: Miscs.bakFileName);
if (result != null) {
_logger.warning('Download backup failed: $result');
await backup();
return;
}

final dlFile = await File(Paths.bakPath).readAsString();
final dlFile = await File(Paths.bak).readAsString();
final dlBak = await Computer.shared.start(Backup.fromJsonString, dlFile);
await dlBak.restore();

Expand All @@ -214,7 +215,7 @@ abstract final class ICloud {

static Future<void> backup() async {
await Backup.backup();
final uploadResult = await upload(relativePath: Paths.bakName);
final uploadResult = await upload(relativePath: Miscs.bakFileName);
if (uploadResult != null) {
_logger.warning('Upload backup failed: $uploadResult');
} else {
Expand Down
7 changes: 4 additions & 3 deletions lib/core/utils/sync/webdav.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:fl_lib/fl_lib.dart';
import 'package:logging/logging.dart';
import 'package:toolbox/data/model/app/backup.dart';
import 'package:toolbox/data/model/app/error.dart';
import 'package:toolbox/data/res/misc.dart';
import 'package:toolbox/data/res/store.dart';
import 'package:webdav_client/webdav_client.dart';

Expand Down Expand Up @@ -96,15 +97,15 @@ abstract final class Webdav {
}

static Future<void> sync() async {
final result = await download(relativePath: Paths.bakName);
final result = await download(relativePath: Miscs.bakFileName);
if (result != null) {
_logger.warning('Download failed: $result');
await backup();
return;
}

try {
final dlFile = await File(Paths.bakPath).readAsString();
final dlFile = await File(Paths.bak).readAsString();
final dlBak = await Computer.shared.start(Backup.fromJsonString, dlFile);
await dlBak.restore();
} catch (e) {
Expand All @@ -117,7 +118,7 @@ abstract final class Webdav {
/// Create a local backup and upload it to WebDAV
static Future<void> backup() async {
await Backup.backup();
final uploadResult = await upload(relativePath: Paths.bakName);
final uploadResult = await upload(relativePath: Miscs.bakFileName);
if (uploadResult != null) {
_logger.warning('Upload failed: $uploadResult');
} else {
Expand Down
43 changes: 14 additions & 29 deletions lib/data/model/container/ps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract final class ContainerPs {
String? net;
String? disk;

factory ContainerPs.fromRawJson(String s, ContainerType typ) => typ.ps(s);
factory ContainerPs.fromRaw(String s, ContainerType typ) => typ.ps(s);

void parseStats(String s);
}
Expand Down Expand Up @@ -110,8 +110,6 @@ final class PodmanPs implements ContainerPs {
}

final class DockerPs implements ContainerPs {
final String? command;
final String? createdAt;
@override
final String? id;
@override
Expand All @@ -129,8 +127,6 @@ final class DockerPs implements ContainerPs {
String? disk;

DockerPs({
this.command,
this.createdAt,
this.id,
this.image,
this.names,
Expand All @@ -141,10 +137,10 @@ final class DockerPs implements ContainerPs {
String? get name => names;

@override
String? get cmd => command;
String? get cmd => null;

@override
bool get running => state == 'running';
bool get running => state?.contains('Up ') ?? false;

@override
void parseStats(String s) {
Expand All @@ -155,26 +151,15 @@ final class DockerPs implements ContainerPs {
disk = stats['BlockIO'];
}

factory DockerPs.fromRawJson(String str) =>
DockerPs.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory DockerPs.fromJson(Map<String, dynamic> json) => DockerPs(
command: json["Command"],
createdAt: json["CreatedAt"],
id: json["ID"],
image: json["Image"],
names: json["Names"],
state: json["State"],
);

Map<String, dynamic> toJson() => {
"Command": command,
"CreatedAt": createdAt,
"ID": id,
"Image": image,
"Names": names,
"State": state,
};
/// CONTAINER ID NAMES IMAGE STATUS
/// a049d689e7a1 aria2-pro p3terx/aria2-pro Up 3 weeks
factory DockerPs.parse(String raw) {
final parts = raw.split(RegExp(r'\s{2,}'));
return DockerPs(
id: parts[0],
names: parts[1],
image: parts[2],
state: parts[3],
);
}
}
2 changes: 1 addition & 1 deletion lib/data/model/container/type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enum ContainerType {
;

ContainerPs Function(String str) get ps => switch (this) {
ContainerType.docker => DockerPs.fromRawJson,
ContainerType.docker => DockerPs.parse,
ContainerType.podman => PodmanPs.fromRawJson,
};

Expand Down
Loading

0 comments on commit d1f14be

Please sign in to comment.