Files
paperless-mobile/lib/features/home/view/widget/_app_drawer.dart
2023-02-10 12:41:30 +01:00

321 lines
13 KiB
Dart

// import 'package:flutter/material.dart';
// import 'package:flutter_bloc/flutter_bloc.dart';
// import 'package:hydrated_bloc/hydrated_bloc.dart';
// import 'package:package_info_plus/package_info_plus.dart';
// import 'package:paperless_api/paperless_api.dart';
// import 'package:paperless_mobile/core/bloc/paperless_server_information_cubit.dart';
// import 'package:paperless_mobile/core/bloc/paperless_server_information_state.dart';
// import 'package:paperless_mobile/core/repository/label_repository.dart';
// import 'package:paperless_mobile/core/repository/provider/label_repositories_provider.dart';
// import 'package:paperless_mobile/core/repository/saved_view_repository.dart';
// import 'package:paperless_mobile/core/repository/state/impl/correspondent_repository_state.dart';
// import 'package:paperless_mobile/core/repository/state/impl/document_type_repository_state.dart';
// import 'package:paperless_mobile/core/repository/state/impl/storage_path_repository_state.dart';
// import 'package:paperless_mobile/core/repository/state/impl/tag_repository_state.dart';
// import 'package:paperless_mobile/extensions/flutter_extensions.dart';
// import 'package:paperless_mobile/features/inbox/cubit/inbox_cubit.dart';
// import 'package:paperless_mobile/features/inbox/view/pages/inbox_page.dart';
// import 'package:paperless_mobile/features/login/bloc/authentication_cubit.dart';
// import 'package:paperless_mobile/features/settings/bloc/application_settings_cubit.dart';
// import 'package:paperless_mobile/features/settings/view/settings_page.dart';
// import 'package:paperless_mobile/generated/l10n.dart';
// import 'package:paperless_mobile/helpers/message_helpers.dart';
// import 'package:paperless_mobile/constants.dart';
// import 'package:url_launcher/link.dart';
// import 'package:url_launcher/url_launcher_string.dart';
// class AppDrawer extends StatefulWidget {
// final VoidCallback? afterInboxClosed;
// const AppDrawer({Key? key, this.afterInboxClosed}) : super(key: key);
// @override
// State<AppDrawer> createState() => _AppDrawerState();
// }
// // enum NavigationDestinations {
// // inbox,
// // settings,
// // reportBug,
// // about,
// // logout;
// // }
// class _AppDrawerState extends State<AppDrawer> {
// @override
// void initState() {
// super.initState();
// }
// @override
// Widget build(BuildContext context) {
// final listtTileShape = RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(32),
// );
// // return NavigationDrawer(
// // selectedIndex: -1,
// // children: [
// // Text(
// // "",
// // style: Theme.of(context).textTheme.titleSmall,
// // ).padded(16),
// // NavigationDrawerDestination(
// // icon: const Icon(Icons.inbox),
// // label: Text(S.of(context).bottomNavInboxPageLabel),
// // ),
// // NavigationDrawerDestination(
// // icon: const Icon(Icons.settings),
// // label: Text(S.of(context).appDrawerSettingsLabel),
// // ),
// // const Divider(
// // indent: 16,
// // ),
// // NavigationDrawerDestination(
// // icon: const Icon(Icons.bug_report),
// // label: Text(S.of(context).appDrawerReportBugLabel),
// // ),
// // NavigationDrawerDestination(
// // icon: const Icon(Icons.info_outline),
// // label: Text(S.of(context).appDrawerAboutLabel),
// // ),
// // ],
// // onDestinationSelected: (idx) {
// // final val = NavigationDestinations.values[idx - 1];
// // switch (val) {
// // case NavigationDestinations.inbox:
// // _onOpenInbox();
// // break;
// // case NavigationDestinations.settings:
// // _onOpenSettings();
// // break;
// // case NavigationDestinations.reportBug:
// // launchUrlString(
// // 'https://github.com/astubenbord/paperless-mobile/issues/new',
// // );
// // break;
// // case NavigationDestinations.about:
// // _onShowAboutDialog();
// // break;
// // case NavigationDestinations.logout:
// // _onLogout();
// // break;
// // }
// // },
// // );
// return SafeArea(
// top: true,
// child: ClipRRect(
// borderRadius: const BorderRadius.only(
// topRight: Radius.circular(16.0),
// bottomRight: Radius.circular(16.0),
// ),
// child: Drawer(
// shape: const RoundedRectangleBorder(
// borderRadius: BorderRadius.only(
// topRight: Radius.circular(16.0),
// bottomRight: Radius.circular(16.0),
// ),
// ),
// child: ListView(
// children: [
// DrawerHeader(
// decoration: BoxDecoration(
// color: Theme.of(context).colorScheme.secondaryContainer,
// ),
// padding: const EdgeInsets.only(
// top: 8,
// left: 8,
// bottom: 0,
// right: 8,
// ),
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Row(
// children: [
// Image.asset(
// 'assets/logos/paperless_logo_white.png',
// height: 32,
// width: 32,
// color:
// Theme.of(context).colorScheme.onPrimaryContainer,
// ).paddedOnly(right: 8.0),
// Text(
// S.of(context).appTitleText,
// style: Theme.of(context)
// .textTheme
// .headlineSmall
// ?.copyWith(
// color: Theme.of(context)
// .colorScheme
// .onPrimaryContainer,
// ),
// ),
// ],
// ),
// Align(
// alignment: Alignment.bottomRight,
// child: BlocBuilder<PaperlessServerInformationCubit,
// PaperlessServerInformationState>(
// builder: (context, state) {
// if (!state.isLoaded) {
// return Container();
// }
// final info = state.information!;
// return Column(
// crossAxisAlignment: CrossAxisAlignment.end,
// children: [
// ListTile(
// contentPadding: EdgeInsets.zero,
// dense: true,
// title: Text(
// S.of(context).appDrawerHeaderLoggedInAsText +
// (info.username ?? '?'),
// style: Theme.of(context).textTheme.bodyMedium,
// overflow: TextOverflow.ellipsis,
// textAlign: TextAlign.end,
// maxLines: 1,
// ),
// subtitle: Column(
// crossAxisAlignment: CrossAxisAlignment.end,
// children: [
// Text(
// state.information!.host ?? '',
// style: Theme.of(context)
// .textTheme
// .bodyMedium,
// overflow: TextOverflow.ellipsis,
// textAlign: TextAlign.end,
// maxLines: 1,
// ),
// Text(
// '${S.of(context).serverInformationPaperlessVersionText} ${info.version} (API v${info.apiVersion})',
// style:
// Theme.of(context).textTheme.bodySmall,
// overflow: TextOverflow.ellipsis,
// textAlign: TextAlign.end,
// maxLines: 1,
// ),
// ],
// ),
// isThreeLine: true,
// ),
// ],
// );
// },
// ),
// ),
// ],
// ),
// ),
// ...[
// ListTile(
// title: Text(S.of(context).bottomNavInboxPageLabel),
// leading: const Icon(Icons.inbox),
// onTap: () => _onOpenInbox(),
// shape: listtTileShape,
// ),
// ListTile(
// leading: const Icon(Icons.settings),
// shape: listtTileShape,
// title: Text(
// S.of(context).appDrawerSettingsLabel,
// ),
// onTap: () => Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) => BlocProvider.value(
// value: context.read<ApplicationSettingsCubit>(),
// child: const SettingsPage(),
// ),
// ),
// ),
// ),
// const Divider(
// indent: 16,
// endIndent: 16,
// ),
// ListTile(
// leading: const Icon(Icons.bug_report),
// title: Text(S.of(context).appDrawerReportBugLabel),
// onTap: () {
// launchUrlString(
// 'https://github.com/astubenbord/paperless-mobile/issues/new');
// },
// shape: listtTileShape,
// ),
// ListTile(
// title: Text(S.of(context).appDrawerAboutLabel),
// leading: Icon(Icons.info_outline_rounded),
// onTap: _onShowAboutDialog,
// shape: listtTileShape,
// ),
// ListTile(
// leading: const Icon(Icons.logout),
// title: Text(S.of(context).appDrawerLogoutLabel),
// shape: listtTileShape,
// onTap: () {
// _onLogout();
// },
// )
// ],
// ],
// ),
// ),
// ),
// );
// }
// void _onLogout() async {
// try {
// await context.read<AuthenticationCubit>().logout();
// await context.read<ApplicationSettingsCubit>().clear();
// await context.read<LabelRepository<Tag, TagRepositoryState>>().clear();
// await context
// .read<LabelRepository<Correspondent, CorrespondentRepositoryState>>()
// .clear();
// await context
// .read<LabelRepository<DocumentType, DocumentTypeRepositoryState>>()
// .clear();
// await context
// .read<LabelRepository<StoragePath, StoragePathRepositoryState>>()
// .clear();
// await context.read<SavedViewRepository>().clear();
// await HydratedBloc.storage.clear();
// } on PaperlessServerException catch (error, stackTrace) {
// showErrorMessage(context, error, stackTrace);
// }
// }
// Future<void> _onOpenInbox() async {
// await Navigator.of(context).push(
// MaterialPageRoute(
// builder: (_) => LabelRepositoriesProvider(
// child: BlocProvider(
// create: (context) => InboxCubit(
// context.read(),
// context.read(),
// context.read(),
// context.read(),
// )..initializeInbox(),
// child: const InboxPage(),
// ),
// ),
// ),
// );
// widget.afterInboxClosed?.call();
// }
// void _onOpenSettings() {
// Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) => BlocProvider.value(
// value: context.read<ApplicationSettingsCubit>(),
// child: const SettingsPage(),
// ),
// ),
// );
// }
// void _onShowAboutDialog() {}
// }