Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions lib/kit/core/build.dart

This file was deleted.

4 changes: 0 additions & 4 deletions lib/kit/core/ext/obj.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ extension ObjectX<T extends Object> on T {
}

extension ObjectXNullable<T extends Object> on T? {
A? nullOr<A>(A Function(T) f) => this != null ? f(this!) : null;

VNode<T?> get vn => VNode<T?>(this);
}

VNode<T?> nvn<T>() => VNode<T?>(null);
7 changes: 0 additions & 7 deletions lib/kit/core/ext/string.dart

This file was deleted.

23 changes: 0 additions & 23 deletions lib/kit/core/func.dart

This file was deleted.

37 changes: 0 additions & 37 deletions lib/kit/core/logger.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import 'dart:io';

import 'package:logging/logging.dart';

import 'build.dart';

abstract final class Loggers {
static final root = Logger('Root');
static final store = Logger('Store');
static final route = Logger('Route');
static final app = Logger('App');

static final sourceReg = RegExp(r'\((.+):(\d+):(\d+)\)');

static void log(Object message, {int skipFrames = 1}) {
Expand All @@ -35,31 +26,3 @@ abstract final class Loggers {
print(message);
}
}

void dprint(Object? msg, [Object? msg2, Object? msg3, Object? msg4]) {
if (!BuildMode.isDebug) return;
lprint(msg, msg2, msg3, msg4, 3);
}

void lprint(
Object? msg, [
Object? msg2,
Object? msg3,
Object? msg4,
int skipFrames = 2,
]) {
final sb = StringBuffer();
sb.write(msg.toString());

if (msg2 != null) {
sb.write('\n$msg2');
if (msg3 != null) {
sb.write('\n$msg3');
if (msg4 != null) {
sb.write('\n$msg4');
}
}
}
final str = sb.toString();
Loggers.log(str, skipFrames: skipFrames);
}
4 changes: 0 additions & 4 deletions lib/kit/core/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ enum Pfs {
}();
}

final isAndroid = Pfs.type == Pfs.android;
final isIOS = Pfs.type == Pfs.ios;
final isLinux = Pfs.type == Pfs.linux;
final isMacOS = Pfs.type == Pfs.macos;
final isWindows = Pfs.type == Pfs.windows;
final isWeb = Pfs.type == Pfs.web;
final isMobile = Pfs.type == Pfs.ios || Pfs.type == Pfs.android;
final isDesktop =
Pfs.type == Pfs.linux || Pfs.type == Pfs.macos || Pfs.type == Pfs.windows;
48 changes: 0 additions & 48 deletions lib/kit/core/rnode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ class RNode implements ChangeNotifier {
}
}

extension RNodeX on RNode {
ListenBuilder listen(Widget Function() builder) {
return ListenBuilder(listenable: this, builder: builder);
}
}

class VNode<T> extends RNode implements ValueNotifier<T> {
T _value;

Expand All @@ -74,45 +68,3 @@ class VNode<T> extends RNode implements ValueNotifier<T> {
@override
String toString() => 'VNode($value)';
}

extension ValueListenableX<T> on ValueListenable<T> {
ValBuilder<T> listenVal(Widget Function(T) builder) {
return ValBuilder<T>(listenable: this, builder: builder);
}
}

final class ValBuilder<T> extends ValueListenableBuilder<T> {
final ValueListenable<T> listenable;

ValBuilder({
super.key,
required this.listenable,
required Widget Function(T) builder,
}) : super(valueListenable: listenable, builder: (_, val, _) => builder(val));
}

final class ListenBuilder extends ListenableBuilder {
ListenBuilder({
super.key,
required super.listenable,
required Widget Function() builder,
}) : super(builder: (_, _) => builder());
}

final class EmptyListenable<T> implements ValueListenable<T?> {
@override
void addListener(VoidCallback listener) {}

@override
void removeListener(VoidCallback listener) {}

@override
T? get value => null;

const EmptyListenable();
}

abstract final class RNodes {
static final app = RNode();
static final dark = VNode<bool>(false);
}
3 changes: 0 additions & 3 deletions lib/kit/kit.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
library;

export 'core/build.dart';
export 'core/ext/datetime.dart';
export 'core/ext/obj.dart';
export 'core/ext/string.dart';
export 'core/ext/widget.dart';
export 'core/func.dart';
export 'core/logger.dart';
export 'core/platform.dart';
export 'core/rnode.dart';
Expand Down
45 changes: 0 additions & 45 deletions lib/kit/res/ui.dart
Original file line number Diff line number Diff line change
@@ -1,55 +1,10 @@
import 'package:flutter/material.dart';

abstract final class UIs {
static const text11 = TextStyle(fontSize: 11);
static const text11Bold = TextStyle(
fontSize: 11,
fontWeight: FontWeight.w500,
);
static const text11Grey = TextStyle(color: Colors.grey, fontSize: 11);
static const text12 = TextStyle(fontSize: 12);
static const text12Bold = TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
);
static const text12Grey = TextStyle(color: Colors.grey, fontSize: 12);
static const text13 = TextStyle(fontSize: 13);
static const text13Bold = TextStyle(
fontSize: 13,
fontWeight: FontWeight.bold,
);
static const text13Grey = TextStyle(color: Colors.grey, fontSize: 13);
static const text15 = TextStyle(fontSize: 15);
static const text15Bold = TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
);
static const text18 = TextStyle(fontSize: 18);
static const text27 = TextStyle(fontSize: 27);
static const textGrey = TextStyle(color: Colors.grey);
static const textRed = TextStyle(color: Colors.red);

