- optimize TextField
- opt apt pwd req times
- use logger in update.dart
This commit is contained in:
Junyuan Feng
2022-05-15 13:48:57 +08:00
parent 282443a548
commit 36d7dc7bb2
15 changed files with 90 additions and 83 deletions

View File

@@ -59,16 +59,17 @@ class _AptManagePageState extends State<AptManagePage>
}
// ignore: prefer_function_declarations_over_variables
PwdRequestFunc onPwdRequest = (user) async {
PwdRequestFunc onPwdRequest = (lastTime, user) async {
if (!mounted) return '';
final textController = TextEditingController();
await showRoundDialog(
context,
s.pwdForUser(user ?? s.unknown),
lastTime ? s.lastTry : (user ?? s.unknown),
TextField(
controller: textController,
keyboardType: TextInputType.visiblePassword,
obscureText: true,
onSubmitted: (_) => textController.text.trim(),
decoration: InputDecoration(
labelText: s.pwd,
),

View File

@@ -89,7 +89,8 @@ class _ConvertPageState extends State<ConvertPage>
Widget _buildInputTop() {
return SizedBox(
height: _media.size.height * 0.33,
child: buildInput(context, _textEditingController),
child: buildInput(context, _textEditingController,
onSubmitted: (_) => _textEditingControllerResult.text = doConvert()),
);
}

View File

@@ -48,7 +48,8 @@ class _PingPageState extends State<PingPage>
padding: const EdgeInsets.symmetric(horizontal: 7),
child: Column(children: [
const SizedBox(height: 13),
buildInput(context, _textEditingController, maxLines: 1),
buildInput(context, _textEditingController,
maxLines: 1, onSubmitted: (_) => doPing()),
_buildControl(),
SizedBox(
width: double.infinity,

View File

@@ -209,7 +209,8 @@ class _ServerPageState extends State<ServerPage>
_buildExplainText('Net'),
_buildExplainText('Disk'),
],
)
),
const SizedBox(height: 3),
],
);
}
@@ -218,7 +219,7 @@ class _ServerPageState extends State<ServerPage>
return DropdownButtonHideUnderline(
child: DropdownButton2(
customButton: const Padding(
padding: EdgeInsets.only(left: 7),
padding: EdgeInsets.symmetric(horizontal: 5, vertical: 1.7),
child: Icon(
Icons.more_vert,
size: 17,

View File

@@ -2,16 +2,21 @@ import 'package:flutter/material.dart';
import 'package:toolbox/view/widget/round_rect_card.dart';
Widget buildInput(BuildContext context, TextEditingController controller,
{int maxLines = 20, String? hint}) {
{int maxLines = 20,
String? hint,
Function(String)? onSubmitted,
bool? obscureText}) {
return RoundRectCard(
TextField(
maxLines: maxLines,
onSubmitted: onSubmitted,
decoration: InputDecoration(
fillColor: Theme.of(context).cardColor,
hintText: hint,
filled: true,
border: InputBorder.none),
controller: controller,
obscureText: obscureText ?? false,
),
);
}