docs: 为核心协议层、服务层与主要页面补充代码注释,修复下载进度计算逻辑
This commit is contained in:
1 parent
7e618adf6c
commit
854f00038c
14 files changed
+244
-28
No files matched your search
@@ -1,8 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../core/utils/background_service.dart';
|
||||
|
||||
/// 自定义背景(壁纸)状态。
|
||||
///
|
||||
/// 壁纸由原生侧(MethodChannel)负责读写,这里只做内存缓存 + 通知刷新,
|
||||
/// 避免每次 build 都跨平台调用。
|
||||
class WallpaperProvider extends ChangeNotifier {
|
||||
String? _wallpaperPath;
|
||||
|
||||
/// 壁纸类型:'image' / 'video'(视频壁纸由原生层渲染)
|
||||
String? _wallpaperType;
|
||||
|
||||
String? get wallpaperPath => _wallpaperPath;
|
||||
@@ -10,6 +16,7 @@ class WallpaperProvider extends ChangeNotifier {
|
||||
|
||||
WallpaperProvider();
|
||||
|
||||
/// 启动时从原生侧读取已设置的壁纸。
|
||||
Future<void> loadWallpaper() async {
|
||||
final data = await BackgroundService.getBackground();
|
||||
_wallpaperType = data['type'];
|
||||
@@ -17,6 +24,7 @@ class WallpaperProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 设置自定义壁纸,同时写入原生侧持久存储。
|
||||
Future<void> setCustomWallpaper(String path, {String type = 'image'}) async {
|
||||
await BackgroundService.setBackground(type, path);
|
||||
_wallpaperType = type;
|
||||
@@ -24,6 +32,7 @@ class WallpaperProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 恢复默认背景。
|
||||
Future<void> resetWallpaper() async {
|
||||
await BackgroundService.clearBackground();
|
||||
_wallpaperType = null;
|
||||
@@ -31,5 +40,7 @@ class WallpaperProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 是否设置了自定义壁纸——页面据此决定要不要把 Scaffold 背景设为透明,
|
||||
/// 以便露出底层的壁纸图层。
|
||||
bool get hasWallpaper => _wallpaperPath != null;
|
||||
}
|
||||
Reference in new issue
Block a user