From b4d44c41e5cd6cb23e7ab195585d5f719e19a023 Mon Sep 17 00:00:00 2001 From: LollipopKit <2036293523@qq.com> Date: Sat, 18 Sep 2021 20:17:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E9=A1=B5=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/analysis.dart | 1 - lib/core/update.dart | 2 ++ lib/core/utils.dart | 6 ++--- lib/data/model/tcp_status.dart | 2 +- lib/main.dart | 1 - lib/view/page/home.dart | 10 +++++-- lib/view/page/server.dart | 49 ++++++++++++++++++++++------------ make.dart | 2 ++ 8 files changed, 47 insertions(+), 26 deletions(-) diff --git a/lib/core/analysis.dart b/lib/core/analysis.dart index 1454a4be..cac7d1f6 100644 --- a/lib/core/analysis.dart +++ b/lib/core/analysis.dart @@ -19,7 +19,6 @@ class Analysis { await Countly.start(); await Countly.enableCrashReporting(); await Countly.giveAllConsent(); - print('Countly init successfully.'); } static void recordView(String view) { diff --git a/lib/core/update.dart b/lib/core/update.dart index 841f5489..d962c46f 100644 --- a/lib/core/update.dart +++ b/lib/core/update.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + import 'dart:io'; import 'package:dio/dio.dart'; diff --git a/lib/core/utils.dart b/lib/core/utils.dart index 246e9dde..e4850f00 100644 --- a/lib/core/utils.dart +++ b/lib/core/utils.dart @@ -27,24 +27,22 @@ void showSnackBarWithAction( } Future 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? showRoundDialog( BuildContext context, String title, Widget child, List actions, - {EdgeInsets? padding}) { + {EdgeInsets? padding, bool barrierDismiss = true}) { return showDialog( context: context, + barrierDismissible: barrierDismiss, builder: (ctx) { return CardDialog( title: Text(title), diff --git a/lib/data/model/tcp_status.dart b/lib/data/model/tcp_status.dart index 0e3440c9..17a2321e 100644 --- a/lib/data/model/tcp_status.dart +++ b/lib/data/model/tcp_status.dart @@ -29,7 +29,7 @@ class TcpStatus { fail = json["fail"]?.toInt(); } Map toJson() { - final Map data = Map(); + final Map data = {}; data["maxConn"] = maxConn; data["active"] = active; data["passive"] = passive; diff --git a/lib/main.dart b/lib/main.dart index a0f3259f..f1a0fa15 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -38,7 +38,6 @@ void runInZone(dynamic Function() body) { } void onError(Object obj, StackTrace stack) { - print('error: $obj'); Analysis.recordException(obj); final debugProvider = locator(); debugProvider.addError(obj); diff --git a/lib/view/page/home.dart b/lib/view/page/home.dart index 5d830935..ff7a09e8 100644 --- a/lib/view/page/home.dart +++ b/lib/view/page/home.dart @@ -2,6 +2,7 @@ import 'package:after_layout/after_layout.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; import 'package:toolbox/core/route.dart'; +import 'package:toolbox/core/update.dart'; import 'package:toolbox/core/utils.dart'; import 'package:toolbox/data/provider/server.dart'; import 'package:toolbox/data/res/build_data.dart'; @@ -52,8 +53,12 @@ class _MyHomePageState extends State body: TabBarView(controller: _tabController, children: const [ ServerPage(), ConvertPage(), - ConvertPage(), - ConvertPage(), + Center( + child: Text('1'), + ), + Center( + child: Text('2'), + ), ]), ); } @@ -106,5 +111,6 @@ class _MyHomePageState extends State Future afterFirstLayout(BuildContext context) async { await GetIt.I.allReady(); await locator().loadLocalData(); + await doUpdate(context); } } diff --git a/lib/view/page/server.dart b/lib/view/page/server.dart index 08019690..5f722b40 100644 --- a/lib/view/page/server.dart +++ b/lib/view/page/server.dart @@ -85,7 +85,10 @@ class _ServerPageState extends State void showAddServerDialog() { showRoundDialog(context, '新建服务器连接', _buildTextInputField(context), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () { + clearTextField(); + Navigator.of(context).pop(); + }, child: const Text('关闭')), TextButton( onPressed: () { @@ -101,12 +104,7 @@ class _ServerPageState extends State port: int.parse(portController.text), user: usernameController.text, authorization: authorization)); - nameController.clear(); - ipController.clear(); - portController.clear(); - usernameController.clear(); - passwordController.clear(); - keyController.clear(); + clearTextField(); Navigator.of(context).pop(); }, child: const Text('连接')) @@ -161,6 +159,15 @@ class _ServerPageState extends State ); } + void clearTextField() { + nameController.clear(); + ipController.clear(); + portController.clear(); + usernameController.clear(); + passwordController.clear(); + keyController.clear(); + } + Widget _buildEachServerCard(ServerStatus ss, ServerPrivateInfo spi) { return GestureDetector( child: _buildEachCardContent(ss, spi), @@ -177,9 +184,12 @@ class _ServerPageState extends State keyController.text = auth['privateKey']; } - showRoundDialog(context, '新建服务器连接', _buildTextInputField(context), [ + showRoundDialog(context, '修改服务器信息', _buildTextInputField(context), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () { + clearTextField(); + Navigator.of(context).pop(); + }, child: const Text('关闭')), TextButton( onPressed: () { @@ -197,16 +207,21 @@ class _ServerPageState extends State port: int.parse(portController.text), user: usernameController.text, authorization: authorization)); - nameController.clear(); - ipController.clear(); - portController.clear(); - usernameController.clear(); - passwordController.clear(); - keyController.clear(); + clearTextField(); Navigator.of(context).pop(); }, - child: const Text('连接')) - ]); + child: const Text('保存')), + TextButton( + onPressed: () { + serverProvider.delServer(spi); + clearTextField(); + Navigator.of(context).pop(); + }, + child: const Text( + '删除', + style: TextStyle(color: Colors.red), + )) + ], barrierDismiss: false); }); } diff --git a/make.dart b/make.dart index 00ef307f..6e664997 100755 --- a/make.dart +++ b/make.dart @@ -1,5 +1,7 @@ #!/usr/bin/env dart +// ignore_for_file: avoid_print + import 'dart:convert'; import 'dart:io';