处理onComplete方法
This commit is contained in:
parent
e930cf2775
commit
e30aef8b44
|
|
@ -226,7 +226,7 @@ class AppUpgradeSimple {
|
|||
required Future<AppUpgradeVersion?> Function() future,
|
||||
bool? showNoUpdateToast,
|
||||
bool? autoInstall,
|
||||
BoolCallback? onComplete,
|
||||
VoidCallback? onComplete,
|
||||
VoidCallback? onUpdateLater,
|
||||
UpgradeConfig? config,
|
||||
}) async {
|
||||
|
|
@ -239,7 +239,6 @@ class AppUpgradeSimple {
|
|||
|
||||
final info = await _prepareUpgradeInfo(future: future, config: effectiveConfig);
|
||||
if (info == null) {
|
||||
onComplete?.call(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -247,7 +246,6 @@ class AppUpgradeSimple {
|
|||
if (finalShowNoUpdateToast && context.mounted) {
|
||||
_showToast('已是最新版本', context, effectiveConfig);
|
||||
}
|
||||
onComplete?.call(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +253,6 @@ class AppUpgradeSimple {
|
|||
context: context,
|
||||
info: info,
|
||||
autoInstall: finalAutoInstall,
|
||||
onComplete: onComplete,
|
||||
onUpdateLater: onUpdateLater,
|
||||
config: effectiveConfig,
|
||||
);
|
||||
|
|
@ -265,7 +262,8 @@ class AppUpgradeSimple {
|
|||
if (context.mounted) {
|
||||
_showToast('检查更新遇到问题', context, effectiveConfig);
|
||||
}
|
||||
onComplete?.call(true);
|
||||
} finally {
|
||||
onComplete?.call();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -308,7 +306,6 @@ class AppUpgradeSimple {
|
|||
required BuildContext context,
|
||||
required UpgradeInfo info,
|
||||
bool? autoInstall,
|
||||
BoolCallback? onComplete,
|
||||
VoidCallback? onUpdateLater,
|
||||
UpgradeConfig? config,
|
||||
}) async {
|
||||
|
|
@ -324,7 +321,6 @@ class AppUpgradeSimple {
|
|||
if (effectiveConfig.showNoUpdateToast && context.mounted) {
|
||||
_showToast('已是最新版本', context, effectiveConfig);
|
||||
}
|
||||
onComplete?.call(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -332,7 +328,6 @@ class AppUpgradeSimple {
|
|||
context: context,
|
||||
info: info,
|
||||
autoInstall: finalAutoInstall,
|
||||
onComplete: onComplete,
|
||||
onUpdateLater: onUpdateLater,
|
||||
config: effectiveConfig,
|
||||
);
|
||||
|
|
@ -483,7 +478,6 @@ class AppUpgradeSimple {
|
|||
required BuildContext context,
|
||||
required UpgradeInfo info,
|
||||
required bool autoInstall,
|
||||
BoolCallback? onComplete,
|
||||
VoidCallback? onUpdateLater,
|
||||
UpgradeConfig? config,
|
||||
}) {
|
||||
|
|
@ -503,7 +497,6 @@ class AppUpgradeSimple {
|
|||
return _SimpleUpgradeDialog(
|
||||
info: info,
|
||||
autoInstall: autoInstall,
|
||||
onComplete: onComplete,
|
||||
onUpdateLater: onUpdateLater,
|
||||
config: effectiveConfig,
|
||||
showToast: (message) => _showToast(message, context, effectiveConfig),
|
||||
|
|
@ -634,7 +627,6 @@ mixin _UpgradeDialogLogic<T extends StatefulWidget> on State<T> {
|
|||
|
||||
UpgradeInfo get info;
|
||||
void Function(String) get showToast;
|
||||
BoolCallback? get onComplete;
|
||||
bool get autoInstall;
|
||||
UpgradeConfig get config;
|
||||
|
||||
|
|
@ -892,7 +884,6 @@ mixin _UpgradeDialogLogic<T extends StatefulWidget> on State<T> {
|
|||
if (mounted && Navigator.canPop(context)) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
onComplete?.call(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1737,7 +1728,6 @@ mixin _UpgradeDialogLogic<T extends StatefulWidget> on State<T> {
|
|||
showToast('无法打开App Store,请稍后重试');
|
||||
}
|
||||
// 移除关闭弹窗代码,始终不关闭
|
||||
onComplete?.call(true);
|
||||
} else {
|
||||
showToast('App Store URL is not available.');
|
||||
}
|
||||
|
|
@ -1830,7 +1820,6 @@ mixin _UpgradeDialogLogic<T extends StatefulWidget> on State<T> {
|
|||
Future<void> _handleMarketAction() async {
|
||||
if (!mounted) return;
|
||||
await _performMarketAction();
|
||||
onComplete?.call(true);
|
||||
// 移除关闭弹窗代码
|
||||
}
|
||||
|
||||
|
|
@ -1936,7 +1925,6 @@ mixin _UpgradeDialogLogic<T extends StatefulWidget> on State<T> {
|
|||
// 不再关闭弹窗,即使用户选择了更新方式
|
||||
if (choice == AppUpgradeMethod.market) {
|
||||
await _performMarketAction();
|
||||
onComplete?.call(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1954,7 +1942,6 @@ mixin _UpgradeDialogLogic<T extends StatefulWidget> on State<T> {
|
|||
class _SimpleUpgradeDialog extends StatefulWidget {
|
||||
final UpgradeInfo info;
|
||||
final bool autoInstall;
|
||||
final BoolCallback? onComplete;
|
||||
final VoidCallback? onUpdateLater;
|
||||
final void Function(String) showToast;
|
||||
final UpgradeConfig config;
|
||||
|
|
@ -1962,7 +1949,6 @@ class _SimpleUpgradeDialog extends StatefulWidget {
|
|||
const _SimpleUpgradeDialog({
|
||||
required this.info,
|
||||
required this.autoInstall,
|
||||
this.onComplete,
|
||||
this.onUpdateLater,
|
||||
required this.showToast,
|
||||
required this.config,
|
||||
|
|
@ -1977,8 +1963,7 @@ class _SimpleUpgradeDialogState extends State<_SimpleUpgradeDialog> with _Upgrad
|
|||
UpgradeInfo get info => widget.info;
|
||||
@override
|
||||
void Function(String) get showToast => widget.showToast;
|
||||
@override
|
||||
BoolCallback? get onComplete => widget.onComplete;
|
||||
|
||||
VoidCallback? get onUpdateLater => widget.onUpdateLater;
|
||||
@override
|
||||
bool get autoInstall => widget.autoInstall;
|
||||
|
|
@ -2066,8 +2051,7 @@ class _SimpleUpgradeDialogState extends State<_SimpleUpgradeDialog> with _Upgrad
|
|||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
widget.onComplete?.call(false);
|
||||
widget.onUpdateLater?.call();
|
||||
onUpdateLater?.call();
|
||||
},
|
||||
child: const Text('稍后更新'),
|
||||
),
|
||||
|
|
@ -2108,8 +2092,6 @@ class _ForceUpgradeDialogState extends State<_ForceUpgradeDialog> with _UpgradeD
|
|||
void Function(String) get showToast =>
|
||||
(message) => AppUpgradeSimple.instance._showToast(message, context, widget.config);
|
||||
@override
|
||||
BoolCallback? get onComplete => null;
|
||||
@override
|
||||
bool get autoInstall => widget.autoInstall;
|
||||
@override
|
||||
UpgradeConfig get config => widget.config;
|
||||
|
|
@ -2266,8 +2248,6 @@ class _ToastWidget extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
typedef BoolCallback = void Function(bool success);
|
||||
|
||||
class _RichTextStyles {
|
||||
_RichTextStyles(ColorScheme colorScheme)
|
||||
: boldStyle = TextStyle(
|
||||
|
|
|
|||
Loading…
Reference in New Issue