Files
e-party-iOS/yana/Utils/APILoading/APILoadingModels.swift
edwinQQQ 4a1b814902 feat: 实现数据迁移和用户信息管理优化
- 在AppDelegate中集成数据迁移管理器,支持从UserDefaults迁移到Keychain。
- 重构UserInfoManager,使用Keychain存储用户信息,增加内存缓存以提升性能。
- 添加API加载效果视图,增强用户体验。
- 更新SplashFeature以支持自动登录和认证状态检查。
- 语言设置迁移至Keychain,确保用户设置的安全性。
2025-07-10 17:20:20 +08:00

73 lines
1.9 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Foundation
// MARK: - API Loading State
/// API
enum APILoadingState: Equatable {
case loading //
case error(message: String) //
case success //
}
// MARK: - API Loading Item
/// API
struct APILoadingItem: Identifiable, Equatable {
let id: UUID
let state: APILoadingState
let shouldShowError: Bool //
let shouldShowLoading: Bool // loading
let createdAt: Date
init(id: UUID = UUID(), state: APILoadingState, shouldShowError: Bool = true, shouldShowLoading: Bool = true) {
self.id = id
self.state = state
self.shouldShowError = shouldShowError
self.shouldShowLoading = shouldShowLoading
self.createdAt = Date()
}
///
var shouldDisplay: Bool {
switch state {
case .loading:
return shouldShowLoading
case .error:
return shouldShowError
case .success:
return false
}
}
///
var isError: Bool {
if case .error = state {
return true
}
return false
}
///
var errorMessage: String? {
if case .error(let message) = state {
return message
}
return nil
}
}
// MARK: - API Loading Configuration
/// API Loading
struct APILoadingConfiguration {
/// Loading
static let loadingSize: CGFloat = 88
///
static let backgroundAlpha: CGFloat = 0.6
///
static let cornerRadius: CGFloat = 12
///
static let errorDisplayDuration: TimeInterval = 2.0
///
static let animationDuration: Double = 0.3
}