diff options
| author | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
|---|---|---|
| committer | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
| commit | 449d8b74bd6d9dae98a07254cdfad677b920e7b0 (patch) | |
| tree | c131c3528c4d517f56e19b854a7453fedb097d40 /lib/widgets/debug/os_storage.dart | |
| download | aves-src-master.tar.gz aves-src-master.zip | |
Diffstat (limited to 'lib/widgets/debug/os_storage.dart')
| -rw-r--r-- | lib/widgets/debug/os_storage.dart | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/widgets/debug/os_storage.dart b/lib/widgets/debug/os_storage.dart new file mode 100644 index 0000000..5765e51 --- /dev/null +++ b/lib/widgets/debug/os_storage.dart @@ -0,0 +1,64 @@ +import 'package:aves/ref/locales.dart'; +import 'package:aves/services/common/services.dart'; +import 'package:aves/utils/android_file_utils.dart'; +import 'package:aves/utils/file_utils.dart'; +import 'package:aves/view/view.dart'; +import 'package:aves/widgets/common/identity/aves_expansion_tile.dart'; +import 'package:aves/widgets/viewer/info/common.dart'; +import 'package:flutter/material.dart'; + +class DebugOSStorageSection extends StatefulWidget { + const DebugOSStorageSection({super.key}); + + @override + State<DebugOSStorageSection> createState() => _DebugOSStorageSectionState(); +} + +class _DebugOSStorageSectionState extends State<DebugOSStorageSection> with AutomaticKeepAliveClientMixin { + final Map<String, int?> _freeSpaceByVolume = {}; + + @override + void initState() { + super.initState(); + androidFileUtils.storageVolumes.forEach((volume) async { + final byteCount = await storageService.getFreeSpace(volume); + setState(() => _freeSpaceByVolume[volume.path] = byteCount); + }); + } + + @override + Widget build(BuildContext context) { + super.build(context); + + return AvesExpansionTile( + title: 'OS Storage', + children: [ + ...androidFileUtils.storageVolumes.expand((v) { + final freeSpace = _freeSpaceByVolume[v.path]; + return [ + Padding( + padding: const EdgeInsets.all(8), + child: Text(v.path), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: InfoRowGroup( + info: { + 'description': v.getDescription(context), + 'isPrimary': '${v.isPrimary}', + 'isRemovable': '${v.isRemovable}', + 'state': v.state, + if (freeSpace != null) 'freeSpace': formatFileSize(asciiLocale, freeSpace), + }, + ), + ), + const Divider(), + ]; + }) + ], + ); + } + + @override + bool get wantKeepAlive => true; +} |