static const placeholder = SizedBox();
static const height7 = SizedBox(height: 7);
static const height13 = SizedBox(height: 13);
static const height77 = SizedBox(height: 77);
static const width7 = SizedBox(width: 7);
static const width13 = SizedBox(width: 13);

static Widget dot({Color? color, double? size}) => Container(
width: size ?? 7,
height: size ?? 7,
decoration: BoxDecoration(
color: color ?? primaryColor,
shape: BoxShape.circle,
),
);

static const centerLoading = Padding(
padding: EdgeInsets.symmetric(vertical: 7),
child: Center(child: CircularProgressIndicator()),
);

static var colorSeed = const Color.fromARGB(255, 72, 15, 15);
static var primaryColor = colorSeed;
}
8 changes: 1 addition & 7 deletions lib/kit/widgets/virtual_window_frame.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import '../core/platform.dart';
import 'appbar.dart';

abstract final class WindowFrameConfig {
static bool _showCaption = true;

static bool get showCaption => _showCaption && isDesktop;

static void setShowCaption(bool value) {
_showCaption = value;
}
static bool get showCaption => isDesktop;
}

class VirtualWindowFrame extends StatelessWidget {
Expand Down
45 changes: 26 additions & 19 deletions lib/pages/download_page/components/task_details_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,32 +203,40 @@ class TaskDetailsDialog {

isLoadingPeers = true;
lastPeersFetchTime = now;
List<Map<String, dynamic>>? peersResult;
String? peersErrorLocal;
try {
final instanceManager = outerContext
.read<InstanceManager>();
final instance = instanceManager.getInstanceById(
currentTask.instanceId,
);
if (instance == null) {
peersError = l10n.targetInstanceNotConnected;
return;
}
final nextClientKey =
'${instance.id}_${instance.protocol}_${instance.host}_${instance.port}_${instance.secret}';
if (peersClientKey != nextClientKey ||
peersClient == null) {
peersClient?.close();
peersClient = Aria2RpcClient(instance);
peersClientKey = nextClientKey;
peersErrorLocal = l10n.targetInstanceNotConnected;
} else {
final nextClientKey =
'${instance.id}_${instance.protocol}_${instance.host}_${instance.port}_${instance.secret}';
if (peersClientKey != nextClientKey ||
peersClient == null) {
peersClient?.close();
peersClient = Aria2RpcClient(instance);
peersClientKey = nextClientKey;
}
peersResult = await peersClient!.getPeers(
currentTask.id,
);
}
peers = await peersClient!.getPeers(currentTask.id);
peersError = null;
} catch (error) {
peersError = '$error';
peersErrorLocal = '$error';
} finally {
isLoadingPeers = false;
if (context.mounted) {
setState(() {});
setState(() {
peersError = peersErrorLocal;
isLoadingPeers = false;
if (peersResult != null) {
peers = peersResult;
}
});
}
}
}
Expand All @@ -242,14 +250,13 @@ class TaskDetailsDialog {
activeTabController = tabController;
activeTabListener = () {
if (!tabController.indexIsChanging) {
currentTabIndex = tabController.index;
setState(() {
currentTabIndex = tabController.index;
});
unawaited(
requestPeersIfNeeded?.call(force: true) ??
Future.value(),
);
if (context.mounted) {
setState(() {});
}
}
};
activeTabController!.addListener(activeTabListener!);
Expand Down
8 changes: 3 additions & 5 deletions lib/pages/download_page/download_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,9 @@ class DownloadPageState extends State<DownloadPage>
if (downloadDataService == null || _selectedTaskKeys.isEmpty) return;

final validKeys = downloadDataService!.tasks.map(_taskKey).toSet();
final before = _selectedTaskKeys.length;
_selectedTaskKeys.removeWhere((key) => !validKeys.contains(key));
if (before != _selectedTaskKeys.length && mounted) {
setState(() {});
}
setState(() {
_selectedTaskKeys.removeWhere((key) => !validKeys.contains(key));
});
}

List<DownloadTask> _filterTasks() {
Expand Down
Loading