56 lines
1.1 KiB
Dart
56 lines
1.1 KiB
Dart
|
|
import 'version_check_service.dart';
|
||
|
|
|
||
|
|
/// 更新状态基类
|
||
|
|
abstract class UpdateState {
|
||
|
|
const UpdateState();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// 初始状态
|
||
|
|
class UpdateInitial extends UpdateState {
|
||
|
|
const UpdateInitial();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// 检查中
|
||
|
|
class UpdateChecking extends UpdateState {
|
||
|
|
const UpdateChecking();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// 发现新版本
|
||
|
|
class UpdateAvailable extends UpdateState {
|
||
|
|
final AppVersionInfo versionInfo;
|
||
|
|
|
||
|
|
const UpdateAvailable(this.versionInfo);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// 下载中
|
||
|
|
class UpdateDownloading extends UpdateState {
|
||
|
|
final double progress;
|
||
|
|
final bool isPatch; // true=差量补丁, false=完整APK
|
||
|
|
|
||
|
|
const UpdateDownloading(this.progress, {required this.isPatch});
|
||
|
|
}
|
||
|
|
|
||
|
|
/// 安装中
|
||
|
|
class UpdateInstalling extends UpdateState {
|
||
|
|
final bool isPatch;
|
||
|
|
|
||
|
|
const UpdateInstalling({required this.isPatch});
|
||
|
|
}
|
||
|
|
|
||
|
|
/// 更新成功
|
||
|
|
class UpdateSuccess extends UpdateState {
|
||
|
|
const UpdateSuccess();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// 已是最新版本
|
||
|
|
class UpdateUpToDate extends UpdateState {
|
||
|
|
const UpdateUpToDate();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// 更新失败
|
||
|
|
class UpdateFailure extends UpdateState {
|
||
|
|
final String error;
|
||
|
|
|
||
|
|
const UpdateFailure(this.error);
|
||
|
|
}
|