添加稍后更新按钮点击后的回调 onUpdateLater

This commit is contained in:
DESKTOP-I3JPKHK\wy 2025-12-10 20:40:58 +08:00
parent 49d9d6a9de
commit c029a3cebb
1 changed files with 10 additions and 0 deletions

View File

@ -227,6 +227,7 @@ class AppUpgradeSimple {
bool? showNoUpdateToast, bool? showNoUpdateToast,
bool? autoInstall, bool? autoInstall,
BoolCallback? onComplete, BoolCallback? onComplete,
VoidCallback? onUpdateLater,
UpgradeConfig? config, UpgradeConfig? config,
}) async { }) async {
// 使 // 使
@ -255,6 +256,7 @@ class AppUpgradeSimple {
info: info, info: info,
autoInstall: finalAutoInstall, autoInstall: finalAutoInstall,
onComplete: onComplete, onComplete: onComplete,
onUpdateLater: onUpdateLater,
config: effectiveConfig, config: effectiveConfig,
); );
} catch (e) { } catch (e) {
@ -307,6 +309,7 @@ class AppUpgradeSimple {
required UpgradeInfo info, required UpgradeInfo info,
bool? autoInstall, bool? autoInstall,
BoolCallback? onComplete, BoolCallback? onComplete,
VoidCallback? onUpdateLater,
UpgradeConfig? config, UpgradeConfig? config,
}) async { }) async {
final effectiveConfig = config ?? _config; final effectiveConfig = config ?? _config;
@ -330,6 +333,7 @@ class AppUpgradeSimple {
info: info, info: info,
autoInstall: finalAutoInstall, autoInstall: finalAutoInstall,
onComplete: onComplete, onComplete: onComplete,
onUpdateLater: onUpdateLater,
config: effectiveConfig, config: effectiveConfig,
); );
} }
@ -480,6 +484,7 @@ class AppUpgradeSimple {
required UpgradeInfo info, required UpgradeInfo info,
required bool autoInstall, required bool autoInstall,
BoolCallback? onComplete, BoolCallback? onComplete,
VoidCallback? onUpdateLater,
UpgradeConfig? config, UpgradeConfig? config,
}) { }) {
final effectiveConfig = config ?? _config; final effectiveConfig = config ?? _config;
@ -499,6 +504,7 @@ class AppUpgradeSimple {
info: info, info: info,
autoInstall: autoInstall, autoInstall: autoInstall,
onComplete: onComplete, onComplete: onComplete,
onUpdateLater: onUpdateLater,
config: effectiveConfig, config: effectiveConfig,
showToast: (message) => _showToast(message, context, effectiveConfig), showToast: (message) => _showToast(message, context, effectiveConfig),
); );
@ -1949,6 +1955,7 @@ class _SimpleUpgradeDialog extends StatefulWidget {
final UpgradeInfo info; final UpgradeInfo info;
final bool autoInstall; final bool autoInstall;
final BoolCallback? onComplete; final BoolCallback? onComplete;
final VoidCallback? onUpdateLater;
final void Function(String) showToast; final void Function(String) showToast;
final UpgradeConfig config; final UpgradeConfig config;
@ -1956,6 +1963,7 @@ class _SimpleUpgradeDialog extends StatefulWidget {
required this.info, required this.info,
required this.autoInstall, required this.autoInstall,
this.onComplete, this.onComplete,
this.onUpdateLater,
required this.showToast, required this.showToast,
required this.config, required this.config,
}); });
@ -1971,6 +1979,7 @@ class _SimpleUpgradeDialogState extends State<_SimpleUpgradeDialog> with _Upgrad
void Function(String) get showToast => widget.showToast; void Function(String) get showToast => widget.showToast;
@override @override
BoolCallback? get onComplete => widget.onComplete; BoolCallback? get onComplete => widget.onComplete;
VoidCallback? get onUpdateLater => widget.onUpdateLater;
@override @override
bool get autoInstall => widget.autoInstall; bool get autoInstall => widget.autoInstall;
@override @override
@ -2058,6 +2067,7 @@ class _SimpleUpgradeDialogState extends State<_SimpleUpgradeDialog> with _Upgrad
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
widget.onComplete?.call(false); widget.onComplete?.call(false);
widget.onUpdateLater?.call();
}, },
child: const Text('稍后更新'), child: const Text('稍后更新'),
), ),