Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c5df097c4 | ||
|
|
73336ce3fa | ||
|
|
baf20e1ca8 |
@@ -7,12 +7,14 @@ class Sheet {
|
|||||||
String name;
|
String name;
|
||||||
String composer;
|
String composer;
|
||||||
DateTime updatedAt;
|
DateTime updatedAt;
|
||||||
|
bool availableOffline;
|
||||||
|
|
||||||
Sheet({
|
Sheet({
|
||||||
required this.uuid,
|
required this.uuid,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.composer,
|
required this.composer,
|
||||||
required this.updatedAt,
|
required this.updatedAt,
|
||||||
|
this.availableOffline = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Creates a [Sheet] from a JSON map returned by the API.
|
/// Creates a [Sheet] from a JSON map returned by the API.
|
||||||
|
|||||||
@@ -254,6 +254,13 @@ class ApiClient {
|
|||||||
return cachedFile;
|
return cachedFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> isPdfFileCached(String sheetUuid) async {
|
||||||
|
final cacheDir = await getTemporaryDirectory();
|
||||||
|
final cachedFile = File('${cacheDir.path}/$sheetUuid.pdf');
|
||||||
|
|
||||||
|
return await cachedFile.exists();
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Annotation Operations
|
// Annotation Operations
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -123,7 +123,13 @@ class _HomePageState extends State<HomePage> with RouteAware {
|
|||||||
|
|
||||||
// Sort and store sheets
|
// Sort and store sheets
|
||||||
_sheets = await _sortSheetsByRecency(result.sheets);
|
_sheets = await _sortSheetsByRecency(result.sheets);
|
||||||
|
setState(() {
|
||||||
_isOnline = result.isOnline;
|
_isOnline = result.isOnline;
|
||||||
|
});
|
||||||
|
|
||||||
|
for (var sheet in _sheets) {
|
||||||
|
sheet.availableOffline = await _apiClient!.isPdfFileCached(sheet.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import '../../../core/models/sheet.dart';
|
import '../../../core/models/sheet.dart';
|
||||||
|
|
||||||
/// A list tile displaying a single sheet's information.
|
/// A list tile displaying a single sheet's information.
|
||||||
@@ -24,6 +25,10 @@ class SheetListItem extends StatelessWidget {
|
|||||||
subtitle: Text(sheet.composer),
|
subtitle: Text(sheet.composer),
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
onLongPress: onLongPress,
|
onLongPress: onLongPress,
|
||||||
|
trailing: Visibility(
|
||||||
|
visible: !kIsWeb && sheet.availableOffline,
|
||||||
|
child: Icon(Icons.download_done, color: Colors.green),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ class _SheetViewerPageState extends State<SheetViewerPage>
|
|||||||
// Native: use file cache
|
// Native: use file cache
|
||||||
final file = await widget.apiClient.getPdfFileCached(widget.sheet.uuid);
|
final file = await widget.apiClient.getPdfFileCached(widget.sheet.uuid);
|
||||||
_document = await PdfDocument.openFile(file.path);
|
_document = await PdfDocument.openFile(file.path);
|
||||||
|
widget.sheet.availableOffline = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 0.2.0
|
version: 0.2.1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.0.0
|
sdk: ^3.0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user