Mã nguồn đã công bố
Tải mã nguồn dạng ZIP
CH-J SM Mobile
Duyệt thư mục và tệp của một bản phát hành ứng dụng cụ thể.
CH-J / SM Mobile
175 tệp
sm-mobile-20261016T185235Z-8e93ecc1b59a
Ngày thêm: · Ngày dựng:
1
import '../vault.dart';3
/// A recently opened or favorite file. Stored encrypted in the Vault (it4
/// can name servers and paths); never exported with profiles.5
class RecentFile {6
final String key, kind, name, location;7
final Map<String, dynamic> source;8
final DateTime opened;9
const RecentFile({10
required this.key,11
required this.kind,12
required this.name,13
required this.location,14
required this.source,15
required this.opened,16
});18
factory RecentFile.fromJson(Map m) => RecentFile(19
key: m['key'] as String,20
kind: m['kind'] as String,21
name: m['name'] as String,22
location: m['location'] as String? ?? '',23
source: Map<String, dynamic>.from(m['source'] as Map? ?? const {}),24
opened: DateTime.fromMillisecondsSinceEpoch(m['opened'] as int? ?? 0),25
);27
Map<String, dynamic> toJson() => {28
'key': key,29
'kind': kind,30
'name': name,31
'location': location,32
'source': source,33
'opened': opened.millisecondsSinceEpoch,34
};35
}37
class RecentFiles {38
static const section = 'documents', limit = 50;39
final Vault vault;40
RecentFiles(this.vault);42
Map<String, dynamic> get _data => vault.section(section);44
List<RecentFile> get recent => [45
for (final m in (_data['recent'] as List? ?? const []))46
RecentFile.fromJson(m as Map),47
];49
List<RecentFile> get favorites => [50
for (final m in (_data['favorites'] as List? ?? const []))51
RecentFile.fromJson(m as Map),52
];54
bool isFavorite(String key) => favorites.any((f) => f.key == key);56
Future<void> touch(RecentFile file) {57
final data = _data;58
final list = [59
file.toJson(),60
for (final m in (data['recent'] as List? ?? const []))61
if ((m as Map)['key'] != file.key) m,62
].take(limit).toList();63
return vault.setSection(section, {...data, 'recent': list});64
}66
Future<void> setFavorite(RecentFile file, bool favorite) {67
final data = _data;68
final list = [69
if (favorite) file.toJson(),70
for (final m in (data['favorites'] as List? ?? const []))71
if ((m as Map)['key'] != file.key) m,72
];73
return vault.setSection(section, {...data, 'favorites': list});74
}76
Future<void> remove(String key) {77
final data = _data;78
return vault.setSection(section, {79
...data,80
'recent': [81
for (final m in (data['recent'] as List? ?? const []))82
if ((m as Map)['key'] != key) m,83
],84
});85
}87
Future<void> clear() =>88
vault.setSection(section, {..._data, 'recent': const <Object>[]});89
}SHA-256
e82b41b0238538924fadbcd978abda5f4bb0c4d5f1f8e2a29bfb8444f301f6baCH-J Proprietary Software License 1.14 · Mã nguồn được cung cấp theo CH-J Proprietary Software License 1.14. Việc công khai mã nguồn không thay đổi các điều khoản giấy phép và không cấp thêm quyền nào.
SHA-256 của tệp nén
46e427a43e87af091004f36145590bda8fe90086dfb0f631afeb5029fb0b5655