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),
|
onPressed: () => _downloadFile(file),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(
|
icon: const Icon(Icons.share, color: AppTheme.secondaryText),
|
||||||
Icons.share_outlined,
|
|
||||||
color: AppTheme.secondaryText,
|
|
||||||
),
|
|
||||||
splashColor: Colors.transparent,
|
splashColor: Colors.transparent,
|
||||||
highlightColor: Colors.transparent,
|
highlightColor: Colors.transparent,
|
||||||
onPressed: () => _shareFile(file),
|
onPressed: () => _shareFile(file),
|
||||||
|
|||||||
@@ -57,18 +57,12 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
|
|||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
// Auto-create share link
|
||||||
_shareUrl = null;
|
await _createShareLink();
|
||||||
_urlController.clear();
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
// Try to create share link anyway
|
||||||
_shareUrl = null;
|
await _createShareLink();
|
||||||
_urlController.clear();
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,25 +158,6 @@ class _ShareFileDialogState extends State<ShareFileDialog> {
|
|||||||
)
|
)
|
||||||
else if (_error != null)
|
else if (_error != null)
|
||||||
Text(_error!, style: TextStyle(color: Colors.red[400]))
|
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
|
else
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
Reference in New Issue
Block a user