Refactor share file dialog to auto-create share link and simplify error handling
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user