Refactor share file dialog to auto-create share link and simplify error handling

This commit is contained in:
Leon Bösche
2026-01-24 21:49:55 +01:00
parent 896f475b03
commit b703a209d0
2 changed files with 5 additions and 33 deletions

View File

@@ -1310,10 +1310,7 @@ class _FileExplorerState extends State<FileExplorer>
onPressed: () => _downloadFile(file),
),
IconButton(
icon: const Icon(
Icons.share_outlined,
color: AppTheme.secondaryText,
),
icon: const Icon(Icons.share, color: AppTheme.secondaryText),
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
onPressed: () => _shareFile(file),

View File

@@ -57,18 +57,12 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
_isLoading = false;
});
} else {
setState(() {
_shareUrl = null;
_urlController.clear();
_isLoading = false;
});
// Auto-create share link
await _createShareLink();
}
} catch (e) {
setState(() {
_shareUrl = null;
_urlController.clear();
_isLoading = false;
});
// Try to create share link anyway
await _createShareLink();
}
}
@@ -164,25 +158,6 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
)
else if (_error != null)
Text(_error!, style: TextStyle(color: Colors.red[400]))
else if (_shareUrl == null)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'No share link exists for this file.',
style: TextStyle(color: AppTheme.secondaryText),
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: _createShareLink,
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.accentColor,
foregroundColor: Colors.white,
),
child: const Text('Create Share Link'),
),
],
)
else
Column(
crossAxisAlignment: CrossAxisAlignment.start,