53 lines
1.8 KiB
Dart
53 lines
1.8 KiB
Dart
/// 약속 (E6): Total Commander 모양의 창 위 한 줄 - 지금 저장 장치 ([root]) 의 남은 공간 / 전체.
|
|
/// 값은 [space] (기기 - ExplorerDevice.diskSpace) 에서 받고, 저장 장치가 바뀔 때만 다시 묻는다 (줄을 다시 그려도 다시 재지 않음).
|
|
/// 못 재면 저장 장치 이름만 보인다.
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../core/files/file_listing.dart' show formatSize;
|
|
import '../../l10n/tr.dart';
|
|
import '../theme.dart';
|
|
|
|
class TcDriveSpace extends StatefulWidget {
|
|
/// 저장 장치의 맨 위 (예: C:\)
|
|
final String root;
|
|
|
|
/// 보이는 이름 (예: "C:")
|
|
final String label;
|
|
final Future<(int, int)?> Function(String path) space;
|
|
const TcDriveSpace({super.key, required this.root, required this.label, required this.space});
|
|
|
|
@override
|
|
State<TcDriveSpace> createState() => _TcDriveSpaceState();
|
|
}
|
|
|
|
class _TcDriveSpaceState extends State<TcDriveSpace> {
|
|
late Future<(int, int)?> _f = widget.space(widget.root);
|
|
|
|
@override
|
|
void didUpdateWidget(TcDriveSpace old) {
|
|
super.didUpdateWidget(old);
|
|
if (old.root != widget.root) _f = widget.space(widget.root);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => FutureBuilder<(int, int)?>(
|
|
future: _f,
|
|
builder: (_, s) {
|
|
final d = s.data;
|
|
return Container(
|
|
height: 22,
|
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
alignment: Alignment.centerLeft,
|
|
child: Text(
|
|
d == null ? '[${widget.label}]' : trf('[{0}] 남은 {1} / 전체 {2}', [widget.label, formatSize(d.$1), formatSize(d.$2)]),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(fontSize: 11.5, color: JjColors.textDim),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|