Update Landing page

This commit is contained in:
Anton Stubenbord
2023-08-01 21:58:20 +02:00
parent b79375cbe0
commit 8e5eb5a6c6
6 changed files with 166 additions and 158 deletions

View File

@@ -35,7 +35,7 @@ PODS:
- DKPhotoGallery/Resource (0.0.17): - DKPhotoGallery/Resource (0.0.17):
- SDWebImage - SDWebImage
- SwiftyGif - SwiftyGif
- edge_detection (1.1.1): - edge_detection (1.1.2):
- Flutter - Flutter
- WeScan - WeScan
- file_picker (0.0.1): - file_picker (0.0.1):
@@ -48,14 +48,16 @@ PODS:
- Flutter - Flutter
- flutter_native_splash (0.0.1): - flutter_native_splash (0.0.1):
- Flutter - Flutter
- flutter_pdfview (1.0.2):
- Flutter
- flutter_secure_storage (6.0.0):
- Flutter
- fluttertoast (0.0.2): - fluttertoast (0.0.2):
- Flutter - Flutter
- Toast - Toast
- FMDB (2.7.5): - FMDB (2.7.5):
- FMDB/standard (= 2.7.5) - FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5) - FMDB/standard (2.7.5)
- in_app_review (0.2.0):
- Flutter
- integration_test (0.0.1): - integration_test (0.0.1):
- Flutter - Flutter
- local_auth_ios (0.0.1): - local_auth_ios (0.0.1):
@@ -67,9 +69,9 @@ PODS:
- path_provider_foundation (0.0.1): - path_provider_foundation (0.0.1):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
- pdfx (1.0.0): - permission_handler_apple (9.1.1):
- Flutter - Flutter
- permission_handler_apple (9.0.4): - printing (1.0.0):
- Flutter - Flutter
- ReachabilitySwift (5.0.0) - ReachabilitySwift (5.0.0)
- receive_sharing_intent (0.0.1): - receive_sharing_intent (0.0.1):
@@ -79,16 +81,15 @@ PODS:
- SDWebImage/Core (5.13.5) - SDWebImage/Core (5.13.5)
- share_plus (0.0.1): - share_plus (0.0.1):
- Flutter - Flutter
- shared_preferences_foundation (0.0.1): - sqflite (0.0.3):
- Flutter
- FlutterMacOS
- sqflite (0.0.2):
- Flutter - Flutter
- FMDB (>= 2.7.5) - FMDB (>= 2.7.5)
- SwiftyGif (5.4.3) - SwiftyGif (5.4.3)
- Toast (4.0.0) - Toast (4.0.0)
- url_launcher_ios (0.0.1): - url_launcher_ios (0.0.1):
- Flutter - Flutter
- webview_flutter_wkwebview (0.0.1):
- Flutter
- WeScan (1.7.0) - WeScan (1.7.0)
DEPENDENCIES: DEPENDENCIES:
@@ -100,20 +101,21 @@ DEPENDENCIES:
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`) - flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`) - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`) - flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- flutter_pdfview (from `.symlinks/plugins/flutter_pdfview/ios`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- in_app_review (from `.symlinks/plugins/in_app_review/ios`)
- integration_test (from `.symlinks/plugins/integration_test/ios`) - integration_test (from `.symlinks/plugins/integration_test/ios`)
- local_auth_ios (from `.symlinks/plugins/local_auth_ios/ios`) - local_auth_ios (from `.symlinks/plugins/local_auth_ios/ios`)
- open_filex (from `.symlinks/plugins/open_filex/ios`) - open_filex (from `.symlinks/plugins/open_filex/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- pdfx (from `.symlinks/plugins/pdfx/ios`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- printing (from `.symlinks/plugins/printing/ios`)
- receive_sharing_intent (from `.symlinks/plugins/receive_sharing_intent/ios`) - receive_sharing_intent (from `.symlinks/plugins/receive_sharing_intent/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`) - share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)
SPEC REPOS: SPEC REPOS:
trunk: trunk:
@@ -143,10 +145,12 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_local_notifications/ios" :path: ".symlinks/plugins/flutter_local_notifications/ios"
flutter_native_splash: flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios" :path: ".symlinks/plugins/flutter_native_splash/ios"
flutter_pdfview:
:path: ".symlinks/plugins/flutter_pdfview/ios"
flutter_secure_storage:
:path: ".symlinks/plugins/flutter_secure_storage/ios"
fluttertoast: fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios" :path: ".symlinks/plugins/fluttertoast/ios"
in_app_review:
:path: ".symlinks/plugins/in_app_review/ios"
integration_test: integration_test:
:path: ".symlinks/plugins/integration_test/ios" :path: ".symlinks/plugins/integration_test/ios"
local_auth_ios: local_auth_ios:
@@ -156,54 +160,55 @@ EXTERNAL SOURCES:
package_info_plus: package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios" :path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation: path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/ios" :path: ".symlinks/plugins/path_provider_foundation/darwin"
pdfx:
:path: ".symlinks/plugins/pdfx/ios"
permission_handler_apple: permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios" :path: ".symlinks/plugins/permission_handler_apple/ios"
printing:
:path: ".symlinks/plugins/printing/ios"
receive_sharing_intent: receive_sharing_intent:
:path: ".symlinks/plugins/receive_sharing_intent/ios" :path: ".symlinks/plugins/receive_sharing_intent/ios"
share_plus: share_plus:
:path: ".symlinks/plugins/share_plus/ios" :path: ".symlinks/plugins/share_plus/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/ios"
sqflite: sqflite:
:path: ".symlinks/plugins/sqflite/ios" :path: ".symlinks/plugins/sqflite/ios"
url_launcher_ios: url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios" :path: ".symlinks/plugins/url_launcher_ios/ios"
webview_flutter_wkwebview:
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios"
SPEC CHECKSUMS: SPEC CHECKSUMS:
connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a
device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
edge_detection: fa02aa120e00d87ada0ca2430b6c6087a501b1e9 edge_detection: b4fb239b018cefa79515a024d0bf3e559336de4e
file_picker: ce3938a0df3cc1ef404671531facef740d03f920 file_picker: ce3938a0df3cc1ef404671531facef740d03f920
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069 flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743 flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
fluttertoast: eb263d302cc92e04176c053d2385237e9f43fad0 flutter_pdfview: 25f53dd6097661e6395b17de506e6060585946bd
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
in_app_review: 318597b3a06c22bb46dc454d56828c85f444f99d integration_test: 13825b8a9334a850581300559b8839134b124670
integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5 local_auth_ios: c6cf091ded637a88f24f86a8875d8b0f526e2605
local_auth_ios: 0d333dde7780f669e66f19d2ff6005f3ea84008d
open_filex: 6e26e659846ec990262224a12ef1c528bb4edbe4 open_filex: 6e26e659846ec990262224a12ef1c528bb4edbe4
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7
path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852 path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
pdfx: 7b876b09de8b7a0bf444a4f82b439ffcff4ee1ec permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce printing: 233e1b73bd1f4a05615548e9b5a324c98588640b
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825 ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
receive_sharing_intent: c0d87310754e74c0f9542947e7cbdf3a0335a3b1 receive_sharing_intent: c0d87310754e74c0f9542947e7cbdf3a0335a3b1
SDWebImage: 23d714cd599354ee7906dbae26dff89b421c4370 SDWebImage: 23d714cd599354ee7906dbae26dff89b421c4370
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68 share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780 SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196 Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
url_launcher_ios: fb12c43172927bb5cf75aeebd073f883801f1993 url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a
WeScan: fed582f6c38014d529afb5aa9ffd1bad38fc72b7 WeScan: fed582f6c38014d529afb5aa9ffd1bad38fc72b7
PODFILE CHECKSUM: 7daa35cc908d9fba025075df27cb57a1ba1ebf13 PODFILE CHECKSUM: 7daa35cc908d9fba025075df27cb57a1ba1ebf13
COCOAPODS: 1.11.3 COCOAPODS: 1.12.0

