improved performance and battery usage on older devices
This commit is contained in:
@@ -191,18 +191,23 @@ class _FilesUploadDialogState extends State<FilesUploadDialog> {
|
||||
}
|
||||
|
||||
final HttpClientResponse uploadTask;
|
||||
final fileIndex = _uploadableFiles.indexOf(file);
|
||||
var lastPercent = -1;
|
||||
try {
|
||||
uploadTask = await webdavClient.putFile(
|
||||
File(filePath),
|
||||
fileStat,
|
||||
PathUri.parse(fullRemotePath),
|
||||
onProgress: (progress) {
|
||||
// Called per 64 KB chunk — thousands of times for a video. Only
|
||||
// rebuild when the visible percentage actually moves.
|
||||
final percent = (progress * 100).floor();
|
||||
if (!mounted || percent == lastPercent) return;
|
||||
lastPercent = percent;
|
||||
setState(() {
|
||||
file._uploadProgress = progress;
|
||||
_overallProgressValue =
|
||||
((progress + _uploadableFiles.indexOf(file)) /
|
||||
_uploadableFiles.length)
|
||||
.toDouble();
|
||||
((progress + fileIndex) / _uploadableFiles.length).toDouble();
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -246,7 +251,12 @@ class _FilesUploadDialogState extends State<FilesUploadDialog> {
|
||||
itemCount: _uploadableFiles.length,
|
||||
itemBuilder: (context, index) {
|
||||
final currentFile = _uploadableFiles[index];
|
||||
currentFile.fileNameController.text = currentFile.fileName;
|
||||
// Only sync when it differs: assigning text resets selection
|
||||
// and notifies the field on every (progress) rebuild.
|
||||
if (currentFile.fileNameController.text !=
|
||||
currentFile.fileName) {
|
||||
currentFile.fileNameController.text = currentFile.fileName;
|
||||
}
|
||||
return ListTile(
|
||||
title: TextField(
|
||||
readOnly: _isUploading,
|
||||
|
||||
Reference in New Issue
Block a user