feat: Implemented new view type, fix connectivity issues, fix offline issues, fix loading animations, fix documents page paging

This commit is contained in:
Anton Stubenbord
2023-02-14 00:24:14 +01:00
parent c5033792aa
commit 6f66bf27fd
29 changed files with 806 additions and 606 deletions

View File

@@ -2,51 +2,59 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/features/documents/view/pages/document_view.dart';
import 'package:provider/provider.dart';
import 'package:shimmer/shimmer.dart';
class DocumentPreview extends StatelessWidget {
final int id;
final DocumentModel document;
final BoxFit fit;
final Alignment alignment;
final double borderRadius;
final bool enableHero;
final double scale;
const DocumentPreview({
super.key,
required this.id,
required this.document,
this.fit = BoxFit.cover,
this.alignment = Alignment.center,
this.borderRadius = 8.0,
this.alignment = Alignment.topCenter,
this.borderRadius = 12.0,
this.enableHero = true,
this.scale = 1.1,
});
@override
Widget build(BuildContext context) {
if (!enableHero) {
return _buildPreview(context);
}
return Hero(
tag: "thumb_$id",
child: _buildPreview(context),
return HeroMode(
enabled: enableHero,
child: Hero(
tag: "thumb_${document.id}",
child: _buildPreview(context),
),
);
}
ClipRRect _buildPreview(BuildContext context) {
Widget _buildPreview(BuildContext context) {
return ClipRRect(
borderRadius: BorderRadius.circular(borderRadius),
child: CachedNetworkImage(
fit: fit,
alignment: Alignment.topCenter,
cacheKey: "thumb_$id",
imageUrl: context.read<PaperlessDocumentsApi>().getThumbnailUrl(id),
errorWidget: (ctxt, msg, __) => Text(msg),
placeholder: (context, value) => Shimmer.fromColors(
baseColor: Colors.grey[300]!,
highlightColor: Colors.grey[100]!,
child: const SizedBox(height: 100, width: 100),
child: Transform.scale(
scale: scale,
child: CachedNetworkImage(
fit: fit,
alignment: alignment,
cacheKey: "thumb_${document.id}",
imageUrl: context
.read<PaperlessDocumentsApi>()
.getThumbnailUrl(document.id),
errorWidget: (ctxt, msg, __) => Text(msg),
placeholder: (context, value) => Shimmer.fromColors(
baseColor: Colors.grey[300]!,
highlightColor: Colors.grey[100]!,
child: const SizedBox(height: 100, width: 100),
),
cacheManager: context.watch<CacheManager>(),
),
cacheManager: context.watch<CacheManager>(),
),
);
}