Remote sync of webdav
This commit is contained in:
parent
f01186df79
commit
483fbeafb6
44 changed files with 4842 additions and 975 deletions
|
|
@ -5,12 +5,11 @@ import 'package:flutter/material.dart';
|
|||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../services/app_state.dart';
|
||||
import '../services/drive_service.dart';
|
||||
|
||||
/// Full-screen, pinch-zoomable view of a receipt photo. Pass
|
||||
/// [localImagePath] for a receipt still held locally, or [driveFileId] for
|
||||
/// one already uploaded to Drive and removed locally — in which case it's
|
||||
/// downloaded on demand (no local caching afterward).
|
||||
/// one already uploaded to the cloud and removed locally — in which case
|
||||
/// it's downloaded on demand (no local caching afterward).
|
||||
class ReceiptImageScreen extends StatefulWidget {
|
||||
final String? localImagePath;
|
||||
final String? driveFileId;
|
||||
|
|
@ -42,11 +41,18 @@ class _ReceiptImageScreenState extends State<ReceiptImageScreen> {
|
|||
_error = null;
|
||||
});
|
||||
|
||||
final authService = context.read<AppState>().driveAuth;
|
||||
final client = authService.authenticatedHttpClient();
|
||||
final provider = context.read<AppState>().activeProvider;
|
||||
if (provider == null) {
|
||||
setState(() {
|
||||
_error = 'Not connected to a cloud storage provider.';
|
||||
_loading = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
final session = provider.beginSession();
|
||||
try {
|
||||
final drive = DriveService(client);
|
||||
final bytes = await drive.downloadFileBytes(widget.driveFileId!);
|
||||
final bytes = await session.downloadFileBytes(widget.driveFileId!);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_downloadedBytes = Uint8List.fromList(bytes);
|
||||
|
|
@ -59,7 +65,7 @@ class _ReceiptImageScreenState extends State<ReceiptImageScreen> {
|
|||
_loading = false;
|
||||
});
|
||||
} finally {
|
||||
client.close();
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue