Compare commits

3 Commits
Author SHA1 Message Date
julian 1c5df097c4 Make this version 0.2.1
Build and deploy the latest docker container / deploy (push) Successful in 1m6s
Build and release the latest android apk / rolling-release-apk (push) Successful in 5m31s
Build and release a versioned android apk / release-apk (push) Successful in 5m9s
2026-07-03 17:51:03 +02:00
julian 73336ce3fa Show offline symbol at first start if offline 2026-07-03 17:49:06 +02:00
julian baf20e1ca8 Add symbol for offline available sheets 2026-07-03 17:46:50 +02:00
6 changed files with 23 additions and 2 deletions
+2
View File
@@ -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.
+7
View File
@@ -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
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
+6
View File
@@ -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
View File
@@ -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