mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-22 16:15:13 +01:00
new: pve (#307)
This commit is contained in:
20
lib/core/extension/duration.dart
Normal file
20
lib/core/extension/duration.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
|
||||
extension DurationX on Duration {
|
||||
String get toStr {
|
||||
final days = inDays;
|
||||
if (days > 0) {
|
||||
return '$days ${l10n.day}';
|
||||
}
|
||||
final hours = inHours % 24;
|
||||
if (hours > 0) {
|
||||
return '$hours ${l10n.hour}';
|
||||
}
|
||||
final minutes = inMinutes % 60;
|
||||
if (minutes > 0) {
|
||||
return '$minutes ${l10n.minute}';
|
||||
}
|
||||
final seconds = inSeconds % 60;
|
||||
return '$seconds ${l10n.second}';
|
||||
}
|
||||
}
|
||||
@@ -33,3 +33,8 @@ extension BigIntX on BigInt {
|
||||
|
||||
String get kb2Str => (this * BigInt.from(1024)).bytes2Str;
|
||||
}
|
||||
|
||||
extension IntX on int {
|
||||
Duration secondsToDuration() => Duration(seconds: this);
|
||||
DateTime get tsToDateTime => DateTime.fromMillisecondsSinceEpoch(this * 1000);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:toolbox/core/extension/listx.dart';
|
||||
import 'package:toolbox/core/persistant_store.dart';
|
||||
|
||||
typedef Order<T> = List<T>;
|
||||
@@ -52,7 +53,7 @@ extension OrderX<T> on Order<T> {
|
||||
move(index, newIndex, property: property, onMove: onMove);
|
||||
}
|
||||
|
||||
/// order: ['d', 'b', 'e']\
|
||||
/// order: ['d', 'b', 'e']
|
||||
/// this: ['a', 'b', 'c', 'd']\
|
||||
/// result: ['d', 'b', 'a', 'c']\
|
||||
/// return: ['e']
|
||||
@@ -64,11 +65,11 @@ extension OrderX<T> on Order<T> {
|
||||
final missed = <T>[];
|
||||
final surplus = <String>[];
|
||||
for (final id in order.toSet()) {
|
||||
try {
|
||||
final item = firstWhere((e) => finder(e, id));
|
||||
newOrder.add(item);
|
||||
} catch (e) {
|
||||
final item = firstWhereOrNull((element) => finder(element, id));
|
||||
if (item == null) {
|
||||
surplus.add(id);
|
||||
} else {
|
||||
newOrder.add(item);
|
||||
}
|
||||
}
|
||||
for (final item in this) {
|
||||
|
||||
7
lib/core/extension/widget.dart
Normal file
7
lib/core/extension/widget.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension WidgetX on Widget {
|
||||
Widget get card {
|
||||
return Card(child: this);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import 'package:toolbox/view/page/iperf.dart';
|
||||
import 'package:toolbox/view/page/ping.dart';
|
||||
import 'package:toolbox/view/page/private_key/edit.dart';
|
||||
import 'package:toolbox/view/page/private_key/list.dart';
|
||||
import 'package:toolbox/view/page/pve.dart';
|
||||
import 'package:toolbox/view/page/server/detail.dart';
|
||||
import 'package:toolbox/view/page/setting/platform/android.dart';
|
||||
import 'package:toolbox/view/page/setting/platform/ios.dart';
|
||||
@@ -227,4 +228,8 @@ class AppRoute {
|
||||
static AppRoute serverFuncBtnsOrder({Key? key}) {
|
||||
return AppRoute(ServerFuncBtnsOrderPage(key: key), 'server_func_btns_seq');
|
||||
}
|
||||
|
||||
static AppRoute pve({Key? key, required ServerPrivateInfo spi}) {
|
||||
return AppRoute(PvePage(key: key, spi: spi), 'pve');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user