View File

@@ -1,6 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:paperless_api/paperless_api.dart'; import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/database/tables/local_user_account.dart'; import 'package:paperless_mobile/core/database/tables/local_user_account.dart';
import 'package:paperless_mobile/extensions/flutter_extensions.dart'; import 'package:paperless_mobile/extensions/flutter_extensions.dart';
@@ -9,12 +8,10 @@ import 'package:paperless_mobile/features/document_search/view/sliver_search_bar
import 'package:paperless_mobile/features/landing/view/widgets/expansion_card.dart'; import 'package:paperless_mobile/features/landing/view/widgets/expansion_card.dart';
import 'package:paperless_mobile/features/landing/view/widgets/mime_types_pie_chart.dart'; import 'package:paperless_mobile/features/landing/view/widgets/mime_types_pie_chart.dart';
import 'package:paperless_mobile/features/saved_view/cubit/saved_view_cubit.dart'; import 'package:paperless_mobile/features/saved_view/cubit/saved_view_cubit.dart';
import 'package:paperless_mobile/features/saved_view_details/view/saved_view_details_preview.dart'; import 'package:paperless_mobile/features/saved_view_details/view/saved_view_preview.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart'; import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
import 'package:paperless_mobile/routes/routes.dart';
import 'package:paperless_mobile/routes/typed/branches/documents_route.dart'; import 'package:paperless_mobile/routes/typed/branches/documents_route.dart';
import 'package:paperless_mobile/routes/typed/branches/inbox_route.dart'; import 'package:paperless_mobile/routes/typed/branches/inbox_route.dart';
import 'package:fl_chart/fl_chart.dart';
class LandingPage extends StatefulWidget { class LandingPage extends StatefulWidget {
const LandingPage({super.key}); const LandingPage({super.key});
@@ -45,7 +42,7 @@ class _LandingPageState extends State<LandingPage> {
slivers: [ slivers: [
SliverToBoxAdapter( SliverToBoxAdapter(
child: Text( child: Text(
"Welcome to Paperless Mobile, ${currentUser.fullName ?? currentUser.username}!", "Welcome, ${currentUser.fullName ?? currentUser.username}!",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
@@ -54,17 +51,34 @@ class _LandingPageState extends State<LandingPage> {
).padded(24), ).padded(24),
), ),
SliverToBoxAdapter(child: _buildStatisticsCard(context)), SliverToBoxAdapter(child: _buildStatisticsCard(context)),
SliverPadding(
padding: const EdgeInsets.fromLTRB(16, 16, 0, 8),
sliver: SliverToBoxAdapter(
child: Text(
"Saved Views",
style: Theme.of(context).textTheme.titleMedium,
),
),
),
BlocBuilder<SavedViewCubit, SavedViewState>( BlocBuilder<SavedViewCubit, SavedViewState>(
builder: (context, state) { builder: (context, state) {
return state.maybeWhen( return state.maybeWhen(
loaded: (savedViews) { loaded: (savedViews) {
final dashboardViews = savedViews.values
.where((element) => element.showOnDashboard)
.toList();
if (dashboardViews.isEmpty) {
return const SliverToBoxAdapter(
child: Text("No views"),
);
}
return SliverList.builder( return SliverList.builder(
itemBuilder: (context, index) { itemBuilder: (context, index) {
return SavedViewDetailsPreview( return SavedViewPreview(
savedView: savedViews.values.elementAt(index), savedView: dashboardViews.elementAt(index),
); );
}, },
itemCount: savedViews.length, itemCount: dashboardViews.length,
); );
}, },
orElse: () => const SliverToBoxAdapter( orElse: () => const SliverToBoxAdapter(
@@ -83,6 +97,7 @@ class _LandingPageState extends State<LandingPage> {
} }
Widget _buildStatisticsCard(BuildContext context) { Widget _buildStatisticsCard(BuildContext context) {
final currentUser = context.read<LocalUserAccount>().paperlessUser;
return FutureBuilder<PaperlessServerStatisticsModel>( return FutureBuilder<PaperlessServerStatisticsModel>(
future: context.read<PaperlessServerStatsApi>().getServerStatistics(), future: context.read<PaperlessServerStatsApi>().getServerStatistics(),
builder: (context, snapshot) { builder: (context, snapshot) {
@@ -118,19 +133,13 @@ class _LandingPageState extends State<LandingPage> {
child: ListTile( child: ListTile(
shape: Theme.of(context).cardTheme.shape, shape: Theme.of(context).cardTheme.shape,
titleTextStyle: Theme.of(context).textTheme.labelLarge, titleTextStyle: Theme.of(context).textTheme.labelLarge,
title: Text("Documents in inbox:"), title: const Text("Documents in inbox:"),
onTap: () { onTap: currentUser.canViewTags && currentUser.canViewDocuments
InboxRoute().go(context); ? () => InboxRoute().go(context)
}, : null,
trailing: Chip( trailing: Text(
padding: EdgeInsets.symmetric( stats.documentsInInbox.toString(),
horizontal: 4, style: Theme.of(context).textTheme.labelLarge,
vertical: 2,
),
labelPadding: EdgeInsets.symmetric(horizontal: 4),
label: Text(
stats.documentsInInbox.toString(),
),
), ),
), ),
), ),
@@ -139,16 +148,16 @@ class _LandingPageState extends State<LandingPage> {
child: ListTile( child: ListTile(
shape: Theme.of(context).cardTheme.shape, shape: Theme.of(context).cardTheme.shape,
titleTextStyle: Theme.of(context).textTheme.labelLarge, titleTextStyle: Theme.of(context).textTheme.labelLarge,
title: Text("Total documents:"), title: const Text("Total documents:"),
onTap: () { onTap: () {
DocumentsRoute().go(context); DocumentsRoute().go(context);
}, },
trailing: Chip( trailing: Chip(
padding: EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 4, horizontal: 4,
vertical: 2, vertical: 2,
), ),
labelPadding: EdgeInsets.symmetric(horizontal: 4), labelPadding: const EdgeInsets.symmetric(horizontal: 4),
label: Text( label: Text(
stats.documentsTotal.toString(), stats.documentsTotal.toString(),
), ),
@@ -160,13 +169,13 @@ class _LandingPageState extends State<LandingPage> {
child: ListTile( child: ListTile(
shape: Theme.of(context).cardTheme.shape, shape: Theme.of(context).cardTheme.shape,
titleTextStyle: Theme.of(context).textTheme.labelLarge, titleTextStyle: Theme.of(context).textTheme.labelLarge,
title: Text("Total characters:"), title: const Text("Total characters:"),
trailing: Chip( trailing: Chip(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 4, horizontal: 4,
vertical: 2, vertical: 2,
), ),
labelPadding: EdgeInsets.symmetric(horizontal: 4), labelPadding: const EdgeInsets.symmetric(horizontal: 4),
label: Text( label: Text(
stats.totalChars.toString(), stats.totalChars.toString(),
), ),

View File

@@ -4,7 +4,14 @@ class ExpansionCard extends StatelessWidget {
final Widget title; final Widget title;
final Widget content; final Widget content;
const ExpansionCard({super.key, required this.title, required this.content}); final bool initiallyExpanded;
const ExpansionCard({
super.key,
required this.title,
required this.content,
this.initiallyExpanded = false,
});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -23,7 +30,7 @@ class ExpansionCard extends StatelessWidget {
), ),
child: ExpansionTile( child: ExpansionTile(
backgroundColor: Theme.of(context).colorScheme.surface, backgroundColor: Theme.of(context).colorScheme.surface,
initiallyExpanded: true, initiallyExpanded: initiallyExpanded,
title: title, title: title,
children: [content], children: [content],
), ),

View File

@@ -75,7 +75,7 @@ class _MimeTypesPieChartState extends State<MimeTypesPieChart> {
), ),
), ),
Wrap( Wrap(
alignment: WrapAlignment.start, alignment: WrapAlignment.spaceAround,
spacing: 8, spacing: 8,
runSpacing: 8, runSpacing: 8,
children: [ children: [
@@ -126,25 +126,18 @@ class _MimeTypesPieChartState extends State<MimeTypesPieChart> {
for (int i = 0; i < widget.statistics.fileTypeCounts.length; i++) { for (int i = 0; i < widget.statistics.fileTypeCounts.length; i++) {
final type = widget.statistics.fileTypeCounts[i]; final type = widget.statistics.fileTypeCounts[i];
final isTouched = i == _touchedIndex; final isTouched = i == _touchedIndex;
final fontSize = isTouched ? 24.0 : 16.0; final fontSize = isTouched ? 18.0 : 16.0;
final radius = isTouched ? 60.0 : 50.0; final radius = isTouched ? 60.0 : 50.0;
const shadows = [ final percentage = type.count / widget.statistics.documentsTotal * 100;
Shadow(color: Colors.black, blurRadius: 2),
];
final color = colorShades[i % colorShades.length];
final textColor =
color.computeLuminance() > 0.5 ? Colors.black : Colors.white;
yield PieChartSectionData( yield PieChartSectionData(
color: colorShades[i % colorShades.length], color: colorShades[i % colorShades.length],
value: type.count.toDouble(), value: type.count.toDouble(),
title: ((type.count / widget.statistics.documentsTotal) * 100) title: percentage.toStringAsFixed(1) + "%",
.toStringAsFixed(1) +
"%",
radius: radius, radius: radius,
titleStyle: TextStyle( titleStyle: TextStyle(
fontSize: fontSize, fontSize: fontSize,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: textColor, color: Colors.black,
), ),
); );
} }

View File

@@ -1,84 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/features/documents/cubit/documents_cubit.dart';
import 'package:paperless_mobile/features/documents/view/widgets/adaptive_documents_view.dart';
import 'package:paperless_mobile/features/documents/view/widgets/items/document_list_item.dart';
import 'package:paperless_mobile/features/landing/view/widgets/expansion_card.dart';
import 'package:paperless_mobile/features/saved_view_details/cubit/saved_view_details_cubit.dart';
import 'package:paperless_mobile/features/saved_view_details/cubit/saved_view_preview_cubit.dart';
import 'package:paperless_mobile/routes/typed/branches/documents_route.dart';
import 'package:provider/provider.dart';
class SavedViewDetailsPreview extends StatelessWidget {
final SavedView savedView;
const SavedViewDetailsPreview({
super.key,
required this.savedView,
});
@override
Widget build(BuildContext context) {
return Provider(
create: (context) =>
SavedViewPreviewCubit(context.read(), savedView)..initialize(),
builder: (context, child) {
return ExpansionCard(
title: Text(savedView.name),
content: BlocBuilder<SavedViewPreviewCubit, SavedViewPreviewState>(
builder: (context, state) {
return Column(
children: [
state.maybeWhen(
loaded: (documents) {
return Column(
children: [
for (final document in documents)
DocumentListItem(
document: document,
isLabelClickable: false,
isSelected: false,
isSelectionActive: false,
onTap: (document) {
DocumentDetailsRoute($extra: document)
.push(context);
},
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
TextButton(
child: Text("Show more"),
onPressed: documents.length >= 5 ? () {} : null,
),
TextButton.icon(
icon: Icon(Icons.open_in_new),
label: Text("Show in documents"),
onPressed: () {
context.read<DocumentsCubit>().updateFilter(
filter: savedView.toDocumentFilter(),
);
DocumentsRoute().go(context);
},
),
],
),
],
);
},
error: () =>
const Text("Error loading preview"), //TODO: INTL
orElse: () => const Padding(
padding: EdgeInsets.all(8.0),
child: Center(child: CircularProgressIndicator()),
),
),
],
);
},
),
);
},
);
}
}

View File

@@ -0,0 +1,78 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/features/documents/cubit/documents_cubit.dart';
import 'package:paperless_mobile/features/documents/view/widgets/items/document_list_item.dart';
import 'package:paperless_mobile/features/landing/view/widgets/expansion_card.dart';
import 'package:paperless_mobile/features/saved_view_details/cubit/saved_view_preview_cubit.dart';
import 'package:paperless_mobile/routes/typed/branches/documents_route.dart';
import 'package:provider/provider.dart';
class SavedViewPreview extends StatelessWidget {
final SavedView savedView;
const SavedViewPreview({
super.key,
required this.savedView,
});
@override
Widget build(BuildContext context) {
return Provider(
create: (context) =>
SavedViewPreviewCubit(context.read(), savedView)..initialize(),
builder: (context, child) {
return ExpansionCard(
initiallyExpanded: true,
title: Text(savedView.name),
content: BlocBuilder<SavedViewPreviewCubit, SavedViewPreviewState>(
builder: (context, state) {
return state.maybeWhen(
loaded: (documents) {
return Column(
children: [
for (final document in documents)
DocumentListItem(
document: document,
isLabelClickable: false,
isSelected: false,
isSelectionActive: false,
onTap: (document) {
DocumentDetailsRoute($extra: document)
.push(context);
},
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
TextButton(
child: Text("Show"),
onPressed: documents.length >= 5 ? () {} : null,
),
TextButton.icon(
icon: Icon(Icons.open_in_new),
label: Text("Show in documents"),
onPressed: () {
context.read<DocumentsCubit>().updateFilter(
filter: savedView.toDocumentFilter(),
);
DocumentsRoute().go(context);
},
),
],
),
],
);
},
error: () => const Text("Error loading preview"), //TODO: INTL
orElse: () => const Padding(
padding: EdgeInsets.all(8.0),
child: Center(child: CircularProgressIndicator()),
),
);
},
),
);
},
);
}
}