Refactor file sharing UI to use TextField for share link display and improve error handling

This commit is contained in:
Leon Bösche
2026-01-24 21:38:29 +01:00
parent 49c578cef2
commit 896f475b03
3 changed files with 91 additions and 80 deletions

View File

@@ -83,63 +83,77 @@ class _PublicFileViewerState extends State<PublicFileViewer> {
: _error != null
? Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.link_off, size: 64, color: Colors.red[400]),
const SizedBox(height: 16),
Text(
_error!,
style: TextStyle(
color: AppTheme.primaryText,
fontSize: 18,
),
textAlign: TextAlign.center,
child: Card(
color: AppTheme.primaryBackground,
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.link_off, size: 64, color: Colors.red[400]),
const SizedBox(height: 16),
Text(
_error!,
style: TextStyle(
color: AppTheme.primaryText,
fontSize: 18,
),
textAlign: TextAlign.center,
),
],
),
],
),
),
)
: _fileData != null
? Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.insert_drive_file,
size: 64,
color: AppTheme.primaryText,
),
const SizedBox(height: 16),
Text(
_fileData!['fileName'] ?? 'Unknown file',
style: TextStyle(
color: AppTheme.primaryText,
fontSize: 24,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
Text(
'Size: ${(_fileData!['fileSize'] ?? 0) ~/ 1024} KB',
style: TextStyle(color: AppTheme.secondaryText),
),
const SizedBox(height: 24),
ElevatedButton.icon(
onPressed: _downloadFile,
icon: const Icon(Icons.download),
label: const Text('Download File'),
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.accentColor,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 12,
child: Card(
color: AppTheme.primaryBackground,
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.insert_drive_file,
size: 64,
color: AppTheme.primaryText,
),
),
const SizedBox(height: 16),
Text(
_fileData!['fileName'] ?? 'Unknown file',
style: TextStyle(
color: AppTheme.primaryText,
fontSize: 24,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
Text(
'Size: ${(_fileData!['fileSize'] ?? 0) ~/ 1024} KB',
style: TextStyle(color: AppTheme.secondaryText),
),
const SizedBox(height: 24),
ElevatedButton.icon(
onPressed: _downloadFile,
icon: const Icon(Icons.download),
label: const Text('Download File'),
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.accentColor,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 12,
),
),
),
],
),
],
),
),
)
: const SizedBox(),