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