transferencia nos professores
This commit is contained in:
@@ -860,6 +860,33 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _downloadFile(String? url, String fileName) async {
|
||||
if (url == null || url.isEmpty) {
|
||||
_showErrorSnackBar('URL do ficheiro não disponível');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
print('Downloading file: $fileName');
|
||||
print('URL: $url');
|
||||
final uri = Uri.parse(url);
|
||||
|
||||
final launched = await launchUrl(
|
||||
uri,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
|
||||
if (launched) {
|
||||
_showSuccessSnackBar('A transferir $fileName...');
|
||||
} else {
|
||||
_showErrorSnackBar('Não foi possível iniciar a transferência');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error downloading file: $e');
|
||||
_showErrorSnackBar('Erro ao transferir ficheiro: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildMaterialCard({
|
||||
required String docId,
|
||||
required String fileName,
|
||||
@@ -934,11 +961,19 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
||||
IconButton(
|
||||
icon: const Icon(Icons.visibility_outlined, color: Colors.blue),
|
||||
tooltip: 'Ver',
|
||||
constraints: const BoxConstraints(minWidth: 40, minHeight: 40),
|
||||
onPressed: () => _openFile(url, fileName),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.download_outlined, color: Colors.green),
|
||||
tooltip: 'Transferir',
|
||||
constraints: const BoxConstraints(minWidth: 40, minHeight: 40),
|
||||
onPressed: () => _downloadFile(url, fileName),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete_outline, color: Colors.red),
|
||||
tooltip: 'Eliminar',
|
||||
constraints: const BoxConstraints(minWidth: 40, minHeight: 40),
|
||||
onPressed: () => _showDeleteConfirmation(
|
||||
docId: docId,
|
||||
fileName: fileName,
|
||||
|
||||
Reference in New Issue
Block a user