- multi dialog on apt pwd request
- update dialog condition error
This commit is contained in:
Junyuan Feng
2022-05-20 19:51:14 +08:00
parent 0533766c1c
commit b4d42eecf3
7 changed files with 33 additions and 25 deletions

View File

@@ -65,10 +65,11 @@ Future<void> doUpdate(BuildContext context, {bool force = false}) async {
await RUpgrade.upgradeFromAppStore('1586449703');
} else if (Platform.isMacOS) {
await RUpgrade.upgradeFromUrl(update.mac);
} else {
showRoundDialog(context, s.attention, Text(s.platformNotSupportUpdate), [
TextButton(
onPressed: () => Navigator.of(context).pop(), child: Text(s.ok))
]);
}
showRoundDialog(context, s.attention, Text(s.platformNotSupportUpdate), [
TextButton(
onPressed: () => Navigator.of(context).pop(), child: Text(s.ok))
]);
});
}

View File

@@ -30,6 +30,7 @@ class AptProvider extends BusyProvider {
String? updateLog;
String lastLog = '';
int triedTimes = 0;
bool isRequestingPwd = false;
AptProvider();
@@ -55,6 +56,7 @@ class AptProvider extends BusyProvider {
onUpdate = null;
onPasswordRequest = null;
triedTimes = 0;
isRequestingPwd = false;
}
Future<void> refreshInstalled() async {
@@ -144,19 +146,22 @@ class AptProvider extends BusyProvider {
}
Future<void> _onPwd(Uint8List e, StreamSink<Uint8List> stdin) async {
if (isRequestingPwd) return;
isRequestingPwd = true;
final event = e.string;
if (event.contains('[sudo] password for ')) {
final user = pwdRequestWithUserReg.firstMatch(event)?.group(1);
logger.info('sudo password request for $user');
triedTimes++;
final pwd =
await (onPasswordRequest ?? (_) async => '')(triedTimes == 3, user);
final pwd = await (onPasswordRequest ?? (_, __) async => '')(
triedTimes == 3, user);
if (pwd.isEmpty) {
logger.info('sudo password request cancelled');
return;
}
stdin.add(Uint8List.fromList(utf8.encode('$pwd\n')));
}
isRequestingPwd = false;
}
String _wrap(String cmd) =>

View File

@@ -2,9 +2,9 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 136;
static const int build = 137;
static const String engine =
"Flutter 3.0.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision ee4e09cce0 (9 days ago) • 2022-05-09 16:45:18 -0700\nEngine • revision d1b9a6938a\nTools • Dart 2.17.0 • DevTools 2.12.2\n";
static const String buildAt = "2022-05-19 15:59:10.728748";
static const int modifications = 15;
"Flutter 3.0.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision ee4e09cce0 (11 days ago) • 2022-05-09 16:45:18 -0700\nEngine • revision d1b9a6938a\nTools • Dart 2.17.0 • DevTools 2.12.2\n";
static const String buildAt = "2022-05-20 19:48:33.039675";
static const int modifications = 7;
}

View File

@@ -37,7 +37,6 @@ class _AptManagePageState extends State<AptManagePage>
super.didChangeDependencies();
_media = MediaQuery.of(context);
s = S.of(context);
_aptProvider.refreshInstalled();
}
@override
@@ -107,6 +106,7 @@ class _AptManagePageState extends State<AptManagePage>
() => scrollControllerUpdate
.jumpTo(scrollControllerUpdate.position.maxScrollExtent),
onPwdRequest);
_aptProvider.refreshInstalled();
}
@override
@@ -141,7 +141,9 @@ class _AptManagePageState extends State<AptManagePage>
}
if (apt.updateLog != null && apt.upgradeable == null) {
return SizedBox(
height: _media.size.height * 0.7,
height: _media.size.height -
_media.padding.top -
_media.padding.bottom,
child: ConstrainedBox(
constraints: const BoxConstraints.expand(),
child: SingleChildScrollView(