支持添加删除服务器信息,以在服务器状态页显示CPU、内存等

This commit is contained in:
LollipopKit
2021-09-17 00:28:58 +08:00
parent c922bad90c
commit 6b72bc9509
15 changed files with 759 additions and 138 deletions

View File

@@ -0,0 +1,3 @@
extension StringX on String {
int get i => int.parse(this);
}

View File

@@ -1,6 +1,8 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:toolbox/core/persistant_store.dart';
import 'package:toolbox/view/widget/card_dialog.dart';
import 'package:url_launcher/url_launcher.dart';
void unawaited(Future<void> future) {}
@@ -24,19 +26,44 @@ void showSnackBarWithAction(
Future<bool> openUrl(String url) async {
print('openUrl $url');
if (!await canLaunch(url)) {
print('canLaunch false');
return false;
}
final ok = await launch(url, forceSafariVC: false);
if (ok == true) {
return true;
}
print('launch $url failed');
return false;
}
Future<T?>? showRoundDialog<T>(
BuildContext context, String title, Widget child, List<Widget> actions,
{EdgeInsets? padding}) {
return showDialog<T>(
context: context,
builder: (ctx) {
return CardDialog(
title: Text(title),
content: child,
actions: actions,
padding: padding,
);
});
}
Widget buildSwitch(BuildContext context, StoreProperty<bool> prop,
{Function(bool)? func}) {
return ValueListenableBuilder(
valueListenable: prop.listenable(),
builder: (context, bool value, widget) {
return Switch(
value: value,
onChanged: (value) {
if (func != null) func(value);
prop.put(value);
});
},
);
}