WIP - Implemented similar documents view

This commit is contained in:
Anton Stubenbord
2023-01-22 01:17:52 +01:00
parent d4978172cf
commit b370fa4164
27 changed files with 476 additions and 381 deletions

View File

@@ -5,84 +5,95 @@ import 'package:paperless_mobile/extensions/flutter_extensions.dart';
import 'package:shimmer/shimmer.dart';
class DocumentsListLoadingWidget extends StatelessWidget {
final List<Widget> above;
final List<Widget> below;
static const tags = [" ", " ", " "];
static const titleLengths = <double>[double.infinity, 150.0, 200.0];
static const correspondentLengths = <double>[200.0, 300.0, 150.0];
static const fontSize = 16.0;
final List<Widget> beforeWidgets;
final List<Widget> afterWidgets;
static const _tags = [" ", " ", " "];
static const _titleLengths = <double>[double.infinity, 150.0, 200.0];
static const _correspondentLengths = <double>[200.0, 300.0, 150.0];
static const _fontSize = 16.0;
const DocumentsListLoadingWidget({
super.key,
this.above = const [],
this.below = const [],
this.beforeWidgets = const [],
this.afterWidgets = const [],
});
@override
Widget build(BuildContext context) {
return ListView(
children: <Widget>[
...above,
...List.generate(25, (idx) {
final r = Random(idx);
final tagCount = r.nextInt(tags.length + 1);
final correspondentLength =
correspondentLengths[r.nextInt(correspondentLengths.length - 1)];
final titleLength = titleLengths[r.nextInt(titleLengths.length - 1)];
return Shimmer.fromColors(
baseColor: Theme.of(context).brightness == Brightness.light
? Colors.grey[300]!
: Colors.grey[900]!,
highlightColor: Theme.of(context).brightness == Brightness.light
? Colors.grey[100]!
: Colors.grey[600]!,
child: ListTile(
contentPadding: const EdgeInsets.all(8),
dense: true,
isThreeLine: true,
leading: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
color: Colors.white,
height: 50,
width: 35,
),
),
title: Container(
padding: const EdgeInsets.symmetric(vertical: 2.0),
width: correspondentLength,
height: fontSize,
color: Colors.white,
),
subtitle: Padding(
padding: const EdgeInsets.symmetric(vertical: 2.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
padding: const EdgeInsets.symmetric(vertical: 2.0),
height: fontSize,
width: titleLength,
color: Colors.white,
),
Wrap(
spacing: 2.0,
children: List.generate(
tagCount,
(index) => InputChip(
label: Text(tags[r.nextInt(tags.length)]),
),
),
).paddedOnly(top: 4),
],
),
),
),
);
}).toList(),
...below,
final _random = Random();
return CustomScrollView(
slivers: [
SliverList(
delegate: SliverChildListDelegate(beforeWidgets),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return _buildFakeListItem(context, _random);
},
),
),
SliverList(delegate: SliverChildListDelegate(afterWidgets))
],
);
}
Widget _buildFakeListItem(BuildContext context, Random random) {
final tagCount = random.nextInt(_tags.length + 1);
final correspondentLength =
_correspondentLengths[random.nextInt(_correspondentLengths.length - 1)];
final titleLength = _titleLengths[random.nextInt(_titleLengths.length - 1)];
return Shimmer.fromColors(
baseColor: Theme.of(context).brightness == Brightness.light
? Colors.grey[300]!
: Colors.grey[900]!,
highlightColor: Theme.of(context).brightness == Brightness.light
? Colors.grey[100]!
: Colors.grey[600]!,
child: ListTile(
contentPadding: const EdgeInsets.all(8),
dense: true,
isThreeLine: true,
leading: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
color: Colors.white,
height: 50,
width: 35,
),
),
title: Container(
padding: const EdgeInsets.symmetric(vertical: 2.0),
width: correspondentLength,
height: _fontSize,
color: Colors.white,
),
subtitle: Padding(
padding: const EdgeInsets.symmetric(vertical: 2.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
padding: const EdgeInsets.symmetric(vertical: 2.0),
height: _fontSize,
width: titleLength,
color: Colors.white,
),
Wrap(
spacing: 2.0,
children: List.generate(
tagCount,
(index) => InputChip(
label: Text(_tags[random.nextInt(_tags.length)]),
),
),
).paddedOnly(top: 4),
],
),
),
),
);
}
}

View File

@@ -6,6 +6,7 @@ import 'package:paperless_mobile/generated/l10n.dart';
class HintCard extends StatelessWidget {
final String hintText;
final double elevation;
final IconData hintIcon;
final VoidCallback? onHintAcknowledged;
final bool show;
const HintCard({
@@ -13,7 +14,8 @@ class HintCard extends StatelessWidget {
required this.hintText,
this.onHintAcknowledged,
this.elevation = 1,
required this.show,
this.show = true,
this.hintIcon = Icons.tips_and_updates_outlined,
});
@override
@@ -31,7 +33,7 @@ class HintCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(
Icons.tips_and_updates_outlined,
hintIcon,
color: Theme.of(context).hintColor,
).padded(),
Align(
@@ -52,7 +54,7 @@ class HintCard extends StatelessWidget {
),
)
else
Padding(padding: EdgeInsets.only(bottom: 24)),
const Padding(padding: EdgeInsets.only(bottom: 24)),
],
).padded(),
).padded(),